Эх сурвалжийг харах

feat:修改http数据集动态参数配置

liu.shiyi 1 жил өмнө
parent
commit
797915ade8

+ 37 - 17
data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue

@@ -257,7 +257,10 @@
                     </el-col>
                     </el-col>
                   </el-row>
                   </el-row>
                   <el-row>
                   <el-row>
-                    <el-col :span="24">
+                    <el-col
+                      :span="12"
+                      :offset="6"
+                    >
                       <div
                       <div
                         class="add-btn"
                         class="add-btn"
                         @click="addHeader"
                         @click="addHeader"
@@ -327,7 +330,10 @@
                     </el-col>
                     </el-col>
                   </el-row>
                   </el-row>
                   <el-row>
                   <el-row>
-                    <el-col :span="24">
+                    <el-col
+                      :span="12"
+                      :offset="6"
+                    >
                       <div
                       <div
                         class="add-btn"
                         class="add-btn"
                         @click="addParam"
                         @click="addParam"
@@ -517,10 +523,9 @@
           <el-table
           <el-table
             align="center"
             align="center"
             :data="dataPreviewList"
             :data="dataPreviewList"
-            max-height="400"
+            max-height="300"
             :border="true"
             :border="true"
-            height="500px"
-            class="bs-el-table bs-scrollbar"
+            class="bs-el-table bs-scrollba preview-table"
           >
           >
             <el-table-column
             <el-table-column
               v-for="(value, key) in dataPreviewList[0]"
               v-for="(value, key) in dataPreviewList[0]"
@@ -615,7 +620,9 @@
       <ParamsSettingDialog
       <ParamsSettingDialog
         ref="paramsSettingDialog"
         ref="paramsSettingDialog"
         :params-list="dataForm.config.paramsList"
         :params-list="dataForm.config.paramsList"
+        :newParamsList="newParamsList"
         @saveParams="saveParams"
         @saveParams="saveParams"
+        @saveNewParams="saveNewParams"
         @getData="getData"
         @getData="getData"
       />
       />
       <OutputFieldDialog
       <OutputFieldDialog
@@ -704,6 +711,7 @@ export default {
       }
       }
     }
     }
     return {
     return {
+      newParamsList: [], // 存放临时的动态参数值
       activeName: 'head',
       activeName: 'head',
       options: [{
       options: [{
         value: 'string',
         value: 'string',
@@ -811,6 +819,7 @@ export default {
           this.dataForm = { id, name, typeId, remark, datasetType, moduleCode, editable, sourceId, config: { ...config } }
           this.dataForm = { id, name, typeId, remark, datasetType, moduleCode, editable, sourceId, config: { ...config } }
           this.fieldDesc = fieldDesc
           this.fieldDesc = fieldDesc
           this.outputFieldList = fieldList
           this.outputFieldList = fieldList
+          this.newParamsList = _.cloneDeep(paramsList)
           this.codemirrorOption.mode = this.dataForm.config.requestType === 'frontend' ? 'text/javascript' : 'text/x-groovy'
           this.codemirrorOption.mode = this.dataForm.config.requestType === 'frontend' ? 'text/javascript' : 'text/x-groovy'
           // this.replaceParams(paramsList)
           // this.replaceParams(paramsList)
           this.scriptExecute(true)
           this.scriptExecute(true)
@@ -899,8 +908,13 @@ export default {
       this.dataForm.config.params.splice(index, 1)
       this.dataForm.config.params.splice(index, 1)
     },
     },
     saveParams (val) {
     saveParams (val) {
+      debugger
       this.dataForm.config.paramsList = val
       this.dataForm.config.paramsList = val
     },
     },
+    saveNewParams (val) {
+      console.log(val)
+      this.newParamsList = val
+    },
     // 取消操作
     // 取消操作
     // cancelField () {
     // cancelField () {
     //   this.structurePreviewListCopy = cloneDeep(this.outputFieldList)
     //   this.structurePreviewListCopy = cloneDeep(this.outputFieldList)
@@ -1005,19 +1019,22 @@ export default {
       // 如果动态参数未配置,则直接打开配置弹窗
       // 如果动态参数未配置,则直接打开配置弹窗
       // const flag = this.dataForm.config.paramsList.some(item => !item.value)
       // const flag = this.dataForm.config.paramsList.some(item => !item.value)
       // 每次执行时只要有动态参数就会打开参数配置的弹窗进行设置
       // 每次执行时只要有动态参数就会打开参数配置的弹窗进行设置
-      this.$refs.paramsSettingDialog.open()
+      if (this.dataForm.config.paramsList && this.dataForm.config.paramsList.length) {
+        this.$refs.paramsSettingDialog.open(true)
+      } else {
+        this.getData()
+      }
     },
     },
     // 调接口
     // 调接口
     getData () {
     getData () {
       // 如果是前端代理,则自行组装接口及参数并调接口
       // 如果是前端代理,则自行组装接口及参数并调接口
       if (this.dataForm.config.requestType === 'frontend') {
       if (this.dataForm.config.requestType === 'frontend') {
         // this.replaceParams(this.dataForm.config.paramsList)
         // this.replaceParams(this.dataForm.config.paramsList)
-        axiosFormatting({ ...this.dataForm.config }).then((res) => {
-          const { resp, response } = res
+        axiosFormatting({ ...this.dataForm.config, paramsList: this.newParamsList }).then((res) => {
           // this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : []
           // this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : []
           this.dataPreviewList = [{}]
           this.dataPreviewList = [{}]
-          for (const item in response.data) {
-            this.dataPreviewList[0][item] = response.data[item]
+          for (const item in res) {
+            this.dataPreviewList[0][item] = res[item]
           }
           }
           // 获取数据后更新输出字段
           // 获取数据后更新输出字段
           this.updateOoutputFieldList(this.dataPreviewList)
           this.updateOoutputFieldList(this.dataPreviewList)
@@ -1246,13 +1263,13 @@ export default {
   }
   }
 }
 }
 
 
-::v-deep .bs-table-box.is-Edit .el-table {
-  max-height: unset !important;
-
-  .el-table__body-wrapper {
-    max-height: unset !important;
-  }
-}
+//::v-deep .bs-table-box.is-Edit .el-table {
+//  max-height: unset !important;
+//
+//  .el-table__body-wrapper {
+//    max-height: unset !important;
+//  }
+//}
 
 
 .bs-table-box {
 .bs-table-box {
   padding: 0;
   padding: 0;
@@ -1283,4 +1300,7 @@ export default {
     cursor: pointer;
     cursor: pointer;
   }
   }
 }
 }
+.preview-table{
+  max-height: 300px!important;
+}
 </style>
 </style>

+ 47 - 43
data-room-ui/packages/DataSetManagement/src/JsComponents/ParamsSettingDialog.vue

@@ -12,7 +12,7 @@
       <div class="bs-table-box">
       <div class="bs-table-box">
         <el-table
         <el-table
           ref="singleTable"
           ref="singleTable"
-          :data="paramsList"
+          :data="params"
           :border="true"
           :border="true"
           align="center"
           align="center"
           class="bs-el-table"
           class="bs-el-table"
@@ -112,32 +112,32 @@
               />
               />
             </template>
             </template>
           </el-table-column>
           </el-table-column>
-<!--          <el-table-column-->
-<!--            label="操作"-->
-<!--            width="105"-->
-<!--            align="center"-->
-<!--          >-->
-<!--            <template slot="header">-->
-<!--              <el-button-->
-<!--                icon="el-icon-plus"-->
-<!--                type="text"-->
-<!--                class="no-border"-->
-<!--                @click="addParam"-->
-<!--              >-->
-<!--                添加-->
-<!--              </el-button>-->
-<!--            </template>-->
-<!--            <template slot-scope="scope">-->
-<!--              <el-button-->
-<!--                type="text"-->
-<!--                style="color: #e47470;"-->
-<!--                class="no-border"-->
-<!--                @click="delRow(scope.$index)"-->
-<!--              >-->
-<!--                删除-->
-<!--              </el-button>-->
-<!--            </template>-->
-<!--          </el-table-column>-->
+          <!--          <el-table-column-->
+          <!--            label="操作"-->
+          <!--            width="105"-->
+          <!--            align="center"-->
+          <!--          >-->
+          <!--            <template slot="header">-->
+          <!--              <el-button-->
+          <!--                icon="el-icon-plus"-->
+          <!--                type="text"-->
+          <!--                class="no-border"-->
+          <!--                @click="addParam"-->
+          <!--              >-->
+          <!--                添加-->
+          <!--              </el-button>-->
+          <!--            </template>-->
+          <!--            <template slot-scope="scope">-->
+          <!--              <el-button-->
+          <!--                type="text"-->
+          <!--                style="color: #e47470;"-->
+          <!--                class="no-border"-->
+          <!--                @click="delRow(scope.$index)"-->
+          <!--              >-->
+          <!--                删除-->
+          <!--              </el-button>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
         </el-table>
         </el-table>
       </div>
       </div>
       <span
       <span
@@ -169,15 +169,27 @@ export default {
     paramsList: {
     paramsList: {
       type: Array,
       type: Array,
       default: () => []
       default: () => []
+    },
+    newParamsList: {
+      type: Array,
+      default: () => []
     }
     }
   },
   },
   data () {
   data () {
     return {
     return {
+      params: [],
+      isUpdate: false,
       dialogVisible: false
       dialogVisible: false
     }
     }
   },
   },
   methods: {
   methods: {
-    open () {
+    open (isUpdate = false) {
+      if (isUpdate) {
+        this.params = cloneDeep(this.newParamsList)
+      } else {
+        this.params = cloneDeep(this.paramsList)
+      }
+      this.isUpdate = isUpdate
       this.dialogVisible = true
       this.dialogVisible = true
     },
     },
     close () {
     close () {
@@ -186,21 +198,8 @@ export default {
     handleClose () {
     handleClose () {
       this.dialogVisible = false
       this.dialogVisible = false
     },
     },
-    addParam () {
-      this.paramsList.push({
-        name: '',
-        type: '',
-        value: '',
-        status: 1,
-        require: 0,
-        remark: ''
-      })
-    },
-    delRow (index) {
-      this.paramsList.splice(index, 1)
-    },
     checkParamsName (value) {
     checkParamsName (value) {
-      const checkList = this.paramsList.filter(item => item.fieldName === value.name)
+      const checkList = this.params.filter(item => item.fieldName === value.name)
       if (checkList.length) {
       if (checkList.length) {
         this.$message.warning('参数名称不可以与字段名相同!')
         this.$message.warning('参数名称不可以与字段名相同!')
         value.name = ''
         value.name = ''
@@ -210,7 +209,12 @@ export default {
       this.dialogVisible = false
       this.dialogVisible = false
     },
     },
     confirm () {
     confirm () {
-      this.$emit('saveParams', cloneDeep(this.paramsList))
+      if (!this.isUpdate) {
+        this.$emit('saveParams', cloneDeep(this.params))
+      } else {
+        console.log(this.params)
+        this.$emit('saveNewParams', cloneDeep(this.params))
+      }
       this.$emit('getData')
       this.$emit('getData')
       this.dialogVisible = false
       this.dialogVisible = false
     }
     }

+ 0 - 2
data-room-ui/packages/js/mixins/commonMixins.js

@@ -77,7 +77,6 @@ export default {
           if (res.executionByFrontend) {
           if (res.executionByFrontend) {
             if (res.data.datasetType === 'http') {
             if (res.data.datasetType === 'http') {
               _res = await axiosFormatting(res.data)
               _res = await axiosFormatting(res.data)
-              _res = _res.resp
             }
             }
             if (res.data.datasetType === 'js') {
             if (res.data.datasetType === 'js') {
               try {
               try {
@@ -124,7 +123,6 @@ export default {
           if (res.executionByFrontend) {
           if (res.executionByFrontend) {
             if (res.data.datasetType === 'http') {
             if (res.data.datasetType === 'http') {
               _res = await axiosFormatting(res.data)
               _res = await axiosFormatting(res.data)
-              _res = _res.resp
             }
             }
             if (res.data.datasetType === 'js') {
             if (res.data.datasetType === 'js') {
               try {
               try {

+ 2 - 4
data-room-ui/packages/js/utils/httpParamsFormatting.js

@@ -40,11 +40,9 @@ export default function axiosFormatting (customConfig) {
       const getResp = new Function('response', newCustomConfig.responseScript)
       const getResp = new Function('response', newCustomConfig.responseScript)
       const resp = getResp(response)
       const resp = getResp(response)
       console.log('resp', resp)
       console.log('resp', resp)
-      return Promise.resolve({ resp, response })
+      return Promise.resolve(resp)
     } else {
     } else {
-      console.log(response.data)
-      const resp = response
-      return Promise.resolve({ resp, response })
+      return Promise.resolve(response.data)
     }
     }
   })
   })
   const body = {}
   const body = {}