fix:光芯交接表单调整

This commit is contained in:
shijing 2025-03-14 13:43:24 +08:00
parent a037a184ba
commit d74ab186d2
2 changed files with 67 additions and 102 deletions

View File

@ -266,10 +266,10 @@ export default {
trigger: "blur", trigger: "blur",
}, },
], ],
recive_user: [ new_batch: [
{ {
required: true, required: true,
message: "请选择接收人", message: "请填写新批次号",
trigger: "blur", trigger: "blur",
}, },
], ],
@ -484,18 +484,13 @@ export default {
} }
}else{ }else{
this.form.handoverb = data; this.form.handoverb = data;
data.forEach(item=>{
this.totalCount += item.count_cando;
})
} }
if(mtype==30){ if(mtype==30){//
this.change_batch = true; this.change_batch = true;
} }
// if(mtype==10){//
// console.log('data',data)
// }else if(mtype==20){//
// this.codeText = data.replace(" ","");
// }else if(mtype==30||this.type==20||this.type==40){//
// this.form.handoverb = data;
// }
this.visible = true; this.visible = true;
return this; return this;
}, },

View File

@ -1,6 +1,6 @@
<template> <template>
<el-dialog <el-dialog
:title="titleMap[type]" :title="titleMap[mtype]"
v-model="visible" v-model="visible"
width="1000px" width="1000px"
:size="1000" :size="1000"
@ -14,7 +14,11 @@
label-width="80px" label-width="80px"
> >
<el-row> <el-row>
<el-col>交接物料{{codeText}} <el-button type="primary" @click="batchAdd">分批</el-button></el-col> <el-col>
<span>交接物料{{codeText}}</span>
<span style="margin: 0 20px;">物料总数{{totalCount}} </span>
<el-button type="primary" @click="batchAdd">分批</el-button>
</el-col>
<el-form-item label="剩余可分配数量:" label-width="130"> <el-form-item label="剩余可分配数量:" label-width="130">
{{saveCount}} {{saveCount}}
</el-form-item> </el-form-item>
@ -25,7 +29,6 @@
<el-form-item label="批次号"> <el-form-item label="批次号">
<el-input v-model="listItem.batch" disabled></el-input> <el-input v-model="listItem.batch" disabled></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="7"> <el-col :span="7">
<el-form-item label="数量"> <el-form-item label="数量">
@ -38,7 +41,7 @@
:step-strictly="true" :step-strictly="true"
style="width: 100%" style="width: 100%"
placeholder="交接数量" placeholder="交接数量"
@change="countChange" @change="countChange($index)"
> >
</el-input-number> </el-input-number>
</el-form-item> </el-form-item>
@ -130,7 +133,6 @@ export default {
}, },
batchOrign:{}, batchOrign:{},
totalCount: 0, totalCount: 0,
deptID:'',
materialOptions: [], materialOptions: [],
visible: false, visible: false,
isSaveing: false, isSaveing: false,
@ -140,61 +142,27 @@ export default {
mounted() { mounted() {
let that = this; let that = this;
that.form.type = that.type; that.form.type = that.type;
let materialObj = that.$TOOL.data.get("MATERIAL_OBJECT"); that.form.handle_date = that.form.send_date = that.$TOOL.dateFormat2(new Date());
that.materialObj = materialObj;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month>9?month:'0'+month;
day = day>9?day:'0'+day;
that.form.handle_date = that.form.send_date = year + "-" + month + "-" + day;
that.form.send_mgroup = that.form.recive_mgroup = that.mgroupId; that.form.send_mgroup = that.form.recive_mgroup = that.mgroupId;
let userInfo = that.$TOOL.data.get("USER_INFO"); let userInfo = that.$TOOL.data.get("USER_INFO");
that.deptID = that.$TOOL.data.get('gx_deptID');
that.form.send_user = that.form.recive_user= userInfo.id; that.form.send_user = that.form.recive_user= userInfo.id;
that.getMaterial();
}, },
methods: { methods: {
// //
getMaterial() { open(mode = "add",data,mtype) {
let that = this; this.mode = mode;
var req = { this.form.mtype = mtype;
page: 0, this.codeText = data.batch;
state:10, this.batchOrign = data;
material__process:that.process this.totalCount = data.count;
}; let obj = { };
that.materialOptions = []; obj.wm = data.id;
req.mgroupx = that.mgroupId; obj.batch = data.batch+"-1";
that.listParams = req; obj.count = data.count;
this.$API.wpm.wmaterial.list.req(req).then((res) => { this.saveCount = 0;
that.materialOptions = res; this.form.handoverb.push(obj)
that.form.handoverb = []; this.visible = true;
res.forEach(item=>{ return this;
that.batchOrign= item;
if(item.batch === that.codeText){
let obj = {};
obj.wm = item.id;
obj.batch = item.batch+'-1';
obj.count = item.count;
that.form.handoverb.push(obj)
}
})
});
},
//
getMaterialNotok() {
let that = this;
that.materialOptions = [];
var req = {
mgroupx: that.mgroupId,
page: 0,
state:20
};
that.listParams = req;
this.$API.wpm.wmaterial.list.req(req).then((res) => {
that.materialOptions = res;
});
}, },
batchAdd(){ batchAdd(){
let that = this; let that = this;
@ -218,36 +186,28 @@ export default {
this.form.handoverb.splice(index,1); this.form.handoverb.splice(index,1);
this.countChange(); this.countChange();
}, },
//
open(mode = "add",data,mtype) { countChange(index){
this.mode = mode;
this.form.mtype = mtype;
this.codeText = data.replace(" ","");
this.visible = true;
return this;
},
materialChange() {
let that = this;
let totalCount = 0;
let data = that.materialOptions.filter((item) => {
return that.selectItems.indexOf(item.id)>-1;
});
data.forEach(item=>{
item.wm = item.id;
item.count = item.count;
totalCount += item.count;
})
that.totalCount = totalCount;
that.form.handoverb = data;
},
countChange(){
let that = this; let that = this;
let totalCount = 0; let totalCount = 0;
if(this.form.handoverb.length>0){ if(this.form.handoverb.length>0){
this.form.handoverb.forEach(item=>{ this.form.handoverb.forEach(item=>{
totalCount += item.count; totalCount += item.count;
}) })
that.saveCount = that.batchOrign.count-totalCount; let saveCount = that.batchOrign.count-totalCount;
if(saveCount<0){//数量不能大于总数量
this.form.handoverb[index].count = 0;
let total = 0;
this.form.handoverb.forEach(item=>{
total += item.count;
})
this.form.handoverb[index].count = that.batchOrign.count-total;
that.saveCount = 0;
}else{
that.saveCount = that.batchOrign.count-totalCount;
}
} }
}, },
// //
@ -255,20 +215,30 @@ export default {
let that = this; let that = this;
that.$refs.dialogForm.validate(async (valid) => { that.$refs.dialogForm.validate(async (valid) => {
if (valid) { if (valid) {
if (that.mode == "add") { let total = 0;
that.$API.wpm.handover.create.req(that.form).then((res) => { if(this.form.handoverb.length>0){
that.$API.wpm.handover.submit.req(res.id).then((res1) => { this.form.handoverb.forEach(item=>{
total += item.count;
})
}
if(total>that.totalCount){
that.$message.error("分配数量不能大于总数量");
}else{
if (that.mode == "add") {
that.$API.wpm.handover.create.req(that.form).then((res) => {
that.$API.wpm.handover.submit.req(res.id).then((res1) => {
that.isSaveing = false;
that.$emit("success");
that.visible = false;
that.$message.success("操作成功");
});
}).catch((err) => {
//
that.isSaveing = false; that.isSaveing = false;
that.$emit("success"); return err;
that.visible = false;
that.$message.success("操作成功");
}); });
}).catch((err) => { }
// }
that.isSaveing = false;
return err;
});
}
} }
}); });
}, },