fix:交接记录手动添加时多选物料

This commit is contained in:
shijing 2024-11-22 09:59:32 +08:00
parent 6a7975e6ce
commit b92937fb9b
1 changed files with 50 additions and 160 deletions

View File

@ -123,25 +123,38 @@
<el-form-item label="交接物料"> <el-form-item label="交接物料">
<el-button type="primary" @click="addMaterial" v-if="mode!=='show'">手动添加</el-button> <el-button type="primary" @click="addMaterial" v-if="mode!=='show'">手动添加</el-button>
<scan-dialog ref="scanDialog" @closed="scanClose"> </scan-dialog> <scan-dialog ref="scanDialog" @closed="scanClose"> </scan-dialog>
<!-- <el-button type="primary" @click="scanCode" v-if="mode!=='show'">扫码添加</el-button> -->
</el-form-item> </el-form-item>
</el-row> </el-row>
<el-col v-if="addShow"> <el-row v-show="addShow">
<el-form-item label=""> <el-col>
<xtSelect <el-form-item label="交接物料">
:apiObj="listApiObj" <el-select
:params = "listParams" v-model="selectItems"
v-model="optionNames" placeholder="交接物料"
v-model:obj="optionItems" filterable
style="width: 100%" multiple
:multiple="true" clearable
> @change="materialChange"
<el-table-column label="id" prop="id"></el-table-column> style="width: 100%"
<el-table-column label="批次" prop="batch"></el-table-column> >
<el-table-column label="数量" prop="count_cando"></el-table-column> <el-option
</xtSelect> v-for="item in materialOptions"
</el-form-item> :key="item.id"
</el-col> :label="item.batch"
:value="item.id"
>
<span>{{ item.batch }}</span>
<div style="float: right">
<span>{{ item.count }}</span>
<span v-if="item.notok_sign_name !== null" style="color: #aaaaaa">
({{ item.notok_sign_name }})
</span>
</div>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row v-for="(listItem,$index) in form.handoverb" :key="listItem"> <el-row v-for="(listItem,$index) in form.handoverb" :key="listItem">
<el-col :span="10"> <el-col :span="10">
<el-form-item label="交接物料"> <el-form-item label="交接物料">
@ -177,61 +190,6 @@
<el-row> <el-row>
<div class="total-count">总计{{ totalCount }}</div> <div class="total-count">总计{{ totalCount }}</div>
</el-row> </el-row>
<!-- <el-row v-for="(listItem,$index) in form.handoverb" :key="listItem">
<el-col :span="10">
<el-form-item label="交接物料">
<el-select
v-if="mode!=='show'"
v-model="listItem.wm"
placeholder="交接物料"
filterable
clearable
@change="materialChange($index)"
style="width: 100%"
>
<el-option
v-for="item in materialOptions"
:key="item.id"
:label="item.label"
:value="item.id"
>
<span>{{ item.batch }}</span>
<div style="float: right">
<span>{{ item.count }}</span>
<span v-if="item.notok_sign_name !== null" style="color: #aaaaaa">
({{ item.notok_sign_name }})
</span>
</div>
</el-option>
</el-select>
<el-input v-else v-model="listItem.batch" disabled></el-input>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="总数量">
<span>{{ listItem.counts }}</span>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item label="交接数量">
<el-input-number
v-model="listItem.count"
controls-position="right"
:min="0"
step="1"
:max="listItem.counts"
:disabled="mode==='show'"
:step-strictly="true"
style="width: 100%"
placeholder="交接数量"
>
</el-input-number>
</el-form-item>
</el-col>
<el-col :span="2" v-if="mode!=='show'">
<el-button type="danger" icon="el-icon-delete" @click="delMaterial($index)"></el-button>
</el-col>
</el-row> -->
</el-form> </el-form>
<el-footer v-if="mode!=='show'"> <el-footer v-if="mode!=='show'">
<el-button type="primary" v-loading="isSaveing" @click="submit">确定</el-button> <el-button type="primary" v-loading="isSaveing" @click="submit">确定</el-button>
@ -262,6 +220,7 @@ export default {
}, },
data() { data() {
return { return {
selectItems:[],
yseorno: ["是", "否"], yseorno: ["是", "否"],
loading: false, loading: false,
mode: "add", mode: "add",
@ -333,8 +292,6 @@ export default {
}, },
totalCount: 0, totalCount: 0,
optionNames:[""],
optionItems:[],
deptID:'', deptID:'',
userList: [], userList: [],
userList2: [], userList2: [],
@ -346,33 +303,8 @@ export default {
scanVisible:false, scanVisible:false,
isSaveing: false, isSaveing: false,
setFiltersVisible: false, setFiltersVisible: false,
listApiObj:this.$API.wpm.wmaterial.list,
}; };
}, },
watch: {
optionItems: {
handler: function (val) {
let that = this;
that.optionNames = [];
that.form.handoverb = [];
let totalCount = 0;
val.forEach(item=>{
let obj = new Object();
obj.wm = item.id;
obj.batch = item.batch;
obj.name = item.material_name;
obj.count_cando = item.count_cando;
obj.count = item.count_cando;
obj.notok_sign = item.notok_sign;
that.form.handoverb.push(obj);
that.optionNames.push(item.id)
totalCount += item.count_cando;
})
that.totalCount = totalCount;
},
deep: true,
},
},
mounted() { mounted() {
let that = this; let that = this;
that.form.type = that.type; that.form.type = that.type;
@ -440,14 +372,7 @@ export default {
req.belong_dept=res[0].id; req.belong_dept=res[0].id;
that.listParams = req; that.listParams = req;
this.$API.wpm.wmaterial.list.req(req).then((res) => { this.$API.wpm.wmaterial.list.req(req).then((res) => {
let arr = []; that.materialOptions = res;
res.forEach(item=>{
let obj = {};
Object.assign(obj,item);
obj.label = item.batch;
arr.push(obj);
})
that.materialOptions = arr;
}); });
} }
}) })
@ -457,14 +382,7 @@ export default {
req.belong_dept=res[0].id; req.belong_dept=res[0].id;
that.listParams = req; that.listParams = req;
this.$API.wpm.wmaterial.list.req(req).then((res) => { this.$API.wpm.wmaterial.list.req(req).then((res) => {
let arr = []; that.materialOptions = res;
res.forEach(item=>{
let obj = {};
Object.assign(obj,item);
obj.label = item.batch;
arr.push(obj);
})
that.materialOptions = arr;
}); });
} }
}) })
@ -472,14 +390,7 @@ export default {
req.mgroupx = that.mgroupId; req.mgroupx = that.mgroupId;
that.listParams = req; that.listParams = req;
this.$API.wpm.wmaterial.list.req(req).then((res) => { this.$API.wpm.wmaterial.list.req(req).then((res) => {
let arr = []; that.materialOptions = res;
res.forEach(item=>{
let obj = {};
Object.assign(obj,item);
obj.label = item.batch;
arr.push(obj);
})
that.materialOptions = arr;
}); });
} }
}, },
@ -494,14 +405,7 @@ export default {
}; };
that.listParams = req; that.listParams = req;
this.$API.wpm.wmaterial.list.req(req).then((res) => { this.$API.wpm.wmaterial.list.req(req).then((res) => {
let arr = []; that.materialOptions = res;
res.forEach(item=>{
let obj = {};
Object.assign(obj,item);
obj.label = item.batch+'('+item.notok_sign_name+')';
arr.push(obj);
})
that.materialOptions = arr;
}); });
}, },
// //
@ -515,9 +419,9 @@ export default {
getCkUserList() { getCkUserList() {
let that = this; let that = this;
this.$API.system.user.list.req({ page: 0, posts__code: "inm&check" }) this.$API.system.user.list.req({ page: 0, posts__code: "inm&check" })
.then((res) => { .then((res) => {
that.userList2 = res; that.userList2 = res;
}); });
}, },
// //
getUserList2() { getUserList2() {
@ -543,7 +447,6 @@ export default {
}, },
addMaterial(){ addMaterial(){
this.addShow = true; this.addShow = true;
// this.form.handoverb.push({wm:'',count:'',counts:null});
}, },
delMaterial(index){ delMaterial(index){
this.form.handoverb.splice(index,1); this.form.handoverb.splice(index,1);
@ -555,14 +458,19 @@ export default {
this.visible = true; this.visible = true;
return this; return this;
}, },
materialChange(index) { materialChange() {
let val = this.form.handoverb[index].wm; let that = this;
let data = this.materialOptions.filter((item) => { let totalCount = 0;
return item.id == val; let data = that.materialOptions.filter((item) => {
return that.selectItems.indexOf(item.id)>-1;
}); });
this.form.handoverb[index].batch = data[0].batch; data.forEach(item=>{
this.form.handoverb[index].counts = data[0].count; item.vm = item.id;
this.form.handoverb[index].count = data[0].count; item.count = item.count_cando;
totalCount += item.count_cando;
})
that.totalCount = totalCount;
that.form.handoverb = data;
}, },
countChange(){ countChange(){
let that = this; let that = this;
@ -574,18 +482,6 @@ export default {
that.totalCount = totalCount; that.totalCount = totalCount;
} }
}, },
//
init() {
this.form = {
handoverb: [],
handovera: [],
handoverc: [],
handoverd: [],
}
this.form.handoverb.forEach(item=>{
})
},
// //
submit() { submit() {
let that = this; let that = this;
@ -647,9 +543,6 @@ export default {
scanCode(){ scanCode(){
let that = this; let that = this;
that.scanVisible = true; that.scanVisible = true;
// that.$nextTick(() => {
// that.$refs.scanDialog.open();
// });
}, },
scanClose(data){ scanClose(data){
if(data==''||data==undefined||data==null){ if(data==''||data==undefined||data==null){
@ -659,17 +552,14 @@ export default {
let id = data.split('#')[1]; let id = data.split('#')[1];
console.log('id',id); console.log('id',id);
this.$API.cm.labelmat.item.req(id).then((res) => { this.$API.cm.labelmat.item.req(id).then((res) => {
// console.log('res',res);
let arr = that.form.handoverb.filter((item) => { let arr = that.form.handoverb.filter((item) => {
return item.batch == res.batch; return item.batch == res.batch;
}) })
// console.log('arr',arr);
if(arr.length>0){ if(arr.length>0){
that.$message.error("该批次已存在") that.$message.error("该批次已存在")
}else{ }else{
that.materialOptions.forEach((item) => { that.materialOptions.forEach((item) => {
if(item.batch == res.batch){ if(item.batch == res.batch){
// let arr = that.form.handoverb
let obj = {}; let obj = {};
obj.wm = item.id; obj.wm = item.id;
obj.batch = item.batch; obj.batch = item.batch;