diff --git a/pages/ftdl/line-down-mater.vue b/pages/ftdl/line-down-mater.vue index 811f05b..478264c 100644 --- a/pages/ftdl/line-down-mater.vue +++ b/pages/ftdl/line-down-mater.vue @@ -23,15 +23,18 @@ - + + + - + - + - + @@ -164,12 +167,56 @@ url: '/pages/ftdl/mater-list0?title=查询物料' }) }, + toScanAdd () { + uni.scanCode({ + success: (res) => { + // console.log('扫码成功:', res.result); + // uni.showToast({ + // title: res.result, + // icon: 'none' + // }) + const parts = res.result.split(';') + if (parts.length !== 5) { + uni.showToast({ + title: '二维码格式不正确,请扫描符合格式的二维码', + icon: 'none' + }) + return + } + let currObj = { + mid: 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9), + container_code: parts[0], + material_code: parts[1], + material_name: parts[2], + qty: parts[3], + measure_unit_id: parts[4], + } + // 检查是否已存在相同卷号 + const exists = this.dataList.some(item => item.container_code === currObj.container_code) + if (exists) { + uni.showToast({ + title: '已存在', + icon: 'none' + }) + return + } + this.dataList.push(currObj) + }, + fail: (err) => { + console.log('扫码失败:', err) + // uni.showToast({ + // title: err + '扫码失败', + // icon: 'none' + // }) + } + }) + }, toAdd () { let currObj = { mid: 'mid_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9), container_code: '', - material_name: '物料', - pscn: '', + material_code: '编码', + material_name: '名称', qty: '1', measure_unit_id: '单位' }