c3c094207ac4934147617cc1347f42947f6ea843.svn-base 20 KB

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