Commit 787cc9ef authored by 黄奎's avatar 黄奎

页面修改

parent 572637df
......@@ -46,7 +46,7 @@
persistent: true,
objOption: {
Id: 0, //主键编号
MenuId: 0, //菜单编号
Menu_Id: 0, //菜单编号
FunctionName: "", //权限名称
FunctionCode: "", //权限编号
Remarks: "", //权限备注
......@@ -67,7 +67,7 @@
Id: this.saveObj.Id
}).then(res => {
this.objOption.Id = res.Data.Id;
this.objOption.MenuId = res.Data.MenuId;
this.objOption.Menu_Id = res.Data.Menu_Id;
this.objOption.FunctionName = res.Data.FunctionName;
this.objOption.FunctionCode = res.Data.FunctionCode;
this.objOption.Remarks = res.Data.Remarks;
......@@ -77,7 +77,7 @@
} else {
this.optionTitle = "新增菜单功能权限"
this.objOption.Id = 0;
this.objOption.MenuId = 0;
this.objOption.Menu_Id = 0;
this.objOption.FunctionName = "";
this.objOption.FunctionCode = "";
this.objOption.Remarks = "";
......
......@@ -16,6 +16,33 @@
title="注意:关闭后,角色将无法正常使用." />
</div>
</div>
<div class="text-caption q-mb-lg q-px-md text-grey-6">权限设置</div>
<q-card>
<template v-for="(item,index) in AuthMenuList">
<q-checkbox v-model="item.IsChecked" :false-value="item.IsChecked" :label="item.MenuName"
@input="menuChange(item)" />
</template>
<div class="row wrap">
<template v-if="SubMenuList&&SubMenuList.length>0" v-for="(subItem,subIndex) in SubMenuList">
<q-card class="my-card" flat style="width:200px;border:1px solid red;float:left;">
<q-card-section>
<div class="text-h6">
<q-checkbox v-model="subItem.IsChecked" :false-value="subItem.IsChecked"
:label="subItem.MenuName" />
</div>
<template v-if="subItem.SubList&&subItem.SubList.length>0"
v-for="(chiildItem,index) in subItem.SubList">
<span style="display:inline-block">
&nbsp;&nbsp;
<q-checkbox v-model="chiildItem.IsChecked" :false-value="chiildItem.IsChecked"
:label="chiildItem.MenuName" />
</span>
</template>
</q-card-section>
</q-card>
</template>
</div>
</q-card>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white">
......@@ -31,6 +58,7 @@
import {
queryRoleInfo,
saveRoleInfo,
GetRolePermission
} from '../../api/system/index'
import selectTree from '../common/select-tree'
export default {
......@@ -54,17 +82,37 @@
},
returnString: [],
optionTitle: "",
//菜单列表
TreeMenuList: [],
saveLoading: false,
//选中的节点
checkMenuArray: [],
AuthMenuList: [], //权限列表
SubMenuList: [], //下级菜单权限
group: [],
}
},
computed: {
},
mounted() {
this.initObj()
this.initObj();
this.queryRolePermission();
},
methods: {
//菜单切换
menuChange(item) {
this.SubMenuList = [];
this.SubMenuList = item.SubList;
},
//获取权限
queryRolePermission() {
var qMsg = {
Role_Id: this.objOption.RoleId
};
GetRolePermission(qMsg).then(res => {
console.log("res", res.Data)
if (res.Code == 1) {
this.AuthMenuList = res.Data;
}
}).catch(() => {})
},
//初始化表单
initObj() {
this.returnString = [];
......@@ -94,7 +142,19 @@
},
//保存菜单
saveRole() {
this.saveLoading = true
this.saveLoading = true;
var tempArray = [];
if (this.AuthMenuList && this.AuthMenuList.length > 0) {
this.AuthMenuList.forEach(item => {
if (item.IsChecked) {
tempArray.push({
});
}
})
}
console.log()
saveRoleInfo(this.objOption).then(res => {
this.saveLoading = false
this.$q.notify({
......
......@@ -34,9 +34,6 @@
<q-td :props="props">
<q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="编辑"
@click="EditRole(props.row)" />
<q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="设置权限"
@click="gotoSub(props.row)" />
</q-td>
</template>
</q-table>
......@@ -137,12 +134,6 @@
this.getRolelist()
},
methods: {
gotoSub(obj) {
var tempStr = '/system/setroleauth?roleId=' + obj.RoleId;
this.$router.push({
path: tempStr
});
},
//重新查询
resetSearch() {
this.msg.pageIndex = 1;
......
<style scoped>
.commonTable {
width: 100%;
border-collapse: collapse;
}
.commonTable tr th {
background: #E6E6E6;
height: 40px;
font-size: 14px;
color: #333;
border: 1px solid #E6E6E6
}
.commonTable tr {
background: #fff;
text-align: center;
height: 40px;
}
.commonTable tr:nth-child(2n+1) {
background: #fafafa;
}
.commonTable tr td {
font-size: 12px;
border: 1px solid #E5E5E5;
}
</style>
<template>
<div class="page-body">
<div class="page-search row items-center">
<div class="col row wrap q-mr-lg q-col-gutter-md">
</div>
<div class="page-option">
<q-btn color="accent" class="q-mr-md" icon="add" label="保存权限" @click="saveRolePermission" />
</div>
</div>
<div class="page-content">
<span>菜单权限</span>
<table class="commonTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
<tr>
<th style="width:200px;">一级菜单</th>
<th style="width:200px;">二级菜单</th>
<th>三级菜单</th>
</tr>
<template v-for="(item,index) in MenuList">
<template v-for="(subItem,subIndex) in item.SubList">
<tr :key="index+'1'+subIndex">
<td v-if="subIndex==0" :rowspan="item.SubList.length">
<el-checkbox v-model="item.IsChecked" :key="index" @change="ChangeItem(item)">{{item.MenuName}}
</el-checkbox>
</td>
<td style="text-align:left;padding-left:5px;">
<el-checkbox v-model="subItem.IsChecked" :key="subIndex"
@change="ChangeItem(subItem);SetParent(subItem,0)">
{{subItem.MenuName}}</el-checkbox>
</td>
<td style="text-align:left;padding-left:5px;">
<template v-for="(childItem,childIndex) in subItem.SubList">
<el-checkbox v-model="childItem.IsChecked" :key="childIndex"
@change="SetParent(childItem,subItem.ParentId)">
{{childItem.MenuName}}</el-checkbox>
</template>
</td>
</tr>
</template>
</template>
</table>
<span>功能权限</span>
<table class="commonTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
<tr>
<th style="width:200px;">一级分类</th>
<th>功能名称</th>
</tr>
<template v-for="(item,index) in ActionList">
<template v-for="(subItem,subIndex) in item.SubList">
<tr :key="index+'1'+subIndex">
<td v-if="subIndex==0" :rowspan="item.SubList.length">
<el-checkbox v-model="item.IsChecked" :key="index" @change="ChangeItem(item)">{{item.CategoryName}}
</el-checkbox>
</td>
<td style="text-align:left;padding-left:5px;">
<el-checkbox v-model="subItem.IsChecked" :key="subIndex"
@change="ChangeItem(subItem);SetParent(subItem,0)">
{{subItem.ActionName}}</el-checkbox>
</td>
</tr>
</template>
</template>
</table>
</div>
</div>
</template>
<script>
import {
GetRolePermission,
SetRolePermission
} from '../../api/system/index'
export default {
meta: {
title: "设置角色权限"
},
components: {
},
data() {
return {
currentUrl: "",
loading: false,
roleId: 0, //角色编号
MenuList: [], //菜单权限
ActionList: [], //功能权限
}
},
mounted() {
this.currentUrl = this.$route.path
if (this.$route.query.roleId) {
this.roleId = this.$route.query.roleId
}
this.queryRolePermission();
},
methods: {
//设置选中
ChangeItem(item) {
if (item.SubList && item.SubList.length > 0) {
item.SubList.forEach(subItem => {
subItem.IsChecked = item.IsChecked;
if (subItem.SubList && subItem.SubList.length > 0) {
subItem.SubList.forEach(childItem => {
childItem.IsChecked = item.IsChecked;
})
}
})
}
},
//设置父项选中
SetParent(pItem, pValue) {
this.MenuList.forEach(item => {
if (item.MenuId == pItem.ParentId && pItem.IsChecked) {
item.IsChecked = pItem.IsChecked
}
if (pValue > 0 && item.MenuId == pValue && pItem.IsChecked) {
item.IsChecked = pItem.IsChecked
}
if (item.SubList && item.SubList.length > 0) {
item.SubList.forEach(subItem => {
if (subItem.MenuId == pItem.ParentId && pItem.IsChecked) {
subItem.IsChecked = pItem.IsChecked
}
if (subItem.SubList && subItem.SubList.length > 0) {
subItem.SubList.forEach(childItem => {
if (childItem.MenuId == pItem.ParentId && pItem.IsChecked) {
childItem.IsChecked = pItem.IsChecked
}
});
}
})
}
})
},
//获取权限
queryRolePermission() {
var qMsg = {
Role_Id: this.roleId
};
GetRolePermission(qMsg).then(res => {
if (res.Code == 1) {
this.MenuList = res.Data.menuList;
this.ActionList = res.Data.functionList;
}
}).catch(() => {
})
},
//保存角色权限
saveRolePermission() {
var tempMenu = [];
var tempAction = [];
if (this.MenuList && this.MenuList.length > 0) {
this.MenuList.forEach(item => {
if (item.IsChecked) {
tempMenu.push({
ID: 0,
Role_Id: this.roleId,
Menu_Id: item.MenuId
});
}
if (item.SubList && item.SubList.length > 0) {
item.SubList.forEach(subItem => {
if (subItem.IsChecked) {
tempMenu.push({
ID: 0,
Role_Id: this.roleId,
Menu_Id: subItem.MenuId
});
}
if (subItem.SubList && subItem.SubList.length > 0) {
subItem.SubList.forEach(childItem => {
if (childItem.IsChecked) {
tempMenu.push({
ID: 0,
Role_Id: this.roleId,
Menu_Id: subItem.MenuId
});
}
});
}
})
}
})
}
if (this.ActionList && this.ActionList.length > 0) {
this.ActionList.forEach(item => {
if (item.SubList && item.SubList.length > 0) {
item.SubList.forEach(subItem => {
if (subItem.IsChecked) {
tempAction.push({
ID: 0,
Role_Id: this.roleId,
Action_Id: item.Action_Id,
ActionName: item.ActionName
});
}
})
}
})
}
var data = {
roleMenu: tempMenu,
roleFunction:tempAction
};
console.log("data",data);
SetRolePermission(data).then(res => {
if (res.Code == 1) {
this
this.queryRolePermission();
}
});
}
}
}
</script>
<style lang="sass">
@import url('~assets/css/table.sass');
</style>
......@@ -77,11 +77,6 @@ const routes = [{
component: () =>
import("pages/system/role.vue")
},
{
path: "/system/setroleauth", //设置角色权限
component: () =>
import("pages/system/setroleauth.vue")
},
{
path: "/course/catagory", //课程分类
component: () =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment