Ver código fonte

fix: 修复自定义JS数据集修改字段描述无效的情况

wu.jian2 2 anos atrás
pai
commit
8e2eee3453

+ 8 - 4
data-room-ui/example/customDatasetComponents/jsDataSet/OutputFieldDialog.vue

@@ -11,7 +11,7 @@
     >
       <div class="bs-table-box">
         <el-table
-          :data="outputFieldList"
+          :data="insideFieldList"
           :border="true"
           align="center"
           class="bs-el-table"
@@ -72,11 +72,14 @@ export default {
   data () {
     return {
       dialogVisible: false,
-      structurePreviewListCopy: []
+      structurePreviewListCopy: [],
+      // 内部的输出字段列表 用于编辑
+      insideFieldList: []
     }
   },
   methods: {
     open () {
+      this.insideFieldList = cloneDeep(this.outputFieldList)
       this.dialogVisible = true
     },
     close () {
@@ -89,11 +92,12 @@ export default {
       this.dialogVisible = false
     },
     setField () {
-      if (this.outputFieldList.length) {
+      if (this.insideFieldList.length) {
         this.fieldDesc = {}
-        this.outputFieldList.forEach(key => {
+        this.insideFieldList.forEach(key => {
           this.fieldDesc[key.fieldName] = key.fieldDesc
         })
+        this.$emit('setFieldList', this.insideFieldList)
       } else {
         this.fieldDesc = null
       }

+ 120 - 115
data-room-ui/example/customDatasetComponents/jsDataSet/index.vue

@@ -200,7 +200,7 @@
               </div>
               <div class="field-wrap bs-field-wrap bs-scrollbar">
                 <div
-                  v-for="(field,key) in outputFieldList"
+                  v-for="(field, key) in outputFieldList"
                   :key="key"
                   class="field-item"
                   @click="$refs.outputFieldDialog.open()"
@@ -338,6 +338,7 @@
       <OutputFieldDialog
         ref="outputFieldDialog"
         :output-field-list="outputFieldList"
+        @setFieldList="(list) => { outputFieldList = list }"
       />
     </el-scrollbar>
     <FieldFillDialog
@@ -369,7 +370,7 @@ export default {
   props: {
     config: {
       type: Object,
-      default: () => {}
+      default: () => { }
     },
     isEdit: {
       type: Boolean,
@@ -448,8 +449,10 @@ export default {
     }
   },
   watch: {
-    'dataForm.config.script' () {
-      this.passTest = false
+    'dataForm.config.script' (val) {
+      if (!val) {
+        this.passTest = false
+      }
     }
   },
   mounted () {
@@ -599,6 +602,7 @@ export default {
     },
     // 脚本执行
     scriptExecute (isInit = false) {
+      console.log(isInit)
       if (this.dataForm.config.script) {
         const javascript = this.dataForm.config.script
         let scriptMethod = null
@@ -635,7 +639,7 @@ export default {
           })
         }
 
-        if (this.outputFieldList.length && this.fieldDesc) {
+        if (this.outputFieldList.length && this.fieldDesc && !isInit) {
           this.buildFieldDesc()
         }
         // 如果有数据,就通过测试
@@ -701,151 +705,152 @@ export default {
 }
 </script>
 
-  <style lang="scss" scoped>
-  @import '~packages/assets/style/bsTheme.scss';
+<style lang="scss" scoped>
+@import '~packages/assets/style/bsTheme.scss';
 
-  .data-set-scrollbar {
-    height: 100%;
-    overflow-y: auto;
-    overflow-x: none;
+.data-set-scrollbar {
+  height: 100%;
+  overflow-y: auto;
+  overflow-x: none;
 
-    .el-scrollbar__view {
-      height: 100%;
-    }
-  }
-
-  /deep/ .el-input__inner {
-    width: 100% !important;
+  .el-scrollbar__view {
+    height: 100%;
   }
+}
 
-  .page-header {
-    display: flex;
-    position: relative;
+/deep/ .el-input__inner {
+  width: 100% !important;
+}
 
-    .page-header-right {
-      position: absolute;
-      right: 16px;
-    }
-  }
+.page-header {
+  display: flex;
+  position: relative;
 
-  .sql-config {
-    padding: 0 16px;
+  .page-header-right {
+    position: absolute;
+    right: 16px;
   }
+}
 
-  .operation {
-    /deep/ .el-select {
-      width: 200px !important;
-      margin-right: 16px;
-    }
+.sql-config {
+  padding: 0 16px;
+}
 
-    display: flex;
+.operation {
+  /deep/ .el-select {
+    width: 200px !important;
+    margin-right: 16px;
   }
 
-  /deep/ .CodeMirror {
-    height: 180px !important;
-    font-family: Helvetica, Tahoma;
-  }
+  display: flex;
+}
 
-  .no-border {
-    border: 0;
-  }
+/deep/ .CodeMirror {
+  height: 180px !important;
+  font-family: Helvetica, Tahoma;
+}
 
-  /deep/ .fieldDescCheck {
-    .el-dialog__body {
-      height: fit-content !important;
-      min-height: unset !important;
-    }
-  }
+.no-border {
+  border: 0;
+}
 
-  .title-style {
-    padding: 8px 12px;
-    background-color: #f6f7fb;
-    border-left: 5px solid var(--bs-el-color-primary);
-    margin: 16px 16px 0 0;
+/deep/ .fieldDescCheck {
+  .el-dialog__body {
+    height: fit-content !important;
+    min-height: unset !important;
   }
+}
 
-  .field-wrap {
-    // max-height: 110px;
-    overflow: auto;
-    margin-right: 16px;
-    cursor: pointer;
+.title-style {
+  padding: 8px 12px;
+  background-color: #f6f7fb;
+  border-left: 5px solid var(--bs-el-color-primary);
+  margin: 16px 16px 0 0;
+}
 
-    .field-item {
-      line-height: 32px;
-      padding: 0 12px 0 16px;
+.field-wrap {
+  // max-height: 110px;
+  overflow: auto;
+  margin-right: 16px;
+  cursor: pointer;
 
-      .edit_field {
-        display: none;
-      }
+  .field-item {
+    line-height: 32px;
+    padding: 0 12px 0 16px;
+
+    .edit_field {
+      display: none;
+    }
 
-      &:hover {
-        background-color: #f2f7fe;
+    &:hover {
+      background-color: #f2f7fe;
 
-        .edit_field {
-          display: block;
-        }
+      .edit_field {
+        display: block;
       }
     }
   }
+}
 
-  .right-setting {
-    height: 358px;
-    overflow: hidden;
-    display: flex;
-    flex-direction: column;
+.right-setting {
+  height: 358px;
+  overflow: hidden;
+  display: flex;
+  flex-direction: column;
 
-    .paramConfig {
-      max-height: 179px;
+  .paramConfig {
+    max-height: 179px;
 
-      .field-wrap {
-        max-height: 127px;
-      }
+    .field-wrap {
+      max-height: 127px;
     }
+  }
 
-    .structure {
-      flex: 1;
-      overflow: hidden;
+  .structure {
+    flex: 1;
+    overflow: hidden;
 
-      .field-wrap {
-        height: calc(100% - 40px);
-      }
+    .field-wrap {
+      height: calc(100% - 40px);
     }
   }
+}
 
-  .result-view {
-    font-size: 14px;
-    font-weight: 600;
-    color: var(--bs-el-text);
-    position: relative;
-    padding: 16px 0;
-    padding-left: 12px;
-    border-bottom: 1px solid var(--bs-background-1);
+.result-view {
+  font-size: 14px;
+  font-weight: 600;
+  color: var(--bs-el-text);
+  position: relative;
+  padding: 16px 0;
+  padding-left: 12px;
+  border-bottom: 1px solid var(--bs-background-1);
 
-    &::before {
-      content: "";
-      height: 14px;
-      position: absolute;
-      left: 0;
-      top: 50%;
-      transform: translateY(-50%);
-      border-left: 4px solid var(--bs-el-color-primary);
-    }
+  &::before {
+    content: "";
+    height: 14px;
+    position: absolute;
+    left: 0;
+    top: 50%;
+    transform: translateY(-50%);
+    border-left: 4px solid var(--bs-el-color-primary);
   }
+}
 
-  /deep/ .bs-table-box.is-Edit .el-table {
-    max-height: unset !important;
+/deep/ .bs-table-box.is-Edit .el-table {
+  max-height: unset !important;
 
-    .el-table__body-wrapper {
-      max-height: unset !important;
-    }
+  .el-table__body-wrapper {
+    max-height: unset !important;
   }
+}
 
-  .bs-table-box {
-    padding: 0;
-    height: 100% !important;
-    margin-bottom: 0 !important;
-  }
-  .tree-box{
-    padding: 0;
-  }
-  </style>
+.bs-table-box {
+  padding: 0;
+  height: 100% !important;
+  margin-bottom: 0 !important;
+}
+
+.tree-box {
+  padding: 0;
+}
+</style>