From e26b272c85c26c02ccbaddd3170fa8bc779f3611 Mon Sep 17 00:00:00 2001 From: z_yu <1534695664@qq.com> Date: Fri, 22 Jul 2022 17:38:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=A0=87=E7=AD=BE=E5=92=8C?= =?UTF-8?q?=E5=B1=82=E4=BD=8D=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/RFID/RFID.js | 17 +++++- src/api/storeManage/levelManage/level.js | 33 ++++++++++++ src/views/components/BindingTagDlg.vue | 20 +++++--- src/views/storeManage/levelManage/index.vue | 57 +++++++++++++++------ 4 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 src/api/storeManage/levelManage/level.js diff --git a/src/api/RFID/RFID.js b/src/api/RFID/RFID.js index b1ca5d5..235bb6a 100644 --- a/src/api/RFID/RFID.js +++ b/src/api/RFID/RFID.js @@ -24,4 +24,19 @@ export function writeEPC(params) { }) } -export default { checkStatus, readEpc, writeEPC } +export function getDeviceMac() { + return request({ + url: 'api/mac/get', + method: 'get' + }) +} + +export function getDeviceIdByMac(mac) { + const params = { mac: mac } + return request({ + url: 'api/RFID/getDeviceIdByMac', + method: 'get', + params + }) +} +export default { checkStatus, readEpc, writeEPC, getDeviceMac, getDeviceIdByMac } diff --git a/src/api/storeManage/levelManage/level.js b/src/api/storeManage/levelManage/level.js new file mode 100644 index 0000000..90642f1 --- /dev/null +++ b/src/api/storeManage/levelManage/level.js @@ -0,0 +1,33 @@ +import request from '@/utils/request' + +export function menu() { + return request({ + url: 'api/tag/menu', + method: 'get' + }) +} + +export function bingdingLabel(data) { + return request({ + url: 'api/tag/bingdingLabel', + method: 'post', + data + }) +} + +export function unbindTag(data) { + return request({ + url: 'api/tag/unbindTag', + method: 'post', + data + }) +} + +export function initTagLogList(parameter) { + return request({ + url: 'api/tag/initTagLogList', + method: 'get', + params: parameter + }) +} +export default { menu, bingdingLabel, unbindTag, initTagLogList } diff --git a/src/views/components/BindingTagDlg.vue b/src/views/components/BindingTagDlg.vue index 630a17f..7339bff 100644 --- a/src/views/components/BindingTagDlg.vue +++ b/src/views/components/BindingTagDlg.vue @@ -126,7 +126,8 @@ export default { step5Message: '当前标签与' + this.bindingTxt + '绑定成功', readData: {}, timeOut: null, - timer: null + timer: null, + devId: '' } }, computed: { @@ -279,7 +280,7 @@ export default { this.coverBindingVisible = true resolve() } else if (res === 1) { - let writeRes = await RFID.writeEPC({ op: 'RFID_WriteEPC', sDevID: 'D002', EAS: '1', Type: this.bindingType, Code: this.bindingId, Tid: this.readData.tid }) + let writeRes = await RFID.writeEPC({ op: 'RFID_WriteEPC', sDevID: this.devId, EAS: '1', Type: this.bindingType, Code: this.bindingId, Tid: this.readData.tid }) writeRes = JSON.parse(writeRes) if (writeRes.code === '0') { this.step = 5 @@ -306,17 +307,24 @@ export default { } }) }, + async getDevId() { + const Mac = await RFID.getDeviceMac() + const dev = await RFID.getDeviceIdByMac(Mac) + return dev.deviceId + }, async opened() { if (!this.isBinding) { - await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: 'D002' }) - await this.readEpc({ op: 'RFID_ReadEpc', sDevID: 'D002' }) + this.devId = await this.getDevId() + await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: this.devId }) + await this.readEpc({ op: 'RFID_ReadEpc', sDevID: this.devId }) await this.startBind() } }, async nextStep() { this.isBinding = false - await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: 'D002' }) - await this.readEpc({ op: 'RFID_ReadEpc', sDevID: 'D002' }) + this.devId = await this.getDevId() + await this.tryConnect({ op: 'RFID_CheckStatus', sDevID: this.devId }) + await this.readEpc({ op: 'RFID_ReadEpc', sDevID: this.devId }) await this.startBind() }, // 关闭 diff --git a/src/views/storeManage/levelManage/index.vue b/src/views/storeManage/levelManage/index.vue index e5637f2..78301e2 100644 --- a/src/views/storeManage/levelManage/index.vue +++ b/src/views/storeManage/levelManage/index.vue @@ -20,7 +20,6 @@ - @@ -47,11 +46,11 @@