f25c2c88e739b54cd9a36ea9970eb4dde2b47bab.svn-base 28 KB

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