fix:成品检验时批次选择实用xselect组件

This commit is contained in:
shijing 2025-04-03 08:59:52 +08:00
parent 25cd8c215a
commit 4c39c13007
1 changed files with 38 additions and 49 deletions

View File

@ -16,24 +16,19 @@
>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="物料批次" prop="batch">
<el-select
<el-form-item label="物料批次" required="true">
<xtSelect
:apiObj="apiObjBatch"
v-model="form.batch"
placeholder="物料批次"
clearable
filterable
v-model:obj="selectBatch"
:valueField="'batch'"
:labelField="'batch'"
style="width:100%"
@change="handleChange"
:disabled="mode != 'add'"
@change="handleBatchChange"
>
<el-option
v-for="item in options"
:key="item.id"
:label="item.batch"
:value="item.id"
>
</el-option>
</el-select>
<el-table-column label="物料批次" prop="batch"></el-table-column>
<el-table-column label="数量" prop="count"></el-table-column>
</xtSelect>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
@ -104,6 +99,7 @@ export default {
emits: ["success", "closed"],
data() {
return {
apiObjBatch:this.$API.inm.warehouse.batch,
apiUserObj: this.$API.system.user.list,
loading: false,
form: {
@ -126,6 +122,7 @@ export default {
},
],
},
selectBatch:null,
visible: false,
isSaveing: false,
options: [],
@ -170,46 +167,38 @@ export default {
that.options = res;
});
},
handleChange(val) {
handleBatchChange() {
let that = this;
console.log(val);
that.options.forEach((item) => {
if (item.id == val) {
that.form.count = item.count;
that.form.batch = item.batch;
that.form.material = item.material;
that.form.mb = item.id;
}
});
that.form.count = that.selectBatch.count;
that.form.batch = that.selectBatch.batch;
that.form.material = that.selectBatch.material;
that.form.mb = that.selectBatch.id;
},
//
submit() {
this.$refs.dialogForm.validate(async (valid) => {
let that = this;
that.$refs.dialogForm.validate(async (valid) => {
if (valid) {
this.isSaveing = true;
that.isSaveing = true;
try {
if (this.mode == "add") {
this.$API.qm.ftestwork.create
.req(this.form)
.then((res) => {
this.isSaveing = false;
this.visible = false;
this.$emit("success");
this.$message.success("操作成功");
});
} else if (this.mode == "edit") {
this.$API.qm.ftestwork.update
.req(this.form.id, this.form)
.then((res) => {
this.isSaveing = false;
this.visible = false;
this.$emit("success");
this.$message.success("操作成功");
});
if (that.mode == "add") {
that.$API.qm.ftestwork.create.req(that.form).then((res) => {
that.isSaveing = false;
that.visible = false;
that.$emit("success");
that.$message.success("操作成功");
}).catch(err => {that.isSaveing = false;});
} else if (that.mode == "edit") {
that.$API.qm.ftestwork.update.req(that.form.id, that.form).then((res) => {
that.isSaveing = false;
that.visible = false;
that.$emit("success");
that.$message.success("操作成功");
}).catch(err => {that.isSaveing = false;});
}
} catch (err) {
//
this.isSaveing = false;
that.isSaveing = false;
return err;
}
}