Browse Source

盒管理 绑定标签

master
z_yu 3 years ago
parent
commit
e46d57f4ad
  1. 35
      src/api/RFID/RFID.js
  2. 13
      src/api/archivesManage/caseManage.js
  3. 11
      src/views/archivesManage/caseManage/index.vue
  4. 106
      src/views/components/BindingTagDlg.vue

35
src/api/RFID/RFID.js

@ -8,7 +8,6 @@ export function checkStatus(params) {
})
}
// 点击排序对话框保存按钮,保存顺序
export function readEpc(params) {
return request({
url: 'api/RFID/ReadEpc',
@ -17,30 +16,12 @@ export function readEpc(params) {
})
}
// export function add(data) {
// data = Object.assign({ isTypeMetic: data.isType === 6 }, data)
// return request({
// url: 'api/archives-type/create',
// method: 'post',
// data
// })
// }
// export function del(ids) {
// const params = { id: ids[0] }
// return request({
// url: 'api/archives-type/delete',
// method: 'delete',
// params
// })
// }
// export function edit(data) {
// return request({
// url: 'api/archives-type/update',
// method: 'put',
// data
// })
// }
export function writeEPC(params) {
return request({
url: 'api/RFID/WriteEPC',
method: 'get',
params
})
}
export default { checkStatus, readEpc }
export default { checkStatus, readEpc, writeEPC }

13
src/api/archivesManage/caseManage.js

@ -12,11 +12,11 @@ export function edit(parameter) {
})
}
export function del(parameter) {
export function del(data) {
return request({
url: 'api/archives/delete',
method: 'post',
data: parameter
data: data
})
}
@ -37,4 +37,13 @@ export function barcodeIsRepeat(parameter) {
})
}
// 写标签
export function bingdingLabel(data) {
return request({
url: 'api/case/bingdingLabel',
method: 'post',
data
})
}
export default { add, edit, del }

11
src/views/archivesManage/caseManage/index.vue

@ -18,7 +18,7 @@
<template v-slot:rightButtonGroup>
<div class="archives-handler-btn">
<el-button class="packing-btn iconfont icon-weibiaoti-2" type="primary">拆盒</el-button>
<el-button class="binding-btn iconfont icon-weibiaoti-2" type="primary" :disabled="crud.selections.length !== 1" @click="bindingTag">绑定标签</el-button>
<el-button class="binding-btn iconfont icon-weibiaoti-2" type="primary" :disabled="crud.selections.length !== 1" @click="bindingTag(crud.selections)">绑定标签</el-button>
</div>
</template>
</crudOperation>
@ -50,8 +50,7 @@
</el-table>
<!--新增编辑表单渲染-->
<eForm />
<!-- :chart-data="lineChartData" -->
<binding-tag-dlg ref="bindingTag" />
<binding-tag-dlg ref="bindingTag" :binding-id="crud.selections[0] && crud.selections[0].id" :binding-type="2" binding-txt="档案盒" @refresh="crud.refresh" />
<pagination />
</div>
</div>
@ -135,7 +134,11 @@ export default {
clickRowHandler(row) {
this.$refs.table.toggleRowSelection(row)
},
bindingTag() {
bindingTag(data) {
if (data[0].tid) {
this.$refs.bindingTag.isBinding = true
this.$refs.bindingTag.tidCode = data[0].tid
}
this.$refs.bindingTag.bindingVisible = true
}
}

106
src/views/components/BindingTagDlg.vue

@ -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()
}
}
}

Loading…
Cancel
Save