54dd9a772661e6e5aaae34505d4dc2e6390526a5.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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.eqcode }}</span>
  42. <el-select v-if="scope.row.Edit" v-model="scope.row.eqcode">
  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: 1, name: '推料车' }, { id: 2, 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. handleSearch() {
  180. console.log('点击了查询')
  181. this.table.getdataListParm.offset = 1
  182. this.getList()
  183. },
  184. handleRefresh() {
  185. console.log('点击了重置')
  186. this.table.getdataListParm.parammaps.eqcode = ''
  187. this.table.getdataListParm.parammaps.tname = ''
  188. this.table.getdataListParm.parammaps.enable = ''
  189. this.table.getdataListParm.parammaps.eqtype = '0'
  190. this.table.getdataListParm.offset = 1
  191. this.getList()
  192. },
  193. handleCreate() {
  194. console.log('点击了新增')
  195. // 编辑true/不可编辑false
  196. // 新增操true,编辑false,编辑保存false
  197. for (let i = 0; i < this.table.list.length; i++) {
  198. if (this.table.list[i].Edit == true) {
  199. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  200. return false
  201. }
  202. }
  203. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'eqcode': '', 'tname': '', 'datacaptureno': '' })
  204. },
  205. createData(row) {
  206. console.log('点击了新增保存')
  207. this.table.temp.pastureid = Cookies.get('pastureid')
  208. this.table.temp.eqcode = row.eqcode
  209. this.table.temp.tname = row.tname
  210. this.table.temp.datacaptureno = row.datacaptureno
  211. this.table.temp.enable = row.enable
  212. this.table.temp.remark = row.remark
  213. this.table.temp.tclassid = '0'
  214. this.table.temp.maxstirfeed = '0'
  215. // 检验用户名称/角色是否为空
  216. if (this.table.temp.eqcode == '' && 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.tname == '' && this.table.temp.datacaptureno == '') {
  220. this.$message({ type: 'error', message: '铲车名称/数据采集卡编号不能为空', duration: 2000 })
  221. return false
  222. } else if (this.table.temp.eqcode == '') {
  223. this.$message({ type: 'error', message: '铲车编号不能为空', duration: 2000 })
  224. return false
  225. } else if (this.table.temp.tname == '') {
  226. this.$message({ type: 'error', message: '铲车名称不能为空', duration: 2000 })
  227. return false
  228. } else if (this.table.temp.datacaptureno == '') {
  229. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  230. return false
  231. }
  232. const datacaptureno = /^([0-9]|(1[0-5]))$/
  233. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  234. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  235. return false
  236. }
  237. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  238. console.log(this.table.temp.eqcode)
  239. if (pattern.test(this.table.temp.eqcode)) {
  240. this.$message({ type: 'error', message: '铲车编号不可输入特殊字符', duration: 2000 })
  241. return false
  242. }
  243. if (pattern.test(this.table.temp.tname)) {
  244. this.$message({ type: 'error', message: '铲车名称不可输入特殊字符', duration: 2000 })
  245. return false
  246. }
  247. this.isokDisable = true
  248. setTimeout(() => {
  249. this.isokDisable = false
  250. }, 1000)
  251. this.requestParam.name = 'insertTMR'
  252. this.requestParam.parammaps = this.table.temp
  253. PostDataByName(this.requestParam).then(response => {
  254. console.log('新增保存发送参数', this.requestParam)
  255. if (response.msg !== 'fail') {
  256. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  257. this.getList()
  258. } else {
  259. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  260. }
  261. })
  262. },
  263. createCancel(row) {
  264. console.log('点击了新增取消')
  265. for (let i = 0; i < this.table.list.length; i++) {
  266. if (row.myId === this.table.list[i].myId) {
  267. var listIndex = this.table.list.indexOf(this.table.list[i])
  268. }
  269. if (listIndex > -1) {
  270. this.table.list.splice(listIndex, 1)
  271. return
  272. }
  273. }
  274. },
  275. handleUpdate(row) {
  276. for (let i = 0; i < this.table.list.length; i++) {
  277. if (this.table.list[i].Edit == true) {
  278. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  279. return false
  280. }
  281. }
  282. // 编辑true,不可编辑false
  283. row.Edit = true
  284. row.NoEdit = false
  285. // 新增false,编辑false,编辑保存true
  286. row.isCreate = false
  287. row.isUpdate = false
  288. row.isUpdateSave = true
  289. },
  290. updateData(row) {
  291. console.log('点击了编辑保存')
  292. this.table.temp.pastureid = Cookies.get('pastureid')
  293. this.table.temp.eqcode = row.eqcode
  294. this.table.temp.tname = row.tname
  295. this.table.temp.datacaptureno = row.datacaptureno
  296. this.table.temp.enable = row.enable
  297. this.table.temp.remark = row.remark
  298. this.table.temp.tclassid = '0'
  299. this.table.temp.maxstirfeed = '0'
  300. this.table.temp.id = row.id
  301. // 检验用户名称/角色是否为空
  302. if (this.table.temp.eqcode == '' && 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.tname == '' && this.table.temp.datacaptureno == '') {
  306. this.$message({ type: 'error', message: '铲车名称/数据采集卡编号不能为空', duration: 2000 })
  307. return false
  308. } else if (this.table.temp.eqcode == '') {
  309. this.$message({ type: 'error', message: '铲车编号不能为空', duration: 2000 })
  310. return false
  311. } else if (this.table.temp.tname == '') {
  312. this.$message({ type: 'error', message: '铲车名称不能为空', duration: 2000 })
  313. return false
  314. } else if (this.table.temp.datacaptureno == '') {
  315. this.$message({ type: 'error', message: '数据采集卡编号不能为空', duration: 2000 })
  316. return false
  317. }
  318. const datacaptureno = /^([0-9]|(1[0-5]))$/
  319. if (!datacaptureno.test(parseInt(this.table.temp.datacaptureno))) {
  320. this.$message({ type: 'error', message: '数据采集卡请输入0-15之间整数', duration: 2000 })
  321. return false
  322. }
  323. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  324. console.log(this.table.temp.eqcode)
  325. if (pattern.test(this.table.temp.eqcode)) {
  326. this.$message({ type: 'error', message: '铲车编号不可输入特殊字符', duration: 2000 })
  327. return false
  328. }
  329. if (pattern.test(this.table.temp.tname)) {
  330. this.$message({ type: 'error', message: '铲车名称不可输入特殊字符', duration: 2000 })
  331. return false
  332. }
  333. this.isokDisable = true
  334. setTimeout(() => {
  335. this.isokDisable = false
  336. }, 1000)
  337. this.requestParam.name = 'updateTMR'
  338. this.requestParam.parammaps = this.table.temp
  339. PostDataByName(this.requestParam).then(response => {
  340. console.log('新增保存发送参数', this.requestParam)
  341. if (response.msg !== 'fail') {
  342. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  343. this.getList()
  344. } else {
  345. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  346. }
  347. })
  348. },
  349. updateCancel(row) {
  350. console.log('点击了编辑取消')
  351. // 编辑false,不可编辑true
  352. row.Edit = false
  353. row.NoEdit = true
  354. // 新增false,编辑true,编辑保存false
  355. row.isCreate = false
  356. row.isUpdate = true
  357. row.isUpdateSave = false
  358. this.getList()
  359. },
  360. handleRowDelete(row) {
  361. console.log('点击了行内删除')
  362. MessageBox.confirm('是否确认删除此信息?', {
  363. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  364. }).then(() => {
  365. this.selectList = []
  366. this.requestParam.data = []
  367. this.requestParam.data[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  368. 'pastureid': row.pastureid,
  369. 'id': row.id
  370. }}
  371. this.requestParam.data[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  372. 'pastureid': row.pastureid,
  373. 'id': row.id
  374. }}
  375. ExecDataByConfig(this.requestParam).then(response => {
  376. console.log('删除保存发送参数', this.requestParam)
  377. if (response.msg === 'fail') {
  378. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  379. } else {
  380. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  381. this.getList()
  382. }
  383. })
  384. }).catch(() => {
  385. this.$message({ type: 'info', message: '已取消删除' })
  386. })
  387. },
  388. handleSelectionChange(val) {
  389. console.log('勾选数据', val)
  390. this.selectList = val
  391. },
  392. handleDelete() {
  393. console.log('点击了删除')
  394. if (this.selectList.length == 0) {
  395. this.$message({ type: 'error', message: '请选择铲车信息', duration: 2000 })
  396. } else {
  397. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  398. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  399. }).then(() => {
  400. console.log(this.selectList)
  401. this.requestParam = {}
  402. this.requestParam.common = { 'returnmap': '0' }
  403. this.requestParam.data = []
  404. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  405. this.requestParam.data[0].children = []
  406. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteTmr', 'type': 'v', 'parammaps': {
  407. id: '@insertSpotList.id',
  408. pastureid: '@insertSpotList.pastureid'
  409. }}
  410. this.requestParam.data[0].children[1] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  411. id: '@insertSpotList.id',
  412. pastureid: '@insertSpotList.pastureid'
  413. }}
  414. ExecDataByConfig(this.requestParam).then(response => {
  415. console.log('删除保存发送参数', this.requestParam)
  416. if (response.msg === 'fail') {
  417. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  418. } else {
  419. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  420. this.getList()
  421. }
  422. })
  423. })
  424. }
  425. }
  426. }
  427. }
  428. </script>
  429. <style lang="scss" scoped>
  430. .search{margin-top:10px;}
  431. .table{margin-top:10px;}
  432. </style>