fix:库存交接时新增表单验证
This commit is contained in:
parent
f83983578f
commit
f16f649dc4
|
@ -12,7 +12,7 @@
|
|||
:rules="rules"
|
||||
label-width="120px"
|
||||
>
|
||||
<el-form-item label="物料" v-if="cate == 'do_out'">
|
||||
<el-form-item label="物料" v-if="cate == 'do_out'" prop="material">
|
||||
<el-select
|
||||
v-model="form.material"
|
||||
value-key="id"
|
||||
|
@ -40,7 +40,7 @@
|
|||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="物料批次" v-else>
|
||||
<el-form-item label="物料批次" v-else prop="batch">
|
||||
<el-select
|
||||
v-model="form.batch"
|
||||
filterable
|
||||
|
@ -91,7 +91,7 @@
|
|||
</el-select>
|
||||
<scan-dialog ref="scanDialog" @closed="scanClose"> </scan-dialog>
|
||||
</el-form-item>
|
||||
<el-form-item label="仓库">
|
||||
<el-form-item label="仓库" prop="warehouse">
|
||||
<el-select
|
||||
v-model="form.warehouse"
|
||||
clearable
|
||||
|
@ -108,7 +108,7 @@
|
|||
<el-form-item label="数量">
|
||||
<el-input-number
|
||||
v-model="form.count"
|
||||
:min="0"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
|
@ -144,9 +144,13 @@ export default {
|
|||
do_out: "生产领料",
|
||||
do_in: "生产入库",
|
||||
},
|
||||
form: {},
|
||||
form: {
|
||||
count:1
|
||||
},
|
||||
rules: {
|
||||
material: [{required: true,message: "请选择物料",trigger: "blur",},],
|
||||
material: [{required: true,message: "请选择物料",trigger: "blur"}],
|
||||
batch: [{required: true,message: "请选择物料批次",trigger: "blur"}],
|
||||
warehouse: [{required: true,message: "请选择仓库",trigger: "blur"}],
|
||||
},
|
||||
visible: false,
|
||||
isSaveing: false,
|
||||
|
@ -158,6 +162,7 @@ export default {
|
|||
selectBatchDisable: false,
|
||||
selectMaterial: null,
|
||||
selectBatch: null,
|
||||
mioitemlist:[],
|
||||
wbatchOptions: [],//工段物料批次
|
||||
};
|
||||
},
|
||||
|
@ -168,6 +173,7 @@ export default {
|
|||
this.inputBatchDisable = true;
|
||||
this.getMaterialOptions();
|
||||
this.getBatchOptions();
|
||||
this.getList();
|
||||
}else{//入库----工段
|
||||
this.getMgroupWmaterial();
|
||||
}
|
||||
|
@ -180,6 +186,14 @@ export default {
|
|||
this.warehouseOptions = res;
|
||||
});
|
||||
},
|
||||
getList(){
|
||||
let that = this;
|
||||
that.$API.inm.mioitem.list.req({mio:that.mioId,page:0}).then(res=>{
|
||||
console.log('mioitemlist',res);
|
||||
that.mioitemlist = res;
|
||||
})
|
||||
},
|
||||
|
||||
//获取物料列表
|
||||
getMaterialOptions() {
|
||||
let that = this;
|
||||
|
@ -240,9 +254,21 @@ export default {
|
|||
}
|
||||
},
|
||||
selectBatchChange(item) {
|
||||
let that = this;
|
||||
if(item&&item.batch){
|
||||
let arr = this.mioitemlist.filter((mioitem) => {
|
||||
return mioitem.batch == item.batch;
|
||||
});
|
||||
console.log('arr',arr);
|
||||
if(arr.length > 0){
|
||||
this.$message.error('该批次已存在');
|
||||
that.selectBatchClear();
|
||||
}else{
|
||||
this.form.batch = item.batch;
|
||||
this.form.mb = item.id;
|
||||
this.form.warehouse = item.warehouse;
|
||||
}
|
||||
}
|
||||
},
|
||||
//选择车间库存物料后的处理
|
||||
selectwmChange(val){
|
||||
|
@ -254,6 +280,7 @@ export default {
|
|||
})
|
||||
},
|
||||
selectBatchClear() {
|
||||
this.selectBatch = "";
|
||||
this.form.batch = "";
|
||||
this.form.mb = "";
|
||||
this.form.warehouse = "";
|
||||
|
@ -266,24 +293,25 @@ 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;
|
||||
that.isSaveing = true;
|
||||
that.form.mio = that.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);
|
||||
if (that.mode == "add") {
|
||||
res = await that.$API.inm.mioitem.create.req(that.form);
|
||||
} else if (that.mode == "edit") {
|
||||
res = await that.$API.inm.mioitem.update.req(that.form.id,that.form);
|
||||
}
|
||||
this.isSaveing = false;
|
||||
this.$emit("success");
|
||||
this.visible = false;
|
||||
this.$message.success("操作成功");
|
||||
that.isSaveing = false;
|
||||
that.$emit("success");
|
||||
that.visible = false;
|
||||
that.$message.success("操作成功");
|
||||
} catch (err) {
|
||||
//可以处理校验错误
|
||||
this.isSaveing = false;
|
||||
that.isSaveing = false;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue