瀏覽代碼

feat:处理参数工作台常用功能限制数量

zhangsiya 1 年之前
父節點
當前提交
658bf6c722

+ 4 - 3
apps/mobile/src/components/treasure-box/AllUse.vue

@@ -53,7 +53,8 @@ export default {
       'tabsUseableFunctions',
       'tabsUseableFunctions',
       'tabsAllFunctions',
       'tabsAllFunctions',
       'commonFunctions',
       'commonFunctions',
-      'boxFeatureType'
+      'boxFeatureType',
+      'commonMaxNum'
     ]),
     ]),
     currentRenderList () {
     currentRenderList () {
       if (this.allNeedBadge) {
       if (this.allNeedBadge) {
@@ -174,8 +175,8 @@ export default {
     badgeHandle (item) {
     badgeHandle (item) {
       let commonArr = JSON.parse(JSON.stringify(this.commonFunctions))
       let commonArr = JSON.parse(JSON.stringify(this.commonFunctions))
       if (item.canAdd) {
       if (item.canAdd) {
-        // 常用功能超出8个提示
-        if(commonArr.length >= 8) {
+        // 常用功能超出最大限制个提示
+        if(commonArr.length >= this.commonMaxNum) {
           this.$toast('已添加满8个,请移除部分功能后再添加')
           this.$toast('已添加满8个,请移除部分功能后再添加')
           return
           return
         }
         }

+ 6 - 6
apps/mobile/src/components/treasure-box/CommonUse.vue

@@ -6,7 +6,7 @@
           :list="commonList"
           :list="commonList"
           :need-grid-bg="true"
           :need-grid-bg="true"
           @openLink="openLink" >
           @openLink="openLink" >
-          <template v-if="moreGrid && !loading && commonUseCount < 8" #more-grid>
+          <template v-if="moreGrid && !loading && commonList.length < commonMaxNum" #more-grid>
             <div class="common-use-grid grid-bg-color clickable" @click="settingCommonFeature">
             <div class="common-use-grid grid-bg-color clickable" @click="settingCommonFeature">
               <!-- <AppIcon name="add-01" color="#aaa" svg size="17" /> -->
               <!-- <AppIcon name="add-01" color="#aaa" svg size="17" /> -->
               <img class="add-fun-icon" src="@/assets/image/icon/add-function.png" />
               <img class="add-fun-icon" src="@/assets/image/icon/add-function.png" />
@@ -67,13 +67,11 @@ export default {
   },
   },
   computed: {
   computed: {
     ...mapGetters('treasureBox', [
     ...mapGetters('treasureBox', [
-      'commonFunctions'
+      'commonFunctions',
+      'commonMaxNum'
     ]),
     ]),
     getList () {
     getList () {
       return this.commonFunctions ? JSON.parse(JSON.stringify(this.commonFunctions)) : []
       return this.commonFunctions ? JSON.parse(JSON.stringify(this.commonFunctions)) : []
-    },
-    commonUseCount () {
-      return this.getList.length
     }
     }
   },
   },
   created () {
   created () {
@@ -87,7 +85,8 @@ export default {
       workspaceCommonUse('list', { platform: this.$env.platform?.toUpperCase() }).then(res => {
       workspaceCommonUse('list', { platform: this.$env.platform?.toUpperCase() }).then(res => {
         const { data = [], error_code: code } = res
         const { data = [], error_code: code } = res
         if (code === 0 && data) {
         if (code === 0 && data) {
-          _this.commonList = data
+          const maxNum = data.num || 8
+          _this.commonList = data.list || []
           _this.commonList.forEach(temp => {
           _this.commonList.forEach(temp => {
             // 计算背景色
             // 计算背景色
             calcImgThemeColor(temp.icon).then(({ color }) => {
             calcImgThemeColor(temp.icon).then(({ color }) => {
@@ -102,6 +101,7 @@ export default {
           })
           })
           // 初始化常用组件
           // 初始化常用组件
           _this.$store.dispatch('treasureBox/setCommonFunction', _this.commonList)
           _this.$store.dispatch('treasureBox/setCommonFunction', _this.commonList)
+          _this.$store.dispatch('treasureBox/setCommonMaxNum', maxNum)
         }
         }
       }).finally(() => {
       }).finally(() => {
         this.loading = false
         this.loading = false

+ 13 - 1
apps/mobile/src/store/modules/treasureBox.js

@@ -5,7 +5,8 @@ export default {
     commonFunctions: [], // 常用功能模块
     commonFunctions: [], // 常用功能模块
     tabsUseableFunctions: [], // tab菜单下可用功能模块
     tabsUseableFunctions: [], // tab菜单下可用功能模块
     tabsAllFunctions: [], // tab菜单下所有功能模块
     tabsAllFunctions: [], // tab菜单下所有功能模块
-    boxFeatureType: localStorage.getItem('box_feature_type') || 'all' // 百宝箱功能类型
+    boxFeatureType: localStorage.getItem('box_feature_type') || 'all', // 百宝箱功能类型
+    commonMaxNum: 8 //常用功能限制数量
   }),
   }),
   mutations: {
   mutations: {
     changeCommonFunction (state, list = []) {
     changeCommonFunction (state, list = []) {
@@ -20,6 +21,9 @@ export default {
     changeBoxFeatureType (state, value) {
     changeBoxFeatureType (state, value) {
       state.boxFeatureType = value
       state.boxFeatureType = value
       localStorage.setItem('box_feature_type', value)
       localStorage.setItem('box_feature_type', value)
+    },
+    changeCommonMaxNum (state, value) {
+      state.commonMaxNum = value
     }
     }
   },
   },
   actions: {
   actions: {
@@ -34,6 +38,10 @@ export default {
     },
     },
     setBoxFeatureType ({ commit }, value) {
     setBoxFeatureType ({ commit }, value) {
       commit('changeBoxFeatureType', value)
       commit('changeBoxFeatureType', value)
+    },
+    // 设置常用功能最大限制数量
+    setCommonMaxNum ({ commit }, value) {
+      commit('changeCommonMaxNum', value)
     }
     }
   },
   },
   getters: {
   getters: {
@@ -51,6 +59,10 @@ export default {
     },
     },
     boxFeatureType  (state) {
     boxFeatureType  (state) {
       return state.boxFeatureType || 'all'
       return state.boxFeatureType || 'all'
+    },
+    // 常用功能最大限制数量
+    commonMaxNum (state) {
+      return state.commonMaxNum || 8
     }
     }
   }
   }
 }
 }

+ 3 - 2
apps/mobile/src/views/treasurebox/FeatureSettings.vue

@@ -4,7 +4,7 @@
       <div class="work-common-box common-use-module">
       <div class="work-common-box common-use-module">
         <p class="pd-lr12 title-box">
         <p class="pd-lr12 title-box">
           <span class="content-title">我的常用</span>
           <span class="content-title">我的常用</span>
-          <span class="content-count">(<em>{{ commonCount }}</em>/8)</span>
+          <span class="content-count">(<em>{{ commonCount }}</em>/{{commonMaxNum}})</span>
         </p>
         </p>
         <common-use  :is-settings="true" :no-data="true"/>
         <common-use  :is-settings="true" :no-data="true"/>
       </div>
       </div>
@@ -41,7 +41,8 @@ export default {
   },
   },
   computed: {
   computed: {
     ...mapGetters('treasureBox', [
     ...mapGetters('treasureBox', [
-      'commonFunctions'
+      'commonFunctions',
+      'commonMaxNum'
     ]),
     ]),
     commonCount () {
     commonCount () {
       return this.commonFunctions?.length || 0
       return this.commonFunctions?.length || 0