|
@ -124,7 +124,9 @@ export default { |
|
|
step3Message: '放入标签后开始读取标签', |
|
|
step3Message: '放入标签后开始读取标签', |
|
|
step4Message: '标签读取成功后,开始绑定档案', |
|
|
step4Message: '标签读取成功后,开始绑定档案', |
|
|
step5Message: '当前标签与' + this.bindingTxt + '绑定成功', |
|
|
step5Message: '当前标签与' + this.bindingTxt + '绑定成功', |
|
|
readData: null |
|
|
|
|
|
|
|
|
readData: {}, |
|
|
|
|
|
timeOut: null, |
|
|
|
|
|
timer: null |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
@ -132,6 +134,11 @@ export default { |
|
|
return this.isBinding ? '重新绑定' : '绑定标签' |
|
|
return this.isBinding ? '重新绑定' : '绑定标签' |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
beforeDestroy() { |
|
|
|
|
|
// 清除定时器 |
|
|
|
|
|
clearTimeout(this.timeOut) |
|
|
|
|
|
this.timeOut = null |
|
|
|
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
initData() { |
|
|
initData() { |
|
|
this.step = 1 |
|
|
this.step = 1 |
|
@ -160,9 +167,44 @@ export default { |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
// async readEpc(param) { |
|
|
|
|
|
// return new Promise((resolve, reject) => { |
|
|
|
|
|
// RFID.readEpc(param).then(res => { |
|
|
|
|
|
// res = JSON.parse(res) |
|
|
|
|
|
// if (res.code && res.code === '0') { |
|
|
|
|
|
// this.step = 3 |
|
|
|
|
|
// this.errorStep = 0 |
|
|
|
|
|
// this.step2Message = '已放入标签' |
|
|
|
|
|
// if (res.data.length > 1) { |
|
|
|
|
|
// this.errorStep = 3 |
|
|
|
|
|
// this.step3Message = '当前标签存在多个,请取出多余的标签只保留一张!' |
|
|
|
|
|
// clearTimeout(this.timer) |
|
|
|
|
|
// this.timer = setTimeout(() => { |
|
|
|
|
|
// reject(this.readEpc(param)) |
|
|
|
|
|
// }, 2000) |
|
|
|
|
|
// } else if (res.data.length === 1) { |
|
|
|
|
|
// this.readData = res.data[0] |
|
|
|
|
|
// this.step3Message = '读取成功!' |
|
|
|
|
|
// this.step = 4 |
|
|
|
|
|
// } |
|
|
|
|
|
// resolve() |
|
|
|
|
|
// } else if (res.code && res.code === '-2') { |
|
|
|
|
|
// this.errorStep = 2 |
|
|
|
|
|
// this.step2Message = '未读取到标签,请重新放入' |
|
|
|
|
|
// clearTimeout(this.timer) |
|
|
|
|
|
// this.timer = setTimeout(() => { |
|
|
|
|
|
// reject(this.readEpc(param)) |
|
|
|
|
|
// }, 2000) |
|
|
|
|
|
// } else { |
|
|
|
|
|
// this.errorStep = 2 |
|
|
|
|
|
// this.step2Message = '读取标签失败' |
|
|
|
|
|
// reject() |
|
|
|
|
|
// } |
|
|
|
|
|
// }) |
|
|
|
|
|
// }) |
|
|
|
|
|
// }, |
|
|
async readEpc(param) { |
|
|
async readEpc(param) { |
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
RFID.readEpc(param).then(res => { |
|
|
|
|
|
|
|
|
let res = await RFID.readEpc(param) |
|
|
res = JSON.parse(res) |
|
|
res = JSON.parse(res) |
|
|
if (res.code && res.code === '0') { |
|
|
if (res.code && res.code === '0') { |
|
|
this.step = 3 |
|
|
this.step = 3 |
|
@ -171,28 +213,35 @@ export default { |
|
|
if (res.data.length > 1) { |
|
|
if (res.data.length > 1) { |
|
|
this.errorStep = 3 |
|
|
this.errorStep = 3 |
|
|
this.step3Message = '当前标签存在多个,请取出多余的标签只保留一张!' |
|
|
this.step3Message = '当前标签存在多个,请取出多余的标签只保留一张!' |
|
|
setTimeout(() => { |
|
|
|
|
|
resolve(this.readEpc(param)) |
|
|
|
|
|
|
|
|
console.log(1) |
|
|
|
|
|
if (!this.timer) { |
|
|
|
|
|
this.timer = setInterval(() => { |
|
|
|
|
|
this.readEpc(param) |
|
|
}, 2000) |
|
|
}, 2000) |
|
|
|
|
|
} |
|
|
|
|
|
throw new Error('当前标签存在多个,请取出多余的标签只保留一张!') |
|
|
} else if (res.data.length === 1) { |
|
|
} else if (res.data.length === 1) { |
|
|
this.readData = res.data[0] |
|
|
this.readData = res.data[0] |
|
|
this.step3Message = '读取成功!' |
|
|
this.step3Message = '读取成功!' |
|
|
this.step = 4 |
|
|
this.step = 4 |
|
|
|
|
|
if (this.timer) { |
|
|
|
|
|
clearTimeout(this.timer) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
resolve() |
|
|
|
|
|
} else if (res.code && res.code === '-2') { |
|
|
} else if (res.code && res.code === '-2') { |
|
|
this.errorStep = 2 |
|
|
this.errorStep = 2 |
|
|
this.step2Message = '未读取到标签,请重新放入' |
|
|
this.step2Message = '未读取到标签,请重新放入' |
|
|
setTimeout(() => { |
|
|
|
|
|
resolve(this.readEpc(param)) |
|
|
|
|
|
|
|
|
if (!this.timer) { |
|
|
|
|
|
this.timer = setInterval(() => { |
|
|
|
|
|
this.readEpc(param) |
|
|
}, 2000) |
|
|
}, 2000) |
|
|
|
|
|
} |
|
|
|
|
|
throw new Error('未读取到标签,请重新放入') |
|
|
} else { |
|
|
} else { |
|
|
this.errorStep = 2 |
|
|
this.errorStep = 2 |
|
|
this.step2Message = '读取标签失败' |
|
|
this.step2Message = '读取标签失败' |
|
|
reject() |
|
|
|
|
|
|
|
|
throw new Error('读取标签失败') |
|
|
} |
|
|
} |
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
}, |
|
|
async tryConnect(param) { |
|
|
async tryConnect(param) { |
|
|
let res |
|
|
let res |
|
@ -209,16 +258,16 @@ export default { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (res) return res |
|
|
if (res) return res |
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
|
this.timeOut = setTimeout(() => { |
|
|
this.$refs.bindingTagDialog.handleClose() |
|
|
this.$refs.bindingTagDialog.handleClose() |
|
|
}, 3000) |
|
|
}, 3000) |
|
|
throw err |
|
|
throw err |
|
|
}, |
|
|
}, |
|
|
async startBind(isCover) { |
|
|
async startBind(isCover) { |
|
|
|
|
|
console.log(isCover) |
|
|
// return new Promise((resolve, reject) => { |
|
|
// return new Promise((resolve, reject) => { |
|
|
this.step4Message = '绑定中' |
|
|
this.step4Message = '绑定中' |
|
|
const data = { id: this.bindingId, labelType: this.bindingType, tid: this.readData.tid } |
|
|
const data = { id: this.bindingId, labelType: this.bindingType, tid: this.readData.tid } |
|
|
console.log(2) |
|
|
|
|
|
if (isCover || this.readData.tid === this.tidCode) { |
|
|
if (isCover || this.readData.tid === this.tidCode) { |
|
|
data.coverLabel = true |
|
|
data.coverLabel = true |
|
|
} |
|
|
} |
|
@ -264,6 +313,9 @@ export default { |
|
|
this.$emit('refresh') |
|
|
this.$emit('refresh') |
|
|
done() |
|
|
done() |
|
|
this.initData() |
|
|
this.initData() |
|
|
|
|
|
if (this.timer) { |
|
|
|
|
|
clearTimeout(this.timer) |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
handleCoverBindingClose(done) { |
|
|
handleCoverBindingClose(done) { |
|
|
done() |
|
|
done() |
|
|