Browse Source

首页统计可根据【openInOutStatistics】字段控制,没有权限时默认打开【进出记录】菜单

刘琳琳 1 month ago
parent
commit
c4c9201381
4 changed files with 71 additions and 68 deletions
  1. 2 1
      src/layout/components/Sidebar/SidebarItem.vue
  2. 5 4
      src/router/index.js
  3. 62 61
      src/views/login/index.vue
  4. 2 2
      vue.config.js

+ 2 - 1
src/layout/components/Sidebar/SidebarItem.vue

@@ -130,8 +130,9 @@ export default {
       if (item.path === '/enterprise' && this.enterpriseName) {
         item.children[0].meta.title = this.enterpriseName + '管理'
       }
+      console.log(item.path)
       // 人员进出统计数据是否展示
-      if (!this.openInOutStatistics && item.path === '/personnel_access_statistics') {
+      if (!this.openInOutStatistics && ['/personnel_access_statistics', '/dashboard'].includes(item.path)) {
         return false
       }
       if (item.path === '/exception_model' && this.role == 99) {

+ 5 - 4
src/router/index.js

@@ -43,9 +43,9 @@ export const constantRoutes = [
     hidden: true
   },
   {
-    path: '/',
+    path: '/dashboard',
     component: Layout,
-    redirect: '/index',
+    redirect: '/dashboard/index',
     children: [
       {
         path: 'index',
@@ -150,11 +150,12 @@ export const constantRoutes = [
     ]
   },
   {
-    path: '/pass_records',
+    path: '/',
     component: Layout,
+    redirect: '/pass_records/index',
     children: [
       {
-        path: 'index',
+        path: '/pass_records/index',
         name: 'pass_records',
         component: () => import('@/views/pass_records/index'),
         meta: {

+ 62 - 61
src/views/login/index.vue

@@ -1,19 +1,19 @@
 <template>
   <div class="login-container">
-    <img class="bg" :src="bg" alt="" />
-    <img class="logo" :src="logo" alt="" />
-    <div class="affiche-box" v-if="noticeData.isShow">
+    <img class="bg" :src="bg" alt="">
+    <img class="logo" :src="logo" alt="">
+    <div v-if="noticeData.isShow" class="affiche-box">
       <h4>{{ noticeData.titile }}</h4>
       <p>
         {{ noticeData.content }}
       </p>
       <div class="qrcode">
-        <img :src="noticeData.picture" alt="" />
+        <img :src="noticeData.picture" alt="">
       </div>
     </div>
     <el-form
-      :rules="rules"
       ref="loginForm"
+      :rules="rules"
       :model="loginForm"
       class="login-form"
       auto-complete="on"
@@ -65,117 +65,116 @@
         type="primary"
         style="width: 100%; margin-top: 10px; background: #3d22d7"
         @click.native.prevent="handleLogin"
-        >登录</el-button
-      >
+      >登录</el-button>
     </el-form>
   </div>
 </template>
 
 <script>
-import { validUsername } from "@/utils/validate";
-const path = require("path");
-import { systemNoticeGetNotice } from "@/api/user_manage";
-import { getPicture } from "@/api/user";
+import { validUsername } from '@/utils/validate'
+const path = require('path')
+import { systemNoticeGetNotice } from '@/api/user_manage'
+import { getPicture } from '@/api/user'
 
 export default {
-  name: "Login",
+  name: 'Login',
   data() {
     const validateUsername = (rule, value, callback) => {
       if (!validUsername(value)) {
-        callback(new Error("Please enter the correct user name"));
+        callback(new Error('Please enter the correct user name'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     const validatePassword = (rule, value, callback) => {
       if (value.length < 6) {
-        callback(new Error("The password can not be less than 6 digits"));
+        callback(new Error('The password can not be less than 6 digits'))
       } else {
-        callback();
+        callback()
       }
-    };
+    }
     return {
       loginForm: {
-        username: "",
-        password: "",
+        username: '',
+        password: ''
       },
       rules: {
         password: [
-          { required: true, message: "请输入密码", trigger: "blur" },
+          { required: true, message: '请输入密码', trigger: 'blur' },
           {
             pattern:
               /^(((?=.*\d)(?=.*[a-z])(?=.*[A-Z]))|((?=.*\d)(?=.*[a-z])(?=.*[~!@#$%^&*]))|((?=.*\d)(?=.*[A-Z])(?=.*[~!@#$%^&*]))|((?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*]))|((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~!@#$%^&*]))).{10,32}$/,
             message:
-              "必须大小写字母、数字、特殊字符,4种组合中至少满足3种,且密码长度在10-32位之间。若无法登录,请联系管理员!",
-          },
-        ],
+              '必须大小写字母、数字、特殊字符,4种组合中至少满足3种,且密码长度在10-32位之间。若无法登录,请联系管理员!'
+          }
+        ]
       },
       loading: false,
-      passwordType: "password",
+      passwordType: 'password',
       redirect: undefined,
       // 公告数据
       noticeData: {},
-      title: "防控终端管理平台",
-      bg:'',
-      logo:'',
-    };
+      title: '防控终端管理平台',
+      bg: '',
+      logo: ''
+    }
   },
   watch: {
     $route: {
-      handler: function (route) {
-        this.redirect = route.query && route.query.redirect;
+      handler: function(route) {
+        this.redirect = route.query && route.query.redirect
       },
-      immediate: true,
-    },
+      immediate: true
+    }
   },
   created() {
-    this.getPicture();
-    this.systemNoticeGetNotice();
+    this.getPicture()
+    this.systemNoticeGetNotice()
   },
   methods: {
     // 获取背景
     getPicture() {
       getPicture().then((res) => {
-        console.log(res);
-        this.title = res.data.title;
-        this.bg = res.data.bg;
-        this.logo = res.data.logo;
-        document.title=res.data.title
-        this.changeFavicon(res.data.favicon);
-      });
+        console.log(res)
+        this.title = res.data.title
+        this.bg = res.data.bg
+        this.logo = res.data.logo
+        document.title = res.data.title
+        this.changeFavicon(res.data.favicon)
+      })
     },
     // 更改favicon.icon
     changeFavicon(link) {
-      let $favicon = document.querySelector('link[rel="icon"]');
+      let $favicon = document.querySelector('link[rel="icon"]')
       if ($favicon !== null) {
-        $favicon.href = link;
+        $favicon.href = link
       } else {
-        $favicon = document.createElement("link");
-        $favicon.rel = "icon";
-        $favicon.href = link;
-        document.head.appendChild($favicon);
+        $favicon = document.createElement('link')
+        $favicon.rel = 'icon'
+        $favicon.href = link
+        document.head.appendChild($favicon)
       }
     },
     // 获取公告栏
     systemNoticeGetNotice() {
       systemNoticeGetNotice().then((res) => {
-        this.noticeData = res.data;
-      });
+        this.noticeData = res.data
+      })
     },
     showPwd() {
-      if (this.passwordType === "password") {
-        this.passwordType = "";
+      if (this.passwordType === 'password') {
+        this.passwordType = ''
       } else {
-        this.passwordType = "password";
+        this.passwordType = 'password'
       }
       this.$nextTick(() => {
-        this.$refs.password.focus();
-      });
+        this.$refs.password.focus()
+      })
     },
     handleLogin() {
       this.$refs.loginForm.validate(async(valid) => {
         if (valid) {
-          this.loading = true;
+          this.loading = true
           // this.$store
           //   .dispatch("user/login", this.loginForm)
           //   .then(() => {
@@ -200,16 +199,18 @@ export default {
           try {
             await this.$store.dispatch('user/login', this.loginForm)
             await this.$store.dispatch('user/getInfo')
+            const openInOutStatistics = this.$store.getters.openInOutStatistics
+            const path = openInOutStatistics ? '/dashboard/index' : '/pass_records/index'
             if (this.$store.getters.role === 1) {
-              this.$router.push({ path: '/index' })
+              this.$router.push({ path })
             } else if (this.$store.getters.role === 2) {
-              this.$router.push({ path: '/index' })
+              this.$router.push({ path })
             } else if (this.$store.getters.role === 3) {
-              this.$router.push({ path: '/index' })
+              this.$router.push({ path })
             } else if (this.$store.getters.role === 4) {
-              this.$router.push({ path: '/index' })
+              this.$router.push({ path })
             } else if (this.$store.getters.role === 5) {
-              this.$router.push({ path: '/index' })
+              this.$router.push({ path })
             } else if (this.$store.getters.role === 99) {
               this.$router.push({ path: '/machine_list/index' })
             }

+ 2 - 2
vue.config.js

@@ -36,9 +36,9 @@ module.exports = {
     // },
     proxy: {
       '/yx-fyzd': {
-        // target: 'https://test.hz-hanghui.com:18890' // 测试
+        target: 'https://test.hz-hanghui.com:18890' // 测试
         // target: 'https://tx.hz-hanghui.com:8088' // 线上
-        target: 'http://192.168.77.253:9100' // 本地
+        // target: 'http://192.168.77.253:9100' // 本地
       }
     }
     // 关闭mock