|
|
@@ -41,10 +41,10 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="cen—bottom">
|
|
|
- <router-link :to="{ path: '/home/doc/personal' }" class="one">
|
|
|
- <p>个人文档</p>
|
|
|
- <img src="../../assets/img/MMB1.png" alt="" />
|
|
|
- </router-link>
|
|
|
+ <div class="one" @click="checkRouteAndNavigate('/home/doc/personal')" style="cursor: pointer;">
|
|
|
+ <p>个人文档</p>
|
|
|
+ <img src="../../assets/img/MMB1.png" alt="" />
|
|
|
+ </div>
|
|
|
<router-link :to="{ path: '/home/doc/dept' }" class="two">
|
|
|
<p>部门文档</p>
|
|
|
<img src="../../assets/img/MMB2.png" alt="" />
|
|
|
@@ -201,7 +201,7 @@
|
|
|
|
|
|
<script>
|
|
|
import Cookies from "js-cookie";
|
|
|
-
|
|
|
+ import store from "@/store";
|
|
|
import "@/styles1/element-ui1.scss";
|
|
|
|
|
|
import {
|
|
|
@@ -282,6 +282,45 @@
|
|
|
// this.loginForm.username = sessionStorage.getItem("name");
|
|
|
},
|
|
|
methods: {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查权限并导航到指定路由
|
|
|
+ * @param {string} routePath - 目标路由路径
|
|
|
+ */
|
|
|
+ checkRouteAndNavigate(routePath) {
|
|
|
+ if (this.checkRouteAccess(routePath)) {
|
|
|
+ this.$router.push(routePath);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查路由访问权限
|
|
|
+ * @param {string} routePath - 要检查的路由路径
|
|
|
+ */
|
|
|
+ checkRouteAccess(routePath) {
|
|
|
+ // 获取用户角色
|
|
|
+ const userRoles = store.getters.roles;
|
|
|
+
|
|
|
+ // 定义角色对应的路由权限(根据你的实际业务调整)
|
|
|
+ const rolePermissions = {
|
|
|
+ admin: ['/home/doc/personal', '/home/doc/dept', '/home/doc/public', '/home/setting/ocr'],
|
|
|
+ user: ['/home/doc/personal'],
|
|
|
+ deptManager: ['/home/doc/personal', '/home/doc/dept']
|
|
|
+ };
|
|
|
+
|
|
|
+ // 检查当前用户的角色是否有访问该路由的权限
|
|
|
+ const hasPermission = userRoles.some(role => {
|
|
|
+ const permissions = rolePermissions[role] || [];
|
|
|
+ return permissions.includes(routePath);
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!hasPermission) {
|
|
|
+ this.$modal.msgWarning('您没有访问该功能的权限');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ },
|
|
|
//通知内容更多
|
|
|
leftMores() {
|
|
|
this.$router.push("/home/page/leftmores");
|