Browse Source

绑定标签和层位管理

master
z_yu 3 years ago
parent
commit
e26b272c85
  1. 17
      src/api/RFID/RFID.js
  2. 33
      src/api/storeManage/levelManage/level.js
  3. 20
      src/views/components/BindingTagDlg.vue
  4. 37
      src/views/storeManage/levelManage/index.vue

17
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 }

33
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 }

20
src/views/components/BindingTagDlg.vue

@ -126,7 +126,8 @@ export default {
step5Message: '当前标签与' + this.bindingTxt + '绑定成功', step5Message: '当前标签与' + this.bindingTxt + '绑定成功',
readData: {}, readData: {},
timeOut: null, timeOut: null,
timer: null
timer: null,
devId: ''
} }
}, },
computed: { computed: {
@ -279,7 +280,7 @@ export default {
this.coverBindingVisible = true this.coverBindingVisible = true
resolve() resolve()
} else if (res === 1) { } 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) writeRes = JSON.parse(writeRes)
if (writeRes.code === '0') { if (writeRes.code === '0') {
this.step = 5 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() { async opened() {
if (!this.isBinding) { 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() await this.startBind()
} }
}, },
async nextStep() { async nextStep() {
this.isBinding = false 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() await this.startBind()
}, },
// //

37
src/views/storeManage/levelManage/index.vue

@ -20,7 +20,6 @@
</div> </div>
</div> </div>
</el-col> </el-col>
<!-- 档案管理列表 --> <!-- 档案管理列表 -->
<el-col class="container-right" style="min-height: calc(100vh - 240px);" :xs="14" :sm="18" :md="19" :lg="18" :xl="19"> <el-col class="container-right" style="min-height: calc(100vh - 240px);" :xs="14" :sm="18" :md="19" :lg="18" :xl="19">
<span class="right-top-line" /> <span class="right-top-line" />
@ -47,8 +46,8 @@
</template> </template>
<script> <script>
import { menu } from '@/api/storeManage/levelManage/level'
import CRUD, { presenter } from '@crud/crud' import CRUD, { presenter } from '@crud/crud'
export default { export default {
name: 'LevelManage', name: 'LevelManage',
components: {}, components: {},
@ -66,12 +65,40 @@ export default {
menuTree: [], menuTree: [],
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'cnName'
label: 'name'
}, },
tableData: [] tableData: []
} }
}, },
created() {
this.getDeviceTree()
},
methods: { methods: {
getDeviceTree() {
console.log(1)
menu().then((data) => {
let storeroom = {}
let devices = []
for (let i = 0; i < data.length; i++) {
if (!storeroom.id) {
console.log(2)
storeroom = data[i].storeroomId
devices.push(data[i])
} else if (storeroom.id !== data[i].storeroomId.id) {
storeroom.children = devices
this.menuTree.push(storeroom)
devices = []
storeroom = data[i].storeroomId
} else {
devices.push(data[i])
}
if (i === data.length - 1) {
storeroom.children = devices
this.menuTree.push(storeroom)
}
}
})
},
handleNodeClick() { handleNodeClick() {
}, },
@ -91,7 +118,7 @@ export default {
.el-button { .el-button {
width: 106px; width: 106px;
height: 30px; height: 30px;
background-color: #1AAE93;
background-color: #1aae93;
border: none; border: none;
&::before { &::before {
padding-right: 5px; padding-right: 5px;
@ -106,7 +133,7 @@ export default {
} }
.warning { .warning {
font-size: 14px; font-size: 14px;
color: #3A99FD;
color: #3a99fd;
span { span {
margin-left: 5px; margin-left: 5px;
} }

Loading…
Cancel
Save