fix:玻纤分批次

This commit is contained in:
shijing 2025-06-27 10:38:54 +08:00
parent 6117de9bc4
commit abfd1b875b
3 changed files with 151 additions and 84 deletions

View File

@ -1,6 +1,6 @@
<template>
<el-dialog
:title="titleMap[mtype]"
title="分批"
v-model="visible"
width="1000px"
:size="1000"
@ -15,39 +15,50 @@
>
<el-row>
<el-col>
<span>交接物料{{codeText}}</span>
<span style="margin: 0 20px;">物料总数{{totalCount}} </span>
<el-button type="primary" @click="batchAdd">分批</el-button>
<el-form-item label="物料批次:" label-width="100px">
<b>{{batchOrign.batch}}</b>
<span style="width: 80px;margin-left:60px;">物料总数</span>
<b>{{batchOrign.count}} </b>
<el-button type="primary" @click="batchAdd" style="margin-left: 40px;">分批</el-button>
</el-form-item>
</el-col>
<el-form-item label="剩余可分配数量:" label-width="130">
{{saveCount}}
</el-form-item>
</el-row>
<el-row v-for="(listItem,$index) in form.handoverb" :key="listItem">
<el-col :span="10">
<el-form-item label="批次号">
<el-input v-model="listItem.batch"></el-input>
<el-input v-model="listItem.batch" :disabled="true"></el-input>
</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="batchOrign.count"
:step-strictly="true"
style="width: 100%"
placeholder="交接数量"
@change="countChange($index)"
>
</el-input-number>
</el-form-item>
<el-col :span="14">
<span style="margin: 0 0 0 20px;">选择物料:</span>
<el-input ref="codeInput"
placeholder="扫描交接物料"
v-model="wm_in" clearable
style="width: 120px;margin: 0 10px;"
@change="formWminChange($index,wm_in)"
></el-input>
<el-select
v-model="listItem.wpr"
placeholder="选择交接物料"
@change="wm_inChange($index)"
style="width: 140px;">
<el-option
v-for="item in wprOptions"
:disabled="item.disabled"
:key="item.id"
:label="item.number"
:value="item.id"
>
</el-option>
</el-select>
<span style="margin: 0 20px;">数量{{ listItem.count }}</span>
<el-button v-if="mode!=='show'" type="danger" icon="el-icon-delete" @click="delMaterial($index)"></el-button>
</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 :span="24" style="padding-left: 80px;margin-bottom: 20px;margin-top: -5px;">
<div v-for="(item2,index2) in form.handoverb[$index].handoverbw" :key="item2.wpr" class="wprItem">
<span>{{ item2.number }}</span>
<el-icon class="circleCloseFilled" @click="deleteWpr($index,index2,item2.wpr)"><el-icon-circleClose-filled /></el-icon>
</div>
</el-col>
</el-row>
<el-row>
@ -100,15 +111,11 @@ export default {
},
data() {
return {
selectItems:[],
loading: false,
mode: "add",
titleMap: {
20: "分批",
30: "合批",
},
wm_in:"",
mtype:20,
saveCount:0,
lastBatchNum:1,
addBactchNum:1,
form: {
send_date: null,
send_user: null,
@ -132,8 +139,9 @@ export default {
},
},
batchOrign:{},
totalCount: 0,
wprOptions: [],
materialOptions: [],
loading: false,
visible: false,
isSaveing: false,
setFiltersVisible: false,
@ -148,67 +156,109 @@ export default {
that.form.send_user = that.form.recive_user= userInfo.id;
},
methods: {
getWpr(id){
let that = this;
that.$API.wpm.wpr.list.req({page:0,wm:id}).then((res) => {
that.wprOptions = res;
});
},
getNum(batch){
let that = this;
that.$API.wpm.batchlog.batchesTo.req({batch:batch}).then((res) => {
if(res.last_batch_num!==null){
that.lastBatchNum = res.last_batch_num;
that.addBactchNum = res.last_batch_num+1;
}else{
that.lastBatchNum = 0;
that.addBactchNum = 1;
}
let obj = { };
obj.wm = that.batchOrign.id;
obj.batch = that.batchOrign.batch+"-"+that.addBactchNum;
that.addBactchNum++;
obj.count = 0;
obj.handoverbw=[];
that.form.handoverb.push(obj);
})
},
//
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.getWpr(data.id);
this.getNum(data.batch);
this.visible = true;
return this;
},
wm_inChange(index){
let that = this;
//handoverbdisabled
that.wprOptions.forEach(item=>{
if(item.id == that.form.handoverb[index].wpr){
let obj = {};
obj.number = item.number;
obj.wpr = item.id;
item.disabled = true;
that.form.handoverb[index].handoverbw.push(obj);
that.form.handoverb[index].wpr = '';
}
})
that.form.handoverb[index].count = that.form.handoverb[index].handoverbw.length;
},
formWminChange(index,number){
let that = this;
//handoverbdisabled
that.wprOptions.forEach(item=>{
if(item.number== number){
if(item.disabled){
that.$message.error("该物料已被分配");
that.form.handoverb[index].wpr = '';
}else{
item.disabled = true;
let obj = {};
obj.number = item.number;
obj.wpr = item.id;
that.form.handoverb[index].handoverbw.push(obj);
that.form.handoverb[index].count = that.form.handoverb[index].handoverbw.length;
that.form.handoverb[index].wpr = '';
}
}
})
},
deleteWpr(index1,index2,wpr){
let that = this;
that.wprOptions.forEach(item=>{
if(item.id == wpr){
item.disabled = false;
}
})
that.form.handoverb[index1].handoverbw.splice(index2,1);
that.form.handoverb[index1].count = that.form.handoverb[index1].handoverbw.length;
},
batchAdd(){
let that = this;
if(that.saveCount>0){
let indexs = that.form.handoverb.length+1;
let count = 0;
that.form.handoverb.forEach(item=>{
count+=item.count;
})
let obj = { };
obj.wm = that.batchOrign.id;
obj.batch = that.codeText+"-"+indexs;
obj.count = that.batchOrign.count - count;
that.saveCount = 0;
that.form.handoverb.push(obj)
}else{
that.$message.warning("已无可分配数量");
}
let obj = { };
obj.wm = that.batchOrign.id;
obj.batch = that.batchOrign.batch+"-"+that.addBactchNum;
that.addBactchNum++;
obj.count =0;
obj.handoverbw=[];
that.form.handoverb.push(obj)
},
delMaterial(index){
this.form.handoverb.splice(index,1);
this.countChange();
},
countChange(index){
let that = this;
let totalCount = 0;
if(this.form.handoverb.length>0){
this.form.handoverb.forEach(item=>{
totalCount += item.count;
})
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;
//wprdisabled
if(that.form.handoverb[index].handoverbw.length>0){
that.form.handoverb[index].handoverbw.forEach(item=>{
that.wprOptions.forEach(item2=>{
if(item2.id == item.wpr){
item2.disabled = false;
}
})
this.form.handoverb[index].count = that.batchOrign.count-total;
that.saveCount = 0;
}else{
that.saveCount = that.batchOrign.count-totalCount;
}
})
}
that.form.handoverb.splice(index,1);
},
//
submit() {
@ -267,4 +317,21 @@ export default {
height: 50px;
line-height: 50px;
}
.wprItem{
background: #eeeeee;
padding: 0 10px;
border-radius: 5px;
display: inline-block;
position: relative;
height: 30px;
line-height: 30px;
margin-right: 20px;
}
.circleCloseFilled{
position: absolute;
top: -7px;
right: -10px;
color: red;
font-size: 20px;
}
</style>

View File

@ -82,9 +82,9 @@
prop="batch"
min-width="120"
>
<!-- <template #default="scope">
<template #default="scope">
<el-link @click="rowClick(scope.row)" type="primary">{{scope.row.batch}}</el-link>
</template> -->
</template>
</el-table-column>
<el-table-column
label="部门/工段"

View File

@ -83,9 +83,9 @@
prop="batch"
min-width="120"
>
<!-- <template #default="scope">
<template #default="scope">
<el-link @click="rowClick(scope.row)" type="primary">{{scope.row.batch}}</el-link>
</template> -->
</template>
</el-table-column>
<el-table-column
label="部门/工段"