浏览代码

fix: 修复自定义JS数据集,脚本发生变化,输出字段不对应的情况

wu.jian2 2 年之前
父节点
当前提交
5acdf292a5

+ 15 - 2
data-room-ui/example/customDatasetComponents/jsDataSet/index.vue

@@ -9,7 +9,7 @@
           <template slot="content">
             <div class="page-header">
               <div class="page-header-left">
-                {{ !isEdit ? 'js数据集详情' : dataForm.id ? 'js数据集编辑' : 'js数据集新增' }}
+                {{ !isEdit ? 'JS数据集详情' : dataForm.id ? 'JS数据集编辑' : 'JS数据集新增' }}
               </div>
               <div class="page-header-right">
                 <el-button
@@ -637,7 +637,20 @@ export default {
             }
           })
         }
-
+        // 如果脚本有变化,生成的keys和outputFieldList的长度不一致,就重新生成outputFieldList,仅添加变化的那个字段,其余的不变化
+        if (this.outputFieldList.length !== keys.length) {
+          const newKeys = keys.filter(item => {
+            return !this.outputFieldList.some(key => {
+              return key.fieldName === item
+            })
+          })
+          newKeys.forEach(item => {
+            this.outputFieldList.push({
+              fieldName: item,
+              fieldDesc: ''
+            })
+          })
+        }
         if (this.outputFieldList.length && this.fieldDesc && !isInit) {
           this.buildFieldDesc()
         }

+ 1 - 1
data-room-ui/packages/ComponentList/index.vue

@@ -120,7 +120,7 @@
           </div>
           <div class="big-screen-card-img">
             <el-image
-              :src="catalogInfo !== 'system'?screen.coverPicture:screen.img"
+              :src="catalogInfo !== 'system' ? screen.coverPicture : screen.img"
               fit="fill"
               style="width: 100%; height: 100%"
             >