|
|
@ -169,82 +169,82 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
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(() => { |
|
|
|
resolve(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(() => { |
|
|
|
resolve(this.readEpc(param)) |
|
|
|
}, 2000) |
|
|
|
} else { |
|
|
|
this.errorStep = 2 |
|
|
|
this.step2Message = '读取标签失败' |
|
|
|
reject() |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 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)) |
|
|
|
// let res = await RFID.readEpc(param) |
|
|
|
// 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 = '当前标签存在多个,请取出多余的标签只保留一张!' |
|
|
|
// console.log(1) |
|
|
|
// if (!this.timer) { |
|
|
|
// this.timer = setInterval(() => { |
|
|
|
// this.readEpc(param) |
|
|
|
// }, 2000) |
|
|
|
// } else { |
|
|
|
// this.errorStep = 2 |
|
|
|
// this.step2Message = '读取标签失败' |
|
|
|
// reject() |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// }) |
|
|
|
// throw new Error('当前标签存在多个,请取出多余的标签只保留一张!') |
|
|
|
// } else if (res.data.length === 1) { |
|
|
|
// this.readData = res.data[0] |
|
|
|
// this.step3Message = '读取成功!' |
|
|
|
// this.step = 4 |
|
|
|
// if (this.timer) { |
|
|
|
// clearTimeout(this.timer) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } else if (res.code && res.code === '-2') { |
|
|
|
// this.errorStep = 2 |
|
|
|
// this.step2Message = '未读取到标签,请重新放入' |
|
|
|
// if (!this.timer) { |
|
|
|
// this.timer = setInterval(() => { |
|
|
|
// this.readEpc(param) |
|
|
|
// }, 2000) |
|
|
|
// } |
|
|
|
// throw new Error('未读取到标签,请重新放入') |
|
|
|
// } else { |
|
|
|
// this.errorStep = 2 |
|
|
|
// this.step2Message = '读取标签失败' |
|
|
|
// throw new Error('读取标签失败') |
|
|
|
// } |
|
|
|
// }, |
|
|
|
async readEpc(param) { |
|
|
|
let res = await RFID.readEpc(param) |
|
|
|
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 = '当前标签存在多个,请取出多余的标签只保留一张!' |
|
|
|
console.log(1) |
|
|
|
if (!this.timer) { |
|
|
|
this.timer = setInterval(() => { |
|
|
|
this.readEpc(param) |
|
|
|
}, 2000) |
|
|
|
} |
|
|
|
throw new Error('当前标签存在多个,请取出多余的标签只保留一张!') |
|
|
|
} else if (res.data.length === 1) { |
|
|
|
this.readData = res.data[0] |
|
|
|
this.step3Message = '读取成功!' |
|
|
|
this.step = 4 |
|
|
|
if (this.timer) { |
|
|
|
clearTimeout(this.timer) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (res.code && res.code === '-2') { |
|
|
|
this.errorStep = 2 |
|
|
|
this.step2Message = '未读取到标签,请重新放入' |
|
|
|
if (!this.timer) { |
|
|
|
this.timer = setInterval(() => { |
|
|
|
this.readEpc(param) |
|
|
|
}, 2000) |
|
|
|
} |
|
|
|
throw new Error('未读取到标签,请重新放入') |
|
|
|
} else { |
|
|
|
this.errorStep = 2 |
|
|
|
this.step2Message = '读取标签失败' |
|
|
|
throw new Error('读取标签失败') |
|
|
|
} |
|
|
|
}, |
|
|
|
async tryConnect(param) { |
|
|
|
let res |
|
|
|
let err |
|
|
@ -267,34 +267,40 @@ export default { |
|
|
|
}, |
|
|
|
async startBind(isCover) { |
|
|
|
console.log(isCover) |
|
|
|
// return new Promise((resolve, reject) => { |
|
|
|
this.step4Message = '绑定中' |
|
|
|
const data = { id: this.bindingId, labelType: this.bindingType, tid: this.readData.tid } |
|
|
|
if (isCover || this.readData.tid === this.tidCode) { |
|
|
|
data.coverLabel = true |
|
|
|
} |
|
|
|
const res = await bingdingLabel(data) |
|
|
|
if (res === '当前标签已被绑定') { |
|
|
|
this.coverBindingVisible = true |
|
|
|
} else { |
|
|
|
let writeRes = await RFID.writeEPC({ op: 'RFID_WriteEPC', sDevID: 'D001', EAS: '1', Type: this.bindingType, Code: this.bindingId, Tid: this.readData.tid }) |
|
|
|
writeRes = JSON.parse(writeRes) |
|
|
|
if (writeRes.code === '0') { |
|
|
|
this.step = 5 |
|
|
|
} else if (writeRes.code === '-1') { |
|
|
|
this.$notify({ |
|
|
|
title: writeRes.message, |
|
|
|
type: 'error', |
|
|
|
duration: 2500 |
|
|
|
}) |
|
|
|
} else if (writeRes.code === '-1000') { |
|
|
|
this.$notify({ |
|
|
|
title: '读写器超时未响应', |
|
|
|
type: 'error', |
|
|
|
duration: 2500 |
|
|
|
}) |
|
|
|
return await new Promise(async(resolve, reject) => { |
|
|
|
this.step4Message = '绑定中' |
|
|
|
const data = { id: this.bindingId, labelType: this.bindingType, tid: this.readData.tid } |
|
|
|
if (isCover || this.readData.tid === this.tidCode) { |
|
|
|
data.coverLabel = true |
|
|
|
} |
|
|
|
} |
|
|
|
const res = await bingdingLabel(data) |
|
|
|
if (res === '当前标签已被绑定') { |
|
|
|
this.coverBindingVisible = true |
|
|
|
resolve() |
|
|
|
// else if() {} else {reject()} |
|
|
|
} else { |
|
|
|
let writeRes = await RFID.writeEPC({ op: 'RFID_WriteEPC', sDevID: 'D001', EAS: '1', Type: this.bindingType, Code: this.bindingId, Tid: this.readData.tid }) |
|
|
|
writeRes = JSON.parse(writeRes) |
|
|
|
if (writeRes.code === '0') { |
|
|
|
this.step = 5 |
|
|
|
resolve() |
|
|
|
} else if (writeRes.code === '-1') { |
|
|
|
this.$notify({ |
|
|
|
title: writeRes.message, |
|
|
|
type: 'error', |
|
|
|
duration: 2500 |
|
|
|
}) |
|
|
|
reject() |
|
|
|
} else if (writeRes.code === '-1000') { |
|
|
|
this.$notify({ |
|
|
|
title: '读写器超时未响应', |
|
|
|
type: 'error', |
|
|
|
duration: 2500 |
|
|
|
}) |
|
|
|
reject() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
async opened() { |
|
|
|
if (!this.isBinding) { |
|
|
|