fix:上盘平磨合批弹窗总计不刷新,交接数量@change的countChanges方法未声明变量报错;总计改为computed计算属性,随handoverb自动汇总,并移除分散的手动累加与500ms定时重算

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-07-14 14:23:34 +08:00
parent 0a3f7d7292
commit 94859d431d
1 changed files with 6 additions and 41 deletions

View File

@ -101,7 +101,6 @@
:step-strictly="true"
style="width: 100%"
placeholder="交接数量"
@change="countChanges($index)"
>
</el-input-number>
</el-form-item>
@ -383,7 +382,6 @@ export default {
route_code: "",
project_code:'',
materials:[],
totalCount: 0,
deptID:'',
bwIndex:0,
checkedStatus:[],
@ -466,6 +464,11 @@ export default {
that.getMgroupOptions();
},
computed: {
// handoverb
totalCount() {
if (!this.form.handoverb || this.form.handoverb.length === 0) return 0;
return this.form.handoverb.reduce((sum, item) => sum + Number(item.count || 0), 0);
},
// state OK(10) defect ""
defectMismatch() {
if (this.mtype !== 30) return false;
@ -490,11 +493,6 @@ export default {
that.checkedStatus.splice(index,1);
this.form.handoverb[this.bwIndex].handoverbw.splice(index,1);
this.form.handoverb[this.bwIndex].count--;
let totalCount = 0;
that.form.handoverb.forEach((item)=>{
totalCount += item.count;
})
that.totalCount = totalCount;
},
showbw(index){
let that = this;
@ -680,7 +678,6 @@ export default {
delMaterial(index){
this.selectItems.splice(index,1);
this.form.handoverb.splice(index,1);
this.countChange();
},
codeTextChange(text){
this.wm_in = text;
@ -701,12 +698,10 @@ export default {
}
that.form.handoverb = data?data:[];
if(data&&data!==''&&data.length>0){
that.totalCount = 0;
data.forEach((item,index)=>{
item.wm = item.id;
that.checkedStatus.push(true)
that.selectItems.push(item.id)
that.totalCount += Number(item.count);
that.getWprList(item.wm,index);
})
if(that.isFeiPinku){
@ -720,7 +715,6 @@ export default {
},
clearSelect(){
let that = this;
that.totalCount = 0;
that.form.handoverb = [];
},
materialChange() {
@ -735,7 +729,7 @@ export default {
});
}
that.form.new_batch = that.route_code=='shangpaipingmo'?that.form.new_batch:"";
let totalCount = 0,data = [];
let data = [];
if(that.selectItems.length>0){
console.log('that.selectItems',that.selectItems)
data = that.materialOptions.filter((item) => {
@ -783,10 +777,8 @@ export default {
// 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);
}
@ -800,7 +792,6 @@ export default {
return true;
});
}
that.totalCount = totalCount;
that.form.handoverb = data;
},
getWprList(id,index){
@ -830,28 +821,6 @@ export default {
}else{
this.checkedStatus[index] = false;
}
this.countChange();
},
countChange(){
let that = this;
let totalCount = 0;
if(this.form.handoverb&&this.form.handoverb.length&&this.form.handoverb.length>0){
this.form.handoverb.forEach(item=>{
totalCount += Number(item.count);
})
that.totalCount = totalCount;
}else{
that.totalCount = 0;
}
},
countChanges(index){
if(this.form.handoverb[index]){}else{}
if(this.form.handoverb.length>0){
this.form.handoverb.forEach(item=>{
totalCount += item.count;
})
that.totalCount = totalCount;
}
},
//
submit() {
@ -910,7 +879,6 @@ export default {
//
setData(data) {
let that = this;
this.totalCount = data.count?data.count:data.handoverb.count;
Object.assign(this.form, data);
this.$API.system.user.list.req({ depts: data.send_dept, page: 0 }).then((res) => {
that.userList = res;
@ -1154,9 +1122,6 @@ export default {
}
}
}
setTimeout(() => {
this.countChange();
}, 500);
},
new_batch(){
let that = this;