From 8fb7cc0325027caa4ed7574443e24f5bd7a8efb7 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期一, 02 九月 2024 23:09:45 +0800
Subject: [PATCH] 考核结果图表bug,登录路由权限控制

---
 src/views/system/user/index.vue         |   22 +++++-----
 src/views/login.vue                     |   58 ++++++++++++++++-------------
 src/layout/components/Navbar.vue        |    5 +-
 src/views/system/check/result/index.vue |   27 ++++++-------
 4 files changed, 59 insertions(+), 53 deletions(-)

diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index c3202d4..90c59ec 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -39,7 +39,7 @@
 
     </div>
     <div class="button-container">
-      <el-button type="primary" @click="toScreen" size="small">鍙鍖栧ぇ灞�</el-button>
+      <el-button v-if="roles.includes('admin') || roles.includes('county_leader') || roles.includes('city_leader')" type="primary" @click="toScreen" size="small">鍙鍖栧ぇ灞�</el-button>
     </div>
     <div class="button-container">
       <el-button type="primary" @click="toSystemB" size="small">璺宠浆B绯荤粺</el-button>
@@ -76,7 +76,8 @@
     ...mapGetters([
       'sidebar',
       'avatar',
-      'device'
+      'device',
+      'roles'
     ]),
     setting: {
       get() {
diff --git a/src/views/login.vue b/src/views/login.vue
index 3231e9f..ba59cc7 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -18,28 +18,28 @@
           <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
             <el-form-item prop="username">
               <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="璐﹀彿">
-                <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
+                <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon"/>
               </el-input>
             </el-form-item>
             <el-form-item prop="password">
               <el-input v-model="loginForm.password" type="password" auto-complete="off" placeholder="瀵嗙爜"
-                @keyup.enter.native="handleLogin">
-                <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
+                        @keyup.enter.native="handleLogin">
+                <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon"/>
               </el-input>
             </el-form-item>
             <el-form-item prop="code" v-if="captchaEnabled">
               <el-input v-model="loginForm.code" auto-complete="off" placeholder="楠岃瘉鐮�" style="width: 63%"
-                @keyup.enter.native="handleLogin">
-                <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon" />
+                        @keyup.enter.native="handleLogin">
+                <svg-icon slot="prefix" icon-class="validCode" class="el-input__icon input-icon"/>
               </el-input>
               <div class="login-code">
-                <img :src="codeUrl" @click="getCode" class="login-code-img" />
+                <img :src="codeUrl" @click="getCode" class="login-code-img"/>
               </div>
             </el-form-item>
             <el-checkbox v-model="loginForm.rememberMe" style=" margin:0px 0px 25px 0px;">璁颁綇瀵嗙爜</el-checkbox>
             <el-form-item style="width:100%;">
               <el-button :loading="loading" size="medium" type="primary" style="width:100%;"
-                @click.native.prevent="handleLogin">
+                         @click.native.prevent="handleLogin">
                 <span v-if="!loading">鐧� 褰�</span>
                 <span v-else>鐧� 褰� 涓�...</span>
               </el-button>
@@ -67,10 +67,10 @@
 </template>
 
 <script>
-import { getCodeImg, getInfo } from "@/api/login";
+import {getCodeImg, getInfo} from "@/api/login";
 import Cookies from "js-cookie";
-import { encrypt, decrypt } from '@/utils/jsencrypt'
-import { updateUserPwd } from "@/api/system/user";
+import {encrypt, decrypt} from '@/utils/jsencrypt'
+import {updateUserPwd} from "@/api/system/user";
 
 export default {
   //鏂板瀵硅薄銆佸彉閲�
@@ -87,8 +87,7 @@
       var regex = /(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[\W_])/;
       if (value.length < 8 || value.length > 10) {
         callback(new Error('璇疯緭鍏�8-10浣嶅ぇ鍐欏瓧姣�+灏忓啓瀛楁瘝+鏁板瓧+鐗规畩瀛楃'));
-      }
-      else if (!regex.test(value)) {
+      } else if (!regex.test(value)) {
         callback(new Error("璇疯緭鍏�8-10浣嶅ぇ鍐欏瓧姣�+灏忓啓瀛楁瘝+鏁板瓧+鐗规畩瀛楃"));
       } else {
         callback();
@@ -110,21 +109,21 @@
       confirmPassword: undefined,
       loginRules: {
         username: [
-          { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勮处鍙�" }
+          {required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勮处鍙�"}
         ],
         password: [
-          { required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勫瘑鐮�" }
+          {required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勫瘑鐮�"}
         ],
-        code: [{ required: true, trigger: "change", message: "璇疯緭鍏ラ獙璇佺爜" }]
+        code: [{required: true, trigger: "change", message: "璇疯緭鍏ラ獙璇佺爜"}]
       },
       rules: {
         newPassword: [
-          { required: true, message: "鏂板瘑鐮佷笉鑳戒负绌�", trigger: "blur" },
-          { required: true, validator: validatePassword, trigger: "blur" }
+          {required: true, message: "鏂板瘑鐮佷笉鑳戒负绌�", trigger: "blur"},
+          {required: true, validator: validatePassword, trigger: "blur"}
         ],
         confirmPassword: [
-          { required: true, message: "纭瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" },
-          { required: true, validator: equalToPassword, trigger: "blur" }
+          {required: true, message: "纭瀵嗙爜涓嶈兘涓虹┖", trigger: "blur"},
+          {required: true, validator: equalToPassword, trigger: "blur"}
         ]
       },
       loading: false,
@@ -174,9 +173,9 @@
           this.loading = true;
 
           if (this.loginForm.rememberMe) {
-            Cookies.set("username", this.loginForm.username, { expires: 30 });
-            Cookies.set("password", encrypt(this.loginForm.password), { expires: 30 });
-            Cookies.set('rememberMe', this.loginForm.rememberMe, { expires: 30 });
+            Cookies.set("username", this.loginForm.username, {expires: 30});
+            Cookies.set("password", encrypt(this.loginForm.password), {expires: 30});
+            Cookies.set('rememberMe', this.loginForm.rememberMe, {expires: 30});
           } else {
             Cookies.remove("username");
             Cookies.remove("password");
@@ -190,11 +189,18 @@
               if (this.loginInfo.firstLogin == 1) {
                 // this.$router.push({ path: "/" }).catch(() => { });
                 // return;
-                this.$router.push({ path: this.redirect || "/screen" }).catch(() => { });
+                if (this.loginInfo.roles.includes("admin") || this.loginInfo.roles.includes("city_leader") || this.loginInfo.roles.includes("county_leader")) {
+                  this.$router.push({path: this.redirect || "/screen"}).catch(() => {
+                  });
+                } else {
+                  this.$router.push({path: this.redirect || "/index"}).catch(() => {
+                  });
+                }
               } else {
                 localStorage.setItem('firstLogin', 0)
               }
-            }).catch(() => { })
+            }).catch(() => {
+            })
           }).catch(() => {
             this.loading = false;
             if (this.captchaEnabled) {
@@ -210,7 +216,8 @@
         // 淇敼瀹屾垚灏唂irstLogin鏀逛负1
         localStorage.setItem('firstLogin', 1)
         this.$modal.msgSuccess("淇敼鎴愬姛");
-        this.$router.push({ path: this.redirect || "/" }).catch(() => { });
+        this.$router.push({path: this.redirect || "/"}).catch(() => {
+        });
       }).catch((e) => {
         console.info(e)
       });
@@ -319,7 +326,6 @@
     animation-delay: 0.1s;
   }
 }
-
 
 
 .login-form {
diff --git a/src/views/system/check/result/index.vue b/src/views/system/check/result/index.vue
index 451a168..e261e84 100644
--- a/src/views/system/check/result/index.vue
+++ b/src/views/system/check/result/index.vue
@@ -78,12 +78,6 @@
       activeIndex: '0',
       date: '',
       company: '',
-      dataList: {
-        name: ['瀵岄『鍘�', '鑽e幙', '楂樻柊鍖�', '鑷祦浜曞尯', '璐′簳鍖�', '澶у畨鍖�', '娌挎哗鍖�'],
-        data1: [95, 96, 97, 95, 94.5, 93.6, 94.5],
-        data2: [93.7, 93.5, 94.3, 96.5, 95.3, 94.2, 93.3],
-        data3: [98.3, 94.3, 93.3, 95.5, 96.8, 96.1, 95.8],
-      },
       // 鏌ヨ鍙傛暟
       queryParams: {
         examineTag: null,
@@ -92,13 +86,13 @@
     }
   },
   created() {
+  },
+  mounted() {
     this.queryParams.examineTag = this.activeIndex
     this.getList();
     this.areaSelect();
-  },
-  mounted() {
     chart = echarts.init(this.$refs.barChart);
-    this.initEchart();
+    this.setChartOption(this.checkScoreList);
   },
   methods: {
     jumpDetail(index) {
@@ -238,17 +232,22 @@
       }
       chart.setOption(option, true);
     },
-    filterData(data, tag) {
-      if (!data) return;
-      if(!Array.isArray(data)) return;
+    filterData(mapData, tag) {
+      if (!mapData) return;
+      if(!Array.isArray(mapData)) return;
       const tempArray = [];
-      data.forEach((item) => {
+      mapData.forEach((item) => {
         if(item.data.length) {
+          let flag = false;
           item.data.forEach((examine) => {
             if(examine.examineCategory === tag) {
+              flag = true
               tempArray.push(examine.score);
             }
           })
+          if(!flag){
+            tempArray.push(0);
+          }
         }
       })
       return tempArray;
@@ -314,8 +313,8 @@
       listScore(this.queryParams).then(response => {
         this.checkScoreList = response.data;
         console.log(this.checkScoreList);
-        this.loading = false;
         this.setChartOption(this.checkScoreList);
+        this.loading = false;
       });
     },
     publish(city) {
diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 5e66247..20c91cd 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -268,17 +268,17 @@
         </el-row>
         <el-row>
           <el-col :span="12">
-            <el-form-item label="宀椾綅">
-              <el-select v-model="form.postIds" multiple placeholder="璇烽�夋嫨宀椾綅">
-                <el-option
-                  v-for="item in postOptions"
-                  :key="item.postId"
-                  :label="item.postName"
-                  :value="item.postId"
-                  :disabled="item.status == 1"
-                ></el-option>
-              </el-select>
-            </el-form-item>
+<!--            <el-form-item label="宀椾綅">-->
+<!--              <el-select v-model="form.postIds" multiple placeholder="璇烽�夋嫨宀椾綅">-->
+<!--                <el-option-->
+<!--                  v-for="item in postOptions"-->
+<!--                  :key="item.postId"-->
+<!--                  :label="item.postName"-->
+<!--                  :value="item.postId"-->
+<!--                  :disabled="item.status == 1"-->
+<!--                ></el-option>-->
+<!--              </el-select>-->
+<!--            </el-form-item>-->
           </el-col>
           <el-col :span="12">
             <el-form-item label="瑙掕壊">

--
Gitblit v1.8.0