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-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>
<el-input ref="codeInput" <el-input ref="codeInput"
id="wm_in"
placeholder="扫描交接物料" placeholder="扫描交接物料"
v-model="wm_in" clearable v-model="wm_in" clearable
:disabled="imputDisable"
@change="formWminChange(wm_in)" @change="formWminChange(wm_in)"
style="width: 300px;margin-left: 10px;" style="width: 300px;margin-left: 10px;"
></el-input> ></el-input>
@ -344,6 +346,7 @@ export default {
bwVisible:false, bwVisible:false,
scanVisible:false, scanVisible:false,
isSaveing: false, isSaveing: false,
imputDisable:false,
change_batch:false, change_batch:false,
setFiltersVisible: false, setFiltersVisible: false,
}; };
@ -733,14 +736,21 @@ export default {
let that = this; let that = this;
that.scanVisible = true; 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==''){ if(data==''){
return; return;
} }
let that = this; let that = this;
that.wm_in = '';
if(data.indexOf('#')>-1){ if(data.indexOf('#')>-1){
let id = data.split('#')[1]; let id = data.split('#')[1];
this.$API.cm.labelmat.item.req(id).then((res) => { let res = await this.$API.cm.labelmat.item.req(id);
let arr = []; let arr = [];
if(that.form.handoverb&&that.form.handoverb.length>0){ if(that.form.handoverb&&that.form.handoverb.length>0){
that.form.handoverb.forEach((item) => { that.form.handoverb.forEach((item) => {
@ -750,7 +760,6 @@ export default {
}) })
} }
if(arr.length>0){ if(arr.length>0){
that.wm_in = "";
that.$message.error("该批次已存在") that.$message.error("该批次已存在")
}else{ }else{
let hasArr = []; let hasArr = [];
@ -787,7 +796,6 @@ export default {
}) })
obj.handoverbw = handoverbw; obj.handoverbw = handoverbw;
that.form.handoverb.push(obj); that.form.handoverb.push(obj);
that.wm_in = "";
}) })
} }
}) })
@ -795,7 +803,6 @@ export default {
that.$message.error("该批次不存在") that.$message.error("该批次不存在")
} }
} }
})
}else{//wprnumber }else{//wprnumber
let arr = []; let arr = [];
arr = that.materialOptions.filter((item) => { arr = that.materialOptions.filter((item) => {
@ -809,7 +816,6 @@ export default {
}) })
} }
if(arr2.length>0){ if(arr2.length>0){
that.wm_in = "";
that.$message.error("该批次已存在") that.$message.error("该批次已存在")
}else{ }else{
let params = {material: arr[0].material,type: that.type}; let params = {material: arr[0].material,type: that.type};
@ -825,18 +831,17 @@ export default {
obj2.count_cando = arr[0].count_canhandover; obj2.count_cando = arr[0].count_canhandover;
obj2.count = arr[0].count_canhandover; obj2.count = arr[0].count_canhandover;
that.form.handoverb.push(obj2); that.form.handoverb.push(obj2);
that.wm_in = "";
} }
}else{// }else{//
that.$API.wpm.wpr.list.req({number:data,page:0}).then((res) => { let res = await that.$API.wpm.wpr.list.req({number:data,page:0});
if(res.length>0){ if(res.length>0){
let indexs = 0,arr =[]; let indexs = 0,arr =[];
if( that.form.handoverb&&that.form.handoverb.length>0){ if( that.form.handoverb&&that.form.handoverb.length>0){
arr = that.form.handoverb.filter((item,index) => { that.form.handoverb.forEach((item,index) => {
if(item.wm == res[0].wm){ if(item.wm == res[0].wm){
indexs = index; indexs = index;
arr.push(item);
} }
return item.wm == res[0].wm;
}) })
} }
//handoverb //handoverb
@ -848,7 +853,6 @@ export default {
return item1.wpr == res[0].id; return item1.wpr == res[0].id;
}) })
if(arr1.length>0){ if(arr1.length>0){
that.wm_in = "";
that.$message.error("该物料已存在"); that.$message.error("该物料已存在");
}else{ }else{
let obj1 = {}; let obj1 = {};
@ -856,7 +860,6 @@ export default {
obj1.number = res[0].number; 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.form.handoverb[indexs].handoverbw.push(obj1);
that.wm_in = "";
} }
}else{ }else{
that.form.handoverb[indexs].handoverbw = []; that.form.handoverb[indexs].handoverbw = [];
@ -865,7 +868,6 @@ export default {
obj1.number = res[0].number; 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.form.handoverb[indexs].handoverbw.push(obj1);
that.wm_in = "";
} }
}else{//handoverb }else{//handoverb
that.materialOptions.forEach((item) => { that.materialOptions.forEach((item) => {
@ -887,17 +889,13 @@ export default {
obj3.wpr = res[0].id; obj3.wpr = res[0].id;
obj3.number = res[0].number; obj3.number = res[0].number;
obj2.handoverbw.push(obj3); obj2.handoverbw.push(obj3);
// that.form.handoverb = [];
that.form.handoverb.push(obj2); that.form.handoverb.push(obj2);
} }
}) })
that.wm_in = "";
} }
}else{ }else{
that.wm_in = "";
that.$message.error("该批次不存在") that.$message.error("该批次不存在")
} }
})
} }
} }
setTimeout(() => { setTimeout(() => {