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