ly 3 anni fa
parent
commit
2608d9c7cf
4 ha cambiato i file con 38 aggiunte e 2 eliminazioni
  1. 4 1
      ui/src/App.vue
  2. 6 0
      ui/src/permission.js
  3. 17 0
      ui/src/router/index.js
  4. 11 1
      ui/src/views/ehs/rcaudit/index.vue

+ 4 - 1
ui/src/App.vue

@@ -1,6 +1,9 @@
 <template>
   <div id="app">
-    <router-view />
+    <keep-alive>
+      <router-view v-if="$route.meta.keepAlive"></router-view>
+    </keep-alive>
+    <router-view v-if="!$route.meta.keepAlive"></router-view>
   </div>
 </template>
 

+ 6 - 0
ui/src/permission.js

@@ -11,6 +11,12 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
 
 router.beforeEach((to, from, next) => {
   NProgress.start()
+  if (from.meta.keepAlive) {
+    const $content = document.querySelector('.el-table__body-wrapper');
+    const scrollTop = $content ? $content.scrollTop : 0;
+    console.log(scrollTop)
+    from.meta.scrollTop = scrollTop;
+  }
   if (getToken()) {
     /* has token*/
     if (to.path === '/login') {

+ 17 - 0
ui/src/router/index.js

@@ -96,6 +96,23 @@ export const constantRoutes = [
       }
     ]
   },
+  {
+    path: '/ehs',
+    component: Layout,
+    hidden: true,
+    alwaysShow: true,
+    children: [
+      {
+        path: 'rcaudit',
+        component: (resolve) => require(['@/views/ehs/rcaudit/index'], resolve),
+        name: 'Rcaudit',
+        meta: { title: 'RC审计助手',
+          keepAlive: true,
+          scrollTop: 0,
+        }
+      }
+    ]
+  },
   {
     path: '/job',
     component: Layout,

+ 11 - 1
ui/src/views/ehs/rcaudit/index.vue

@@ -15,6 +15,7 @@
         </div>
         <div class="head-container">
           <el-table
+            ref="menuTable"
             v-loading="loading"
             :data="menuOptions"
             style="margin-bottom: 20px"
@@ -484,6 +485,16 @@
         this.getMenuList();
       }
     },
+    activated() {
+      this.$nextTick(()=> {
+        setTimeout(() => {
+          const scrollTop = this.$route.meta.scrollTop;
+          console.log('++++++++' + scrollTop)
+          this.$refs.menuTable.bodyWrapper.scrollTop = scrollTop
+          console.log('------' + this.$refs.menuTable.bodyWrapper.scrollTop)
+        }, 13)
+      })
+    },
     created() {
       //设置表格高度对应屏幕高度
       this.$nextTick(() => {
@@ -547,7 +558,6 @@
       naFormat(row, column) {
         return this.selectDictLabel(this.naOptions, row.na);
       },
-
       // 取消按钮
       cancel() {
         this.open = false;