|
|
@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<el-dialog class="bindingDialog" :title="bindingTitle" :visible.sync="bindingVisible" :close-on-click-modal="false" :before-close="handleClose" @opened="opened"> |
|
|
|
<el-dialog ref="dialog" class="bindingDialog" :title="bindingTitle" :visible.sync="bindingVisible" :close-on-click-modal="false" :before-close="handleClose" @opened="opened"> |
|
|
|
<span class="dialog-right-top" /> |
|
|
|
<span class="dialog-left-bottom" /> |
|
|
|
<div class="setting-dialog"> |
|
|
@ -132,38 +132,68 @@ export default { |
|
|
|
this.step4Message = '标签读取成功后,开始绑定档案' |
|
|
|
this.step5Message = '当前标签与档案绑定成功' |
|
|
|
}, |
|
|
|
opened() { |
|
|
|
RFID.checkStatus({ op: 'RFID_CheckStatus', sDevID: 'D001' }).then((res) => { |
|
|
|
async checkStatus(param) { |
|
|
|
return RFID.checkStatus(param).then((res) => { |
|
|
|
res = JSON.parse(res) |
|
|
|
if (res.code === '0') { |
|
|
|
this.step = 2 |
|
|
|
this.step1Message = '连接成功' |
|
|
|
RFID.readEpc({ op: 'RFID_ReadEpc', sDevID: 'D001' }).then((res) => { |
|
|
|
return true |
|
|
|
} else { |
|
|
|
this.errorStep = 1 |
|
|
|
if (res.code === '-1') { |
|
|
|
this.step1Message = '读写器状态异常(例如读写器USB线未插入)' |
|
|
|
} else if (res.code === '-1000') { |
|
|
|
this.step1Message = '读写器超时未响应(例如终端读写服务未开启或网络异常)' |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
async readEpc(param) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
RFID.readEpc(param).then(res => { |
|
|
|
res = JSON.parse(res) |
|
|
|
console.log(res) |
|
|
|
if (res.code === '0') { |
|
|
|
this.step = 3 |
|
|
|
this.step2Message = '已放入标签' |
|
|
|
} else if (res.code === '-2') { |
|
|
|
resolve() |
|
|
|
} else if (res.code === '2') { |
|
|
|
this.errorStep = 2 |
|
|
|
this.step2Message = '未读取到标签,请重新放入' |
|
|
|
setTimeout(() => { |
|
|
|
resolve(this.readEpc(param)) |
|
|
|
}, 1000) |
|
|
|
} else { |
|
|
|
this.errorStep = 2 |
|
|
|
this.step2Message = '读取标签失败' |
|
|
|
reject() |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
}) |
|
|
|
}, |
|
|
|
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.errorStep = 1 |
|
|
|
if (res.code === '-1') { |
|
|
|
this.step1Message = '读写器状态异常(例如读写器USB线未插入)' |
|
|
|
} else if (res.code === '-1000') { |
|
|
|
this.step1Message = '读写器超时未响应(例如终端读写服务未开启或网络异常)' |
|
|
|
this.step1Message = '连接失败,请检查网络' |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(() => { |
|
|
|
this.errorStep = 1 |
|
|
|
this.step1Message = '连接失败,请检查网络' |
|
|
|
}) |
|
|
|
if (res) return res |
|
|
|
setTimeout(() => { |
|
|
|
this.$refs.dialog.handleClose() |
|
|
|
}, 3000) |
|
|
|
throw err |
|
|
|
}, |
|
|
|
async opened() { |
|
|
|
await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: 'D001' }) |
|
|
|
await this.readEpc({ op: 'RFID_ReadEpc', sDevID: 'D001' }) |
|
|
|
}, |
|
|
|
// 关闭 |
|
|
|
handleClose(done) { |
|
|
|