index.vue 30 KB

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