Răsfoiți Sursa

fix:值来源数据模板预览bug修复

luoaoxuan 1 an în urmă
părinte
comite
6800bd8921

+ 109 - 107
src/business/platform/data/templaterender/preview/types/value-source.vue

@@ -1,23 +1,23 @@
 <template>
 <template>
-  <!--值来源-->
-  <el-dialog
-    :title="title"
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    class="data-template-renderer-value-source-dialog"
-    append-to-body
-    @open="getFormData"
-    @close="closeDialog"
-  >
-    <el-alert type="warning" :closable="false"> 实际是会返回数据到表单下拉:</el-alert>
+    <!--值来源-->
+    <el-dialog
+        :title="title"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        class="data-template-renderer-value-source-dialog"
+        append-to-body
+        @open="getFormData"
+        @close="closeDialog"
+    >
+        <el-alert type="warning" :closable="false"> 实际是会返回数据到表单下拉:</el-alert>
 
 
-    <ibps-highlight>{{ dataResult }}</ibps-highlight>
-    <ibps-pagination
-      :pagination="pagination"
-      @pagination-change="handlePaginationChange"
-    />
-  </el-dialog>
+        <ibps-highlight v-loading="loading">{{ dataResult }}</ibps-highlight>
+        <ibps-pagination
+            :pagination="pagination"
+            @pagination-change="handlePaginationChange"
+        />
+    </el-dialog>
 </template>
 </template>
 <script>
 <script>
 import { queryDataTable } from '@/api/platform/data/dataTemplate'
 import { queryDataTable } from '@/api/platform/data/dataTemplate'
@@ -26,105 +26,107 @@ import TypeMixin from '../mixins/types'
 import IbpsPagination from '@/components/ibps-pagination'
 import IbpsPagination from '@/components/ibps-pagination'
 
 
 export default {
 export default {
-  components: {
-    IbpsPagination
-  },
-  mixins: [TypeMixin],
-  props: {
-    visible: {
-      type: Boolean,
-      default: false
+    components: {
+        IbpsPagination
     },
     },
-    data: {
-      type: Object
+    mixins: [TypeMixin],
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        data: {
+            type: Object
+        },
+        dynamicParams: Object
     },
     },
-    dynamicParams: Object
-  },
-  data() {
-    return {
-      dialogVisible: this.visible,
-      dataTemplate: {},
-      template: {},
-      dataResult: [],
-      filterConditionKey: '',
-      treeData: [],
-      defaultPagination: {
-        page: 1,
-        limit: 20,
-        totalCount: 0
-      },
-      pagination: {
-        page: 1,
-        limit: 20
-      }
-    }
-  },
-  computed: {
-    title() {
-      return this.dataTemplate.name || '值来源'
+    data () {
+        return {
+            loading: false,
+            dialogVisible: this.visible,
+            dataTemplate: {},
+            template: {},
+            dataResult: [],
+            filterConditionKey: '',
+            treeData: [],
+            defaultPagination: {
+                page: 1,
+                limit: 20,
+                totalCount: 0
+            },
+            pagination: {
+                page: 1,
+                limit: 20
+            }
+        }
     },
     },
-    pkKey() {
-      return this.dataTemplate.unique || 'id_'
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = val
-      },
-      immediate: true
-    }
-  },
-  created() {
-    this.pagination = JSON.parse(JSON.stringify(this.defaultPagination))
-  },
-  methods: {
-    // 关闭当前窗口
-    closeDialog() {
-      this.$emit('close', false)
+    computed: {
+        title () {
+            return this.dataTemplate.name || '值来源'
+        },
+        pkKey () {
+            return this.dataTemplate.unique || 'id_'
+        }
+    },
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = val
+            },
+            immediate: true
+        }
     },
     },
-    getFormData() {
-      this.dataTemplate = JSON.parse(JSON.stringify(this.data))
-      const templates = this.dataTemplate.templates || []
-      this.template = templates[0] || {}
-      this.loadData()
+    created () {
+        this.pagination = JSON.parse(JSON.stringify(this.defaultPagination))
+        this.getFormData()
     },
     },
-    /**
+    methods: {
+    // 关闭当前窗口
+        closeDialog () {
+            this.$emit('close', false)
+        },
+        getFormData () {
+            this.dataTemplate = JSON.parse(JSON.stringify(this.data))
+            const templates = this.dataTemplate.templates || []
+            this.template = templates[0] || {}
+            this.loadData()
+        },
+        /**
      * 加载数据
      * 加载数据
      */
      */
-    loadData() {
-      this.loading = true
-      queryDataTable(this.getFormatParams()).then(response => {
-        this.loading = false
-        const data = response.data
-        this.dataResult = data.dataResult || []
-        this.pagination = data.pageResult || {}
-      }).catch(() => {
-        this.loading = false
-      })
-    },
-    handlePaginationChange({ page, limit }) {
-      this.pagination.page = page
-      this.pagination.limit = limit
-      this.loadData()
-    },
-    /**
+        loadData () {
+            this.loading = true
+            queryDataTable(this.getFormatParams()).then(response => {
+                this.loading = false
+                const data = response.data
+                this.dataResult = data.dataResult || []
+                this.pagination = data.pageResult || {}
+            }).catch(() => {
+                this.loading = false
+            })
+        },
+        handlePaginationChange ({ page, limit }) {
+            this.pagination.page = page
+            this.pagination.limit = limit
+            this.loadData()
+        },
+        /**
      * 获取格式化参数
      * 获取格式化参数
      */
      */
-    getFormatParams() {
-      let formParams = {}
-      if (this.$refs['searchForm']) {
-        formParams = this.$refs['searchForm'].getSearcFormData() || {}
-      }
-      const responseData = JSON.parse(JSON.stringify(this.template))
-      responseData.datasetKey = this.dataTemplate.datasetKey
-      responseData.unique = this.pkKey
-      responseData['dynamic_params'] = this.dynamicParams
-      formParams['response_data'] = JSON.stringify(responseData)
-      formParams['filter_condition_key'] = this.filterConditionKey
-      return ActionUtils.formatParams(formParams, this.pagination)
+        getFormatParams () {
+            let formParams = {}
+            if (this.$refs['searchForm']) {
+                formParams = this.$refs['searchForm'].getSearcFormData() || {}
+            }
+            const responseData = JSON.parse(JSON.stringify(this.template))
+            responseData.datasetKey = this.dataTemplate.datasetKey
+            responseData.unique = this.pkKey
+            responseData['dynamic_params'] = this.dynamicParams
+            formParams['response_data'] = JSON.stringify(responseData)
+            formParams['filter_condition_key'] = this.filterConditionKey
+            return ActionUtils.formatParams(formParams, this.pagination)
+        }
     }
     }
-  }
 }
 }
 </script>
 </script>
 <style lang="scss" >
 <style lang="scss" >