浏览代码

Merge remote-tracking branch 'origin/master'

liu.shiyi 1 年之前
父节点
当前提交
a0720799a0

+ 1 - 2
data-room-ui/packages/DataSetManagement/src/CustomEditForm.vue

@@ -1277,8 +1277,7 @@ export default {
             item.sourceTable = this.tableNameList[0]
           })
         }
-        this.structurePreviewListCopy = cloneDeep(this.structurePreviewList)
-        this.structurePreviewListCopy = this.structurePreviewListCopy.sort((a, b) => {
+        this.structurePreviewListCopy = cloneDeep(this.structurePreviewList).sort((a, b) => {
           return a.orderNum - b.orderNum
         })
         let paramsNameCheck = false

+ 9 - 4
data-room-ui/packages/DataSetManagement/src/JsComponents/ParamsSettingDialog.vue

@@ -171,6 +171,11 @@ export default {
       default: () => []
     }
   },
+  computed: {
+    innerParamsList () {
+      return cloneDeep(this.paramsList)
+    }
+  },
   data () {
     return {
       dialogVisible: false
@@ -187,7 +192,7 @@ export default {
       this.dialogVisible = false
     },
     addParam () {
-      this.paramsList.push({
+      this.innerParamsList.push({
         name: '',
         type: '',
         value: '',
@@ -197,10 +202,10 @@ export default {
       })
     },
     delRow (index) {
-      this.paramsList.splice(index, 1)
+      this.innerParamsList.splice(index, 1)
     },
     checkParamsName (value) {
-      const checkList = this.paramsList.filter(item => item.fieldName === value.name)
+      const checkList = this.innerParamsList.filter(item => item.fieldName === value.name)
       if (checkList.length) {
         this.$message.warning('参数名称不可以与字段名相同!')
         value.name = ''
@@ -210,7 +215,7 @@ export default {
       this.dialogVisible = false
     },
     confirm () {
-      this.$emit('saveParams', cloneDeep(this.paramsList))
+      this.$emit('saveParams', this.innerParamsList)
       this.dialogVisible = false
     }
   }

+ 23 - 19
data-room-ui/packages/DataSetManagement/src/JsEditForm.vue

@@ -432,6 +432,7 @@ export default {
       })
     }
     return {
+      autoFill: true,
       dataForm: {
         id: '',
         name: '',
@@ -642,7 +643,9 @@ export default {
         try {
           const scriptAfterReplacement = javascript.replace(/\${(.*?)}/g, (match, p) => {
             const value = this.dataForm.config.paramsList.find(param => param.name === p).value
-            if (!isNaN(value)) {
+            if (value === null || value === undefined || value === '') {
+              return "''"
+            } else if (!isNaN(value)) {
               return value
             } else {
               return `'${value}'`
@@ -654,8 +657,8 @@ export default {
           this.passTest = false
           const javascriptParams = javascript.match(/\${(.*?)}/g)
           // 取出${}中的参数名
+          let paramList = []
           if (javascriptParams) {
-            const paramList = []
             javascriptParams.forEach(item => {
               const name = item.replace(/\${(.*?)}/g, '$1')
               const param = this.dataForm.config.paramsList.find(param => param.name === name)
@@ -664,24 +667,12 @@ export default {
                 paramList.push(name)
               }
             })
-            this.$confirm(`脚本中的参数${paramList.join(',')}不存在,是否添加?`, '提示', {
-              confirmButtonText: '确定',
-              cancelButtonText: '取消',
-              customClass: 'bs-el-message-box',
-              type: 'warning'
-            }).then(() => {
-              paramList.forEach(name => {
-                this.dataForm.config.paramsList.push({
-                  name,
-                  type: '',
-                  value: '',
-                  status: 1,
-                  require: 0,
-                  remark: ''
-                })
-              })
-            }).catch(() => {})
+            if (this.autoFill && paramList.length > 0) {
+              this.addParams(paramList)
+              paramList = []
+            }
           } else {
+            console.info(error)
             this.$message.error(`脚本执行错误,请检查脚本,具体错误:${error}`)
           }
           return
@@ -762,6 +753,19 @@ export default {
         this.$message.error('请填写脚本')
       }
     },
+    addParams (paramList) {
+      this.$refs.paramsSettingDialog.open()
+      paramList.forEach(name => {
+        this.dataForm.config.paramsList.push({
+          name,
+          type: '',
+          value: '',
+          status: 1,
+          require: 0,
+          remark: ''
+        })
+      })
+    },
     // 执行事件
     // toExecute () {
     // if (this.dataForm.config.paramsList.length) {

+ 26 - 7
data-room-ui/packages/DataSetManagement/src/OriginalEditForm.vue

@@ -319,7 +319,7 @@
             </div>
             <div class="field-wrap bs-field-wrap bs-scrollbar">
               <div
-                v-for="field in structurePreviewList"
+                v-for="field in sortedStructurePreviewList"
                 :key="field.fieldName"
                 class="field-item"
                 @click="fieldsetVisible = true"
@@ -363,15 +363,15 @@
             class="bs-el-table bs-scrollbar"
           >
             <el-table-column
-              v-for="(value, key) in dataPreviewList[0] ? dataPreviewList[0] : noDataTableDisplayFields"
+              v-for="(value, key) in sortedTablePreviewList"
               :key="key"
-              :label="key"
+              :label="value"
               align="center"
               show-overflow-tooltip
               :render-header="renderHeader"
             >
               <template slot-scope="scope">
-                <span>{{ scope.row[key] }}</span>
+                <span>{{ scope.row[value] }}</span>
               </template>
             </el-table-column>
           </el-table>
@@ -609,6 +609,21 @@ export default {
         tableColumnObject[item.fieldName] = ''
       })
       return tableColumnObject
+    },
+    sortedTablePreviewList () {
+      const tableList = this.dataPreviewList[0] ? this.dataPreviewList[0] : this.noDataTableDisplayFields
+      const list = Object.keys(tableList)
+      list.sort((a, b) => {
+        return this.structurePreviewListCopy.findIndex(item => item.fieldName === a) - this.structurePreviewListCopy.findIndex(item => item.fieldName === b)
+      })
+      return list
+    },
+    sortedStructurePreviewList () {
+      const list = this.structurePreviewList
+      list.sort((a, b) => {
+        return a.orderNum - b.orderNum
+      })
+      return list
     }
   },
   watch: {
@@ -630,8 +645,10 @@ export default {
       },
       deep: true,
       immediate: true
+    },
+    sortedStructurePreviewList (val) {
+      this.structurePreviewListCopy = cloneDeep(val)
     }
-
   },
   mounted () {
     this.init()
@@ -718,7 +735,7 @@ export default {
         if (this.dataForm.fieldList == null) {
           this.dataForm.fieldList = cloneDeep(data.structure)
         }
-        this.dataPreviewList = data.data.list
+        this.dataPreviewList = cloneDeep(data.data.list)
         this.totalCount = data.data.totalCount
         this.tableLoading = false
       }).catch(() => {
@@ -958,7 +975,9 @@ export default {
           })
         }
 
-        this.structurePreviewListCopy = cloneDeep(this.structurePreviewList)
+        this.structurePreviewListCopy = cloneDeep(this.structurePreviewList).sort((a, b) => {
+          return a.orderNum - b.orderNum
+        })
         this.totalCount = data.data.totalCount
         this.currentCount = data.data.currentCount
         this.tableLoading = false

+ 6 - 3
data-room-ui/packages/js/mixins/commonMixins.js

@@ -156,8 +156,9 @@ export default {
               try {
                 const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => {
                   const value = this.config.dataSource?.params[p]
-
-                  if (!isNaN(value)) {
+                  if (value === null || value === undefined || value === '') {
+                    return "''"
+                  } else if (!isNaN(value)) {
                     return value || p
                   } else {
                     return `'${value}' || '${p}'`
@@ -224,7 +225,9 @@ export default {
               try {
                 const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => {
                   const value = this.config.dataSource?.params[p]
-                  if (!isNaN(value)) {
+                  if (value === null || value === undefined || value === '') {
+                    return "''"
+                  } else if (!isNaN(value)) {
                     return value || p
                   } else {
                     return `'${value}' || '${p}'`