From 977dbb7c41e37427acf8af35ae90d8a4d0e1ae63 Mon Sep 17 00:00:00 2001 From: lb Date: Tue, 14 Mar 2023 17:07:59 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=B7=B7=E6=96=99=E6=89=B9=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogJustForm.vue | 13 +++++-- src/views/atomViews/ListViewWithHead.vue | 23 +++++++++---- src/views/modules/pms/blenderBatch/config.js | 36 ++++++++++++++++++-- src/views/modules/pms/blenderBatch/index.vue | 1 + 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/components/DialogJustForm.vue b/src/components/DialogJustForm.vue index 9c92757..1b9b4b3 100644 --- a/src/components/DialogJustForm.vue +++ b/src/components/DialogJustForm.vue @@ -248,7 +248,7 @@ export default { }, /** init **/ - init(id, detailMode) { + init(id, detailMode, extraParams) { // console.log("[DialogJustForm] init", this.dataForm, id, detailMode); if (this.$refs.dataForm) { // console.log("[DialogJustForm] clearing form validation..."); @@ -257,6 +257,7 @@ export default { } this.detailMode = detailMode ?? false; + this.$nextTick(() => { this.dataForm.id = id || null; if (this.dataForm.id) { @@ -297,7 +298,15 @@ export default { }); }); } else { - // 如果不是编辑 + // 如果不是编辑,看看是否有其他 extraParams + + if (extraParams && typeof extraParams === "object") { + for (const [key, value] of Object.entries(extraParams)) { + this.$set(this.dataForm, key, value); + console.log('[DialogJustForm] setting: ', key, value) + } + } + this.loadingStatus = false; } }); diff --git a/src/views/atomViews/ListViewWithHead.vue b/src/views/atomViews/ListViewWithHead.vue index 55ec5ec..6c3f83c 100644 --- a/src/views/atomViews/ListViewWithHead.vue +++ b/src/views/atomViews/ListViewWithHead.vue @@ -75,6 +75,11 @@ export default { type: Array, default: () => ["key"], }, + attachListQueryExtra: { + // 新增时,附带 listQueryExtra 里的哪些键和对应值 + type: String, + default: "", + }, initDataWhenLoad: { type: Boolean, default: true }, /** dialog configs 或许可以从 tableConfig 计算出来 computed... */ dialogConfigs: { @@ -83,8 +88,8 @@ export default { }, triggerUpdate: { type: String, - default: '' - } + default: "", + }, }, computed: { dialogType() { @@ -99,9 +104,9 @@ export default { triggerUpdate(val, oldVal) { if (val && val !== oldVal) { // get list - this.getList() + this.getList(); } - } + }, }, data() { return { @@ -442,9 +447,15 @@ export default { /** 打开对话框 */ openDialog(row_id, detail_mode, tag_info) { this.dialogVisible = true; - + let extraParams = null; + if (this.attachListQueryExtra && this.listQueryExtra.length) { + this.listQueryExtra.forEach((item) => { + let found = item[this.attachListQueryExtra]; + if (found !== null && found !== undefined) extraParams = found; + }); + } this.$nextTick(() => { - this.$refs["edit-dialog"].init(/** some args... */ row_id, detail_mode, tag_info); + this.$refs["edit-dialog"].init(/** some args... */ row_id, detail_mode, tag_info, extraParams); }); }, }, diff --git a/src/views/modules/pms/blenderBatch/config.js b/src/views/modules/pms/blenderBatch/config.js index de2fd6b..d1e828d 100644 --- a/src/views/modules/pms/blenderBatch/config.js +++ b/src/views/modules/pms/blenderBatch/config.js @@ -1,5 +1,5 @@ import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent"; -// import TableTextComponent from "@/components/noTemplateComponents/detailComponent"; +import TableTextComponent from "@/components/noTemplateComponents/detailComponent"; // import StatusComponent from "@/components/noTemplateComponents/statusComponent"; import { timeFilter } from "@/utils/filters"; @@ -42,14 +42,44 @@ export default function () { { button: { type: "plain", - name: "新增批次", + name: "新增", permission: "", }, }, ]; + const dialogJustFormConfigs = { + // extra blenderOrderId + // extraIds: {}, + form: { + rows: [ + [ + { + input: true, + label: "批次编码", + prop: "batchNo", + rules: { required: true, message: "必填项不能为空", trigger: "blur" }, + elparams: { placeholder: "请输入批次编码" }, + }, + { + input: true, + label: "批次重量", + prop: "batchSize", + rules: { required: true, message: "必填项不能为空", trigger: "blur" }, + elparams: { placeholder: "请输入批次重量" }, + }, + ], + ], + operations: [ + { name: "add", label: "保存", type: "primary", permission: "", showOnEdit: false }, + { name: "update", label: "更新", type: "primary", permission: "", showOnEdit: true }, + { name: "reset", label: "重置", type: "warning", showAlways: true }, + ], + }, + }; + return { - // dialogConfigs, + dialogConfigs: dialogJustFormConfigs, tableConfig: { table: null, // 此处可省略,el-table 上的配置项 column: tableProps, // el-column-item 上的配置项 diff --git a/src/views/modules/pms/blenderBatch/index.vue b/src/views/modules/pms/blenderBatch/index.vue index 3a63903..b907730 100644 --- a/src/views/modules/pms/blenderBatch/index.vue +++ b/src/views/modules/pms/blenderBatch/index.vue @@ -4,6 +4,7 @@ :head-config="headFormConfigs" :dialog-configs="dialogConfigs" :list-query-extra="[{ blenderOrderId: id }]" + attach-list-query-extra="blenderOrderId" :trigger-update="triggerUpdateKey" />