From 4a6f3951196eac4f6a94709d68b5bd25d763faee Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 24 Mar 2023 16:59:28 +0800 Subject: [PATCH] update --- src/components/DialogJustForm.vue | 30 +++++++++++++++++-- .../modules/pms/palletizingLine/config.js | 9 ++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/components/DialogJustForm.vue b/src/components/DialogJustForm.vue index fcde1ee..70699e0 100644 --- a/src/components/DialogJustForm.vue +++ b/src/components/DialogJustForm.vue @@ -21,6 +21,8 @@ + + { row.forEach((col) => { - if (col.prop) dataForm[col.prop] = col.default ?? null; + if (!col.eraseOnSubmit && col.prop) dataForm[col.prop] = col.default ?? null; + else shadowDataForm[col.prop] = col.default ?? null; + + if ("autoUpdateProp" in col) { + savedDatalist[col.prop] = []; + } if (col.fetchData) col.fetchData().then(({ data: res }) => { @@ -148,6 +157,10 @@ export default { value: col.optionValue ? i[col.optionValue] : i.id, })) ); + + if ("autoUpdateProp" in col) { + this.$set(savedDatalist, col.prop, res.data.list); + } } else if (Array.isArray(res.data)) { this.$set( col, @@ -157,6 +170,9 @@ export default { value: col.optionValue ? i[col.optionValue] : i.id, })) ); + if ("autoUpdateProp" in col) { + this.$set(savedDatalist, col.prop, res.data); + } } // col.options = res.data.list; } else { @@ -184,6 +200,8 @@ export default { return { loadingStatus: false, dataForm, + shadowDataForm, + savedDatalist, detailMode: false, baseDialogConfig: null, defaultQuillConfig: { @@ -258,6 +276,9 @@ export default { if (excludeId && key === "id") return; this.dataForm[key] = null; }); + Object.keys(this.shadowDataForm).forEach((key) => { + this.shadowDataForm[key] = null; + }); console.log("[DialogJustForm resetForm()] clearing form..."); this.$refs.dataForm.clearValidate(); this.$emit("dialog-closed"); // 触发父组件销毁自己 @@ -332,7 +353,12 @@ export default { /** handlers */ handleSelectChange(col, eventValue) { - // console.log("[dialog] select change: ", col, eventValue); + if ("autoUpdateProp" in col) { + // 自动更新 相关联 的字段 + // console.log(col.options, eventValue, this.savedDatalist); + const item = this.savedDatalist[col.prop].find(item => item.id === eventValue) + this.shadowDataForm[col.autoUpdateProp] = item.cate ?? null + } this.$forceUpdate(); }, diff --git a/src/views/modules/pms/palletizingLine/config.js b/src/views/modules/pms/palletizingLine/config.js index 6424cee..43d5c0c 100644 --- a/src/views/modules/pms/palletizingLine/config.js +++ b/src/views/modules/pms/palletizingLine/config.js @@ -141,8 +141,17 @@ export default function () { label: "订单号", options: [], fetchData: () => this.$http.post('/pms/order/pageCom', { limit: 999, page: 1, code: '', type: 1 }), + optionLabel: 'code', rules: { required: true, message: "必填项不能为空", trigger: "blur" }, elparams: { filterable: true, placeholder: "请选择订单" }, + autoUpdateProp: 'cate' // 改变时自动更新 cate 字段 + }, + { + forceDisabled: true, + prop: 'cate', + label: '订单子号', + elparams: {}, + eraseOnSubmit: true }, { input: true,