From 8da7c27a36b427fc49f54d04c99ba77e9e492f3d Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 3 Apr 2023 16:45:55 +0800 Subject: [PATCH] =?UTF-8?q?finish=20=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E6=A3=80=E6=9F=A5=E4=BF=A1=E6=81=AF+DialogJu?= =?UTF-8?q?stForm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogJustForm.vue | 24 +++++++++++++++++++ .../pms/qualityInspectionRecord/config.js | 18 +++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/components/DialogJustForm.vue b/src/components/DialogJustForm.vue index c77651c..d9001b1 100644 --- a/src/components/DialogJustForm.vue +++ b/src/components/DialogJustForm.vue @@ -153,6 +153,11 @@ export default { } }); }); + + this.configs.extraFields.forEach((cnf) => { + dataForm[cnf.prop] = cnf.default ?? null; + }); + return { loadingStatus: false, dataForm, @@ -375,6 +380,25 @@ export default { } }); }); + + this.configs.extraFields.forEach((cnf) => { + if (cnf.listenTo) { + console.log("set watcher for: ", cnf.prop); + const unwatch = this.$watch( + () => this.dataForm[cnf.listenTo.prop], + (carId) => { + console.log("do watcher for: ", cnf.prop); + if (!carId) return; + if (cnf.disableWatcherOnEdit && this.editMode) return; + cnf.listenTo.handler.call(this, this.cachedList[cnf.listenTo.prop], carId); + }, + { + immediate: false, + } + ); + this.watchList.push(unwatch); + } + }); }, computed: { uploadHeaders() { diff --git a/src/views/modules/pms/qualityInspectionRecord/config.js b/src/views/modules/pms/qualityInspectionRecord/config.js index 1dc474d..d864144 100644 --- a/src/views/modules/pms/qualityInspectionRecord/config.js +++ b/src/views/modules/pms/qualityInspectionRecord/config.js @@ -25,7 +25,7 @@ export default function () { subcomponent: TableOperaionComponent, options: [ { name: "edit", label: "编辑", icon: "edit-outline", }, - { name: 'delete', label: '删除', icon: 'delete' }, + { name: 'delete', label: '删除', icon: 'delete', emitFull: true }, // 只有 injectRow.task 为手动时,才允许编辑 // { name:"edit", label: "编辑", icon: "edit-outline", enable: injectRow => { return 'task' in injectRow && injectRow.task === 'Manual' } }, @@ -92,6 +92,21 @@ export default function () { const dialogJustFormConfigs = { // extra blenderOrderId // extraIds: {}, + extraFields: [{ + prop: 'hisId', + disableWatcherOnEdit: true, + listenTo: { + prop: 'carId', // 应该监听 carId,随 carId 而更新, + handler: function (carList, carId) { + console.log('this. ', carList, this.cachedList) + const car = carList.find(item => item.carId === carId) + console.log('car. ', car) + // 需要 bind + this.$set(this.dataForm, 'hisId', car.id) + console.log('this.dataForm.hisId', this.dataForm, this.dataForm.hisId) + } + } + }], form: { rows: [ [ @@ -154,6 +169,7 @@ export default function () { prop: "orderId", options: [], optionLabel: 'orderCode', + optionValue: 'orderId', // toggleFetchData: 'carId', // 当 carId 改变的时候,也会 fetchData hasPrev: 'carId', // 当 carId 改变的时候,也会 fetchData fetchDataParam: { search: 'carId', get: 'id' }, // 伴随着 hasPrev 出现