| | |
| | | </view> |
| | | <view class="item"> |
| | | <view class="code-decs">物料码:</view> |
| | | <input type="text" placeholder=" 扫码 / 输入" v-model="matnr" :focus="matFocus" @input="findMat()"> |
| | | <!-- <view class="item-right"> |
| | | <button></button> |
| | | <text style="text-align: right;color: #409EFF;" @click="selectMat()">提取+</text> |
| | | <uni-icons type="right" color="#c1c1c1"></uni-icons> |
| | | </view> --> |
| | | <!-- <input type="text" placeholder=" 扫码 / 输入" v-model="matnr" :focus="matFocus" @input="findMat()"> --> |
| | | <textarea style="background-color: #f0f0f0;max-height: 100rpx;padding: 4px;margin: 4px;" |
| | | type="textarea" placeholder=" 扫码 / 输入" maxlength="1000" v-model="matnr" :focus="matFocus" |
| | | @input="analysis2()" /> |
| | | </view> |
| | | </view> |
| | | <view class="mat-list-title"> |
| | |
| | | this.token = uni.getStorageSync('token'); |
| | | }, |
| | | methods: { |
| | | analysis2() { |
| | | const data = this.matnr |
| | | |
| | | const parseData = (data) => { |
| | | const lines = data.split('\n'); |
| | | const t = { |
| | | packageGroupNo: '', |
| | | rollType: '', |
| | | boxType: '', |
| | | thickness: '', |
| | | wideInWidth: '', |
| | | totalGrossWeight: '', |
| | | totalNetWeight: '', |
| | | rolls: [] |
| | | }; |
| | | |
| | | // console.log(lines); |
| | | // 解析基本信息 |
| | | lines.forEach(line => { |
| | | if (line.startsWith('包装组号:')) t.packageGroupNo = line.split(':')[1].trim(); |
| | | else if (line.startsWith('管芯类型:')) t.rollType = line.split(':')[1].trim(); |
| | | else if (line.startsWith('木箱类型:')) t.boxType = line.split(':')[1].trim(); |
| | | else if (line.startsWith('厚度:')) t.thickness = line.split(':')[1].trim(); |
| | | else if (line.startsWith('宽幅:')) t.wideInWidth = line.split(':')[1].trim(); |
| | | else if (line.startsWith('总毛重:')) t.totalGrossWeight = line.split(':')[1].trim(); |
| | | else if (line.startsWith('总净重:')) t.totalNetWeight = line.split(':')[1].trim(); |
| | | }); |
| | | |
| | | // 解析卷号信息 |
| | | let rollData = {}; |
| | | let roll = { |
| | | rollNo: '', |
| | | boxNo: '', |
| | | specs: '', |
| | | length: '', |
| | | splices: '', |
| | | netWeight: '', |
| | | grossWeight: '', |
| | | fqTime: '', |
| | | } |
| | | lines.forEach(line => { |
| | | const match = line.match(/卷号(\d+):(.+)/) || line.match(/箱号(\d+):(.+)/) || line.match(/规格(\d+):(.+)/) || |
| | | line.match(/长度(\d+):(.+)/) || line.match(/净重(\d+):(.+)/) || line.match(/毛重(\d+):(.+)/) || |
| | | line.match(/接头(\d+):(.+)/) || line.match(/分切时间(\d+):(.+)/); |
| | | |
| | | if (match) { |
| | | const index = match[1]; // 获取序号 |
| | | const key = match[0].split(':')[0]; // 获取参数名称 |
| | | const value = match[2].trim(); // 获取参数值 |
| | | |
| | | |
| | | // 初始化卷信息对象 |
| | | if (!rollData[index]) rollData[index] = {}; |
| | | rollData[index][key] = value; |
| | | if (!roll[index]) roll[index] = {}; |
| | | if (key.startsWith('卷号')) roll[index].rollNo = value; |
| | | else if (key.startsWith('箱号')) roll[index].boxNo = value; |
| | | else if (key.startsWith('规格')) roll[index].specs = value; |
| | | else if (key.startsWith('长度')) roll[index].length = value; |
| | | else if (key.startsWith('净重')) roll[index].netWeight = value; |
| | | else if (key.startsWith('毛重')) roll[index].grossWeight = value; |
| | | else if (key.startsWith('接头')) roll[index].splices = value; |
| | | else if (key.startsWith('分切时间')) roll[index].fqTime = value; |
| | | |
| | | // 如果有所有参数,则将其推入 rolls 数组 |
| | | if (Object.keys(rollData[index]).length === 8) { // 所有字段都已经填充 |
| | | t.rolls.push(rollData[index]); |
| | | rollData[index] = {}; // 重置以准备下一个卷 |
| | | } |
| | | |
| | | } |
| | | }); |
| | | return t; |
| | | }; |
| | | |
| | | const result = parseData(data); |
| | | |
| | | this.secAnalysis(result) |
| | | |
| | | }, |
| | | // 二次解析 |
| | | secAnalysis(data) { |
| | | let rolls = data.rolls |
| | | let nedata = { |
| | | packageGroupNo: data.packageGroupNo, |
| | | rollType: data.rollType, |
| | | boxType: data.boxType, |
| | | thickness: data.thickness, |
| | | wideInWidth: data.wideInWidth, |
| | | totalGrossWeight: data.totalGrossWeight, |
| | | totalNetWeight: data.totalNetWeight, |
| | | } |
| | | |
| | | |
| | | for (let item of rolls) { |
| | | let roll = { |
| | | rollNo: '', |
| | | boxNo: '', |
| | | specs: '', |
| | | length: '', |
| | | splices: '', |
| | | netWeight: '', |
| | | grossWeight: '', |
| | | fqTime: '', |
| | | } |
| | | Object.keys(item).forEach(key=>{ |
| | | if (key.startsWith('卷号')) roll.rollNo = item[key]; |
| | | else if (key.startsWith('箱号')) roll.boxNo = item[key]; |
| | | else if (key.startsWith('规格')) roll.specs = item[key]; |
| | | else if (key.startsWith('长度')) roll.length = item[key].split(' ')[0]; |
| | | else if (key.startsWith('净重')) roll.netWeight = item[key].split(' ')[0]; |
| | | else if (key.startsWith('毛重')) roll.grossWeight = item[key].split(' ')[0]; |
| | | else if (key.startsWith('接头')) roll.splices = item[key].split(' ')[0]; |
| | | else if (key.startsWith('分切时间')) roll.fqTime = item[key]; |
| | | }) |
| | | let newObj = {...nedata,...roll} |
| | | if (this.dataList.length > 0) this.checkAdd(newObj) |
| | | else this.dataList.push(newObj); |
| | | |
| | | } |
| | | this.focuss() |
| | | }, |
| | | // 确认添加 |
| | | checkAdd(newMat) { |
| | | // let mats = this.dataList |
| | | // for (let item of mats) { |
| | | // if (item.packagingGroupNumber != newMat.packagingGroupNumber) { |
| | | // if (item.rollNo == newMat.rollNo) |
| | | // } this.dataList.push(newMat); |
| | | // } |
| | | |
| | | var len = this.dataList.length |
| | | var add = true |
| | | for (let k of this.dataList) { |
| | | if (newMat.packageGroupNo == k.packageGroupNo && newMat.rollNo == k.rollNo) { |
| | | add = false |
| | | } |
| | | } |
| | | if (add) { |
| | | this.dataList.unshift(newMat) |
| | | } |
| | | }, |
| | | messageToggle(type) { |
| | | this.msgType1 = type |
| | | this.$refs.message.open() |
| | |
| | | // 不设置定时器 会出现扫入的字符串不全 |
| | | setTimeout(() => { |
| | | var len = this.barcode.length |
| | | if (len != 6) { |
| | | uni.showToast({ |
| | | title: '托盘码有误请重试', |
| | | icon: "none", |
| | | position: 'top' |
| | | }); |
| | | this.barcodeFocuss() |
| | | return; |
| | | } |
| | | // if (len != 6) { |
| | | // uni.showToast({ |
| | | // title: '托盘码有误请重试', |
| | | // icon: "none", |
| | | // position: 'top' |
| | | // }); |
| | | // this.barcodeFocuss() |
| | | // return; |
| | | // } |
| | | this.focuss() |
| | | }, 200) |
| | | }, |
| | |
| | | }); |
| | | }, 1000); |
| | | } else { |
| | | that.goto() |
| | | that.messageText = res.msg |
| | | that.messageToggle('error') |
| | | if (res.msg === '盘点确认异常') { |
| | | that.messageText = res.msg |
| | | that.messageToggle('error') |
| | | setTimeout(()=>{ |
| | | that.goto() |
| | | }) |
| | | } else { |
| | | that.messageText = res.msg |
| | | that.messageToggle('error') |
| | | } |
| | | |
| | | } |
| | | } |
| | | }); |
| | |
| | | .code { |
| | | width: 100%; |
| | | position: fixed; |
| | | min-height: 200rpx; |
| | | /* min-height: 200rpx; */ |
| | | background-color: #FFF; |
| | | z-index: 10; |
| | | } |
| | |
| | | .item { |
| | | display: flex; |
| | | align-items: center; |
| | | height: 100rpx; |
| | | /* height: 100rpx; */ |
| | | margin-left: 20rpx; |
| | | border-bottom: 1px solid #DCDFE6; |
| | | } |
| | |
| | | width: 100%; |
| | | background-color: white; |
| | | position: fixed; |
| | | margin-top: 200rpx; |
| | | margin-top: 180rpx; |
| | | z-index: 9; |
| | | /* border-top: 1px solid #DCDFE6; */ |
| | | text-align: center; |