9f67af09d83f51856cd4577199aeeffa02b69fdf.svn-base 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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" 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="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 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' })
  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. this.table.temp.pastureid = Cookies.get('pastureid')
  279. this.table.temp.eqcode = row.eqcode
  280. this.table.temp.tname = row.tname
  281. this.table.temp.datacaptureno = row.datacaptureno
  282. this.table.temp.tclassid = row.tclassid
  283. this.table.temp.tclassname = this.table.temp.tclassname
  284. this.table.temp.maxstirfeed = row.maxstirfeed
  285. this.table.temp.enable = row.enable
  286. this.table.temp.remark = row.remark
  287. this.table.temp.tcolor = row.tcolor
  288. this.table.temp.datainterface = row.datainterface
  289. this.table.temp.autozone = row.autozone
  290. this.table.temp.autosecond = row.autosecond
  291. this.table.temp.autosecondname = this.table.temp.autosecondname
  292. // 检验用户名称/角色是否为空
  293. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  294. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  295. return false
  296. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  297. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  298. return false
  299. } else if (this.table.temp.datacaptureno == '' && 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.tclassid == '' && this.table.temp.maxstirfeed == '') {
  303. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  304. return false
  305. } else if (this.table.temp.eqcode == '') {
  306. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  307. return false
  308. } else if (this.table.temp.tname == '') {
  309. this.$message({ type: 'error', message: 'TMR设备名称不能为空', duration: 2000 })
  310. return false
  311. } else if (this.table.temp.datacaptureno == '') {
  312. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  313. return false
  314. } else if (this.table.temp.tclassid == '') {
  315. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  316. return false
  317. } else if (this.table.temp.maxstirfeed == '') {
  318. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  319. return false
  320. }
  321. const datacaptureno = /^([0-9]|(1[0-5]))$/
  322. if (!datacaptureno.test(parseFloat(this.table.temp.datacaptureno))) {
  323. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  324. return false
  325. }
  326. const autozone = /^(?:[0-9]|1[0-9])$/
  327. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  328. this.$message({ type: 'error', message: '跳转重量域请输入0-20之间整数', duration: 2000 })
  329. return false
  330. }
  331. const maxstirfeed = /^[1-9]\d*$/
  332. if (!maxstirfeed.test(parseFloat(this.table.temp.maxstirfeed))) {
  333. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  334. return false
  335. }
  336. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  337. if (pattern.test(this.table.temp.eqcode)) {
  338. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  339. return false
  340. }
  341. if (pattern.test(this.table.temp.tname)) {
  342. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  343. return false
  344. }
  345. this.isokDisable = true
  346. setTimeout(() => {
  347. this.isokDisable = false
  348. }, 1000)
  349. this.requestParam.name = 'insertTMR'
  350. this.requestParam.parammaps = this.table.temp
  351. PostDataByName(this.requestParam).then(response => {
  352. console.log('新增保存发送参数', this.requestParam)
  353. if (response.msg !== 'fail') {
  354. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  355. this.getList()
  356. } else {
  357. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  358. }
  359. })
  360. },
  361. createCancel(row) {
  362. console.log('点击了新增取消')
  363. for (let i = 0; i < this.table.list.length; i++) {
  364. if (row.myId === this.table.list[i].myId) {
  365. var listIndex = this.table.list.indexOf(this.table.list[i])
  366. }
  367. if (listIndex > -1) {
  368. this.table.list.splice(listIndex, 1)
  369. return
  370. }
  371. }
  372. },
  373. handleUpdate(row) {
  374. for (let i = 0; i < this.table.list.length; i++) {
  375. if (this.table.list[i].Edit == true) {
  376. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  377. return false
  378. }
  379. }
  380. // 编辑true,不可编辑false
  381. row.Edit = true
  382. row.NoEdit = false
  383. // 新增false,编辑false,编辑保存true
  384. row.isCreate = false
  385. row.isUpdate = false
  386. row.isUpdateSave = true
  387. row.tclassid = String(row.tclassid)
  388. row.autosecond = String(row.autosecond)
  389. this.table.temp.tclassid = row.tclassid
  390. this.table.temp.tclassname = row.tclassname
  391. },
  392. updateData(row) {
  393. console.log('点击了编辑保存', row)
  394. if (row.tcolor == null) {
  395. row.tcolor = '#CCCCCC'
  396. }
  397. this.table.temp.pastureid = Cookies.get('pastureid')
  398. this.table.temp.eqcode = row.eqcode
  399. this.table.temp.tname = row.tname
  400. this.table.temp.datacaptureno = row.datacaptureno
  401. this.table.temp.tclassid = row.tclassid
  402. this.table.temp.tclassname = this.table.temp.tclassname
  403. this.table.temp.maxstirfeed = row.maxstirfeed
  404. this.table.temp.enable = row.enable
  405. this.table.temp.remark = row.remark
  406. this.table.temp.id = row.id
  407. this.table.temp.tcolor = row.tcolor
  408. this.table.temp.imei = row.imei
  409. this.table.temp.datainterface = row.datainterface
  410. this.table.temp.autozone = row.autozone
  411. this.table.temp.autosecond = row.autosecond
  412. this.table.temp.autosecondname = this.table.temp.autosecondname
  413. // 检验用户名称/角色是否为空
  414. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  415. this.$message({ type: 'error', message: 'TMR设备编号/TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  416. return false
  417. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '' && this.table.temp.tclassid == '' && this.table.temp.maxstirfeed == '') {
  418. this.$message({ type: 'error', message: 'TMR设备名称/数据采集卡编号/TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  419. return false
  420. } else if (this.table.temp.datacaptureno == '' && 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.tclassid == '' && this.table.temp.maxstirfeed == '') {
  424. this.$message({ type: 'error', message: 'TMR设备类型/最大搅拌量不能为空', duration: 2000 })
  425. return false
  426. } else if (this.table.temp.eqcode == '') {
  427. this.$message({ type: 'error', message: 'TMR设备编号不能为空', duration: 2000 })
  428. return false
  429. } else if (this.table.temp.tname == '') {
  430. this.$message({ type: 'error', message: '设备名称不能为空', duration: 2000 })
  431. return false
  432. } else if (this.table.temp.datacaptureno == '') {
  433. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  434. return false
  435. } else if (this.table.temp.tclassid == '') {
  436. this.$message({ type: 'error', message: '设备类型不能为空', duration: 2000 })
  437. return false
  438. } else if (this.table.temp.maxstirfeed == '') {
  439. this.$message({ type: 'error', message: '最大搅拌量不能为空', duration: 2000 })
  440. return false
  441. }
  442. const datacaptureno = /^([0-9]|(1[0-5]))$/
  443. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  444. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  445. return false
  446. }
  447. const maxstirfeed = /^[1-9]\d*$/
  448. if (!maxstirfeed.test(parseInt(this.table.temp.maxstirfeed))) {
  449. this.$message({ type: 'error', message: '最大搅拌量请输入正整数', duration: 2000 })
  450. return false
  451. }
  452. const autozone = /^(?:[0-9]|1[0-9])$/
  453. if (!autozone.test(parseFloat(this.table.temp.autozone))) {
  454. this.$message({ type: 'error', message: '跳转重量域请输入0-20之间整数', duration: 2000 })
  455. return false
  456. }
  457. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  458. if (pattern.test(this.table.temp.eqcode)) {
  459. this.$message({ type: 'error', message: 'TMR设备编号不可输入特殊字符', duration: 2000 })
  460. return false
  461. }
  462. if (pattern.test(this.table.temp.tname)) {
  463. this.$message({ type: 'error', message: 'TMR设备名称不可输入特殊字符', duration: 2000 })
  464. return false
  465. }
  466. this.isokDisable = true
  467. setTimeout(() => {
  468. this.isokDisable = false
  469. }, 1000)
  470. this.requestParam.name = 'updateTMR'
  471. this.requestParam.parammaps = this.table.temp
  472. PostDataByName(this.requestParam).then(response => {
  473. console.log('新增保存发送参数', this.requestParam)
  474. if (response.msg !== 'fail') {
  475. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  476. this.getList()
  477. } else {
  478. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  479. }
  480. })
  481. },
  482. updateCancel(row) {
  483. console.log('点击了编辑取消')
  484. // 编辑false,不可编辑true
  485. row.Edit = false
  486. row.NoEdit = true
  487. // 新增false,编辑true,编辑保存false
  488. row.isCreate = false
  489. row.isUpdate = true
  490. row.isUpdateSave = false
  491. this.getList()
  492. },
  493. // 删除
  494. handleRowDelete(row) {
  495. console.log('点击了行内删除')
  496. MessageBox.confirm('是否确认删除此信息?', {
  497. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  498. }).then(() => {
  499. this.selectList = []
  500. this.requestParam = {}
  501. this.requestParam.common = { 'returnmap': '0' }
  502. this.requestParam.data = []
  503. this.requestParam.data[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  504. 'pastureid': row.pastureid,
  505. 'id': row.id
  506. }}
  507. this.requestParam.data[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  508. 'pastureid': row.pastureid,
  509. 'id': row.id
  510. }}
  511. ExecDataByConfig(this.requestParam).then(response => {
  512. console.log('删除保存发送参数', this.requestParam)
  513. if (response.msg === 'fail') {
  514. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  515. } else {
  516. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  517. this.getList()
  518. }
  519. })
  520. }).catch(() => {
  521. this.$message({ type: 'info', message: '已取消删除' })
  522. })
  523. },
  524. handleSelectionChange(val) {
  525. console.log('勾选数据', val)
  526. this.selectList = val
  527. },
  528. handleDelete() {
  529. console.log('点击了删除')
  530. if (this.selectList.length == 0) {
  531. this.$message({ type: 'error', message: '请选择TMR设备信息', duration: 2000 })
  532. } else {
  533. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  534. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  535. }).then(() => {
  536. console.log(this.selectList)
  537. this.requestParam = {}
  538. this.requestParam.common = { 'returnmap': '0' }
  539. this.requestParam.data = []
  540. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  541. this.requestParam.data[0].children = []
  542. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  543. id: '@insertSpotList.id',
  544. pastureid: '@insertSpotList.pastureid'
  545. }}
  546. this.requestParam.data[0].children[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  547. id: '@insertSpotList.id',
  548. pastureid: '@insertSpotList.pastureid'
  549. }}
  550. ExecDataByConfig(this.requestParam).then(response => {
  551. console.log('删除保存发送参数', this.requestParam)
  552. if (response.msg === 'fail') {
  553. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  554. } else {
  555. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  556. this.getList()
  557. }
  558. })
  559. })
  560. }
  561. }
  562. }
  563. }
  564. </script>
  565. <style lang="scss" scoped>
  566. .search{margin-top:10px;}
  567. .table{margin-top:10px;}
  568. </style>