修复权限bug

dev_2022-05-11
yujialong 3 years ago
parent 6aa514738b
commit 5f6e0307d8
  1. 7
      src/layouts/header/index.vue
  2. 1
      src/pages/account/login/index.vue
  3. 2
      src/pages/achievement/list/index.vue
  4. 10
      src/pages/system/list/role.vue
  5. 14
      src/pages/system/list/staff.vue
  6. 12
      src/pages/system/list/stafftree.vue
  7. 48
      src/router/index.js

@ -16,7 +16,6 @@
</template> </template>
<script> <script>
import { mapState, mapActions } from "vuex"; import { mapState, mapActions } from "vuex";
import util from "@/libs/util";
export default { export default {
data() { data() {
@ -37,18 +36,18 @@ export default {
...mapActions("user", [ ...mapActions("user", [
"setTitle", "setLogoUrl", "setAvatar", "setUserName" "setTitle", "setLogoUrl", "setAvatar", "setUserName"
]), ]),
loginout() { loginout() { // 退
this.$router.push('/login'); this.$router.push('/login');
localStorage.clear(); localStorage.clear();
sessionStorage.clear() sessionStorage.clear()
location.reload(); location.reload();
}, },
toPersonal() { toPersonal() { // ()
if (!this.customer) { if (!this.customer) {
this.$router.push("/setting/person"); this.$router.push("/setting/person");
} }
}, },
getSystemDetail () { getSystemDetail () { // logo
this.$get(this.api.logoDetail).then(res => { this.$get(this.api.logoDetail).then(res => {
if (res.status === 200) { if (res.status === 200) {
if (res.data) { if (res.data) {

@ -74,6 +74,7 @@ export default {
code: "", // code: "", //
random: "", // random: "", //
distinguish: 1, // ,1,2 distinguish: 1, // ,1,2
type: 0, // 0-> 1-> 2->
platform: Setting.platformId platform: Setting.platformId
}, },
loginRules: { loginRules: {

@ -76,7 +76,7 @@
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button v-if="auth('练习成绩管理') || auth('考核成绩管理')" type="text" @click="entry(scope.row)">成绩管理</el-button> <el-button v-if="auth('练习成绩管理') || auth('考核成绩管理')" type="text" @click="entry(scope.row)">成绩管理</el-button>
<el-button v-if="auth('删除')" type="text" :disabled="scope.row.isDel" @click="handleDelete(scope.row)" >删除</el-button> <el-button v-if="auth('删除')" type="text" :disabled="scope.row.isDel !== 0" @click="handleDelete(scope.row)" >删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>

@ -8,8 +8,8 @@
</li> </li>
</ul> </ul>
<div> <div>
<el-button type="primary" round @click="addRole">新增角色</el-button> <el-button v-if="auth('角色权限-新增角色')" type="primary" round @click="addRole">新增角色</el-button>
<el-button type="primary" round @click="delAllSelection">批量删除</el-button> <el-button v-if="auth('角色权限-批量删除')" type="primary" round @click="delAllSelection">批量删除</el-button>
</div> </div>
</div> </div>
@ -24,9 +24,9 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="showRole(scope.row)">查看</el-button> <el-button v-if="auth('角色权限-查看')" type="text" @click="showRole(scope.row)">查看</el-button>
<el-button type="text" @click="editRole(scope.row)">编辑</el-button> <el-button v-if="auth('角色权限-编辑')" type="text" @click="editRole(scope.row)">编辑</el-button>
<el-button type="text" @click="handleDelete(scope.row)">删除</el-button> <el-button v-if="auth('角色权限-删除')" type="text" @click="handleDelete(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>

@ -13,9 +13,9 @@
</li> </li>
</ul> </ul>
<div> <div>
<el-button type="primary" round @click="addTeacher">新增员工</el-button> <el-button v-if="auth('员工管理-新增员工')" type="primary" round @click="addTeacher">新增员工</el-button>
<el-button type="primary" round @click="batchImport">批量导入</el-button> <el-button v-if="auth('员工管理-批量导入')" type="primary" round @click="batchImport">批量导入</el-button>
<el-button type="primary" round @click="delAllSelection">批量删除</el-button> <el-button v-if="auth('员工管理-批量删除')" type="primary" round @click="delAllSelection">批量删除</el-button>
</div> </div>
</div> </div>
@ -30,10 +30,10 @@
<el-table-column prop="lastLoginTime" label="上次登录时间" align="center"></el-table-column> <el-table-column prop="lastLoginTime" label="上次登录时间" align="center"></el-table-column>
<el-table-column label="操作" width="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" @click="showTeacher(scope.row)">查看</el-button> <el-button v-if="auth('员工管理-员工查看')" type="text" @click="showTeacher(scope.row)">查看</el-button>
<el-button type="text" @click="editTeacher(scope.row)">编辑</el-button> <el-button v-if="auth('员工管理-员工编辑')" type="text" @click="editTeacher(scope.row)">编辑</el-button>
<el-button type="text" @click="resetPassword(scope.row)">重置密码</el-button> <el-button v-if="auth('员工管理-重置密码')" type="text" @click="resetPassword(scope.row)">重置密码</el-button>
<el-button type="text" @click="delTeacher(scope.row)">删除</el-button> <el-button v-if="auth('员工管理-员工删除')" type="text" @click="delTeacher(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>

@ -1,7 +1,7 @@
<template> <template>
<div class="side_view"> <div class="side_view">
<p class="side_icon mab20"> <p class="side_icon mab20">
<i class="icon-jiahao mar20" @click="addMajor"></i> <i v-if="auth('员工管理-新增专业')" class="icon-jiahao mar20" @click="addMajor"></i>
</p> </p>
<div class="side_tree" v-for="(item,index) in data" :key="index"> <div class="side_tree" v-for="(item,index) in data" :key="index">
<div class="item" @click.stop="open(item,1)"> <div class="item" @click.stop="open(item,1)">
@ -14,13 +14,13 @@
<i v-else class="empty"></i> <i v-else class="empty"></i>
<i :class="item.ischeck ? 'icon-yigouxuan' : 'icon-weigouxuan'" @click.stop="fircheckitem(item)"></i> <i :class="item.ischeck ? 'icon-yigouxuan' : 'icon-weigouxuan'" @click.stop="fircheckitem(item)"></i>
<span>{{ item.label }}</span> <span>{{ item.label }}</span>
<svg t="1604370117041" class="icon edit ft" @click.stop="editMajor(item)" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9029" width="16" height="16"> <svg v-if="auth('员工管理-编辑专业')" t="1604370117041" class="icon edit ft" @click.stop="editMajor(item)" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9029" width="16" height="16">
<path <path
d="M511.979 30.125c-266.13 0-481.871 215.741-481.871 481.871s215.741 481.871 481.871 481.871S993.85 778.126 993.85 511.996 778.109 30.125 511.979 30.125zM459.644 693.015c-15.876 18.135-22.818 22.486-44.972 30.657-34.111 12.787-96.687 36.27-137.374 51.515-7.706 3.056-36.735 1.495-24.578-27.036 13.784-39.757 34.045-98.414 45.636-131.894 8.436-23.615 11.758-29.76 28.73-45.603l175.271-175.271 124.055 124.088C626.413 519.471 508.469 642.264 459.644 693.015zM653.084 492.867 528.996 368.779l26.605-26.605 124.088 124.121L653.084 492.867zM759.469 386.482l-53.176 53.209L582.205 315.569l53.209-53.176c19.596-19.596 51.316-19.596 70.912 0l53.209 53.176C779.065 335.166 779.065 366.919 759.469 386.482z" d="M511.979 30.125c-266.13 0-481.871 215.741-481.871 481.871s215.741 481.871 481.871 481.871S993.85 778.126 993.85 511.996 778.109 30.125 511.979 30.125zM459.644 693.015c-15.876 18.135-22.818 22.486-44.972 30.657-34.111 12.787-96.687 36.27-137.374 51.515-7.706 3.056-36.735 1.495-24.578-27.036 13.784-39.757 34.045-98.414 45.636-131.894 8.436-23.615 11.758-29.76 28.73-45.603l175.271-175.271 124.055 124.088C626.413 519.471 508.469 642.264 459.644 693.015zM653.084 492.867 528.996 368.779l26.605-26.605 124.088 124.121L653.084 492.867zM759.469 386.482l-53.176 53.209L582.205 315.569l53.209-53.176c19.596-19.596 51.316-19.596 70.912 0l53.209 53.176C779.065 335.166 779.065 366.919 759.469 386.482z"
p-id="9030" fill="#9076ff"></path> p-id="9030" fill="#9076ff"></path>
</svg> </svg>
<i class="el-icon-circle-plus ft fz" @click.stop="addDepartment(item)"></i> <i v-if="auth('员工管理-新增部门')" class="el-icon-circle-plus ft fz" @click.stop="addDepartment(item)"></i>
<i class="icon-delete ft" @click.stop="delMajor(item,index)"></i> <i v-if="auth('员工管理-删除专业')" class="icon-delete ft" @click.stop="delMajor(item,index)"></i>
</div> </div>
<div v-show="item.ifVisible" v-if="item.children&&item.children.length!=0"> <div v-show="item.ifVisible" v-if="item.children&&item.children.length!=0">
@ -28,12 +28,12 @@
<div class="item2" @click.stop="open(item1,2)"> <div class="item2" @click.stop="open(item1,2)">
<i :class="item1.ischeck ? 'icon-yigouxuan' : 'icon-weigouxuan'" @click.stop="twocheckitem(item1)"></i> <i :class="item1.ischeck ? 'icon-yigouxuan' : 'icon-weigouxuan'" @click.stop="twocheckitem(item1)"></i>
<span>{{ item1.label }}</span> <span>{{ item1.label }}</span>
<svg t="1604370117041" class="icon edit ft" @click.stop="editDepartment(item1)" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9029" width="16" height="16"> <svg v-if="auth('员工管理-编辑部门')" t="1604370117041" class="icon edit ft" @click.stop="editDepartment(item1)" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9029" width="16" height="16">
<path <path
d="M511.979 30.125c-266.13 0-481.871 215.741-481.871 481.871s215.741 481.871 481.871 481.871S993.85 778.126 993.85 511.996 778.109 30.125 511.979 30.125zM459.644 693.015c-15.876 18.135-22.818 22.486-44.972 30.657-34.111 12.787-96.687 36.27-137.374 51.515-7.706 3.056-36.735 1.495-24.578-27.036 13.784-39.757 34.045-98.414 45.636-131.894 8.436-23.615 11.758-29.76 28.73-45.603l175.271-175.271 124.055 124.088C626.413 519.471 508.469 642.264 459.644 693.015zM653.084 492.867 528.996 368.779l26.605-26.605 124.088 124.121L653.084 492.867zM759.469 386.482l-53.176 53.209L582.205 315.569l53.209-53.176c19.596-19.596 51.316-19.596 70.912 0l53.209 53.176C779.065 335.166 779.065 366.919 759.469 386.482z" d="M511.979 30.125c-266.13 0-481.871 215.741-481.871 481.871s215.741 481.871 481.871 481.871S993.85 778.126 993.85 511.996 778.109 30.125 511.979 30.125zM459.644 693.015c-15.876 18.135-22.818 22.486-44.972 30.657-34.111 12.787-96.687 36.27-137.374 51.515-7.706 3.056-36.735 1.495-24.578-27.036 13.784-39.757 34.045-98.414 45.636-131.894 8.436-23.615 11.758-29.76 28.73-45.603l175.271-175.271 124.055 124.088C626.413 519.471 508.469 642.264 459.644 693.015zM653.084 492.867 528.996 368.779l26.605-26.605 124.088 124.121L653.084 492.867zM759.469 386.482l-53.176 53.209L582.205 315.569l53.209-53.176c19.596-19.596 51.316-19.596 70.912 0l53.209 53.176C779.065 335.166 779.065 366.919 759.469 386.482z"
p-id="9030" fill="#9076ff"></path> p-id="9030" fill="#9076ff"></path>
</svg> </svg>
<i class="icon-delete ft" @click.stop="delDepartment(item1,index1)"></i> <i v-if="auth('员工管理-删除部门')" class="icon-delete ft" @click.stop="delDepartment(item1,index1)"></i>
</div> </div>
</div> </div>
</div> </div>

@ -16,7 +16,6 @@ const createRouter = () => new Router({
routes routes
}); });
console.log(routes);
export function resetRouter() { export function resetRouter() {
const newRouter = createRouter(); const newRouter = createRouter();
router.matcher = newRouter.matcher; router.matcher = newRouter.matcher;
@ -57,7 +56,7 @@ function getPermission() {
// 取得路由的值,使用addRouter添加进路由里 // 取得路由的值,使用addRouter添加进路由里
// 该项目的路由实际上做了两层处理,一层指向了默认的路由,对应模块,用于基础布局的nav,下面一层才是实际上的路由跳转, // 该项目的路由实际上做了两层处理,一层指向了默认的路由,对应模块,用于基础布局的nav,下面一层才是实际上的路由跳转,
// 所以需要默认进行赋值,实际操作时根据path去禁用掉对应的nav即可。 // 所以需要默认进行赋值,实际操作时根据path去禁用掉对应的nav即可。
const arr = ["student", "evaluation", "assessment", "achievement", "course", "information", "match", "project", "system"]; const arr = ['achievement','assessment','course',"evaluation",'information','match','project','setting','student','system'];
let permissionRouters = []; // 最后处理好的路由数组 let permissionRouters = []; // 最后处理好的路由数组
let data = res.permissionMenu[0].children; let data = res.permissionMenu[0].children;
@ -66,7 +65,6 @@ function getPermission() {
// 第一级路由,需要根据匹配到的path,塞进对应的路由children里 // 第一级路由,需要根据匹配到的path,塞进对应的路由children里
let str = e.path.split("/")[1]; let str = e.path.split("/")[1];
let index = arr.indexOf(str); let index = arr.indexOf(str);
console.log(index);
if (index !== -1) { if (index !== -1) {
let obj = { let obj = {
path: e.path, path: e.path,
@ -81,8 +79,6 @@ function getPermission() {
if (e.children && e.children.length > 0) { if (e.children && e.children.length > 0) {
e.children.forEach(i => { e.children.forEach(i => {
// 避免重复生成路由 // 避免重复生成路由
console.log(i.path);
console.log(permissionRouters[index]);
if (i.path && permissionRouters[index] && !permissionRouters[index].children.some(e => i.path === e.path)) { if (i.path && permissionRouters[index] && !permissionRouters[index].children.some(e => i.path === e.path)) {
// console.log(i.path,'当前二级路由的路径') // console.log(i.path,'当前二级路由的路径')
let obj = { let obj = {
@ -158,10 +154,50 @@ function getPermission() {
} else { } else {
meta.push(i.name+"-"+j.name); meta.push(i.name+"-"+j.name);
} }
if (j.children && j.children.length) {
j.children.forEach(k => {
if (k.path && permissionRouters[index] && !permissionRouters[index].children.some(e => k.path === e.path)) {
// console.log(j.path,'当前四级路由的路径')
let obj = {
path: k.path,
name: arr[index] + "-" + k.path.split("/").pop(),
component: () => import(`@/pages${k.path}`),
meta: { title: k.name, btn: [] },
children: []
};
// 没找到第一级就生成一个
if (!permissionRouters.some(e => e.path === `/${str}`)) {
let one = {
path: "/" + arr[index],
name: arr[index],
redirect: {
name: `${arr[index]}-list`
},
component: BasicLayout,
children: []// 传来的路由实际上传入对应的children中
};
one.children.push(obj);
permissionRouters.push(one);
} else {
// 找到第一级,判断没有重复地址直接塞进去
let nowIndex = permissionRouters.findIndex(e => {
return e.path === `/${str}`;
});
if (nowIndex != -1 && permissionRouters[nowIndex] && !permissionRouters[nowIndex].children.some(e => e.path === obj.path)) {
permissionRouters[nowIndex].children.push(obj);
}
}
// permissionRouters.push(obj) // path是页面,要塞入上一级同级里,需要单独push进去生成路由
meta.push(j.name+"-"+k.name);
} else {
meta.push(j.name+"-"+k.name);
}
})
}
}) })
} }
}); });
} }
obj.meta.btn = meta; obj.meta.btn = meta;
obj.children = children; obj.children = children;

Loading…
Cancel
Save