优化权限

role1.0
fanluyan 1 year ago
parent 3c869485ab
commit 9e2ad20c0b

@ -251,6 +251,8 @@ export default {
if (this.role !== "0") { if (this.role !== "0") {
this.menuList = JSON.parse(localStorage.getItem("menuPermission")); this.menuList = JSON.parse(localStorage.getItem("menuPermission"));
console.log(this.menuList); console.log(this.menuList);
this.menuList.push({ id: 8, key: "/stritl", desc: "首页-菜单" });
this.menuList = this.menuList.sort((a, b) => a.id - b.id);
this.getMenuArr(this.menuList); this.getMenuArr(this.menuList);
} else { } else {
console.log("我是超管"); console.log("我是超管");

@ -82,7 +82,6 @@ export default {
console.log(res.data); console.log(res.data);
this.$store.commit("SET_TOKEN", res.data.token); //tokenvuex this.$store.commit("SET_TOKEN", res.data.token); //tokenvuex
this.$store.commit("SET_USERINFO", res.data); //vuex this.$store.commit("SET_USERINFO", res.data); //vuex
this.$router.push("/stritl"); this.$router.push("/stritl");
this.$message({ this.$message({
duration: 1500, duration: 1500,

@ -8,16 +8,29 @@
@close="hide" @close="hide"
> >
<div class="treeBoxList" v-loading="treeLoading"> <div class="treeBoxList" v-loading="treeLoading">
<div class="menuBox">
<h3>菜单选项</h3>
<el-checkbox-group v-model="checkedMenu"> <el-checkbox-group v-model="checkedMenu">
<el-checkbox <el-checkbox
v-for="item in menuCheckOption" v-for="item in menuCheckOption"
:label="item.id" :label="item.id"
:key="item.id" :key="item.id"
:disabled="item.key == '/stritl'"
>{{ item.desc }}</el-checkbox >{{ item.desc }}</el-checkbox
> >
</el-checkbox-group> </el-checkbox-group>
</div> </div>
<div class="btnBox">
<h3>功能选项</h3>
<el-checkbox-group v-model="checkedBtn">
<el-checkbox
v-for="item in btnCheckOption"
:label="item.id"
:key="item.id"
>{{ item.desc }}</el-checkbox
>
</el-checkbox-group>
</div>
</div>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="isShow = false"> </el-button> <el-button @click="isShow = false"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button> <el-button type="primary" @click="submitForm()"> </el-button>
@ -38,10 +51,13 @@ export default {
isShow: false, isShow: false,
treeLoading: false, treeLoading: false,
rowData: "", rowData: "",
allCheckList: [], //
menuList: [], menuList: [],
checkedMenu: [], //checkbox checkedMenu: [], //checkbox
menuCheckOption: [], //checkbox menuCheckOption: [], //checkbox
checkedIds: [], //id checkedIds: [], //id
checkedBtn: [], //
btnCheckOption: [],
}; };
}, },
methods: { methods: {
@ -56,7 +72,13 @@ export default {
.then((res) => { .then((res) => {
if (res.code == 200) { if (res.code == 200) {
console.log(res); console.log(res);
this.menuCheckOption = res.data; this.allCheckList = res.data;
this.menuCheckOption = res.data.filter((item) =>
item.key.includes("/")
);
this.btnCheckOption = res.data.filter((item) =>
item.key.includes("Btn")
);
this.getRolePermission(); this.getRolePermission();
} else { } else {
this.$message.error(res.msg); this.$message.error(res.msg);
@ -72,12 +94,11 @@ export default {
if (res.code == 200) { if (res.code == 200) {
console.log(res); console.log(res);
this.checkedIds = res.data; this.checkedIds = res.data;
console.log(this.checkedIds); console.log(this.checkedIds);
this.checkedMenu = this.checkedIds.map((obj) => obj.resourceId); this.checkedMenu = this.checkedIds.map((obj) => obj.resourceId);
console.log("我时查询到的选中的值", this.checkedMenu); this.checkedBtn = this.checkedIds.map((obj) => obj.resourceId);
this.checkedMenu.push(this.menuCheckOption[0].id); console.log("我时查询到的选中的值", this.checkedIds);
this.treeLoading = false; this.treeLoading = false;
} else { } else {
this.$message.error(res.msg); this.$message.error(res.msg);
@ -88,10 +109,20 @@ export default {
// //
submitForm() { submitForm() {
console.log(this.checkedMenu); console.log(this.checkedMenu);
console.log(this.checkedBtn);
let paramsList = []; let paramsList = [];
this.checkedMenu.map((id) => { this.checkedMenu.map((id) => {
paramsList.push({ resourceId: id }); paramsList.push({ resourceId: id });
}); });
this.checkedBtn.map((id) => {
paramsList.push({ resourceId: id });
});
paramsList = paramsList.filter((item, index, self) => {
return (
self.findIndex((t) => t.resourceId === item.resourceId) === index
);
});
console.log(paramsList);
// //
getRolechangePermissionApi({ getRolechangePermissionApi({
list: paramsList, list: paramsList,
@ -120,7 +151,9 @@ export default {
}, },
hide() { hide() {
this.isShow = false; this.isShow = false;
this.allCheckList = [];
this.checkedMenu = []; this.checkedMenu = [];
this.checkedBtn = [];
}, },
}, },
mounted() {}, mounted() {},
@ -131,6 +164,16 @@ export default {
.treeBoxList { .treeBoxList {
height: 600px; height: 600px;
overflow: auto; overflow: auto;
display: flex;
justify-content: space-between;
.menuBox,
.btnBox {
h3 {
font-size: 14px;
margin-bottom: 12px;
font-weight: normal;
}
}
.el-checkbox-group { .el-checkbox-group {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

Loading…
Cancel
Save