diff --git a/src/views/wpm_bx/handover_form.vue b/src/views/wpm_bx/handover_form.vue index d04f7670..301f4aaa 100644 --- a/src/views/wpm_bx/handover_form.vue +++ b/src/views/wpm_bx/handover_form.vue @@ -665,7 +665,16 @@ export default { }); }, addMaterial(){ - this.addShow = true; + let that = this; + that.addShow = true; + // 将已扫板段对应的批次预填入多选,避免手动添加把扫描数据顶掉 + if(that.form.handoverb && that.form.handoverb.length > 0){ + that.form.handoverb.forEach(item => { + if(item.wm && that.selectItems.indexOf(item.wm) === -1){ + that.selectItems.push(item.wm); + } + }); + } }, delMaterial(index){ this.selectItems.splice(index,1); @@ -715,6 +724,15 @@ export default { }, materialChange() { let that = this; + // shangpaipingmo:先缓存已扫板段数据,重建后保留 + let scannedMap = {}; + if(that.route_code == 'shangpaipingmo'){ + (that.form.handoverb || []).forEach(h => { + if(h.wm && h.handoverbw && h.handoverbw.length > 0){ + scannedMap[h.wm] = h; + } + }); + } that.form.new_batch = that.route_code=='shangpaipingmo'?that.form.new_batch:""; let totalCount = 0,data = []; if(that.selectItems.length>0){ @@ -755,15 +773,31 @@ export default { } data.forEach((item,index)=>{ item.wm = item.id; - item.count = item.count_canhandover; - totalCount += Number(item.count_canhandover); item.tracking = item.material_.tracking; if(item.material_.process_name){ item.process = item.material_.process_name; } - item.handoverbw = []; - that.getWprList(item.id,index); + let scanned = scannedMap[item.id]; + if(scanned){ + // 保留已扫板段的 handoverbw 和数量 + item.handoverbw = scanned.handoverbw; + item.count = scanned.count; + totalCount += Number(scanned.count); + } else { + item.count = item.count_canhandover; + totalCount += Number(item.count_canhandover); + item.handoverbw = []; + that.getWprList(item.id,index); + } }) + // 同步 checkedStatus:全选状态由各批次 handoverbw 实际勾选情况决定 + that.checkedStatus = data.map(item => { + let scanned = scannedMap[item.id]; + if(scanned && scanned.handoverbw && scanned.handoverbw.length > 0){ + return scanned.handoverbw.every(w => w.checked !== false); + } + return true; + }); } that.totalCount = totalCount; that.form.handoverb = data; @@ -1049,16 +1083,22 @@ export default { let obj1 = {}; obj1.wpr = res[0].id; obj1.number = res[0].number; + obj1.checked = true; that.form.handoverb[indexs].count+=1; that.form.handoverb[indexs].handoverbw.push(obj1); + that.checkedStatus.push(true) + that.selectItems.push(res[0].id) } }else{ that.form.handoverb[indexs].handoverbw = []; let obj1 = {}; obj1.wpr = res[0].id; + obj1.checked = true; obj1.number = res[0].number; that.form.handoverb[indexs].count=1; that.form.handoverb[indexs].handoverbw.push(obj1); + that.checkedStatus.push(true) + that.selectItems.push(res[0].id) } }else{//handoverb里没有有这个物料批次 if(that.new_wm==''){ @@ -1082,9 +1122,12 @@ export default { obj2.count = 1; let obj3 = {}; obj3.wpr = res[0].id; + obj3.checked = true; obj3.number = res[0].number; obj2.handoverbw.push(obj3); that.form.handoverb.push(obj2); + that.checkedStatus.push(true) + that.selectItems.push(res[0].id) } }) }else{ @@ -1097,9 +1140,12 @@ export default { obj2.count = 1; let obj3 = {}; obj3.wpr = res[0].id; + obj3.checked = true; obj3.number = res[0].number; obj2.handoverbw.push(obj3); that.form.handoverb.push(obj2); + that.checkedStatus.push(true) + that.selectItems.push(res[0].id) } } }else{