Commit 224d0500 authored by 徐来柯's avatar 徐来柯

update

parent 2e215bdd
......@@ -102,6 +102,9 @@ export default {
typeV: '',
}
},
mounted() {
this.scanGunCode()
},
methods: {
handleSelectionChange (val) {
this.checkList = val
......@@ -114,6 +117,96 @@ export default {
this.tableData = this.AllTableData.slice((num-1)*this.pageSize + 1,this.pageSize*num)
}
},
// 扫码枪扫码
scanGunCode() {
let barCode = ''
let lastTime, nextTime
let lastCode, nextCode
window.document.onkeypress = e => {
if (this.loading) {
// 防止高频率扫码,只能扫一次
return
}
if (window.event) {
// IE
nextCode = e.keyCode
} else if (e.which) {
// Netscape/Firefox/Opera
nextCode = e.which
}
if (e.which === 13) {
if (barCode.length < 3) return // 手动输入的时间不会让code的长度大于2,所以这里只会对扫码枪有
console.log(barCode)
console.log('扫码结束')
// this.loading = true
const cacheCode = barCode
// request({
// url: `/returnOrder/scanCodeForReturnOrder/${this.$route.query.id}`,
// method: 'put',
// data: {
// barcode: cacheCode
// }
// })
// .then(res => {
// this.loading = false
// if (res.data.code === 200) {
// if (res.data.data.returnInfo.length === 1) {
// // 只有一个商品直接更新数量
// const data = res.data.data.returnInfo[0]
// request({
// url: `/returnOrder/returnOrderGoods/${data.id}`,
// method: 'put',
// data: {
// ...data,
// realNum: data.realNum + 1,
// code: cacheCode
// }
// }).then(res => {
// if (res.data.code === 200) {
// this.$message.success('扫描成功')
// this.print(data.id)
// this.getDetails(true)
// }
// })
// } else if (res.data.data.returnInfo.length >= 2) {
// // 多个商品弹窗
// this.editModal = {
// loading: false,
// type: 12,
// show: true,
// editData: res.data.data,
// code: cacheCode
// }
// }
// }
// })
// .catch(() => {
// this.loading = false
// })
barCode = ''
lastCode = ''
lastTime = ''
return
}
nextTime = new Date().getTime()
if (!lastTime && !lastCode) {
console.log('扫码开始。。。')
barCode += e.key
}
if (lastCode && lastTime && nextTime - lastTime > 500) {
// 当扫码前有keypress事件时,防止首字缺失
console.log('防止首字缺失。。。')
barCode = e.key
} else if (lastCode && lastTime) {
console.log('扫码中。。。')
barCode += e.key
}
lastCode = nextCode
lastTime = nextTime
console.log(lastCode)
}
},
delData () {
if (this.checkList.length === 0) {
this.deleteShow = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment