b3a100b782407df495f53e1f794e13301e7c941b.svn-base 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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="110px" 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" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:10px 0;" maxlength="32" />
  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="90px" align="center">
  53. <template slot-scope="scope">
  54. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="vertical-align: middle;" />
  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 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="110px" 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="110px" 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="110px" 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="110px" 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="110px" 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="110px" 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. isRoleEdit: [],
  148. requestParams: [
  149. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['TMR设备类型'] },
  150. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['跳转延时'] },
  151. { name: 'getDictByName3', offset: 0, pagecount: 0, params: ['数据接口'] }
  152. ],
  153. typeList: [], // TMR设备类型
  154. enableList: [{ id: 1, name: '是' }, { id: 0, name: '否' }], // 是否启用
  155. jumpDelayList: [], // 跳转延时
  156. dataInterfaceList: [], // 数据接口
  157. table: {
  158. getdataListParm: {
  159. name: 'getTMRList',
  160. page: 1,
  161. offset: 1,
  162. pagecount: 10,
  163. returntype: 'Map',
  164. parammaps: {
  165. pastureid: Cookies.get('pastureid'),
  166. eqcode: '',
  167. classname: '',
  168. enable: '',
  169. eqtype: '1'
  170. }
  171. },
  172. tableKey: 0,
  173. list: [],
  174. total: 0,
  175. listLoading: true,
  176. temp: {}
  177. },
  178. requestParam: {},
  179. isokDisable: false,
  180. selectList: [],
  181. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  182. cellStyle: { padding: 0 + 'px' }
  183. }
  184. },
  185. created() {
  186. this.getList()
  187. this.getDownList()
  188. this.getButtons()
  189. },
  190. methods: {
  191. getButtons() {
  192. const Edit = 'EquipmentTMR'
  193. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  194. this.isRoleEdit = isRoleEdit
  195. console.log(this.isRoleEdit)
  196. },
  197. getDownList() {
  198. GetDataByNames(this.requestParams).then(response => {
  199. this.typeList = response.data.getDictByName.list
  200. this.jumpDelayList = response.data.getDictByName2.list
  201. this.dataInterfaceList = response.data.getDictByName3.list
  202. })
  203. },
  204. getList() {
  205. this.table.listLoading = true
  206. GetDataByName(this.table.getdataListParm).then(response => {
  207. console.log('table数据', response.data.list)
  208. if (response.data.list !== null) {
  209. for (let i = 0; i < response.data.list.length; i++) {
  210. this.$set(response.data.list[i], 'Edit', false) // 编辑
  211. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  212. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  213. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  214. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  215. }
  216. this.table.list = response.data.list
  217. this.table.pageNum = response.data.pageNum
  218. this.table.pageSize = response.data.pageSize
  219. this.table.total = response.data.total
  220. } else {
  221. this.table.list = []
  222. }
  223. setTimeout(() => {
  224. this.table.listLoading = false
  225. }, 100)
  226. })
  227. },
  228. handleEnableChange() {
  229. console.log('点击了是否启用')
  230. },
  231. handleSearch() {
  232. console.log('点击了查询')
  233. this.table.getdataListParm.offset = 1
  234. this.getList()
  235. },
  236. handleRefresh() {
  237. console.log('点击了重置')
  238. this.table.getdataListParm.parammaps.eqcode = ''
  239. this.table.getdataListParm.parammaps.classname = ''
  240. this.table.getdataListParm.parammaps.enable = ''
  241. this.table.getdataListParm.parammaps.eqtype = '1'
  242. this.table.getdataListParm.offset = 1
  243. this.getList()
  244. },
  245. handleCreate() {
  246. console.log('点击了新增')
  247. // 编辑true/不可编辑false
  248. // 新增操true,编辑false,编辑保存false
  249. for (let i = 0; i < this.table.list.length; i++) {
  250. if (this.table.list[i].Edit == true) {
  251. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  252. return false
  253. }
  254. }
  255. 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' })
  256. },
  257. // TMR设备类型
  258. changeType(item) {
  259. this.table.temp.tclassname = this.typeList.find(obj => obj.value == item).label
  260. },
  261. // 跳转延时
  262. changeAutosecond(item, row) {
  263. console.log(item, row)
  264. this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value == item).label
  265. if (this.table.temp.autosecondname == '禁用') {
  266. row.autozone = ''
  267. }
  268. },
  269. changeDataInterface(item, row) {
  270. console.log(item, row)
  271. // this.table.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  272. },
  273. createData(row) {
  274. console.log('点击了新增保存', row)
  275. this.table.temp.pastureid = Cookies.get('pastureid')
  276. this.table.temp.eqcode = row.eqcode
  277. this.table.temp.tname = row.tname
  278. this.table.temp.datacaptureno = row.datacaptureno
  279. this.table.temp.tclassid = row.tclassid
  280. this.table.temp.tclassname = this.table.temp.tclassname
  281. this.table.temp.maxstirfeed = row.maxstirfeed
  282. this.table.temp.enable = row.enable
  283. this.table.temp.remark = row.remark
  284. this.table.temp.tcolor = row.tcolor
  285. this.table.temp.datainterface = row.datainterface
  286. this.table.temp.autozone = row.autozone
  287. this.table.temp.autosecond = row.autosecond
  288. this.table.temp.autosecondname = this.table.temp.autosecondname
  289. // 检验用户名称/角色是否为空
  290. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  291. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  292. return false
  293. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  294. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  295. return false
  296. } else if (this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  297. this.$message({ type: 'error', message: '数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  298. return false
  299. } else if (this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  300. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  301. return false
  302. } else if (this.table.temp.eqcode == '') {
  303. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  304. return false
  305. } else if (this.table.temp.tname == '') {
  306. this.$message({ type: 'error', message: 'TMR设备名称不能为空', duration: 2000 })
  307. return false
  308. } else if (this.table.temp.datacaptureno == '') {
  309. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  310. return false
  311. } else if (this.table.temp.tclassid == '') {
  312. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  313. return false
  314. } else if (this.table.temp.maxstirfeed == '') {
  315. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  316. return false
  317. }
  318. const datacaptureno = /^([0-9]|(1[0-5]))$/
  319. if (!datacaptureno.test(parseFloat(this.table.temp.datacaptureno))) {
  320. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  321. return false
  322. }
  323. const autozone = /^(?:[0-9]|1[0-9])$/
  324. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  325. this.$message({ type: 'error', message: '跳转重量域请输入0-20之间整数', duration: 2000 })
  326. return false
  327. }
  328. const maxstirfeed = /^[1-9]\d*$/
  329. if (!maxstirfeed.test(parseFloat(this.table.temp.maxstirfeed))) {
  330. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  331. return false
  332. }
  333. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  334. if (pattern.test(this.table.temp.eqcode)) {
  335. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  336. return false
  337. }
  338. if (pattern.test(this.table.temp.tname)) {
  339. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  340. return false
  341. }
  342. this.isokDisable = true
  343. setTimeout(() => {
  344. this.isokDisable = false
  345. }, 1000)
  346. this.requestParam.name = 'insertTMR'
  347. this.requestParam.parammaps = this.table.temp
  348. PostDataByName(this.requestParam).then(response => {
  349. console.log('新增保存发送参数', this.requestParam)
  350. if (response.msg !== 'fail') {
  351. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  352. this.getList()
  353. } else {
  354. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  355. }
  356. })
  357. },
  358. createCancel(row) {
  359. console.log('点击了新增取消')
  360. for (let i = 0; i < this.table.list.length; i++) {
  361. if (row.myId === this.table.list[i].myId) {
  362. var listIndex = this.table.list.indexOf(this.table.list[i])
  363. }
  364. if (listIndex > -1) {
  365. this.table.list.splice(listIndex, 1)
  366. return
  367. }
  368. }
  369. },
  370. handleUpdate(row) {
  371. for (let i = 0; i < this.table.list.length; i++) {
  372. if (this.table.list[i].Edit == true) {
  373. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  374. return false
  375. }
  376. }
  377. // 编辑true,不可编辑false
  378. row.Edit = true
  379. row.NoEdit = false
  380. // 新增false,编辑false,编辑保存true
  381. row.isCreate = false
  382. row.isUpdate = false
  383. row.isUpdateSave = true
  384. row.tclassid = String(row.tclassid)
  385. row.autosecond = String(row.autosecond)
  386. this.table.temp.tclassid = row.tclassid
  387. this.table.temp.tclassname = row.tclassname
  388. },
  389. updateData(row) {
  390. console.log('点击了编辑保存', row)
  391. if (row.tcolor == null) {
  392. row.tcolor = '#CCCCCC'
  393. }
  394. this.table.temp.pastureid = Cookies.get('pastureid')
  395. this.table.temp.eqcode = row.eqcode
  396. this.table.temp.tname = row.tname
  397. this.table.temp.datacaptureno = row.datacaptureno
  398. this.table.temp.tclassid = row.tclassid
  399. this.table.temp.tclassname = this.table.temp.tclassname
  400. this.table.temp.maxstirfeed = row.maxstirfeed
  401. this.table.temp.enable = row.enable
  402. this.table.temp.remark = row.remark
  403. this.table.temp.id = row.id
  404. this.table.temp.tcolor = row.tcolor
  405. this.table.temp.imei = row.imei
  406. this.table.temp.datainterface = row.datainterface
  407. this.table.temp.autozone = row.autozone
  408. this.table.temp.autosecond = row.autosecond
  409. this.table.temp.autosecondname = this.table.temp.autosecondname
  410. // 检验用户名称/角色是否为空
  411. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  412. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  413. return false
  414. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  415. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  416. return false
  417. } else if (this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  418. this.$message({ type: 'error', message: '数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  419. return false
  420. } else if (this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  421. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  422. return false
  423. } else if (this.table.temp.eqcode == '') {
  424. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  425. return false
  426. } else if (this.table.temp.tname == '') {
  427. this.$message({ type: 'error', message: '设备名称不能为空', duration: 2000 })
  428. return false
  429. } else if (this.table.temp.datacaptureno == '') {
  430. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  431. return false
  432. } else if (this.table.temp.tclassid == '') {
  433. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  434. return false
  435. } else if (this.table.temp.maxstirfeed == '') {
  436. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  437. return false
  438. }
  439. const datacaptureno = /^([0-9]|(1[0-5]))$/
  440. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  441. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  442. return false
  443. }
  444. const maxstirfeed = /^[1-9]\d*$/
  445. if (!maxstirfeed.test(parseInt(this.table.temp.maxstirfeed))) {
  446. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  447. return false
  448. }
  449. const autozone = /^(?:[0-9]|1[0-9])$/
  450. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  451. this.$message({ type: 'error', message: '跳转重量域请输入0-20之间整数', duration: 2000 })
  452. return false
  453. }
  454. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  455. if (pattern.test(this.table.temp.eqcode)) {
  456. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  457. return false
  458. }
  459. if (pattern.test(this.table.temp.tname)) {
  460. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  461. return false
  462. }
  463. this.isokDisable = true
  464. setTimeout(() => {
  465. this.isokDisable = false
  466. }, 1000)
  467. this.requestParam.name = 'updateTMR'
  468. this.requestParam.parammaps = this.table.temp
  469. PostDataByName(this.requestParam).then(response => {
  470. console.log('新增保存发送参数', this.requestParam)
  471. if (response.msg !== 'fail') {
  472. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  473. this.getList()
  474. } else {
  475. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  476. }
  477. })
  478. },
  479. updateCancel(row) {
  480. console.log('点击了编辑取消')
  481. // 编辑false,不可编辑true
  482. row.Edit = false
  483. row.NoEdit = true
  484. // 新增false,编辑true,编辑保存false
  485. row.isCreate = false
  486. row.isUpdate = true
  487. row.isUpdateSave = false
  488. this.getList()
  489. },
  490. // 删除
  491. handleRowDelete(row) {
  492. console.log('点击了行内删除')
  493. MessageBox.confirm('是否确认删除此信息?', {
  494. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  495. }).then(() => {
  496. this.selectList = []
  497. this.requestParam = {}
  498. this.requestParam.common = { 'returnmap': '0' }
  499. this.requestParam.data = []
  500. this.requestParam.data[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  501. 'pastureid': row.pastureid,
  502. 'id': row.id
  503. }}
  504. this.requestParam.data[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  505. 'pastureid': row.pastureid,
  506. 'id': row.id
  507. }}
  508. ExecDataByConfig(this.requestParam).then(response => {
  509. console.log('删除保存发送参数', this.requestParam)
  510. if (response.msg === 'fail') {
  511. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  512. } else {
  513. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  514. this.getList()
  515. }
  516. })
  517. }).catch(() => {
  518. this.$message({ type: 'info', message: '已取消删除' })
  519. })
  520. },
  521. handleSelectionChange(val) {
  522. console.log('勾选数据', val)
  523. this.selectList = val
  524. },
  525. handleDelete() {
  526. console.log('点击了删除')
  527. if (this.selectList.length == 0) {
  528. this.$message({ type: 'error', message: '请选择TMR设备信息', duration: 2000 })
  529. } else {
  530. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  531. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  532. }).then(() => {
  533. console.log(this.selectList)
  534. this.requestParam = {}
  535. this.requestParam.common = { 'returnmap': '0' }
  536. this.requestParam.data = []
  537. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  538. this.requestParam.data[0].children = []
  539. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  540. id: '@insertSpotList.id',
  541. pastureid: '@insertSpotList.pastureid'
  542. }}
  543. this.requestParam.data[0].children[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  544. id: '@insertSpotList.id',
  545. pastureid: '@insertSpotList.pastureid'
  546. }}
  547. ExecDataByConfig(this.requestParam).then(response => {
  548. console.log('删除保存发送参数', this.requestParam)
  549. if (response.msg === 'fail') {
  550. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  551. } else {
  552. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  553. this.getList()
  554. }
  555. })
  556. })
  557. }
  558. }
  559. }
  560. }
  561. </script>
  562. <style lang="scss" scoped>
  563. .search{margin-top:10px;}
  564. .table{margin-top:10px;}
  565. </style>