Переглянути джерело

车间管家调整点击菜单栏页面函数不执行的问题

Lijy 1 рік тому
батько
коміт
e7d13dcd5e

+ 38 - 13
fhKeeper/formulahousekeeper/timesheet-workshop/src/views/product/list.vue

@@ -645,6 +645,10 @@ a {
             },
             filterText2(val) {
                 this.$refs.chooseMembTree2.filter(val);
+            },
+            '$route' (to, from) {
+                // console.log('路由发送了变化')
+                this.mountedEnter()
             }
         },
         updated () {
@@ -654,6 +658,24 @@ a {
             })
         },
         methods: {
+            // 进入页面所执行的函数
+            mountedEnter() {
+                this.cateId =  this.$route.params.cateId;
+                console.log('分类参数', this.cateId);
+                this.getCateName();
+                this.userssHu()
+                this.getDepartment();
+                this.getDepartment2();
+                this.projectListPageComponentKey++;
+                //localStorage中为string类型,需转化为int类型才会发生渲染
+                if (localStorage.productPageIndex) {
+                    this.page = parseInt(localStorage.productPageIndex);
+                }
+                
+                this.getList();
+                this.getUsers();
+            },
+
             defaultExpandAllFlgCli() {
                 this.defaultExpandAllFlg = !this.defaultExpandAllFlg
                 this.list = JSON.parse(JSON.stringify(this.list))
@@ -2759,20 +2781,23 @@ a {
             console.log('activated分类参数', cateId);
         },
         mounted() {
-            this.cateId =  this.$route.params.cateId;
-            console.log('分类参数', this.cateId);
-            this.getCateName();
-            this.userssHu()
-            this.getDepartment();
-            this.getDepartment2();
-            this.projectListPageComponentKey++;
-            //localStorage中为string类型,需转化为int类型才会发生渲染
-            if (localStorage.productPageIndex) {
-                this.page = parseInt(localStorage.productPageIndex);
-            }
+            // this.cateId =  this.$route.params.cateId;
+            // console.log('分类参数', this.cateId);
+            // this.getCateName();
+            // this.userssHu()
+            // this.getDepartment();
+            // this.getDepartment2();
+            // this.projectListPageComponentKey++;
+            // //localStorage中为string类型,需转化为int类型才会发生渲染
+            // if (localStorage.productPageIndex) {
+            //     this.page = parseInt(localStorage.productPageIndex);
+            // }
+            
+            // this.getList();
+            // this.getUsers();
             
-            this.getList();
-            this.getUsers();
+            // 进入页面需要执行的函数和方法全写在 mountedEnter 函数里面
+            this.mountedEnter()
         }
     };
 </script>