【前端】智能库房综合管理系统前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
7.7 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. import { FetchInitBorrowRule, FetchBillBorrowConfirm, FetchArchivesReturnConfirm } from '@/api/archivesManage/lendManage'
  2. import { FetchFindAllSubsetById } from '@/api/archivesConfig/dictDetail'
  3. import RFID from '@/api/RFID/RFID'
  4. export const lendingCrud = {
  5. filters: {
  6. borrowStatus(val) {
  7. switch (val) {
  8. case 1:
  9. return '待登记'
  10. case 2:
  11. return '待借阅'
  12. case 3:
  13. return '待归还'
  14. case 4:
  15. return '已归还'
  16. case 5:
  17. return '逾期'
  18. }
  19. },
  20. tidType(val) {
  21. switch (val) {
  22. case 1:
  23. return '档案'
  24. case 2:
  25. return '档案盒'
  26. case 3:
  27. return '层架位'
  28. }
  29. }
  30. },
  31. // 组件共用属性
  32. data() {
  33. return {
  34. lineStateVal: '',
  35. lendQuery: {},
  36. lendSelect: '',
  37. options: [],
  38. departOptions: [],
  39. idTypeOptions: [
  40. { value: '身份证', label: '身份证' },
  41. { value: '军官证', label: '军官证' },
  42. { value: '士官证', label: '士官证' },
  43. { value: '文职人员证', label: '文职人员证' }
  44. ],
  45. // epc
  46. btnDisabled: false,
  47. devId: 'D001',
  48. timer: null,
  49. flagNum: 0,
  50. unbindWarnLoading: false,
  51. tipIndex: 0,
  52. ase: 0
  53. }
  54. },
  55. // 组件挂载时的共用方法
  56. mounted() {
  57. if (this.queryOption) {
  58. this.lendSelect = this.queryOption[0].value
  59. }
  60. },
  61. // 组件共用方法
  62. methods: {
  63. borrowStyle(val) {
  64. switch (val) {
  65. case '逾期':
  66. return 'cell-lend have-lend'
  67. case '已归还':
  68. return 'cell-lend has-return'
  69. default:
  70. return 'cell-lend no-lend '
  71. }
  72. },
  73. // 获取部门list
  74. getDepart() {
  75. FetchFindAllSubsetById({ id: 'BA3910917510B181160A9A' }).then(data => {
  76. this.departOptions = data
  77. })
  78. },
  79. selectionChangeHandler(val) {
  80. this.selections = val
  81. },
  82. // 档案详情
  83. handleDbClick(row) {
  84. this.$nextTick(() => {
  85. const archiveDetailDom = this.$refs.archiveDetailDom
  86. archiveDetailDom.detailVisible = true
  87. archiveDetailDom.rowData = row
  88. archiveDetailDom.getBillDetails()
  89. })
  90. },
  91. // 判断当前借阅规则
  92. getBorrowRule() {
  93. FetchInitBorrowRule().then(data => {
  94. if (data) {
  95. this.lineStateVal = data === 'true' ? 'online' : 'offline'
  96. }
  97. })
  98. },
  99. // 借出确认 / 归还确认
  100. confirmLendOrReturn(type, params, selections) {
  101. if (type === 0) {
  102. FetchBillBorrowConfirm(params).then(data => {
  103. if (data === selections.length) {
  104. this.$message.success('借阅成功 ' + data + ' 条数据' + ' ' + '借阅失败0条数据')
  105. this.releaseAlarmVisible = false
  106. this.crud.refresh()
  107. }
  108. })
  109. } else {
  110. FetchArchivesReturnConfirm(params).then(data => {
  111. if (data === selections.length) {
  112. this.$message.success('归还成功 ' + data + ' 条数据' + ' ' + '归还失败0条数据')
  113. this.releaseAlarmVisible = false
  114. this.crud.refresh()
  115. }
  116. })
  117. }
  118. },
  119. // 解除/恢复中关闭icon不可操作
  120. handleCancle() {
  121. this.releaseAlarmVisible = !!this.btnDisabled
  122. },
  123. // 解除/恢复 状态style
  124. cellWarn({ row, columnIndex }) {
  125. if ((row.warnState === '未解除' || row.warnState === '未恢复') && columnIndex === 4) {
  126. return 'no-clear'
  127. } else if ((row.warnState === '已解除' || row.warnState === '已恢复') && columnIndex === 4) {
  128. return 'have-clear'
  129. } else if ((row.warnState === '解除失败' || row.warnState === '恢复失败') && columnIndex === 4) {
  130. return 'fail-clear'
  131. }
  132. },
  133. // 写epc
  134. async writeEPC(ase) {
  135. this.flagNum++
  136. this.ase = ase
  137. this.btnDisabled = true
  138. this.unbindWarnLoading = true
  139. return new Promise(async(resolve, reject) => {
  140. const params = { op: 'RFID_WriteEPC', sDevID: this.devId, EAS: this.ase, Type: this.tipTable[this.tipIndex].tagType, Code: this.tipTable[this.tipIndex].archivesId, Tid: this.tipTable[this.tipIndex].tid }
  141. let writeRes = await RFID.writeEPC(params)
  142. writeRes = JSON.parse(writeRes)
  143. if (writeRes.code === '0') {
  144. if (this.ase === 0) {
  145. this.tipTable[this.tipIndex].warnState = '已解除'
  146. } else {
  147. this.tipTable[this.tipIndex].warnState = '已恢复'
  148. }
  149. this.btnDisabled = false
  150. this.unbindWarnLoading = false
  151. this.tipIndex = this.tipIndex + 1
  152. if (this.tipIndex !== this.tipTable.length) {
  153. this.flagNum = 0
  154. this.btnDisabled = true
  155. this.unbindWarnLoading = true
  156. clearTimeout(this.timer)
  157. this.timer = setTimeout(() => {
  158. if (this.ase === 0) {
  159. resolve(this.writeEPC(0))
  160. } else {
  161. resolve(this.writeEPC(1))
  162. }
  163. }, 2000)
  164. } else {
  165. clearTimeout(this.timer)
  166. setTimeout(() => {
  167. const index = this.tipTable.findIndex((item) => item.warnState === '解除失败' || item.warnState === '恢复失败')
  168. if (index === -1) {
  169. let params
  170. if (this.ase === 0) {
  171. params = this.lendSelections.map(item => item.orderNo)
  172. } else {
  173. params = this.lendSelections.map(item => item.id)
  174. }
  175. this.confirmLendOrReturn(this.ase, params, this.lendSelections)
  176. } else {
  177. this.alarmErrorTip()
  178. }
  179. }, 2000)
  180. }
  181. // resolve()
  182. } else if (writeRes.code === '-1') {
  183. this.releaseAlarmErrorHandle(resolve, '标签损坏或丢失,需要用户自主去解除或恢复电子标签绑定')
  184. // reject()
  185. } else if (writeRes.code === '-1000') {
  186. this.releaseAlarmErrorHandle(resolve, '读写器超时未响应')
  187. // reject()
  188. }
  189. })
  190. },
  191. // 只要有一条未解除/恢复成功即errorTip
  192. alarmErrorTip() {
  193. if (this.ase === 0) {
  194. this.$message.error('借阅成功0条数据' + ' ' + '借阅失败' + this.lendSelections.length + '条数据')
  195. } else {
  196. this.$message.error('归还成功0条数据' + ' ' + '归还失败' + this.lendSelections.length + '条数据')
  197. }
  198. this.releaseAlarmVisible = false
  199. this.crud.refresh()
  200. },
  201. // 写epc不成功时的操作提示 -1 / -1000
  202. releaseAlarmErrorHandle(resolve, message) {
  203. if (this.flagNum >= 3) {
  204. if (this.ase === 0) {
  205. this.tipTable[this.tipIndex].warnState = '解除失败'
  206. } else {
  207. this.tipTable[this.tipIndex].warnState = '恢复失败'
  208. }
  209. this.btnDisabled = false
  210. this.unbindWarnLoading = false
  211. this.tipIndex = this.tipIndex + 1
  212. this.flagNum = 0
  213. this.$message({
  214. message: message,
  215. type: 'error'
  216. })
  217. }
  218. if (this.tipIndex !== this.tipTable.length) {
  219. this.btnDisabled = true
  220. this.unbindWarnLoading = true
  221. clearTimeout(this.timer)
  222. this.timer = setTimeout(() => {
  223. if (this.ase === 0) {
  224. resolve(this.writeEPC(0))
  225. } else {
  226. resolve(this.writeEPC(1))
  227. }
  228. }, 2000)
  229. } else {
  230. clearTimeout(this.timer)
  231. this.timer = setTimeout(() => {
  232. const findErrorArray = this.tipTable.map((item) => item.warnState === '解除失败' || item.warnState === '恢复失败')
  233. if (findErrorArray.length === this.tipTable.length) {
  234. this.alarmErrorTip()
  235. }
  236. }, 2000)
  237. }
  238. }
  239. }
  240. }