From a94d5c27150e23e1435a2c6d839bdf15db8b7baa Mon Sep 17 00:00:00 2001 From: lb Date: Wed, 15 Mar 2023 14:57:54 +0800 Subject: [PATCH] =?UTF-8?q?udpate=20=E6=B7=B7=E6=96=99=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogJustForm.vue | 23 +++++++++++-------- .../operationComponent.js | 16 ++++++------- src/views/atomViews/ListViewWithHead.vue | 3 ++- src/views/modules/pms/blenderBatch/config.js | 4 ++-- src/views/modules/pms/blenderBatch/index.vue | 8 +++---- .../components/ListViewWithHead.vue | 2 +- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/components/DialogJustForm.vue b/src/components/DialogJustForm.vue index 1b9b4b3..0bddb6a 100644 --- a/src/components/DialogJustForm.vue +++ b/src/components/DialogJustForm.vue @@ -121,6 +121,10 @@ export default { type: Boolean, default: false, }, + // extraParams: { + // type: Object, + // default: () => ({}) + // } }, inject: ["urls"], data() { @@ -248,7 +252,7 @@ export default { }, /** init **/ - init(id, detailMode, extraParams) { + init(id, detailMode, tagInfo, extraParams) { // console.log("[DialogJustForm] init", this.dataForm, id, detailMode); if (this.$refs.dataForm) { // console.log("[DialogJustForm] clearing form validation..."); @@ -258,6 +262,14 @@ export default { this.detailMode = detailMode ?? false; + /** 判断 extraParams */ + if (extraParams && typeof extraParams === "object") { + for (const [key, value] of Object.entries(extraParams)) { + // console.log("[dialog] dataForm | key | value", this.dataForm, key, value); + this.$set(this.dataForm, key, value); + } + } + this.$nextTick(() => { this.dataForm.id = id || null; if (this.dataForm.id) { @@ -298,15 +310,6 @@ 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/components/noTemplateComponents/operationComponent.js b/src/components/noTemplateComponents/operationComponent.js index bf4118a..3132e72 100644 --- a/src/components/noTemplateComponents/operationComponent.js +++ b/src/components/noTemplateComponents/operationComponent.js @@ -59,23 +59,23 @@ export default { let emitFull = false; let eventType = "default"; let customField; + let payload = {}; if (typeof opt === "object") { eventType = opt.name; customField = opt.emitField || "id"; emitFull = opt.emitFull || false; + if ("url" in opt) { + payload.url = this.injectData.url; + } + if ("toRouter" in opt) { + payload.toRouter = opt.toRouter; + } } else { eventType = opt; } /** 处理 toRouter */ - let payload = { type: eventType, data: emitFull ? this.injectData : customField ? this.injectData[customField] : this.injectData.id }; - if ("url" in opt) { - payload.url = this.injectData.url; - } - if ("toRouter" in opt) { - payload.toRouter = opt.toRouter; - } - // this.$emit('emit-data', { type: eventType, data: emitFull ? this.injectData : customField ? this.injectData[customField] : this.injectData.id, url: this.injectData.url, toRouter: opt.toRouter }) + payload = { ...payload, type: eventType, data: emitFull ? this.injectData : customField ? this.injectData[customField] : this.injectData.id }; this.$emit("emit-data", payload); }, }, diff --git a/src/views/atomViews/ListViewWithHead.vue b/src/views/atomViews/ListViewWithHead.vue index 6c3f83c..99308b6 100644 --- a/src/views/atomViews/ListViewWithHead.vue +++ b/src/views/atomViews/ListViewWithHead.vue @@ -451,10 +451,11 @@ export default { if (this.attachListQueryExtra && this.listQueryExtra.length) { this.listQueryExtra.forEach((item) => { let found = item[this.attachListQueryExtra]; - if (found !== null && found !== undefined) extraParams = found; + if (found !== null && found !== undefined) extraParams = item; }); } this.$nextTick(() => { + console.log(`[edit-dialog] extraParams: ${extraParams}`) 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 d1e828d..61f49dd 100644 --- a/src/views/modules/pms/blenderBatch/config.js +++ b/src/views/modules/pms/blenderBatch/config.js @@ -29,9 +29,9 @@ export default function () { prop: "operations", name: "操作", fixed: "right", - width: 160, + width: 120, subcomponent: TableOperaionComponent, - options: ['add', { name: 'edit', enable: injectRow => { return 'task' in injectRow && injectRow.task === 'Manual'} }] // 只有 injectRow.task 为手动时,才允许编辑 + options: [{ name: 'edit', enable: injectRow => { return 'task' in injectRow && injectRow.task === 'Manual' } }] // 只有 injectRow.task 为手动时,才允许编辑 }, ]; diff --git a/src/views/modules/pms/blenderBatch/index.vue b/src/views/modules/pms/blenderBatch/index.vue index b907730..2361736 100644 --- a/src/views/modules/pms/blenderBatch/index.vue +++ b/src/views/modules/pms/blenderBatch/index.vue @@ -24,7 +24,7 @@ export default { computed: { // 混料订单id id() { - return this.$route.params.id || ""; + return this.$route.query.id || ""; }, }, data() { @@ -39,10 +39,10 @@ export default { }, watch: { $route: { - handler: function (val) { - if (val.params.id) { + handler: function (route) { + if (route.query.id) { this.triggerUpdateKey = Math.random().toString() - console.log('[$oute changed] val.params.id', val.params.id, this.triggerUpdateKey) + console.log('[$oute changed] val.params.id', route.query.id, this.triggerUpdateKey) } }, immediate: true, diff --git a/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue b/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue index a937f49..415e561 100644 --- a/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue +++ b/src/views/modules/pms/blenderOrder/components/ListViewWithHead.vue @@ -212,7 +212,7 @@ export default { case 'view-batch': { this.$router.push({ name: toRouter, - params: { + query: { id: data // 混料订单id } })