ソースを参照

增加左侧菜单提示数。

zhengqiang 5 年 前
コミット
1b6c9dcd84

+ 2 - 2
.env.development

@@ -1,3 +1,3 @@
-VUE_APP_BACKEND_URL=http://localhost:8081/picc-admin-server
+//VUE_APP_BACKEND_URL=http://localhost:8081/picc-admin-server
 //VUE_APP_BACKEND_URL=http://gyxm.jing-zhou.gov.cn/picc-admin-server
-//VUE_APP_BACKEND_URL=http://picc.jzrccs.com/picc-admin-server
+VUE_APP_BACKEND_URL=http://picc.jzrccs.com/picc-admin-server

+ 4 - 0
src/components/MenuTreeItem/index.vue

@@ -37,6 +37,10 @@ export default {
 </script>
 
 <style lang="scss" scoped>
+  .item{
+    margin-bottom:5px;
+  }
+
 	.el-menu--collapse {
 		.menu-wrapper{
 			.el-menu-item{

+ 2 - 1
src/store/index.js

@@ -1,6 +1,7 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
 import user from './modules/user'
+import menu from './modules/menu'
 
 Vue.use(Vuex)
 
@@ -8,7 +9,7 @@ const debug = process.env.NODE_ENV !== 'production'
 
 export default new Vuex.Store({
   modules: {
-    user
+    user,menu
   },
   strict: debug,
   state:{

+ 132 - 0
src/store/modules/menu.js

@@ -0,0 +1,132 @@
+
+import messageApi from "@/api/base/message";
+import insuranceApplicationApi from "@/api/business/insuranceApplication";
+import approvalApi from "@/api/business/approval";
+
+const state = {
+   menuList:[]
+}
+
+const mutations = {
+    setMenuList : (state, menuList) => {
+        state.menuList = menuList
+    },
+    setMenuBadgeNum(state,{sortNo,num}) {
+        //定义菜单的提示数
+        var menuList = state.menuList;
+
+        for(var i=0;i<state.menuList.length;i++){
+            var menu = menuList[i];
+
+            if(menu.sortNo == sortNo){
+                menu.msgNum = num;
+                console.log(menu.sortNo + "=" + num);
+
+                break;
+            }
+            else if(menu.children!=null){
+                var filterItems = menu.children.filter(item=>item.sortNo==sortNo);
+
+                if(filterItems.length>0){
+                    filterItems[0].msgNum = num;
+                    break;
+                }
+            }
+        }
+    }
+}
+
+const actions = {
+    //获取未读消息数
+    getUnReadMessageNum(context) {
+        return new Promise((resolve,reject)=>{
+            messageApi.getMessageCount().then(resp => {
+                if (resp.data.result) {
+                    var num = resp.data.data;
+                    
+                    context.commit("setMenuBadgeNum",{
+                        sortNo:700,
+                        num: num
+                    });
+
+                    resolve(resp);
+                }
+                else{
+                    reject();
+                }
+            });
+        });
+    },
+    //获取新增投保各状态数量    
+    getInsuranceApplicationNum(context) {
+        var formData = new FormData();
+
+        return new Promise((resolve,reject)=>{
+            insuranceApplicationApi.tabCount(formData).then(response=>{
+                var jsonData = response.data;
+        
+                if(jsonData.result){
+                    this.statusListNum = jsonData.data;
+        
+                    let num1 = this.statusListNum[20] + this.statusListNum[50];
+                    let num2 = this.statusListNum[30] + this.statusListNum[60];
+        
+                    context.commit("setMenuBadgeNum",{
+                        sortNo:201,
+                        num: num1
+                    });
+
+                    context.commit("setMenuBadgeNum",{
+                        sortNo:301,
+                        num: num2
+                    });
+
+                    resolve(response);
+                }
+                else{
+                    reject();
+                }
+            })
+        });
+    },
+    //获取下月投保各状态数量
+    getInsurancePolicyNum(context) {
+        var formData = new FormData();
+
+        return new Promise((resolve,reject)=>{
+            approvalApi.tabCount(formData).then(response=>{
+                var jsonData = response.data;
+        
+                if(jsonData.result){
+                    this.statusListNum = jsonData.data;
+        
+                    let num1 = this.statusListNum[20] + this.statusListNum[50];
+                    let num2 = this.statusListNum[30] + this.statusListNum[60];
+        
+                    context.commit("setMenuBadgeNum",{
+                        sortNo:202,
+                        num: num1
+                    });
+
+                    context.commit("setMenuBadgeNum",{
+                        sortNo:302,
+                        num: num2
+                    });
+
+                    resolve(response);
+                }
+                else{
+                    reject();
+                }
+            })
+        });
+    }
+}
+
+
+export default {
+  namespaced: true, //必填,否则声明都为root,state,mutations,action 一定要对外声明后才能在外部调用
+  state,
+  mutations,
+  actions
+}

+ 4 - 0
src/views/business/insuranceFirst-list.vue

@@ -188,6 +188,7 @@ import approvalApi from "@/api/business/approval";
 
 import NProgress from "nprogress"; // progress bar
 import "nprogress/nprogress.css"; // progress bar style
+import {mapState, mapMutations} from 'vuex';
 
 export default {
   components: {
@@ -229,6 +230,9 @@ export default {
     };
   },
   methods: {
+    ...mapMutations('menu',{
+      setMenuBadgeNum: 'setMenuBadgeNum'
+    }),
     changePage(pageIndex) {
       var self = this;
 

+ 23 - 29
src/views/layout/index.vue

@@ -37,14 +37,16 @@ import MenuTreeItem from "@/components/MenuTreeItem";
 import menuApi from "@/api/sys/menu";
 import userApi from "@/api/sys/user";
 import messageApi from "@/api/base/message";
+import {mapState,mapMutations, mapActions} from 'vuex';
+import insuranceApplicationApi from "@/api/business/insuranceApplication";
+import approvalApi from "@/api/business/approval";
+
 
 export default {
   data() {
     return {
-      menuList: [],
       loading: false,
       user: {},
-      messageNum: 0,
       collapse: false
     };
   },
@@ -58,13 +60,20 @@ export default {
         "icon-icon_left_arrow" : this.collapse,
         "icon-icon_right_arrow" : !this.collapse
       }
-    }
+    },
+    ...mapState('menu', {
+      menuList: state => state.menuList
+    })
   },
-  // created() {
-  //   //获取未读消息数
-  //   this.getUnReadMessageNum();
-  // },
   methods: {
+    ...mapMutations('menu',[
+      'setMenuList'
+    ]),
+    ...mapActions('menu',[
+      'getUnReadMessageNum',
+      'getInsuranceApplicationNum',
+      'getInsurancePolicyNum'
+    ]),
     handleOpen(key, keyPath) {
       console.log(key, keyPath);
     },
@@ -72,33 +81,12 @@ export default {
       console.log(key, keyPath);
     },
     handleSelect(key, keyPath) {
-      //console.log(key, keyPath);
       this.$router.push({ path: key });
     },
     logout() {
       this.$store.dispatch("user/logout").then(() => {
         this.$router.push({ path: "/login" });
       });
-    }, //获取未读消息数
-    getUnReadMessageNum() {
-      messageApi.getMessageCount().then(resp => {
-        if (resp.data.result) {
-          this.messageNum = resp.data.data;
-          this.resetMenu();
-        }
-      });
-    },
-    //定义菜单的未读消息数
-    resetMenu() {
-      //定义菜单的未读消息数
-      var menuList = this.menuList;
-      console.log(menuList);
-      for (var key in menuList) {
-        if (menuList[key]["menuName"] == "我的消息") {
-          menuList[key]["msgNum"] = this.messageNum; //this.messageNum;
-        }
-      }
-      this.menuList = menuList;
     }
   },
   components: {
@@ -121,8 +109,14 @@ export default {
 
         var jsonData = response.data;
 
-        this.menuList = jsonData.data;
+        this.setMenuList(jsonData.data);
+
         this.getUnReadMessageNum();
+        
+        this.getInsuranceApplicationNum();
+
+        this.getInsurancePolicyNum();
+
         this.loading = false;
       })
       .catch(exception => {