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",
},
],
recive_user: [
new_batch: [
{
required: true,
message: "请选择接收人",
message: "请填写新批次号",
trigger: "blur",
},
],
@ -484,18 +484,13 @@ export default {
}
}else{
this.form.handoverb = data;
data.forEach(item=>{
this.totalCount += item.count_cando;
})
}
if(mtype==30){
if(mtype==30){//
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;
return this;
},

View File

@ -1,6 +1,6 @@
<template>
<el-dialog
:title="titleMap[type]"
:title="titleMap[mtype]"
v-model="visible"
width="1000px"
:size="1000"
@ -14,7 +14,11 @@
label-width="80px"
>
<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">
{{saveCount}}
</el-form-item>
@ -25,7 +29,6 @@
<el-form-item label="批次号">
<el-input v-model="listItem.batch" disabled></el-input>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item label="数量">
@ -38,7 +41,7 @@
:step-strictly="true"
style="width: 100%"
placeholder="交接数量"
@change="countChange"
@change="countChange($index)"
>
</el-input-number>
</el-form-item>
@ -130,7 +133,6 @@ export default {
},
batchOrign:{},
totalCount: 0,
deptID:'',
materialOptions: [],
visible: false,
isSaveing: false,
@ -140,61 +142,27 @@ export default {
mounted() {
let that = this;
that.form.type = that.type;
let materialObj = that.$TOOL.data.get("MATERIAL_OBJECT");
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.handle_date = that.form.send_date = that.$TOOL.dateFormat2(new Date());
that.form.send_mgroup = that.form.recive_mgroup = that.mgroupId;
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.getMaterial();
},
methods: {
//
getMaterial() {
let that = this;
var req = {
page: 0,
state:10,
material__process:that.process
};
that.materialOptions = [];
req.mgroupx = that.mgroupId;
that.listParams = req;
this.$API.wpm.wmaterial.list.req(req).then((res) => {
that.materialOptions = res;
that.form.handoverb = [];
res.forEach(item=>{
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;
});
//
open(mode = "add",data,mtype) {
this.mode = mode;
this.form.mtype = mtype;
this.codeText = data.batch;
this.batchOrign = data;
this.totalCount = data.count;
let obj = { };
obj.wm = data.id;
obj.batch = data.batch+"-1";
obj.count = data.count;
this.saveCount = 0;
this.form.handoverb.push(obj)
this.visible = true;
return this;
},
batchAdd(){
let that = this;
@ -218,36 +186,28 @@ export default {
this.form.handoverb.splice(index,1);
this.countChange();
},
//
open(mode = "add",data,mtype) {
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(){
countChange(index){
let that = this;
let totalCount = 0;
if(this.form.handoverb.length>0){
this.form.handoverb.forEach(item=>{
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;
that.$refs.dialogForm.validate(async (valid) => {
if (valid) {
if (that.mode == "add") {
that.$API.wpm.handover.create.req(that.form).then((res) => {
that.$API.wpm.handover.submit.req(res.id).then((res1) => {
let total = 0;
if(this.form.handoverb.length>0){
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.$emit("success");
that.visible = false;
that.$message.success("操作成功");
return err;
});
}).catch((err) => {
//
that.isSaveing = false;
return err;
});
}
}
}
}
});
},