175501a3d0537d03a48a2318fddac36da34124e2.svn-base 26 KB

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