5bca6612c078da520bfab7657033673fd9b04e89.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-input v-model="table.getdataListParm.parammaps.eqcode" placeholder="TMR设备编号" style="width: 180px;" class="filter-item" clearable />
  5. <el-select v-model="table.getdataListParm.parammaps.classname" filterable placeholder="TMR设备类型" class="filter-item" style="width: 140px;" clearable>
  6. <el-option v-for="item in typeList" :key="item.id" :label="item.label" :value="item.label" />
  7. </el-select>
  8. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  9. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  12. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  13. </div>
  14. <div class="operation">
  15. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  16. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  17. </div>
  18. <div class="table">
  19. <el-table
  20. :key="table.tableKey"
  21. v-loading="table.listLoading"
  22. element-loading-text="给我一点时间"
  23. :data="table.list"
  24. border
  25. fit
  26. highlight-current-row
  27. style="width: 100%;"
  28. :row-style="rowStyle"
  29. :cell-style="cellStyle"
  30. class="elTable table-fixed"
  31. @selection-change="handleSelectionChange"
  32. >
  33. <el-table-column type="selection" align="center" width="50" />
  34. <el-table-column label="序号" align="center" type="index" width="50px">
  35. <template slot-scope="scope">
  36. <span v-if="table.pageNum">{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  37. <span v-else>1</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="TMR设备编号" min-width="100px" align="center">
  41. <template slot-scope="scope">
  42. <span v-if="scope.row.NoEdit">{{ scope.row.eqcode }}</span>
  43. <el-input v-if="scope.row.Edit" v-model="scope.row.eqcode" placeholder="1-32个字符" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="TMR设备名称" min-width="110px" align="center">
  47. <template slot-scope="scope">
  48. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  49. <el-input v-if="scope.row.Edit" v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" maxlength="32" />
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="车辆颜色" min-width="70px" align="center">
  53. <template slot-scope="scope">
  54. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="scope.row.NoEdit" />
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="数据采集卡编号" min-width="90px" align="center">
  58. <template slot-scope="scope">
  59. <span v-if="scope.row.NoEdit">{{ scope.row.datacaptureno }}</span>
  60. <el-input v-if="scope.row.Edit" v-model="scope.row.datacaptureno" type="number" step="0.01" style="width:95%;padding:10px 0;" />
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="TMR设备类型" min-width="110px" align="center">
  64. <template slot-scope="scope">
  65. <span v-if="scope.row.NoEdit">{{ scope.row.tclassname }}</span>
  66. <el-select v-if="scope.row.Edit" v-model="scope.row.tclassid" filterable :disabled="scope.row.islock == 1" placeholder="TMR设备类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeType">
  67. <el-option v-for="item in typeList" :key="item.id" :label="item.label" :value="item.value" />
  68. </el-select>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="最大搅拌量(KG)" min-width="85px" align="center">
  72. <template slot-scope="scope">
  73. <span v-if="scope.row.NoEdit">{{ scope.row.maxstirfeed }}</span>
  74. <el-input v-if="scope.row.Edit" v-model="scope.row.maxstirfeed" style="width: 80%;" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="跳转重量域(kg)" min-width="85px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.autozone }}</span>
  80. <el-input v-if="scope.row.Edit" v-model="scope.row.autozone" type="textarea" :disabled="scope.row.autosecond=='0'" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" />
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="跳转延时(s)" min-width="100px" align="center">
  84. <template slot-scope="scope">
  85. <span v-if="scope.row.NoEdit">{{ scope.row.autosecondname }}</span>
  86. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeAutosecond(value,scope.row)}">
  87. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  88. </el-select>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="数据接口" min-width="110px" align="center">
  92. <template slot-scope="scope">
  93. <span v-if="scope.row.NoEdit">{{ scope.row.datainterface }}</span>
  94. <el-select v-if="scope.row.Edit" v-model="scope.row.datainterface" filterable placeholder="TMR数据接口" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeDataInterface(value, scope.row)}">
  95. <el-option v-for="item in dataInterfaceList" :key="item.value" :label="item.label" :value="item.value" />
  96. </el-select>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="Imei" min-width="100px" align="center">
  100. <template slot-scope="scope">
  101. <span v-if="scope.row.NoEdit">{{ scope.row.imei }}</span>
  102. <el-input v-if="scope.row.Edit" v-model="scope.row.imei" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" />
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="备注" min-width="90px" align="center">
  106. <template slot-scope="scope">
  107. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  108. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" />
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="是否启用" min-width="70px" align="center">
  112. <template slot-scope="scope">
  113. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  117. <template slot-scope="{row}">
  118. <!-- 新增 -->
  119. <el-button v-if="row.isCreate" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  120. <span v-if="row.isCreate" class="centerSpan">|</span>
  121. <el-button v-if="row.isCreate" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  122. <!-- 编辑 -->
  123. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  124. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  125. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  126. <!-- 编辑保存 -->
  127. <el-button v-if="row.isUpdateSave" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  128. <span v-if="row.isUpdateSave" class="centerSpan">|</span>
  129. <el-button v-if="row.isUpdateSave" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  134. </div>
  135. </div>
  136. </template>
  137. <script>
  138. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  139. import Cookies from 'js-cookie'
  140. import Pagination from '@/components/Pagination'
  141. import { MessageBox } from 'element-ui'
  142. export default {
  143. name: 'EquipmentTMR',
  144. components: { Pagination },
  145. data() {
  146. return {
  147. predefineColors: [
  148. '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#2196F3', '#03A9F4', '#00BCD4', '#009688', '#4CAF50', '#8BC34A', '#CDDC39', '#FFEB3B', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B'
  149. ],
  150. isRoleEdit: [],
  151. requestParams: [
  152. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['TMR设备类型'] },
  153. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['跳转延时'] },
  154. { name: 'getDictByName3', offset: 0, pagecount: 0, params: ['数据接口'] }
  155. ],
  156. typeList: [], // TMR设备类型
  157. enableList: [{ id: 1, name: '是' }, { id: 0, name: '否' }], // 是否启用
  158. jumpDelayList: [], // 跳转延时
  159. dataInterfaceList: [], // 数据接口
  160. table: {
  161. getdataListParm: {
  162. name: 'getTMRList',
  163. page: 1,
  164. offset: 1,
  165. pagecount: parseInt(Cookies.get('pageCount')),
  166. returntype: 'Map',
  167. parammaps: {
  168. pastureid: Cookies.get('pastureid'),
  169. eqcode: '',
  170. classname: '',
  171. enable: '',
  172. eqtype: '1'
  173. }
  174. },
  175. tableKey: 0,
  176. list: [],
  177. total: 0,
  178. listLoading: true,
  179. temp: {}
  180. },
  181. requestParam: {},
  182. isokDisable: false,
  183. selectList: [],
  184. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  185. cellStyle: { padding: 0 + 'px' }
  186. }
  187. },
  188. created() {
  189. this.getList()
  190. this.getDownList()
  191. this.getButtons()
  192. },
  193. methods: {
  194. getButtons() {
  195. const Edit = 'EquipmentTMR'
  196. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  197. this.isRoleEdit = isRoleEdit
  198. console.log(this.isRoleEdit)
  199. },
  200. getDownList() {
  201. GetDataByNames(this.requestParams).then(response => {
  202. this.typeList = response.data.getDictByName.list
  203. this.jumpDelayList = response.data.getDictByName2.list
  204. this.dataInterfaceList = response.data.getDictByName3.list
  205. })
  206. },
  207. getList() {
  208. this.table.listLoading = true
  209. GetDataByName(this.table.getdataListParm).then(response => {
  210. console.log('table数据', response.data.list)
  211. if (response.data.list !== null) {
  212. for (let i = 0; i < response.data.list.length; i++) {
  213. this.$set(response.data.list[i], 'Edit', false) // 编辑
  214. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  215. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  216. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  217. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  218. }
  219. this.table.list = response.data.list
  220. this.table.pageNum = response.data.pageNum
  221. this.table.pageSize = response.data.pageSize
  222. this.table.total = response.data.total
  223. } else {
  224. this.table.list = []
  225. }
  226. setTimeout(() => {
  227. this.table.listLoading = false
  228. }, 100)
  229. })
  230. },
  231. handleEnableChange() {
  232. console.log('点击了是否启用')
  233. },
  234. handleSearch() {
  235. console.log('点击了查询')
  236. this.table.getdataListParm.offset = 1
  237. this.getList()
  238. },
  239. handleRefresh() {
  240. console.log('点击了重置')
  241. this.table.getdataListParm.parammaps.eqcode = ''
  242. this.table.getdataListParm.parammaps.classname = ''
  243. this.table.getdataListParm.parammaps.enable = ''
  244. this.table.getdataListParm.parammaps.eqtype = '1'
  245. this.table.getdataListParm.offset = 1
  246. this.getList()
  247. },
  248. handleCreate() {
  249. console.log('点击了新增')
  250. // 编辑true/不可编辑false
  251. // 新增操true,编辑false,编辑保存false
  252. for (let i = 0; i < this.table.list.length; i++) {
  253. if (this.table.list[i].Edit == true) {
  254. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  255. return false
  256. }
  257. }
  258. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'eqcode': '', 'tname': '', 'datacaptureno': '', 'tclassid': '', 'maxstirfeed': '', 'tcolor': '#ccc', 'autosecond': '0', 'imei': '' })
  259. },
  260. // TMR设备类型
  261. changeType(item) {
  262. this.table.temp.tclassname = this.typeList.find(obj => obj.value == item).label
  263. },
  264. // 跳转延时
  265. changeAutosecond(item, row) {
  266. console.log(item, row)
  267. this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value == item).label
  268. if (this.table.temp.autosecondname == '禁用') {
  269. row.autozone = ''
  270. }
  271. },
  272. changeDataInterface(item, row) {
  273. console.log(item, row)
  274. // this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  275. },
  276. createData(row) {
  277. console.log('点击了新增保存', row)
  278. if (row.autosecond == '0') {
  279. row.autozone = ''
  280. row.autosecondname = ''
  281. this.table.temp.autosecondname = ''
  282. }
  283. this.table.temp.pastureid = Cookies.get('pastureid')
  284. this.table.temp.eqcode = row.eqcode
  285. this.table.temp.tname = row.tname
  286. this.table.temp.datacaptureno = row.datacaptureno
  287. this.table.temp.tclassid = row.tclassid
  288. this.table.temp.tclassname = this.table.temp.tclassname
  289. this.table.temp.maxstirfeed = row.maxstirfeed
  290. this.table.temp.enable = row.enable
  291. this.table.temp.remark = row.remark
  292. this.table.temp.tcolor = row.tcolor
  293. this.table.temp.datainterface = row.datainterface
  294. this.table.temp.autozone = row.autozone
  295. this.table.temp.autosecond = row.autosecond
  296. this.table.temp.autosecondname = this.table.temp.autosecondname
  297. this.table.temp.imei = row.imei
  298. // 检验用户名称/角色是否为空
  299. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  300. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  301. return false
  302. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  303. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  304. return false
  305. } else if (this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  306. this.$message({ type: 'error', message: '数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  307. return false
  308. } else if (this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  309. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  310. return false
  311. } else if (this.table.temp.eqcode == '') {
  312. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  313. return false
  314. } else if (this.table.temp.tname == '') {
  315. this.$message({ type: 'error', message: 'TMR设备名称不能为空', duration: 2000 })
  316. return false
  317. } else if (this.table.temp.datacaptureno == '') {
  318. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  319. return false
  320. } else if (this.table.temp.tclassid == '') {
  321. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  322. return false
  323. } else if (this.table.temp.maxstirfeed == '') {
  324. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  325. return false
  326. }
  327. const datacaptureno = /^([0-9]|(1[0-5]))$/
  328. if (!datacaptureno.test(parseFloat(this.table.temp.datacaptureno))) {
  329. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  330. return false
  331. }
  332. if (row.autosecond !== '0') {
  333. const autozone = /^(?:[0-9]|1[0-9])$/
  334. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  335. this.$message({ type: 'error', message: '跳转重量域请输入0-20之间整数', duration: 2000 })
  336. return false
  337. }
  338. }
  339. const maxstirfeed = /^[1-9]\d*$/
  340. if (!maxstirfeed.test(parseFloat(this.table.temp.maxstirfeed))) {
  341. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  342. return false
  343. }
  344. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  345. if (pattern.test(this.table.temp.eqcode)) {
  346. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  347. return false
  348. }
  349. if (pattern.test(this.table.temp.tname)) {
  350. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  351. return false
  352. }
  353. this.isokDisable = true
  354. setTimeout(() => {
  355. this.isokDisable = false
  356. }, 1000)
  357. this.requestParam.name = 'insertTMR'
  358. this.requestParam.parammaps = this.table.temp
  359. PostDataByName(this.requestParam).then(response => {
  360. console.log('新增保存发送参数', this.requestParam)
  361. if (response.msg !== 'fail') {
  362. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  363. this.getList()
  364. } else {
  365. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  366. }
  367. })
  368. },
  369. createCancel(row) {
  370. console.log('点击了新增取消')
  371. for (let i = 0; i < this.table.list.length; i++) {
  372. if (row.myId === this.table.list[i].myId) {
  373. var listIndex = this.table.list.indexOf(this.table.list[i])
  374. }
  375. if (listIndex > -1) {
  376. this.table.list.splice(listIndex, 1)
  377. return
  378. }
  379. }
  380. },
  381. handleUpdate(row) {
  382. for (let i = 0; i < this.table.list.length; i++) {
  383. if (this.table.list[i].Edit == true) {
  384. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  385. return false
  386. }
  387. }
  388. // 编辑true,不可编辑false
  389. row.Edit = true
  390. row.NoEdit = false
  391. // 新增false,编辑false,编辑保存true
  392. row.isCreate = false
  393. row.isUpdate = false
  394. row.isUpdateSave = true
  395. row.tclassid = String(row.tclassid)
  396. row.autosecond = String(row.autosecond)
  397. this.table.temp.tclassid = row.tclassid
  398. this.table.temp.tclassname = row.tclassname
  399. },
  400. updateData(row) {
  401. console.log('点击了编辑保存', row)
  402. if (row.tcolor == null) {
  403. row.tcolor = '#CCCCCC'
  404. }
  405. if (row.autosecond == '0') {
  406. row.autozone = ''
  407. row.autosecondname = ''
  408. this.table.temp.autosecondname = ''
  409. }
  410. this.table.temp.pastureid = Cookies.get('pastureid')
  411. this.table.temp.eqcode = row.eqcode
  412. this.table.temp.tname = row.tname
  413. this.table.temp.datacaptureno = row.datacaptureno
  414. this.table.temp.tclassid = row.tclassid
  415. this.table.temp.tclassname = this.table.temp.tclassname
  416. this.table.temp.maxstirfeed = row.maxstirfeed
  417. this.table.temp.enable = row.enable
  418. this.table.temp.remark = row.remark
  419. this.table.temp.id = row.id
  420. this.table.temp.tcolor = row.tcolor
  421. this.table.temp.imei = row.imei
  422. this.table.temp.datainterface = row.datainterface
  423. this.table.temp.autozone = row.autozone
  424. this.table.temp.autosecond = row.autosecond
  425. this.table.temp.autosecondname = this.table.temp.autosecondname
  426. // 检验用户名称/角色是否为空
  427. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  428. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  429. return false
  430. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  431. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  432. return false
  433. } else if (this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  434. this.$message({ type: 'error', message: '数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  435. return false
  436. } else if (this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  437. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  438. return false
  439. } else if (this.table.temp.eqcode == '') {
  440. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  441. return false
  442. } else if (this.table.temp.tname == '') {
  443. this.$message({ type: 'error', message: '设备名称不能为空', duration: 2000 })
  444. return false
  445. } else if (this.table.temp.datacaptureno == '') {
  446. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  447. return false
  448. } else if (this.table.temp.tclassid == '') {
  449. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  450. return false
  451. } else if (this.table.temp.maxstirfeed == '') {
  452. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  453. return false
  454. }
  455. const datacaptureno = /^([0-9]|(1[0-5]))$/
  456. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  457. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  458. return false
  459. }
  460. const maxstirfeed = /^[1-9]\d*$/
  461. if (!maxstirfeed.test(parseInt(this.table.temp.maxstirfeed))) {
  462. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  463. return false
  464. }
  465. console.log(row.autozone, '=0000')
  466. if (row.autosecond !== '0') {
  467. const autozone = /^(?:[0-9]|1[0-9])$/
  468. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  469. this.$message({ type: 'error', message: '跳转重量域请输入0-20之间整数', duration: 2000 })
  470. return false
  471. }
  472. }
  473. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  474. if (pattern.test(this.table.temp.eqcode)) {
  475. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  476. return false
  477. }
  478. if (pattern.test(this.table.temp.tname)) {
  479. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  480. return false
  481. }
  482. this.isokDisable = true
  483. setTimeout(() => {
  484. this.isokDisable = false
  485. }, 1000)
  486. this.requestParam.name = 'updateTMR'
  487. this.requestParam.parammaps = this.table.temp
  488. PostDataByName(this.requestParam).then(response => {
  489. console.log('新增保存发送参数', this.requestParam)
  490. if (response.msg !== 'fail') {
  491. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  492. this.getList()
  493. } else {
  494. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  495. }
  496. })
  497. },
  498. updateCancel(row) {
  499. console.log('点击了编辑取消')
  500. // 编辑false,不可编辑true
  501. row.Edit = false
  502. row.NoEdit = true
  503. // 新增false,编辑true,编辑保存false
  504. row.isCreate = false
  505. row.isUpdate = true
  506. row.isUpdateSave = false
  507. this.getList()
  508. },
  509. // 删除
  510. handleRowDelete(row) {
  511. console.log('点击了行内删除')
  512. MessageBox.confirm('是否确认删除此信息?', {
  513. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  514. }).then(() => {
  515. this.selectList = []
  516. this.requestParam = {}
  517. this.requestParam.common = { 'returnmap': '0' }
  518. this.requestParam.data = []
  519. this.requestParam.data[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  520. 'pastureid': row.pastureid,
  521. 'id': row.id
  522. }}
  523. this.requestParam.data[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  524. 'pastureid': row.pastureid,
  525. 'id': row.id
  526. }}
  527. ExecDataByConfig(this.requestParam).then(response => {
  528. console.log('删除保存发送参数', this.requestParam)
  529. if (response.msg === 'fail') {
  530. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  531. } else {
  532. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  533. this.getList()
  534. }
  535. })
  536. }).catch(() => {
  537. this.$message({ type: 'info', message: '已取消删除' })
  538. })
  539. },
  540. handleSelectionChange(val) {
  541. console.log('勾选数据', val)
  542. this.selectList = val
  543. },
  544. handleDelete() {
  545. console.log('点击了删除')
  546. if (this.selectList.length == 0) {
  547. this.$message({ type: 'error', message: '请选择TMR设备信息', duration: 2000 })
  548. } else {
  549. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  550. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  551. }).then(() => {
  552. console.log(this.selectList)
  553. this.requestParam = {}
  554. this.requestParam.common = { 'returnmap': '0' }
  555. this.requestParam.data = []
  556. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  557. this.requestParam.data[0].children = []
  558. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  559. id: '@insertSpotList.id',
  560. pastureid: '@insertSpotList.pastureid'
  561. }}
  562. this.requestParam.data[0].children[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  563. id: '@insertSpotList.id',
  564. pastureid: '@insertSpotList.pastureid'
  565. }}
  566. ExecDataByConfig(this.requestParam).then(response => {
  567. console.log('删除保存发送参数', this.requestParam)
  568. if (response.msg === 'fail') {
  569. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  570. } else {
  571. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  572. this.getList()
  573. }
  574. })
  575. })
  576. }
  577. }
  578. }
  579. }
  580. </script>
  581. <style lang="scss" scoped>
  582. .search{margin-top:10px;}
  583. .table{margin-top:10px;}
  584. </style>