fix:车间领料和入库mioitem可多选

This commit is contained in:
shijing 2025-05-19 16:44:06 +08:00
parent 1524f6f414
commit fdb7dbb8e8
1 changed files with 143 additions and 66 deletions

View File

@ -46,6 +46,7 @@
filterable
value-key="id"
style="width: 100%;"
multiple
@change="selectwmChange"
>
<el-option
@ -77,7 +78,6 @@
style="width:150px;margin-left: 4px;"
@keyup.enter="codeTextChange(codeText)"
></el-input>
<!-- <scan-dialog ref="scanDialog" @closed="scanClose"> </scan-dialog> -->
</el-form-item>
<el-form-item label="批次" v-if="cate == 'do_out'">
<el-select
@ -85,8 +85,10 @@
value-key="id"
clearable
filterable
multiple
@change="selectBatchChange"
@clear="selectBatchClear"
style="width: 60%;"
>
<el-option
v-for="item in batchOptions"
@ -114,9 +116,52 @@
style="width:150px;margin-left: 4px;"
@keyup.enter="codeTextChange(codeText)"
></el-input>
<!-- <scan-dialog ref="scanDialog" @closed="scanClose"> </scan-dialog> -->
</el-form-item>
<el-form-item label="仓库" prop="warehouse">
<template v-if="cate == 'do_out'&&mode == 'add'">
<el-row v-for="item in selectList" :key="item.mb">
<el-col :span="12">
<el-form-item label="批次号">
<el-input v-model="item.batch" disabled />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="仓库" label-width="60px">
<el-select
v-model="item.warehouse"
disabled
style="width: 100%"
>
<el-option
v-for="item in warehouseOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="数量" label-width="60px">
<el-input v-model="item.count" disabled />
</el-form-item>
</el-col>
</el-row>
</template>
<template v-if="cate == 'do_in'&&mode == 'add'">
<el-row v-for="item in selectList" :key="item.mb">
<el-col :span="12">
<el-form-item label="批次号">
<el-input v-model="item.batch" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数量" label-width="60px">
<el-input v-model="item.count" disabled />
</el-form-item>
</el-col>
</el-row>
</template>
<el-form-item label="仓库" prop="warehouse" v-if="(cate == 'do_in'&&mode == 'add')||mode == 'edit'" >
<el-select
v-model="form.warehouse"
clearable
@ -130,7 +175,7 @@
></el-option>
</el-select>
</el-form-item>
<el-form-item label="数量">
<el-form-item label="数量" v-if="mode == 'edit'">
<el-input-number
v-model="form.count"
:min="0"
@ -177,6 +222,7 @@ export default {
codeText: "",
visible: false,
isSaveing: false,
selectList: [],
materialOptions: [],
batchOptions: [],
inputBatchDisable: false,
@ -282,7 +328,6 @@ export default {
if(data==''||data==undefined||data==null){
return;
}
// data = data.replace(' ','');
let id = data.split('#')[1];
this.$API.cm.labelmat.item.req(id).then((res) => {
console.log('res',res);
@ -294,42 +339,37 @@ export default {
}
console.log('arr',arr);
if(arr.length>0){
that.form.material = arr[0].material;
that.selectBatch = arr[0].id;
that.form.batch = arr[0].batch;
that.form.count = arr[0].count;
if(this.cate == 'do_out'){
that.form.mb = arr[0].id;
that.form.warehouse = arr[0].warehouse;
// that.selectBatch = arr[0].id;
if(that.mode == "add"){
that.selectBatch.push(arr[0].id);
let obj = {};
obj.batch = arr[0].batch;
obj.warehouse = arr[0].warehouse;
obj.mb = arr[0].id;
obj.count = Number(arr[0].count);
if(this.cate == 'do_out'){
obj.mb = arr[0].id;
obj.warehouse = arr[0].warehouse;
}else{
obj.wm = arr[0].id;
}
that.selectList.push(obj);
}else{
that.form.wm = arr[0].id;
that.selectBatch = arr[0].id;
that.form.material = arr[0].material;
that.form.batch = arr[0].batch;
that.form.count = arr[0].count;
if(this.cate == 'do_out'){
that.form.mb = arr[0].id;
that.form.warehouse = arr[0].warehouse;
}else{
that.form.wm = arr[0].id;
}
}
}else{
that.$message.error("该批次不存在")
}
})
// that.form.batch = id;
// let arr = [];
// if(this.cate == 'do_out'){//---
// arr = this.batchOptions.filter(item => item.batch == that.codeText);
// }else{//----
// arr = this.wbatchOptions.filter(item => item.batch == that.codeText);
// }
// console.log('arr',arr);
// if(arr.length>0){
// that.form.material = arr[0].material
// that.selectBatch = arr[0].id;
// that.form.batch = arr[0].batch;
// that.form.count = arr[0].count;
// if(this.cate == 'do_out'){
// that.form.mb = arr[0].id;
// that.form.warehouse = arr[0].warehouse;
// }else{
// that.form.wm = arr[0].id;
// }
// }else{
// this.$message.warning("");
// }
},
selectMaterialChange() {
this.getBatchOptions();
@ -341,28 +381,53 @@ export default {
}
}
},
selectBatchChange(id) {
selectBatchChange() {
let that = this;
console.log('selectBatch',that.selectBatch);
that.selectList = [];
that.batchOptions.forEach((item) => {
if(item.id == id){
console.log('item',item);
this.form.batch = item.batch;
this.form.warehouse = item.warehouse;
this.form.mb = item.id;
that.form.count = Number(item.count);
console.log('indexOfselectBatch',that.selectBatch.indexOf(item.id));
if(that.mode == "add"){//
if(that.selectBatch.indexOf(item.id)>-1){
let obj = {};
console.log('item',item);
obj.batch = item.batch;
obj.warehouse = item.warehouse;
obj.mb = item.id;
obj.count = Number(item.count);
that.selectList.push(obj);
}
}else{
if(item.id == id){
that.form.batch = item.batch;
that.form.warehouse = item.warehouse;
that.form.mb = item.id;
that.form.count = Number(item.count);
}
}
})
},
//
selectwmChange(id){
let that = this;
that.selectList = [];
that.wbatchOptions.forEach((item) => {
if(item.id == id){
console.log('item',item);
that.form.batch = item.batch;
that.form.wm = item.id;
that.form.count = Number(item.count);
}
if(that.mode == "add"){//
if(that.selectBatch.indexOf(item.id)>-1){
let obj = {};
console.log('item',item);
obj.batch = item.batch;
obj.wm = item.id;
obj.count = Number(item.count);
that.selectList.push(obj);
}
}else{
if(item.id == id){
that.form.batch = item.batch;
that.form.wm = item.id;
that.form.count = Number(item.count);
}
}
})
},
selectBatchClear() {
@ -380,25 +445,37 @@ export default {
},
//
submit() {
this.$refs.dialogForm.validate(async (valid) => {
let that = this;
that.$refs.dialogForm.validate(async (valid) => {
if (valid) {
this.isSaveing = true;
this.form.mio = this.mioId;
try {
var res;
if (this.mode == "add") {
res = await this.$API.inm.mioitem.create.req(this.form);
} else if (this.mode == "edit") {
res = await this.$API.inm.mioitem.update.req(this.form.id,this.form);
}
this.isSaveing = false;
this.$emit("success");
this.visible = false;
this.$message.success("操作成功");
} catch (err) {
//
this.isSaveing = false;
return err;
that.isSaveing = true;
that.form.mio = that.mioId;
if(that.mode == "add"){
that.selectList.forEach((item) => {
let obj = {};
obj = item;
obj.mio = that.mioId;
if(that.cate == 'do_out'){
obj.material = that.form.material;
}else{
obj.warehouse = that.form.warehouse;
}
that.$API.inm.mioitem.create.req(obj).then((res) => {
that.isSaveing = false;
that.$emit("success");
that.visible = false;
})
})
}else{
that.$API.inm.mioitem.update.req(that.form.id,that.form).then((res) => {
that.isSaveing = false;
that.$emit("success");
that.visible = false;
that.$message.success("操作成功");
}).then(() => {
that.isSaveing = false;
return err;
})
}
}
});