5c88cb5474b5f4c9a80feffc405d95bd333ed9d2.svn-base 27 KB

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