|
|
@ -1,6 +1,6 @@ |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<el-dialog ref="dialog" class="bindingDialog" :title="bindingTitle" :visible.sync="bindingVisible" :close-on-click-modal="false" :before-close="handleClose" @opened="opened"> |
|
|
|
<el-dialog ref="bindingTagDialog" 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"> |
|
|
@ -67,14 +67,14 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div v-if="isBinding" slot="footer" class="dialog-footer"> |
|
|
|
<el-button type="primary" @click="isBinding=false">下一步</el-button> |
|
|
|
<el-button type="primary" @click="nextStep">下一步</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 是否覆盖 --> |
|
|
|
<el-dialog title="覆盖绑定" :append-to-body="true" :visible.sync="coverBindingVisible" :before-close="handleClose"> |
|
|
|
<el-dialog ref="coverBindingDialog" title="覆盖绑定" :append-to-body="true" :visible.sync="coverBindingVisible" :before-close="handleCoverBindingClose"> |
|
|
|
<span class="dialog-right-top" /> |
|
|
|
<span class="dialog-left-bottom" /> |
|
|
|
<div class="setting-dialog"> |
|
|
@ -82,8 +82,8 @@ |
|
|
|
<p><span>当前标签已被绑定,是否覆盖?</span></p> |
|
|
|
</div> |
|
|
|
<div slot="footer" class="dialog-footer"> |
|
|
|
<el-button type="primary">确定覆盖</el-button> |
|
|
|
<el-button type="text" @click="coverBindingVisible=false">取消</el-button> |
|
|
|
<el-button type="primary" @click="doCoverBinding">确定覆盖</el-button> |
|
|
|
<el-button type="text" @click="cancel">取消</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
@ -92,6 +92,7 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import RFID from '@/api/RFID/RFID' |
|
|
|
import { bingdingLabel } from '@/api/archivesManage/caseManage' |
|
|
|
export default { |
|
|
|
name: 'BindingTagDlg', |
|
|
|
components: {}, |
|
|
@ -104,14 +105,17 @@ export default { |
|
|
|
bindingType: { |
|
|
|
type: Number, |
|
|
|
default: 1 |
|
|
|
}, |
|
|
|
bindingTxt: { |
|
|
|
type: String, |
|
|
|
default: '档案' |
|
|
|
} |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
isBinding: false, // 读取标签是否被覆盖 |
|
|
|
bindingVisible: false, // 绑定标签对话框是否显示 |
|
|
|
bindingTitle: '绑定标签', |
|
|
|
tidCode: null, |
|
|
|
tidCode: '', |
|
|
|
coverBindingVisible: false, |
|
|
|
step: 1, |
|
|
|
errorStep: 0, |
|
|
@ -119,7 +123,13 @@ export default { |
|
|
|
step2Message: '请放入标签', |
|
|
|
step3Message: '放入标签后开始读取标签', |
|
|
|
step4Message: '标签读取成功后,开始绑定档案', |
|
|
|
step5Message: '当前标签与档案绑定成功' |
|
|
|
step5Message: '当前标签与' + this.bindingTxt + '绑定成功', |
|
|
|
readData: null |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
bindingTitle: function() { |
|
|
|
return this.isBinding ? '重新绑定' : '绑定标签' |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
@ -130,18 +140,19 @@ export default { |
|
|
|
this.step2Message = '请放入标签' |
|
|
|
this.step3Message = '放入标签后开始读取标签' |
|
|
|
this.step4Message = '标签读取成功后,开始绑定档案' |
|
|
|
this.step5Message = '当前标签与档案绑定成功' |
|
|
|
this.step5Message = '当前标签与' + this.bindingTxt + '绑定成功' |
|
|
|
this.isBinding = false |
|
|
|
}, |
|
|
|
async checkStatus(param) { |
|
|
|
return RFID.checkStatus(param).then((res) => { |
|
|
|
res = JSON.parse(res) |
|
|
|
if (res.code === '0') { |
|
|
|
if (res.code && res.code === '0') { |
|
|
|
this.step = 2 |
|
|
|
this.step1Message = '连接成功' |
|
|
|
return true |
|
|
|
} else { |
|
|
|
this.errorStep = 1 |
|
|
|
if (res.code === '-1') { |
|
|
|
if (res.code && res.code === '-1') { |
|
|
|
this.step1Message = '读写器状态异常(例如读写器USB线未插入)' |
|
|
|
} else if (res.code === '-1000') { |
|
|
|
this.step1Message = '读写器超时未响应(例如终端读写服务未开启或网络异常)' |
|
|
@ -153,16 +164,28 @@ export default { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
RFID.readEpc(param).then(res => { |
|
|
|
res = JSON.parse(res) |
|
|
|
if (res.code === '0') { |
|
|
|
if (res.code && res.code === '0') { |
|
|
|
this.step = 3 |
|
|
|
this.errorStep = 0 |
|
|
|
this.step2Message = '已放入标签' |
|
|
|
if (res.data.length > 1) { |
|
|
|
this.errorStep = 3 |
|
|
|
this.step3Message = '当前标签存在多个,请取出多余的标签只保留一张!' |
|
|
|
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 === '2') { |
|
|
|
} else if (res.code && res.code === '-2') { |
|
|
|
this.errorStep = 2 |
|
|
|
this.step2Message = '未读取到标签,请重新放入' |
|
|
|
setTimeout(() => { |
|
|
|
resolve(this.readEpc(param)) |
|
|
|
}, 1000) |
|
|
|
}, 2000) |
|
|
|
} else { |
|
|
|
this.errorStep = 2 |
|
|
|
this.step2Message = '读取标签失败' |
|
|
@ -187,19 +210,72 @@ export default { |
|
|
|
} |
|
|
|
if (res) return res |
|
|
|
setTimeout(() => { |
|
|
|
this.$refs.dialog.handleClose() |
|
|
|
this.$refs.bindingTagDialog.handleClose() |
|
|
|
}, 3000) |
|
|
|
throw err |
|
|
|
}, |
|
|
|
async startBind(isCover) { |
|
|
|
// return new Promise((resolve, reject) => { |
|
|
|
this.step4Message = '绑定中' |
|
|
|
const data = { id: this.bindingId, labelType: this.bindingType, tid: this.readData.tid } |
|
|
|
console.log(2) |
|
|
|
if (isCover || this.readData.tid === this.tidCode) { |
|
|
|
data.coverLabel = true |
|
|
|
} |
|
|
|
const res = await bingdingLabel(data) |
|
|
|
if (res.message === '当前标签已被绑定') { |
|
|
|
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 |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
async opened() { |
|
|
|
if (!this.isBinding) { |
|
|
|
await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: 'D001' }) |
|
|
|
await this.readEpc({ op: 'RFID_ReadEpc', sDevID: 'D001' }) |
|
|
|
await this.startBind() |
|
|
|
} |
|
|
|
}, |
|
|
|
async nextStep() { |
|
|
|
this.isBinding = false |
|
|
|
await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: 'D001' }) |
|
|
|
await this.readEpc({ op: 'RFID_ReadEpc', sDevID: 'D001' }) |
|
|
|
await this.startBind() |
|
|
|
}, |
|
|
|
// 关闭 |
|
|
|
handleClose(done) { |
|
|
|
this.coverBindingVisible = false |
|
|
|
this.$emit('refresh') |
|
|
|
done() |
|
|
|
this.initData() |
|
|
|
}, |
|
|
|
handleCoverBindingClose(done) { |
|
|
|
done() |
|
|
|
this.bindingVisible = false |
|
|
|
this.initData() |
|
|
|
}, |
|
|
|
doCoverBinding() { |
|
|
|
this.coverBindingVisible = false |
|
|
|
this.startBind(true) |
|
|
|
}, |
|
|
|
cancel() { |
|
|
|
this.$refs.coverBindingDialog.handleClose() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|