From 42f2d2250fc789d2976c26bbb829ad1de2772646 Mon Sep 17 00:00:00 2001 From: "wu.jian2" Date: Mon, 3 Jul 2023 17:10:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89JS=E6=95=B0=E6=8D=AE=E9=9B=86=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=8F=98=E5=8C=96=EF=BC=8C=E8=BE=93=E5=87=BA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=B8=8D=E5=8F=98=E5=8C=96=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsDataSet/index.vue | 39 ++++++++++++++----- data-room-ui/package.json | 2 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue b/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue index e6969a37..0341557e 100644 --- a/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue +++ b/data-room-ui/example/customDatasetComponents/jsDataSet/index.vue @@ -641,20 +641,39 @@ export default { } }) } - // 如果脚本有变化,生成的keys和outputFieldList的长度不一致,就重新生成outputFieldList,仅添加变化的那个字段,其余的不变化 + // 如果脚本有变化,生成的keys和outputFieldList的长度不一致,就重新生成outputFieldList,仅删除或添加变化的那个字段,其余的不变化 if (this.outputFieldList.length !== keys.length) { - const newKeys = keys.filter(item => { - return !this.outputFieldList.some(key => { - return key.fieldName === item - }) + const newOutputFieldList = [] + keys.forEach(key => { + const field = this.outputFieldList.find(item => item.fieldName === key) + if (field) { + newOutputFieldList.push(field) + } else { + newOutputFieldList.push({ + fieldName: key, + fieldDesc: '' + }) + } }) - newKeys.forEach(item => { - this.outputFieldList.push({ - fieldName: item, - fieldDesc: '' - }) + this.outputFieldList = newOutputFieldList + } + // 如果脚本有变化,生成的keys和outputFieldList的长度一致,仅字段名变化了,就重新生成outputFieldList + if (this.outputFieldList.length === keys.length) { + const newOutputFieldList = [] + keys.forEach(key => { + const field = this.outputFieldList.find(item => item.fieldName === key) + if (field) { + newOutputFieldList.push(field) + } else { + newOutputFieldList.push({ + fieldName: key, + fieldDesc: '' + }) + } }) + this.outputFieldList = newOutputFieldList } + // 如果有字段描述,就同步 if (this.outputFieldList.length && this.fieldDesc && !isInit) { this.buildFieldDesc() } diff --git a/data-room-ui/package.json b/data-room-ui/package.json index eb4d5e1e..fe594cdb 100644 --- a/data-room-ui/package.json +++ b/data-room-ui/package.json @@ -1,6 +1,6 @@ { "name": "@gcpaas/data-room-ui", - "version": "0.0.1-2023070302-Alpha", + "version": "0.0.1-2023070303-Alpha", "description": "自定义大屏", "author": "gc-starter", "license": "MIT",