Ver Fonte

Merge branch 'Inspection' into online

wolyshaw há 4 anos atrás
pai
commit
52a2258a9a
4 ficheiros alterados com 54 adições e 43 exclusões
  1. 16 0
      src/App.vue
  2. 33 1
      src/store/modules/app.js
  3. 1 0
      src/store/modules/permission.js
  4. 4 42
      src/views/main/index.vue

+ 16 - 0
src/App.vue

@@ -337,3 +337,19 @@ input[type="number"] {
   opacity: 1;
 }
 </style>
+<style lang="less">
+.main-dot {
+  position: relative;
+  &::after{
+    content: '';
+    display: block;
+    position: absolute;
+    height: 8px;
+    width: 8px;
+    background-color: #F56C6C;
+    border-radius: 50%;
+    right: -10px;
+    top: 15px;
+  }
+}
+</style>

+ 33 - 1
src/store/modules/app.js

@@ -1,11 +1,18 @@
+/* eslint-disable no-empty */
 import Cookies from 'js-cookie'
+import { hasIndexErrData } from '@/views/main/api'
+import { permission } from '@/utils/directivePage'
 
 const state = {
   sidebar: {
     opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
     withoutAnimation: false
   },
-  device: 'desktop'
+  device: 'desktop',
+  dotStatus: {
+    indexErrData: false,
+    remindMatterData: false,
+  },
 }
 
 const mutations = {
@@ -26,6 +33,23 @@ const mutations = {
   },
   TOGGLE_DEVICE: (state, device) => {
     state.device = device
+  },
+  COMMIT_DOT_STATUS: (state, status) => {
+    toggleDot(status)
+    state.status = status
+  }
+}
+
+const toggleDot = status => {
+  const { indexErrData, remindMatterData } = status
+  const dotStatus =  indexErrData || remindMatterData
+  const el = document.querySelector('.menu-wrapper a[href="#/main/main"] span')
+  if (el) {
+    if (dotStatus) {
+      el.classList.add('main-dot')
+    } else {
+      el.classList.remove('main-dot')
+    }
   }
 }
 
@@ -38,6 +62,14 @@ const actions = {
   },
   toggleDevice ({ commit }, device) {
     commit('TOGGLE_DEVICE', device)
+  },
+  async setDotStatus({ commit }) {
+    if (permission('hasIndexErrData')) {
+      try {
+        const res = await hasIndexErrData()
+        commit('COMMIT_DOT_STATUS', res.data)
+      } catch (error) {}
+    }
   }
 }
 

+ 1 - 0
src/store/modules/permission.js

@@ -121,6 +121,7 @@ const actions = {
           window.localStorage.removeItem('permission')
           window.localStorage.setItem('permission', tempArr)
           resolve(accessedRoutes)
+          this.dispatch('app/setDotStatus')
         }
       })
     })

+ 4 - 42
src/views/main/index.vue

@@ -32,7 +32,6 @@ import abnormal from './abnormal'
 import teamSchedule from './teamSchedule'
 import ScheduleBranch from './schedule-branch'
 import reminders from './reminders'
-import { hasIndexErrData } from './api'
 export default {
   name: 'Main',
   components: {
@@ -45,50 +44,29 @@ export default {
   data() {
     return {
       activeKey: '',
-      status: {
-        indexErrData: false,
-        remindMatterData: false,
-      }
     }
   },
   computed: {
     hasError() {
       const { indexErrData, remindMatterData } = this.status
       return indexErrData || remindMatterData
+    },
+    status() {
+      return this.$store.state.app.status
     }
   },
   watch: {
     '$route.query'(newValue, oldValue) {
       if (newValue.tabrouter !== oldValue.tabrouter) {
         this.$forceUpdate()
-        this.FetchDot()
+        this.$store.dispatch('app/setDotStatus')
       }
     }
   },
-  mounted() {
-    this.FetchDot()
-  },
   methods: {
     changeKey(val) {
       this.activeKey = val
     },
-    async FetchDot() {
-      try {
-        const res = await hasIndexErrData()
-        this.status = res.data
-        this.toggleDot()
-      } catch (error) {}
-    },
-    toggleDot() {
-      const el = document.querySelector('.menu-wrapper a[href="#/main/main"] span')
-      if (el) {
-        if (this.hasError) {
-          el.classList.add('main-dot')
-        } else {
-          el.classList.remove('main-dot')
-        }
-      }
-    },
     __init () {
       getIndex().then(res => {
         if (res.code == 200) {
@@ -166,19 +144,3 @@ export default {
   }
 }
 </style>
-<style lang="less">
-.main-dot {
-  position: relative;
-  &::after{
-    content: '';
-    display: block;
-    position: absolute;
-    height: 8px;
-    width: 8px;
-    background-color: #F56C6C;
-    border-radius: 50%;
-    right: -10px;
-    top: 15px;
-  }
-}
-</style>