Commit e0e9f503 authored by 高宇's avatar 高宇

扫码

parent b7cd03d0
...@@ -1935,21 +1935,34 @@ export default { ...@@ -1935,21 +1935,34 @@ export default {
/** 上方表格的厂家*/ /** 上方表格的厂家*/
manufacturer: [{ manufacturer: [{
value: '1', value: '1',
label: '黄金糕科技厂' label: '黄金糕科技厂',
code: 'venderFirst',
}, { }, {
value: '2', value: '2',
label: '双皮奶科技厂' label: '双皮奶科技厂',
code: 'venderSecond'
}, { }, {
value: '3', value: '3',
label: '蚵仔煎科技厂' label: '蚵仔煎科技厂',
}, { code: 'venderThird'
value: '4',
label: '龙须面科技厂'
}, {
value: '5',
label: '北京烤鸭科技厂'
}], }],
/**
* 扫码规则
* **/
scanRule: [
{
label: 'venderFirst',
value: {jcLot:1,jcPn:2,jcRank:3,jcNum:4}
},
{
label: 'venderSecond',
value: {jcLot:1,jcPn:0,jcRank:0,jcNum:0}
},
{
label: 'venderThird',
value: {}
}
],
rules: { rules: {
jcLot: [{ required: true, message: '请输入LOT', trigger: 'blur' }], jcLot: [{ required: true, message: '请输入LOT', trigger: 'blur' }],
jcPn: [{ jcPn: [{
...@@ -2058,7 +2071,7 @@ export default { ...@@ -2058,7 +2071,7 @@ export default {
inspectInfoList: { inspectInfoList: {
businessId: undefined, businessId: undefined,
jcPn: '', jcPn: '',
jcCj: '', jcCj: '1',
jcCode: '', jcCode: '',
jcLot: '', jcLot: '',
jcNum: '', jcNum: '',
...@@ -2207,6 +2220,21 @@ export default { ...@@ -2207,6 +2220,21 @@ export default {
this.handleCyPn() this.handleCyPn()
}, },
methods: { methods: {
// 测试json
handleChagnge() {
const obj = {
jcLot: 1,
jcPn: 2,
jcRank: 3,
jcNum: 4
}
console.log('文本',JSON.stringify(obj))
const test = '{"jcLot":1,"jcPn":2,"jcRank":3,"jcNum":4}'
console.log('对象',JSON.parse(test))
// 测试空文本
const text2 = '{}'
console.log('测试空文本',JSON.parse(text2).jcLot)
},
handelTab(i, e) { handelTab(i, e) {
const that = this const that = this
if (!that.$refs['input' + i]) { if (!that.$refs['input' + i]) {
...@@ -3261,34 +3289,6 @@ export default { ...@@ -3261,34 +3289,6 @@ export default {
return '' return ''
} }
}, },
/**
* @description: 处理从二维码得到的数据
* @author: gaoyu
* @param: list
* @return:
**/
processCode(list) {
switch (list.length) {
case 1:
this.inspectInfoList.jcLot = list[0]
break
case 2:
this.inspectInfoList.jcLot = list[0]
this.inspectInfoList.jcPn = list[1]
break
case 3:
this.inspectInfoList.jcLot = list[0]
this.inspectInfoList.jcPn = list[1]
this.inspectInfoList.jcRank = list[2]
break
case 4:
this.inspectInfoList.jcLot = list[0]
this.inspectInfoList.jcPn = list[1]
this.inspectInfoList.jcRank = list[2]
this.inspectInfoList.jcNum = list[3]
break
}
},
/** /**
* @description: 扫码 将获取 * @description: 扫码 将获取
* @author: gaoyu * @author: gaoyu
...@@ -3296,7 +3296,6 @@ export default { ...@@ -3296,7 +3296,6 @@ export default {
* @return: * @return:
**/ **/
scanCodes() { scanCodes() {
console.log('扫码', 11)
const params = { const params = {
flag: 'openScan' flag: 'openScan'
} }
...@@ -3306,13 +3305,75 @@ export default { ...@@ -3306,13 +3305,75 @@ export default {
let list = [] let list = []
list = res.split(':') list = res.split(':')
if (list && list.length > 0) { if (list && list.length > 0) {
console.log('list', list) selt.getValueByScanRule(list)
selt.processCode(list)
} }
}) })
// 调用扫码接口 // 调用扫码接口
// var s = 'a,b,c,d' // var s = 'a,b,c,d'
}, },
/**
* @description: 根据扫码规则 获取对于的值
* @author: gaoyu
* @param:
* @return:
**/
getValueByScanRule(list){
var scanRulesObj = this.getScanCodeRules()
console.log('scanRulesObj',scanRulesObj)
if (scanRulesObj.jcLot !== undefined) {
if (scanRulesObj.jcLot === 0) {
this.inspectInfoList.jcLot = ''
} else {
this.inspectInfoList.jcLot = list[scanRulesObj.jcLot-1]
}
} else {
this.inspectInfoList.jcLot = ''
}
if ( this.inspectInfoList.jcPn !== undefined) {
if (scanRulesObj.jcPn === 0) {
this.inspectInfoList.jcPn = ''
} else {
this.inspectInfoList.jcPn = list[scanRulesObj.jcPn-1]
}
} else {
this.inspectInfoList.jcPn = ''
}
if (this.inspectInfoList.jcRank !== undefined) {
if (scanRulesObj.jcRank === 0) {
this.inspectInfoList.jcRank = ''
} else {
this.inspectInfoList.jcRank = list[scanRulesObj.jcRank-1]
}
} else {
this.inspectInfoList.jcRank = ''
}
},
/**
* @description: 获取扫码规则
* @author: gaoyu
* @param:
* @return: 扫码规则
**/
getScanCodeRules() {
/**
* 1.根据当前厂家获取当前厂家code值
* 2.code值 获取对于的扫码规则
* **/
var rules = {}
if (!this.inspectInfoList.jcCj || this.inspectInfoList.jcCj === undefined || this.inspectInfoList.jcCj === '') {
return rules;
}
if (this.manufacturer.find(item => item.value === this.inspectInfoList.jcCj)) {
let code = this.manufacturer.find(item => item.value === this.inspectInfoList.jcCj).code
if (this.scanRule.find(Litem => Litem.label === code)) {
rules = this.scanRule.find(Litem => Litem.label === code).value
}
}
return rules
},
handleClick(tab, event) { handleClick(tab, event) {
console.log(tab, event) console.log(tab, event)
}, },
......
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