fix:防止网络慢时扫码乱批处理

This commit is contained in:
shijing 2025-09-11 14:07:24 +08:00
parent 4b27653e18
commit 5d4b61e893
1 changed files with 117 additions and 119 deletions

View File

@ -17,8 +17,10 @@
<el-form-item label="交接物料">
<el-button type="primary" @click="addMaterial" v-if="mode!=='show'">手动添加</el-button>
<el-input ref="codeInput"
id="wm_in"
placeholder="扫描交接物料"
v-model="wm_in" clearable
v-model="wm_in" clearable
:disabled="imputDisable"
@change="formWminChange(wm_in)"
style="width: 300px;margin-left: 10px;"
></el-input>
@ -344,6 +346,7 @@ export default {
bwVisible:false,
scanVisible:false,
isSaveing: false,
imputDisable:false,
change_batch:false,
setFiltersVisible: false,
};
@ -733,69 +736,73 @@ export default {
let that = this;
that.scanVisible = true;
},
formWminChange(data){
async formWminChange(data){
this.imputDisable = true;
await this.getInputText(data);
this.imputDisable = false;
this.$refs.codeInput.focus();
},
async getInputText(data){
if(data==''){
return;
}
let that = this;
that.wm_in = '';
if(data.indexOf('#')>-1){
let id = data.split('#')[1];
this.$API.cm.labelmat.item.req(id).then((res) => {
let arr = [];
if(that.form.handoverb&&that.form.handoverb.length>0){
that.form.handoverb.forEach((item) => {
if(item.batch == res.batch&&item.state==res.state&&item.defect==res.defect){
arr.push(item);
}
})
}
if(arr.length>0){
that.wm_in = "";
that.$message.error("该批次已存在")
}else{
let hasArr = [];
that.materialOptions.forEach((item) => {
if(item.batch == res.batch){
hasArr.push(item);
let params = {material: item.material,type: that.type};
that.$API.wpm.handover.mgroups.req(params).then((res0) => {
that.mgroupOptions = res0;
if(res0.length==1){
that.form.recive_mgroup = res0[0].id;
that.getUserList2();
}
})
let obj = {};
obj.wm = item.id;
obj.batch = item.batch;
if(item.material_.process_name){
obj.process = item.material_.process_name;
}
obj.count_cando = item.count_canhandover;
obj.count = item.count_canhandover;
obj.state = res.state;
obj.defect = res.defect;
obj.handoverbw = [];
that.$API.wpm.wpr.list.req({wm:item.id,page:0}).then((res) => {
let handoverbw = [];
let list = res;
list.forEach(item1=>{
let obj1 = {};
obj1.wpr = item1.id;
obj1.number = item1.number;
handoverbw.push(obj1);
})
obj.handoverbw = handoverbw;
that.form.handoverb.push(obj);
that.wm_in = "";
})
}
})
if(hasArr.length>0){}else{
that.$message.error("该批次不存在")
let res = await this.$API.cm.labelmat.item.req(id);
let arr = [];
if(that.form.handoverb&&that.form.handoverb.length>0){
that.form.handoverb.forEach((item) => {
if(item.batch == res.batch&&item.state==res.state&&item.defect==res.defect){
arr.push(item);
}
})
}
if(arr.length>0){
that.$message.error("该批次已存在")
}else{
let hasArr = [];
that.materialOptions.forEach((item) => {
if(item.batch == res.batch){
hasArr.push(item);
let params = {material: item.material,type: that.type};
that.$API.wpm.handover.mgroups.req(params).then((res0) => {
that.mgroupOptions = res0;
if(res0.length==1){
that.form.recive_mgroup = res0[0].id;
that.getUserList2();
}
})
let obj = {};
obj.wm = item.id;
obj.batch = item.batch;
if(item.material_.process_name){
obj.process = item.material_.process_name;
}
obj.count_cando = item.count_canhandover;
obj.count = item.count_canhandover;
obj.state = res.state;
obj.defect = res.defect;
obj.handoverbw = [];
that.$API.wpm.wpr.list.req({wm:item.id,page:0}).then((res) => {
let handoverbw = [];
let list = res;
list.forEach(item1=>{
let obj1 = {};
obj1.wpr = item1.id;
obj1.number = item1.number;
handoverbw.push(obj1);
})
obj.handoverbw = handoverbw;
that.form.handoverb.push(obj);
})
}
})
if(hasArr.length>0){}else{
that.$message.error("该批次不存在")
}
})
}
}else{//wprnumber
let arr = [];
arr = that.materialOptions.filter((item) => {
@ -809,7 +816,6 @@ export default {
})
}
if(arr2.length>0){
that.wm_in = "";
that.$message.error("该批次已存在")
}else{
let params = {material: arr[0].material,type: that.type};
@ -825,79 +831,71 @@ export default {
obj2.count_cando = arr[0].count_canhandover;
obj2.count = arr[0].count_canhandover;
that.form.handoverb.push(obj2);
that.wm_in = "";
}
}else{//
that.$API.wpm.wpr.list.req({number:data,page:0}).then((res) => {
if(res.length>0){
let indexs = 0,arr =[];
if( that.form.handoverb&&that.form.handoverb.length>0){
arr = that.form.handoverb.filter((item,index) => {
if(item.wm == res[0].wm){
indexs = index;
}
return item.wm == res[0].wm;
let res = await that.$API.wpm.wpr.list.req({number:data,page:0});
if(res.length>0){
let indexs = 0,arr =[];
if( that.form.handoverb&&that.form.handoverb.length>0){
that.form.handoverb.forEach((item,index) => {
if(item.wm == res[0].wm){
indexs = index;
arr.push(item);
}
})
}
//handoverb
if(arr.length>0){
//wprwpr
if(that.form.handoverb[indexs].handoverbw&&that.form.handoverb[indexs].handoverbw.length>0){
let arr1 = [];
arr1 = that.form.handoverb[indexs].handoverbw.filter((item1) => {
return item1.wpr == res[0].id;
})
}
//handoverb
if(arr.length>0){
//wprwpr
if(that.form.handoverb[indexs].handoverbw&&that.form.handoverb[indexs].handoverbw.length>0){
let arr1 = [];
arr1 = that.form.handoverb[indexs].handoverbw.filter((item1) => {
return item1.wpr == res[0].id;
})
if(arr1.length>0){
that.wm_in = "";
that.$message.error("该物料已存在");
}else{
let obj1 = {};
obj1.wpr = res[0].id;
obj1.number = res[0].number;
that.form.handoverb[indexs].count+=1;
that.form.handoverb[indexs].handoverbw.push(obj1);
that.wm_in = "";
}
if(arr1.length>0){
that.$message.error("该物料已存在");
}else{
that.form.handoverb[indexs].handoverbw = [];
let obj1 = {};
obj1.wpr = res[0].id;
obj1.number = res[0].number;
that.form.handoverb[indexs].count=1;
that.form.handoverb[indexs].count+=1;
that.form.handoverb[indexs].handoverbw.push(obj1);
that.wm_in = "";
}
}else{//handoverb
that.materialOptions.forEach((item) => {
if(item.id == res[0].wm){
let params = {material: item.material,type: that.type};
that.$API.wpm.handover.mgroups.req(params).then((res1) => {
that.mgroupOptions = res1;
})
let obj2 = {};
obj2.wm = item.id;
obj2.batch = item.batch;
if(item.material_.process_name){
obj2.process = item.material_.process_name;
}
obj2.count_cando = item.count_canhandover;
obj2.handoverbw = [];
obj2.count = 1;
let obj3 = {};
obj3.wpr = res[0].id;
obj3.number = res[0].number;
obj2.handoverbw.push(obj3);
// that.form.handoverb = [];
that.form.handoverb.push(obj2);
}
})
that.wm_in = "";
}else{
that.form.handoverb[indexs].handoverbw = [];
let obj1 = {};
obj1.wpr = res[0].id;
obj1.number = res[0].number;
that.form.handoverb[indexs].count=1;
that.form.handoverb[indexs].handoverbw.push(obj1);
}
}else{
that.wm_in = "";
that.$message.error("该批次不存在")
}else{//handoverb
that.materialOptions.forEach((item) => {
if(item.id == res[0].wm){
let params = {material: item.material,type: that.type};
that.$API.wpm.handover.mgroups.req(params).then((res1) => {
that.mgroupOptions = res1;
})
let obj2 = {};
obj2.wm = item.id;
obj2.batch = item.batch;
if(item.material_.process_name){
obj2.process = item.material_.process_name;
}
obj2.count_cando = item.count_canhandover;
obj2.handoverbw = [];
obj2.count = 1;
let obj3 = {};
obj3.wpr = res[0].id;
obj3.number = res[0].number;
obj2.handoverbw.push(obj3);
that.form.handoverb.push(obj2);
}
})
}
})
}else{
that.$message.error("该批次不存在")
}
}
}
setTimeout(() => {