Просмотр исходного кода

fix: 修改示例按钮获取方式

johnsen 1 месяц назад
Родитель
Сommit
500e8f431c

+ 22 - 1
src/business/platform/data/templaterender/templates/list.vue

@@ -593,6 +593,11 @@ export default {
     },
     setting() {
       return this.$store.getters.setting
+    },
+    exampleList() {
+      return this.$store.getters.exampleList
+        ? this.$store.getters.exampleList.filter((t) => t)
+        : []
     }
   },
   watch: {
@@ -700,7 +705,23 @@ export default {
       this.key = pkKey
     },
     initUI() {
-      console.log('this.template====>', this.template)
+      const item =
+        this.template &&
+        this.exampleList &&
+        this.exampleList.find(
+          (t) =>
+            t.DEFAULT_URL_ && t.DEFAULT_URL_.includes(this.template.template_id)
+        )
+      console.log('this.exampleList==>', this.template, item)
+      if (item) {
+        if (this.template.attrs) {
+          this.template.attrs.formExample = item.shi_li_shang_chua || ''
+        } else {
+          this.template.attrs = {
+            formExample: item.shi_li_shang_chua || ''
+          }
+        }
+      }
       this.initialization = false
       if (!this.initialization) {
         this.initJTemplate()

+ 4 - 1
src/store/getters.js

@@ -94,5 +94,8 @@ export default {
   licence: (state) => (state.ibps.licence ? state.ibps.licence.licJson : {}),
   // 获取配置信息
   setting: (state) =>
-    state.ibps.param && state.ibps.param.setting ? state.ibps.param.setting : {}
+    state.ibps.param && state.ibps.param.setting ? state.ibps.param.setting : {},
+  // 获取示例列表
+  exampleList: (state) =>
+    state.ibps.page && state.ibps.page.exampleList ? state.ibps.page.exampleList : []
 }

+ 25 - 1
src/store/modules/ibps/modules/page.js

@@ -1,6 +1,7 @@
 import { get } from 'lodash'
 import router from '@/router'
 import setting from '@/setting.js'
+import common from '@/utils/common'
 
 // 判定是否需要缓存
 const isKeepAlive = (data) => get(data, 'meta.cache', false)
@@ -20,7 +21,9 @@ export default {
     // 当前页面
     current: '',
     // 需要缓存的页面 name
-    keepAlive: []
+    keepAlive: [],
+    // 当前页面示例集合
+    exampleList: []
   },
   actions: {
     /**
@@ -37,6 +40,24 @@ export default {
         }, 10)
       })
     },
+    getExampleList({ commit }) {
+      common
+        .request('query', {
+          key: 'getFormAttr',
+          params: [null]
+        })
+        .then((res) => {
+          const { data = [] } = res.variables || {}
+          commit('setExampleList', data)
+          // dispatch('ibps/param/setUserList', data, {
+          //   root: true
+          // })
+        })
+        .catch((error) => {
+          console.log(error)
+          alert('获取所有用户信息失败!')
+        })
+    },
     /**
      * @class opened
      * @description 从持久化数据载入标签页列表
@@ -434,6 +455,9 @@ export default {
         .filter((item) => isKeepAlive(item))
         .map((e) => e.name)
     },
+    setExampleList(state, data) {
+      state.exampleList = data
+    },
     /**
      * @description 删除一个页面的缓存设置
      * @param {Object} state state

+ 1 - 0
src/store/modules/ibps/modules/user.js

@@ -140,6 +140,7 @@ export default {
                 await dispatch('getUserList', level)
                 // 获取所有部门信息
                 await dispatch('getDeptList', level)
+                await dispatch('ibps/page/getExampleList', null, { root: true })
                 // 获取当前子系统
                 await dispatch('ibps/system/loadSystem', null, {
                   root: true