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. 57
      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 + '绑定成功',
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()
},
//

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

@ -20,7 +20,6 @@
</div>
</div>
</el-col>
<!-- 档案管理列表 -->
<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" />
@ -47,11 +46,11 @@
</template>
<script>
import { menu } from '@/api/storeManage/levelManage/level'
import CRUD, { presenter } from '@crud/crud'
export default {
name: 'LevelManage',
components: { },
components: {},
mixins: [presenter()],
cruds() {
return [
@ -66,12 +65,40 @@ export default {
menuTree: [],
defaultProps: {
children: 'children',
label: 'cnName'
label: 'name'
},
tableData: []
}
},
created() {
this.getDeviceTree()
},
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() {
},
@ -84,30 +111,30 @@ export default {
</script>
<style lang="scss" scoped>
.head-container{
.head-container {
display: flex;
justify-content: space-between;
align-items: center;
.el-button{
.el-button {
width: 106px;
height: 30px;
background-color: #1AAE93;
background-color: #1aae93;
border: none;
&::before{
padding-right:5px ;
&::before {
padding-right: 5px;
}
}
}
::v-deep .el-icon-more:before{
margin-right: 8px;
::v-deep .el-icon-more:before {
margin-right: 8px;
}
.app-container{
.app-container {
margin-top: 0;
}
.warning{
.warning {
font-size: 14px;
color: #3A99FD;
span{
color: #3a99fd;
span {
margin-left: 5px;
}
}

Loading…
Cancel
Save