Procházet zdrojové kódy

fix:解决列表筛选条件打开对话框后原列表顶部按钮脚本逻辑失效的问题;

liujiayin před 2 roky
rodič
revize
2ca68ce63c

+ 5 - 0
src/business/platform/data/components/search-form/index.vue

@@ -211,6 +211,8 @@
                     :type="item.field_options.dialog_type||'dialog'"
                     :dynamic-params="getLinkDynamicParams(item.field_options,params)"
                     :temp-search="true"
+                    :previous-data-template="previousDataTemplate"
+                    @close="handleRenderDialogClose"
                 />
                 <!-- 关联数据-->
                 <ibps-link-data
@@ -547,6 +549,9 @@ export default {
                 default:
                     return 'date'
             }
+        },
+        handleRenderDialogClose (visible, previousDataTemplate) {
+            this.$emit('close', visible, previousDataTemplate)
         }
     }
 }

+ 46 - 38
src/business/platform/data/components/search-form/props.js

@@ -1,42 +1,50 @@
+/*
+ * @Descripttion: 表单/数据模板脚本:
+ * @version: 1.0
+ * @Author: Liu_jiaYin
+ */
 export const formProps = {
-  // 尺寸 ['medium ', 'small', 'mini']
-  size: {
-    type: String,
-    validator: sizeValidator
-  },
-  // 是否在一行
-  inline: {
-    type: Boolean,
-    default: true
-  },
-  // 文本的宽度
-  labelWidth: {
-    type: Number,
-    default: 100
-  },
-  // 输入框的宽度
-  itemWidth: Number,
-  // 异步数据
-  fuzzy: {
-    type: Boolean,
-    default: false
-  },
-  // 表单
-  forms: {
-    type: Array,
-    required: true
-  },
-  disabled: {
-    type: Boolean,
-    default: false
-  }
+    // 尺寸 ['medium ', 'small', 'mini']
+    size: {
+        type: String,
+        validator: sizeValidator
+    },
+    // 是否在一行
+    inline: {
+        type: Boolean,
+        default: true
+    },
+    // 文本的宽度
+    labelWidth: {
+        type: Number,
+        default: 100
+    },
+    // 输入框的宽度
+    itemWidth: Number,
+    // 异步数据
+    fuzzy: {
+        type: Boolean,
+        default: false
+    },
+    // 表单
+    forms: {
+        type: Array,
+        required: true
+    },
+    disabled: {
+        type: Boolean,
+        default: false
+    },
+    previousDataTemplate: {
+        type: Object
+    }
 }
 
-function sizeValidator(value) {
-  const methodTypes = ['medium ', 'small', 'mini']
-  const valid = methodTypes.indexOf(value.toLowerCase()) !== -1 || value === ''
-  if (!valid) {
-    throw new Error(`Size must be one of ['medium ', 'small', 'mini']`)
-  }
-  return valid
+function sizeValidator (value) {
+    const methodTypes = ['medium ', 'small', 'mini']
+    const valid = methodTypes.indexOf(value.toLowerCase()) !== -1 || value === ''
+    if (!valid) {
+        throw new Error(`Size must be one of ['medium ', 'small', 'mini']`)
+    }
+    return valid
 }

+ 111 - 107
src/business/platform/data/templaterender/custom-dialog/dialog.vue

@@ -1,16 +1,16 @@
 <template>
-  <data-template-dialog
-    :visible.sync="selectorVisible"
-    :data="dataTemplate"
-    :dynamic-params="dynamicParams"
-    :multiple="multiple"
-    :value="selectorValue"
-    :label-key="labelKey"
-    :preview="false"
-    type="dialog"
-    @close="closeDialog"
-    @action-event="handleSelectorActionEvent"
-  />
+    <data-template-dialog
+        :visible.sync="selectorVisible"
+        :data="dataTemplate"
+        :dynamic-params="dynamicParams"
+        :multiple="multiple"
+        :value="selectorValue"
+        :label-key="labelKey"
+        :preview="false"
+        type="dialog"
+        @close="closeDialog"
+        @action-event="handleSelectorActionEvent"
+    />
 </template>
 <script>
 import { getByKey } from '@/api/platform/data/dataTemplate'
@@ -18,109 +18,113 @@ import DataTemplateDialog from '../preview'
 import { buildLabelTitle } from '../utils'
 
 export default {
-  components: {
-    DataTemplateDialog
-  },
-  props: {
-    visible: Boolean, // 是否可见
-    value: [Object, Array],
-    templateKey: { // 数据模版key
-      type: String
+    components: {
+        DataTemplateDialog
     },
-    dynamicParams: { // 动态参数
-      type: Object
-    },
-    multiple: {
-      type: Boolean,
-      default: true
-    }
-  },
-  data() {
-    return {
-      dataTemplate: {},
-      labelKey: '',
-      valueKey: '',
-      selectorVisible: false,
-      selectorValue: this.multiple ? [] : {},
-      cacheData: {},
-      bindIdValue: ''
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        if (val) {
-          this.loadTemplateData()
-        } else {
-          this.selectorVisible = val
+    props: {
+        visible: Boolean, // 是否可见
+        value: [Object, Array],
+        templateKey: { // 数据模版key
+            type: String
+        },
+        dynamicParams: { // 动态参数
+            type: Object
+        },
+        multiple: {
+            type: Boolean,
+            default: true
+        },
+        previousDataTemplate: {
+            type: Object
         }
-      },
-      immediate: true
-    },
-    value: {
-      handler(val, oldVal) {
-        this.initData()
-      },
-      immediate: true
-    }
-  },
-  methods: {
-    loadTemplateData() {
-      if (this.$utils.isEmpty(this.templateKey)) {
-        return
-      }
-      getByKey({
-        dataTemplateKey: this.templateKey
-      }).then(response => {
-        this.dataTemplate = this.$utils.parseData(response.data)
-        this.initDataTemplate()
-        this.selectorVisible = true
-      }).catch(() => {
-      })
+
     },
-    initDataTemplate() {
-      this.valueKey = this.dataTemplate.unique
-      this.labelKey = buildLabelTitle(this.dataTemplate)
+    data () {
+        return {
+            dataTemplate: {},
+            labelKey: '',
+            valueKey: '',
+            selectorVisible: false,
+            selectorValue: this.multiple ? [] : {},
+            cacheData: {},
+            bindIdValue: ''
+        }
     },
-    handleLabel(data) {
-      const config = this.labelKey
-      if (typeof config === 'function') {
-        return config(data)
-      } else if (typeof config === 'string') {
-        return data[config]
-      } else if (typeof config === 'undefined') {
-        const dataProp = data['name']
-        return dataProp === undefined ? '' : dataProp
-      }
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                if (val) {
+                    this.loadTemplateData()
+                } else {
+                    this.selectorVisible = val
+                }
+            },
+            immediate: true
+        },
+        value: {
+            handler (val, oldVal) {
+                this.initData()
+            },
+            immediate: true
+        }
     },
-    /**
+    methods: {
+        loadTemplateData () {
+            if (this.$utils.isEmpty(this.templateKey)) {
+                return
+            }
+            getByKey({
+                dataTemplateKey: this.templateKey
+            }).then(response => {
+                this.dataTemplate = this.$utils.parseData(response.data)
+                this.initDataTemplate()
+                this.selectorVisible = true
+            }).catch(() => {
+            })
+        },
+        initDataTemplate () {
+            this.valueKey = this.dataTemplate.unique
+            this.labelKey = buildLabelTitle(this.dataTemplate)
+        },
+        handleLabel (data) {
+            const config = this.labelKey
+            if (typeof config === 'function') {
+                return config(data)
+            } else if (typeof config === 'string') {
+                return data[config]
+            } else if (typeof config === 'undefined') {
+                const dataProp = data['name']
+                return dataProp === undefined ? '' : dataProp
+            }
+        },
+        /**
      * 初始化数据
      */
-    initData(init = true) {
-      this.selectorValue = this.multiple ? [] : {}
-    },
-    // ===================事件处理=========
-    closeDialog() {
-      this.$emit('close', false)
-    },
-    handleSelectorActionEvent(buttonKey, data) {
-      switch (buttonKey) {
-        case 'ok':// 确定
-          this.closeDialog()
-          this.$emit('action-event', buttonKey, data)
-          break
-        case 'cleanClose': // 清空关闭
-          this.closeDialog()
-          this.selectorValue = this.multiple ? [] : {}
-          this.$emit('action-event', buttonKey, this.selectorValue)
-          break
-        case 'cancel':// 取消
-          this.closeDialog()
-          this.selectorValue = this.multiple ? [] : {}
-          break
+        initData (init = true) {
+            this.selectorValue = this.multiple ? [] : {}
+        },
+        // ===================事件处理=========
+        closeDialog () {
+            this.$emit('close', false)
+        },
+        handleSelectorActionEvent (buttonKey, data) {
+            switch (buttonKey) {
+                case 'ok':// 确定
+                    this.closeDialog()
+                    this.$emit('action-event', buttonKey, data)
+                    break
+                case 'cleanClose': // 清空关闭
+                    this.closeDialog()
+                    this.selectorValue = this.multiple ? [] : {}
+                    this.$emit('action-event', buttonKey, this.selectorValue)
+                    break
+                case 'cancel':// 取消
+                    this.closeDialog()
+                    this.selectorValue = this.multiple ? [] : {}
+                    break
         // TODO:自定义按钮事件处理
-      }
+            }
+        }
     }
-  }
 }
 </script>

+ 8 - 1
src/business/platform/data/templaterender/custom-dialog/index.vue

@@ -24,7 +24,7 @@
             :preview="false"
             :temp-search="tempSearch"
             type="dialog"
-            @close="visible=>selectorVisible =visible"
+            @close="handleClose"
             @action-event="handleSelectorActionEvent"
         />
     </div>
@@ -104,6 +104,9 @@ export default {
         tempSearch: { // 是否是数据模板使用的筛选条件
             type: Boolean,
             default: false
+        },
+        previousDataTemplate: {
+            type: Object
         }
     },
     data () {
@@ -472,6 +475,10 @@ export default {
         handleInput (val) {
             this.$emit('input', val, this.selectorValue)
             this.$emit('change-link-attr', val, this.selectorValue)
+        },
+        handleClose (visible) {
+            this.selectorVisible = visible
+            this.$emit('close', visible, this.previousDataTemplate)
         }
     }
 }

+ 3 - 0
src/business/platform/data/templaterender/templates/list.vue

@@ -40,7 +40,9 @@
                     :inline="listConfig.searchForm.inline"
                     :label-width="listConfig.searchForm.labelWidth"
                     :item-width="listConfig.searchForm.itemWidth"
+                    :previous-data-template="dataTemplate"
                     @search="search"
+                    @close="handleRenderDialogClose"
                 />
             </template>
             <!--数字-->
@@ -1886,6 +1888,7 @@ export default {
         },
         // 数据模板打开数据模板时候,被打开的数据模板弹框关闭逻辑
         handleRenderDialogClose (visible, previousDataTemplate) {
+            console.log('1889 previousDataTemplate', previousDataTemplate)
             this.dataTemplate = previousDataTemplate
             this.templateDialogVisible = visible
             this.initJTemplate()