优化权限

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

@ -251,6 +251,8 @@ export default {
if (this.role !== "0") {
this.menuList = JSON.parse(localStorage.getItem("menuPermission"));
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);
} else {
console.log("我是超管");

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

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

Loading…
Cancel
Save