update blender-order

This commit is contained in:
lb 2023-08-09 09:35:03 +08:00
父節點 3601b574fb
當前提交 bfd6a42349
共有 3 個文件被更改,包括 133 次插入19 次删除

查看文件

@ -1,5 +1,5 @@
{
"printWidth": 120,
"printWidth": 108,
"bracketSameLine": true,
"htmlWhitespaceSensitivity": "ignore",
"semi": true,

查看文件

@ -279,12 +279,12 @@ export default {
},
handleSwitchChange(val) {
console.log("[dialog] switch change: ", val, this.dataForm);
// console.log("[dialog] switch change: ", val, this.dataForm);
},
handleComponentModelUpdate(propName, { subject, payload: { data } }) {
this.dataForm[propName] = JSON.stringify(data);
console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]);
// console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]);
},
addOrUpdate(method = "POST") {

查看文件

@ -9,6 +9,7 @@
<el-dialog
class="blender-order-dialog"
:visible="visible"
width="30%"
@close="close"
@closed="$emit('destroy')"
:close-on-click-modal="false"
@ -21,10 +22,40 @@
</div>
<!-- form -->
<el-form ref="dataForm" :model="dataForm" size="small">
<el-form ref="dataForm" :model="dataForm" v-loading="optionsLoading || formLoading">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="订单状态" prop="statusDictValue" :rules="null"></el-form-item>
<el-col :span="24">
<el-form-item label="混料订单" prop="code" :rules="null">
<el-input v-model="dataForm.code" disabled></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item
label="配方"
prop="bomId"
:rules="[{ required: true, message: '必填项不能为空', trigger: 'blur' }]">
<el-select v-model="dataForm.bomId" placeholder="请选择配方">
<el-option v-for="bom in bomList" :key="bom.value" :label="bom.label" :value="bom.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item
label="混料机"
prop="blender"
:rules="[{ required: true, message: '必填项不能为空', trigger: 'blur' }]">
<el-select v-model="dataForm.blender" placeholder="请选择混料机">
<el-option
v-for="bdr in blenderList"
:key="bdr.value"
:label="bdr.label"
:value="bdr.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
@ -32,10 +63,18 @@
<!-- footer -->
<div slot="footer">
<!-- TODO: permission 相关内容 未添加 -->
<el-button v-if="mode.includes('create')" type="primary" @click="handleSave('POST')" :loading="btnLoading">
<el-button
v-if="mode.includes('create')"
type="primary"
@click="handleSave('POST')"
:loading="btnLoading">
保存
</el-button>
<el-button v-if="mode.includes('edit')" type="primary" @click="handleSave('PUT')" :loading="btnLoading">
<el-button
v-if="mode.includes('edit')"
type="primary"
@click="handleSave('PUT')"
:loading="btnLoading">
更新
</el-button>
<el-button v-if="mode.includes('reset')" type="warning" @click="handleReset">重置</el-button>
@ -58,29 +97,104 @@ export default {
btnLoading: false,
dataForm: {
id: null,
code: null,
bomId: null,
blender: null,
},
bomList: [],
blenderList: [],
};
},
computed: {},
mounted() {},
methods: {
init(id) {
console.log("[blenderOrderEdit] init", id);
this.visible = true;
init({ id, blender, blenderCode, bomCode, bomId, bomName, code, orderCode, orderId }) {
// console.log("[blenderOrderEdit] init");
Promise.all([this.getBlenderList(), this.getBomList(bomCode)])
.then((r1, r2) => {
this.dataForm = {
id: id,
code: code,
bomId: bomId,
blender: blender,
};
this.visible = true;
})
.catch((err) => {
console.log(err);
this.close();
});
},
close() {
this.visible = false;
},
handleSave(type) {
switch (type) {
case "POST":
break;
case "PUT":
break;
async getBomList(bomCode) {
this.optionsLoading = true;
const { data: res } = await this.$http.get("/pms/bom/pageVersion", {
params: { key: bomCode, limit: 999, page: 1 },
});
this.optionsLoading = false;
if (res.code === 0) {
this.bomList = res.data.list.map((bom) => ({
label: bom.code,
value: bom.id,
}));
}
},
handleReset() {},
async getBlenderList() {
this.optionsLoading = true;
const { data: res } = await this.$http.get("/pms/equipment/list", {
params: { workSequenceName: "混料工序" },
});
this.optionsLoading = false;
if (res.code === 0) {
this.blenderList = res.data.map((bdr) => ({
label: bdr.code,
value: bdr.id,
}));
}
},
handleSave(type) {
this.$refs.dataForm.validate(async (valid) => {
if (valid) {
this.btnLoading = true;
const { id, blender, bomId } = this.dataForm;
const { data: res } = await this.$http.get("/pms/order/changeBlender", {
params: { id, blender, bomId },
});
this.btnLoading = false;
if (res.code == 0) {
this.$message.success("修改成功");
this.close();
this.$emit("refreshDataList");
} else {
this.$message.error(res.msg);
}
}
});
// switch (type) {
// case "POST":
// break;
// case "PUT":
// break;
// }
},
handleReset() {
Object.keys(this.dataForm).forEach((key) => {
if (key != "id" && key != "code") this.dataForm[key] = null;
});
this.$refs.dataForm.clearValidate();
},
},
};
</script>
<style scoped lang="scss"></style>
<style lang="scss">
.blender-order-dialog .el-dialog__body {
padding: 10px 20px;
}
.el-select {
width: 100%;
}
</style>