Browse Source

解除/恢复报警bug

master
xuhuajiao 2 years ago
parent
commit
6229bb2220
  1. 4
      src/views/archivesManage/lendManage/components/releaseAlarm.vue
  2. 133
      src/views/archivesManage/lendManage/mixins/lending.js

4
src/views/archivesManage/lendManage/components/releaseAlarm.vue

@ -6,7 +6,7 @@
<span class="dialog-left-bottom" />
<div class="setting-dialog">
<p style="color: #fff; margin: 0 0 20px 40px;">{{ '以下档案需要先'+ isRealseOrRecoverBtn +'电子标签警报' }}</p>
<el-table :key="Math.random()" :data="tipTable" :cell-class-name="cellWarn" height="325px">
<el-table :key="isKey" :data="tipTable" :cell-class-name="cellWarn" height="325px">
<el-table-column type="index" label="序号" align="center" width="80" />
<el-table-column prop="tagType" label="类型" align="center">
<template slot-scope="scope">
@ -24,7 +24,7 @@
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button v-loading="unbindWarnLoading" type="primary" :disabled="btnDisabled" @click="writeEPC(isRealseOrRecoverType)">{{ isRealseOrRecoverBtn + '报警' }}</el-button>
<el-button v-loading="unbindWarnLoading" type="primary" :disabled="btnDisabled" @click="opened(isRealseOrRecoverType)">{{ isRealseOrRecoverBtn + '报警' }}</el-button>
</div>
</div>
</el-dialog>

133
src/views/archivesManage/lendManage/mixins/lending.js

@ -54,12 +54,18 @@ export const lendingCrud = {
],
// epc
btnDisabled: false,
devId: 'D001',
devId: '',
devIp: '',
timer: null,
flagNum: 0,
unbindWarnLoading: false,
tipIndex: 0,
ase: 0
ase: 0,
tagType: null,
arcId: null,
aseTid: null,
isFlag: false,
isKey: false
}
},
// 组件挂载时的共用方法
@ -158,16 +164,23 @@ export const lendingCrud = {
}
},
// 写epc
async writeEPC(ase) {
async writeEPC() {
if (this.isFlag) {
this.tagType = this.tipTable[this.tipIndex].tagType
this.arcId = this.tipTable[this.tipIndex].archivesId
this.aseTid = this.tipTable[this.tipIndex].tid
}
this.flagNum++
this.ase = ase
this.btnDisabled = true
this.unbindWarnLoading = true
return new Promise(async(resolve, reject) => {
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 }
const params = { op: 'RFID_WriteEPC', sDevID: this.devId, EAS: this.ase, Type: this.tagType, Code: this.arcId, Tid: this.aseTid, ip: this.devIp }
let writeRes = await RFID.writeEPC(params)
writeRes = JSON.parse(writeRes)
if (writeRes.code === '0') {
this.isKey = !this.isKey
// 判断是解除还是恢复
if (this.ase === 0) {
this.tipTable[this.tipIndex].warnState = '已解除'
} else {
@ -175,18 +188,15 @@ export const lendingCrud = {
}
this.btnDisabled = false
this.unbindWarnLoading = false
this.tipIndex = this.tipIndex + 1
// this.tipIndex = this.tipIndex + 1
if (this.tipIndex !== this.tipTable.length) {
this.flagNum = 0
this.btnDisabled = true
this.unbindWarnLoading = true
clearTimeout(this.timer)
this.timer = setTimeout(() => {
if (this.ase === 0) {
resolve(this.writeEPC(0))
} else {
resolve(this.writeEPC(1))
}
resolve(this.writeEPC())
}, 2000)
} else {
clearTimeout(this.timer)
@ -199,11 +209,13 @@ export const lendingCrud = {
} else {
params = this.lendSelections.map(item => item.id)
}
console.log(params)
// 全部成功之后确认借出 / 归还
this.confirmLendOrReturn(this.ase, params, this.lendSelections)
} else {
this.alarmErrorTip()
}
}, 2000)
}, 4000)
}
// resolve()
} else if (writeRes.code === '-1') {
@ -215,6 +227,97 @@ export const lendingCrud = {
}
})
},
async getDevId() {
return await new Promise(async(resolve, reject) => {
// const mac = await RFID.getDeviceMac()
const mac = '12-34-56-12-34-56'
if (!mac || mac === '') {
this.$message.error('获取mac地址失败')
} else {
const dev = await RFID.getDeviceIdByMac(mac)
if (!dev || dev === {} || !dev.deviceId) {
this.$message.error('当前电脑未绑定读写器,请到档案设备里进行绑定')
} else {
resolve(dev)
}
}
})
},
readEpc(param) {
return new Promise((resolve, reject) => {
RFID.readEpc(param).then(res => {
res = JSON.parse(res)
if (res.code && res.code === '0') {
this.$message.success('已放入标签')
// 判断table内的标签和桌面读取标签比较
this.tipTable.map((item, index) => {
res.data.map((item1, index1) => {
if (item.tid === item1.tid) {
this.isFlag = true
console.log('index', index)
this.tipIndex = index
resolve(this.writeEPC())
} else {
console.log('index2', index)
this.isFlag = false
this.$message.error('请注意,未读到正确的档案标签')
}
})
})
} else if (res.code && res.code === '-2') {
this.$message.error('未读取到标签,请重新放入')
clearTimeout(this.timer)
this.timer = setTimeout(() => {
resolve(this.readEpc(param))
}, 2000)
} else {
this.$message.error('读取标签失败')
reject()
}
})
})
},
async opened(ase) {
this.ase = ase
const devInfo = await this.getDevId()
this.devId = devInfo.deviceId
this.devIp = devInfo.deviceIp + ':' + devInfo.devicePort
await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: devInfo.deviceId, ip: this.devIp })
await this.readEpc({ op: 'RFID_ReadEpc', sDevID: devInfo.deviceId, ip: this.devIp })
// await this.writeEPC(ase)
},
async checkStatus(param) {
return RFID.checkStatus(param).then((res) => {
res = JSON.parse(res)
if (res.code && res.code === '0') {
this.$message.success('连接成功')
return true
} else {
if (res.code && res.code === '-1') {
this.$message.error('读写器状态异常(例如读写器USB线未插入)')
} else if (res.code === '-1000') {
this.$message.error('读写器超时未响应(例如终端读写服务未开启或网络异常)')
}
}
})
},
async tryConnect(param) {
let res
let err
const MAX_NUM_RETRIES = 3
for (let i = 0; i < MAX_NUM_RETRIES; i++) {
try {
res = await this.checkStatus(param)
break
} catch (e) {
err = e
this.$message.error('连接失败,请检查网络')
}
}
if (res) return res
throw err
},
// 只要有一条未解除/恢复成功即errorTip
alarmErrorTip() {
if (this.ase === 0) {
@ -247,11 +350,7 @@ export const lendingCrud = {
this.unbindWarnLoading = true
clearTimeout(this.timer)
this.timer = setTimeout(() => {
if (this.ase === 0) {
resolve(this.writeEPC(0))
} else {
resolve(this.writeEPC(1))
}
resolve(this.writeEPC())
}, 2000)
} else {
clearTimeout(this.timer)

Loading…
Cancel
Save