631e2b4fa1663ca3e1acc974bef56ef11f37ec37.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-input v-model="table.getdataListParm.parammaps.eqcode" placeholder="GPS编号" style="width: 180px;" class="filter-item" clearable />
  5. <el-input v-model="table.getdataListParm.parammaps.tname" placeholder="GPS名称" style="width: 180px;" class="filter-item" clearable />
  6. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  7. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  8. </el-select>
  9. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  10. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  11. </div>
  12. <div class="operation">
  13. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  14. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  15. </div>
  16. <div class="table">
  17. <el-form ref="form" :rules="table.rules" :model="table">
  18. <el-table
  19. :key="table.tableKey"
  20. v-loading="table.listLoading"
  21. element-loading-text="给我一点时间"
  22. :data="table.list"
  23. border
  24. fit
  25. highlight-current-row
  26. style="width: 100%;"
  27. :row-style="rowStyle"
  28. :cell-style="cellStyle"
  29. class="elTable table-fixed"
  30. @selection-change="handleSelectionChange"
  31. >
  32. <el-table-column type="selection" align="center" width="50" />
  33. <el-table-column label="序号" align="center" type="index" width="50px">
  34. <template slot-scope="scope">
  35. <span v-if="table.pageNum">{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  36. <span v-else>1</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="GPS编号" min-width="110px" align="center">
  40. <template slot-scope="scope">
  41. <span v-if="scope.row.NoEdit">{{ scope.row.eqcode }}</span>
  42. <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:80%;padding:10px 0;" />
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="GPS名称" min-width="110px" align="center">
  46. <template slot-scope="scope">
  47. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  48. <el-input v-if="scope.row.Edit" v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="关联设备" min-width="110px" align="center">
  52. <template slot-scope="scope">
  53. <span v-if="scope.row.NoEdit">{{ scope.row.eqcode }}</span>
  54. <el-select v-if="scope.row.Edit" v-model="scope.row.associatedDevices" @change="(value)=> {handleAssociatedDevicesChange(value,scope.row)}">
  55. <el-option v-for="item in associatedDevicesList" :key="item.id" :label="`名称:${item.name} 编号:${item.name2}类型:${item.name3}`" :value="item.id" />
  56. </el-select>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="备注" min-width="110px" align="center">
  60. <template slot-scope="scope">
  61. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  62. <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;" />
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="是否启用" min-width="110px" align="center">
  66. <template slot-scope="scope">
  67. <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)" />
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  71. <template slot-scope="{row}">
  72. <!-- 新增 -->
  73. <el-button v-if="row.isCreate" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  74. <span v-if="row.isCreate" class="centerSpan">|</span>
  75. <el-button v-if="row.isCreate" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  76. <!-- 编辑 -->
  77. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  78. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  79. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  80. <!-- 编辑保存 -->
  81. <el-button v-if="row.isUpdateSave" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  82. <span v-if="row.isUpdateSave" class="centerSpan">|</span>
  83. <el-button v-if="row.isUpdateSave" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. </el-form>
  88. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  89. </div>
  90. </div>
  91. </template>
  92. <script>
  93. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, checkButtons } from '@/api/common'
  94. import Cookies from 'js-cookie'
  95. import Pagination from '@/components/Pagination'
  96. import { MessageBox } from 'element-ui'
  97. export default {
  98. name: 'ManagementGPS',
  99. components: { Pagination },
  100. data() {
  101. return {
  102. isRoleEdit: [],
  103. enableList: [{ id: 1, name: '是' }, { id: 0, name: '否' }],
  104. associatedDevicesList: [{ id: 0, name: '设备001', name2: '00123', name3: '铲车' }, { id: 1, name: '设备002', name2: '00124', name3: '铲车' }, { id: 2, name: '设备003', name2: '00125', name3: '铲车' }],
  105. table: {
  106. rules: {
  107. name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
  108. },
  109. getdataListParm: {
  110. name: 'getTMRList',
  111. page: 1,
  112. offset: 1,
  113. pagecount: parseInt(Cookies.get('pageCount')),
  114. returntype: 'Map',
  115. parammaps: {
  116. pastureid: Cookies.get('pastureid'),
  117. eqcode: '',
  118. tclassname: '',
  119. enable: '',
  120. eqtype: '0'
  121. }
  122. },
  123. tableKey: 0,
  124. list: [],
  125. total: 0,
  126. listLoading: true,
  127. temp: {}
  128. },
  129. requestParam: {},
  130. isokDisable: false,
  131. selectList: [],
  132. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  133. cellStyle: { padding: 0 + 'px' }
  134. }
  135. },
  136. created() {
  137. this.getList()
  138. this.getButtons()
  139. },
  140. methods: {
  141. getButtons() {
  142. const Edit = 'ForkliftManagement'
  143. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  144. this.isRoleEdit = isRoleEdit
  145. },
  146. getList() {
  147. this.table.listLoading = true
  148. GetDataByName(this.table.getdataListParm).then(response => {
  149. console.log('table数据', response.data.list)
  150. if (response.data.list !== null) {
  151. for (let i = 0; i < response.data.list.length; i++) {
  152. this.$set(response.data.list[i], 'Edit', false) // 编辑
  153. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  154. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  155. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  156. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  157. }
  158. this.table.list = response.data.list
  159. this.table.pageNum = response.data.pageNum
  160. this.table.pageSize = response.data.pageSize
  161. this.table.total = response.data.total
  162. } else {
  163. this.table.list = []
  164. }
  165. setTimeout(() => {
  166. this.table.listLoading = false
  167. }, 100)
  168. })
  169. },
  170. handleEnableChange() {
  171. console.log('点击了是否启用')
  172. },
  173. handleSearch() {
  174. console.log('点击了查询')
  175. this.table.getdataListParm.offset = 1
  176. this.getList()
  177. },
  178. handleRefresh() {
  179. console.log('点击了重置')
  180. this.table.getdataListParm.parammaps.eqcode = ''
  181. this.table.getdataListParm.parammaps.tname = ''
  182. this.table.getdataListParm.parammaps.enable = ''
  183. this.table.getdataListParm.parammaps.eqtype = '0'
  184. this.table.getdataListParm.offset = 1
  185. this.getList()
  186. },
  187. handleAssociatedDevicesChange(item, row) {
  188. row.associatedDevices = this.associatedDevicesList.find(obj => obj.id === item).name
  189. },
  190. handleCreate() {
  191. console.log('点击了新增')
  192. // 编辑true/不可编辑false
  193. // 新增操true,编辑false,编辑保存false
  194. for (let i = 0; i < this.table.list.length; i++) {
  195. if (this.table.list[i].Edit == true) {
  196. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  197. return false
  198. }
  199. }
  200. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'eqcode': '', 'tname': '', 'datacaptureno': '' })
  201. },
  202. createData(row) {
  203. console.log('点击了新增保存')
  204. this.table.temp.pastureid = Cookies.get('pastureid')
  205. this.table.temp.eqcode = row.eqcode
  206. this.table.temp.tname = row.tname
  207. this.table.temp.datacaptureno = row.datacaptureno
  208. this.table.temp.enable = row.enable
  209. this.table.temp.remark = row.remark
  210. this.table.temp.tclassid = '0'
  211. this.table.temp.maxstirfeed = '0'
  212. // 检验用户名称/角色是否为空
  213. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '') {
  214. this.$message({ type: 'error', message: '铲车编号/铲车名称/数据采集卡编号不能为空', duration: 2000 })
  215. return false
  216. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '') {
  217. this.$message({ type: 'error', message: '铲车名称/数据采集卡编号不能为空', duration: 2000 })
  218. return false
  219. } else if (this.table.temp.eqcode == '') {
  220. this.$message({ type: 'error', message: '铲车编号不能为空', duration: 2000 })
  221. return false
  222. } else if (this.table.temp.tname == '') {
  223. this.$message({ type: 'error', message: '铲车名称不能为空', duration: 2000 })
  224. return false
  225. } else if (this.table.temp.datacaptureno == '') {
  226. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  227. return false
  228. }
  229. const datacaptureno = /^([0-9]|(1[0-5]))$/
  230. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  231. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  232. return false
  233. }
  234. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  235. console.log(this.table.temp.eqcode)
  236. if (pattern.test(this.table.temp.eqcode)) {
  237. this.$message({ type: 'error', message: '铲车编号不可输入特殊字符', duration: 2000 })
  238. return false
  239. }
  240. if (pattern.test(this.table.temp.tname)) {
  241. this.$message({ type: 'error', message: '铲车名称不可输入特殊字符', duration: 2000 })
  242. return false
  243. }
  244. this.isokDisable = true
  245. setTimeout(() => {
  246. this.isokDisable = false
  247. }, 1000)
  248. this.requestParam.name = 'insertTMR'
  249. this.requestParam.parammaps = this.table.temp
  250. PostDataByName(this.requestParam).then(response => {
  251. console.log('新增保存发送参数', this.requestParam)
  252. if (response.msg !== 'fail') {
  253. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  254. this.getList()
  255. } else {
  256. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  257. }
  258. })
  259. },
  260. createCancel(row) {
  261. console.log('点击了新增取消')
  262. for (let i = 0; i < this.table.list.length; i++) {
  263. if (row.myId === this.table.list[i].myId) {
  264. var listIndex = this.table.list.indexOf(this.table.list[i])
  265. }
  266. if (listIndex > -1) {
  267. this.table.list.splice(listIndex, 1)
  268. return
  269. }
  270. }
  271. },
  272. handleUpdate(row) {
  273. for (let i = 0; i < this.table.list.length; i++) {
  274. if (this.table.list[i].Edit == true) {
  275. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  276. return false
  277. }
  278. }
  279. // 编辑true,不可编辑false
  280. row.Edit = true
  281. row.NoEdit = false
  282. // 新增false,编辑false,编辑保存true
  283. row.isCreate = false
  284. row.isUpdate = false
  285. row.isUpdateSave = true
  286. },
  287. updateData(row) {
  288. console.log('点击了编辑保存')
  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.enable = row.enable
  294. this.table.temp.remark = row.remark
  295. this.table.temp.tclassid = '0'
  296. this.table.temp.maxstirfeed = '0'
  297. this.table.temp.id = row.id
  298. // 检验用户名称/角色是否为空
  299. if (this.table.temp.eqcode == '' && this.table.temp.tname == '' && this.table.temp.datacaptureno == '') {
  300. this.$message({ type: 'error', message: '铲车编号/铲车名称/数据采集卡编号不能为空', duration: 2000 })
  301. return false
  302. } else if (this.table.temp.tname == '' && this.table.temp.datacaptureno == '') {
  303. this.$message({ type: 'error', message: '铲车名称/数据采集卡编号不能为空', duration: 2000 })
  304. return false
  305. } else if (this.table.temp.eqcode == '') {
  306. this.$message({ type: 'error', message: '铲车编号不能为空', duration: 2000 })
  307. return false
  308. } else if (this.table.temp.tname == '') {
  309. this.$message({ type: 'error', message: '铲车名称不能为空', duration: 2000 })
  310. return false
  311. } else if (this.table.temp.datacaptureno == '') {
  312. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  313. return false
  314. }
  315. const datacaptureno = /^([0-9]|(1[0-5]))$/
  316. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  317. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  318. return false
  319. }
  320. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  321. console.log(this.table.temp.eqcode)
  322. if (pattern.test(this.table.temp.eqcode)) {
  323. this.$message({ type: 'error', message: '铲车编号不可输入特殊字符', duration: 2000 })
  324. return false
  325. }
  326. if (pattern.test(this.table.temp.tname)) {
  327. this.$message({ type: 'error', message: '铲车名称不可输入特殊字符', duration: 2000 })
  328. return false
  329. }
  330. this.isokDisable = true
  331. setTimeout(() => {
  332. this.isokDisable = false
  333. }, 1000)
  334. this.requestParam.name = 'updateTMR'
  335. this.requestParam.parammaps = this.table.temp
  336. PostDataByName(this.requestParam).then(response => {
  337. console.log('新增保存发送参数', this.requestParam)
  338. if (response.msg !== 'fail') {
  339. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  340. this.getList()
  341. } else {
  342. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  343. }
  344. })
  345. },
  346. updateCancel(row) {
  347. console.log('点击了编辑取消')
  348. // 编辑false,不可编辑true
  349. row.Edit = false
  350. row.NoEdit = true
  351. // 新增false,编辑true,编辑保存false
  352. row.isCreate = false
  353. row.isUpdate = true
  354. row.isUpdateSave = false
  355. this.getList()
  356. },
  357. handleRowDelete(row) {
  358. console.log('点击了行内删除')
  359. MessageBox.confirm('是否确认删除此信息?', {
  360. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  361. }).then(() => {
  362. this.selectList = []
  363. this.requestParam.data = []
  364. this.requestParam.data[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  365. 'pastureid': row.pastureid,
  366. 'id': row.id
  367. }}
  368. this.requestParam.data[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  369. 'pastureid': row.pastureid,
  370. 'id': row.id
  371. }}
  372. ExecDataByConfig(this.requestParam).then(response => {
  373. console.log('删除保存发送参数', this.requestParam)
  374. if (response.msg === 'fail') {
  375. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  376. } else {
  377. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  378. this.getList()
  379. }
  380. })
  381. }).catch(() => {
  382. this.$message({ type: 'info', message: '已取消删除' })
  383. })
  384. },
  385. handleSelectionChange(val) {
  386. console.log('勾选数据', val)
  387. this.selectList = val
  388. },
  389. handleDelete() {
  390. console.log('点击了删除')
  391. if (this.selectList.length == 0) {
  392. this.$message({ type: 'error', message: '请选择铲车信息', duration: 2000 })
  393. } else {
  394. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  395. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  396. }).then(() => {
  397. console.log(this.selectList)
  398. this.requestParam = {}
  399. this.requestParam.common = { 'returnmap': '0' }
  400. this.requestParam.data = []
  401. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  402. this.requestParam.data[0].children = []
  403. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  404. id: '@insertSpotList.id',
  405. pastureid: '@insertSpotList.pastureid'
  406. }}
  407. this.requestParam.data[0].children[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  408. id: '@insertSpotList.id',
  409. pastureid: '@insertSpotList.pastureid'
  410. }}
  411. ExecDataByConfig(this.requestParam).then(response => {
  412. console.log('删除保存发送参数', this.requestParam)
  413. if (response.msg === 'fail') {
  414. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  415. } else {
  416. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  417. this.getList()
  418. }
  419. })
  420. })
  421. }
  422. }
  423. }
  424. }
  425. </script>
  426. <style lang="scss" scoped>
  427. .search{margin-top:10px;}
  428. .table{margin-top:10px;}
  429. </style>