😎代码优化(字段和接口黑名单相关)
This commit is contained in:
parent
384da76e0d
commit
800225501f
@ -27,6 +27,9 @@ public class SysRoleApiService : ITransient
|
|||||||
{
|
{
|
||||||
await _sysRoleApiRep.DeleteAsync(u => u.RoleId == input.Id);
|
await _sysRoleApiRep.DeleteAsync(u => u.RoleId == input.Id);
|
||||||
|
|
||||||
|
if (input.ApiList == null || input.ApiList.Count < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
var roleApis = input.ApiList.Where(u => !string.IsNullOrWhiteSpace(u)).Select(u => new SysRoleApi
|
var roleApis = input.ApiList.Where(u => !string.IsNullOrWhiteSpace(u)).Select(u => new SysRoleApi
|
||||||
{
|
{
|
||||||
RoleId = input.Id,
|
RoleId = input.Id,
|
||||||
|
|||||||
@ -192,9 +192,6 @@ public class SysRoleService : IDynamicApiController, ITransient
|
|||||||
[DisplayName("授权角色表格")]
|
[DisplayName("授权角色表格")]
|
||||||
public async Task GrantRoleTable(RoleTableInput input)
|
public async Task GrantRoleTable(RoleTableInput input)
|
||||||
{
|
{
|
||||||
if (input.TableColumnList == null || input.TableColumnList.Count < 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
await _sysRoleTableService.GrantRoleTable(input);
|
await _sysRoleTableService.GrantRoleTable(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,9 @@ public class SysRoleTableService : ITransient
|
|||||||
{
|
{
|
||||||
await _sysRoleTableRep.AsDeleteable().Where(u => u.RoleId == input.Id).ExecuteCommandAsync();
|
await _sysRoleTableRep.AsDeleteable().Where(u => u.RoleId == input.Id).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
if (input.TableColumnList == null || input.TableColumnList.Count < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
var sysRoleTableList = new List<SysRoleTable>();
|
var sysRoleTableList = new List<SysRoleTable>();
|
||||||
foreach (var item in input.TableColumnList)
|
foreach (var item in input.TableColumnList)
|
||||||
{
|
{
|
||||||
@ -87,11 +90,11 @@ public class SysRoleTableService : ITransient
|
|||||||
// 排除特定表格
|
// 排除特定表格
|
||||||
var ignoreTables = new List<string>
|
var ignoreTables = new List<string>
|
||||||
{
|
{
|
||||||
"DingTalkUser",
|
//"DingTalkUser",
|
||||||
"ApprovalFlow",
|
//"ApprovalFlow",
|
||||||
"GoViewPro",
|
//"GoViewPro",
|
||||||
"GoViewPro",
|
//"GoViewPro",
|
||||||
"GoViewProData"
|
//"GoViewProData"
|
||||||
};
|
};
|
||||||
// 排除特定字段
|
// 排除特定字段
|
||||||
var ignoreColumns = new List<string>
|
var ignoreColumns = new List<string>
|
||||||
|
|||||||
@ -40,9 +40,8 @@ import NoticeBar from '/@/components/noticeBar/index.vue';
|
|||||||
|
|
||||||
import { getAPI } from '/@/utils/axios-utils';
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
import { SysMenuApi, SysRoleApi } from '/@/api-services/api';
|
import { SysMenuApi, SysRoleApi } from '/@/api-services/api';
|
||||||
import { SysMenu, UpdateRoleInput } from '/@/api-services/models';
|
import { SysMenu } from '/@/api-services/models';
|
||||||
|
|
||||||
const ruleFormRef = ref();
|
|
||||||
const treeRef = ref<InstanceType<typeof ElTree>>();
|
const treeRef = ref<InstanceType<typeof ElTree>>();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -50,7 +49,6 @@ const state = reactive({
|
|||||||
drawerTitle: '',
|
drawerTitle: '',
|
||||||
menuIdList: [] as any,
|
menuIdList: [] as any,
|
||||||
roleId: 0,
|
roleId: 0,
|
||||||
ruleForm: {} as UpdateRoleInput,
|
|
||||||
menuData: [] as Array<SysMenu>, // 菜单数据
|
menuData: [] as Array<SysMenu>, // 菜单数据
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -68,9 +66,7 @@ const openDrawer = async (row: any) => {
|
|||||||
state.drawerTitle = '授权角色菜单【' + row.name + '】';
|
state.drawerTitle = '授权角色菜单【' + row.name + '】';
|
||||||
|
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
ruleFormRef.value?.resetFields();
|
|
||||||
treeRef.value?.setCheckedKeys([]); // 清空选中值
|
treeRef.value?.setCheckedKeys([]); // 清空选中值
|
||||||
state.ruleForm = JSON.parse(JSON.stringify(row));
|
|
||||||
if (row.id != undefined) {
|
if (row.id != undefined) {
|
||||||
var res = await getAPI(SysRoleApi).apiSysRoleOwnMenuListGet(row.id);
|
var res = await getAPI(SysRoleApi).apiSysRoleOwnMenuListGet(row.id);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -98,7 +94,7 @@ const treeNodeClass = (node: SysMenu) => {
|
|||||||
let addClass = true; // 添加叶子节点同行显示样式
|
let addClass = true; // 添加叶子节点同行显示样式
|
||||||
for (var key in node.children) {
|
for (var key in node.children) {
|
||||||
// 如果存在子节点非叶子节点,不添加样式
|
// 如果存在子节点非叶子节点,不添加样式
|
||||||
if (node.children[key].children?.length ?? 0 > 0) {
|
if (node.children[key as any].children?.length ?? 0 > 0) {
|
||||||
addClass = false;
|
addClass = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,17 +40,15 @@ import NoticeBar from '/@/components/noticeBar/index.vue';
|
|||||||
|
|
||||||
import { getAPI } from '/@/utils/axios-utils';
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
import { SysRoleApi } from '/@/api-services/api';
|
import { SysRoleApi } from '/@/api-services/api';
|
||||||
import { RoleTableOutput, UpdateRoleInput } from '/@/api-services/models';
|
import { RoleTableOutput } from '/@/api-services/models';
|
||||||
|
|
||||||
const ruleFormRef = ref();
|
|
||||||
const treeRef = ref<InstanceType<typeof ElTree>>();
|
const treeRef = ref<InstanceType<typeof ElTree>>();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
loading: false,
|
loading: false,
|
||||||
isVisible: false,
|
isVisible: false,
|
||||||
drawerTitle: '',
|
drawerTitle: '',
|
||||||
menuIdList: [] as any,
|
tableColumnList: [] as any,
|
||||||
roleId: 0,
|
roleId: 0,
|
||||||
ruleForm: {} as UpdateRoleInput,
|
|
||||||
roleTableData: [] as Array<RoleTableOutput>, // 表格字段数据
|
roleTableData: [] as Array<RoleTableOutput>, // 表格字段数据
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -68,9 +66,7 @@ const openDrawer = async (row: any) => {
|
|||||||
state.drawerTitle = '设置角色字段黑名单【' + row.name + '】';
|
state.drawerTitle = '设置角色字段黑名单【' + row.name + '】';
|
||||||
|
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
ruleFormRef.value?.resetFields();
|
|
||||||
treeRef.value?.setCheckedKeys([]); // 清空选中值
|
treeRef.value?.setCheckedKeys([]); // 清空选中值
|
||||||
state.ruleForm = JSON.parse(JSON.stringify(row));
|
|
||||||
if (row.id != undefined) {
|
if (row.id != undefined) {
|
||||||
var res = await getAPI(SysRoleApi).apiSysRoleRoleTableRoleIdGet(row.id);
|
var res = await getAPI(SysRoleApi).apiSysRoleRoleTableRoleIdGet(row.id);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -88,8 +84,8 @@ const cancel = () => {
|
|||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
state.menuIdList = treeRef.value?.getCheckedKeys() as Array<number>; //.concat(treeRef.value?.getHalfCheckedKeys());
|
state.tableColumnList = treeRef.value?.getCheckedKeys() as Array<number>; //.concat(treeRef.value?.getHalfCheckedKeys());
|
||||||
await getAPI(SysRoleApi).apiSysRoleGrantRoleTablePost({ id: state.roleId, tableColumnList: state.menuIdList });
|
await getAPI(SysRoleApi).apiSysRoleGrantRoleTablePost({ id: state.roleId, tableColumnList: state.tableColumnList });
|
||||||
cancel();
|
cancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user