|
|
@ -6,13 +6,14 @@ import type { VbenFormProps } from '@vben/common-ui'; |
|
|
import type { FeatureDefinitionDto } from '../../../types/definitions'; |
|
|
import type { FeatureDefinitionDto } from '../../../types/definitions'; |
|
|
import type { FeatureGroupDefinitionDto } from '../../../types/groups'; |
|
|
import type { FeatureGroupDefinitionDto } from '../../../types/groups'; |
|
|
|
|
|
|
|
|
import { defineAsyncComponent, h, onMounted, reactive, ref } from 'vue'; |
|
|
import { defineAsyncComponent, h, onMounted, ref } from 'vue'; |
|
|
|
|
|
|
|
|
import { useVbenModal } from '@vben/common-ui'; |
|
|
import { useVbenModal } from '@vben/common-ui'; |
|
|
import { $t } from '@vben/locales'; |
|
|
import { $t } from '@vben/locales'; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
|
listToTree, |
|
|
listToTree, |
|
|
|
|
|
sortby, |
|
|
useLocalization, |
|
|
useLocalization, |
|
|
useLocalizationSerializer, |
|
|
useLocalizationSerializer, |
|
|
} from '@abp/core'; |
|
|
} from '@abp/core'; |
|
|
@ -35,8 +36,8 @@ defineOptions({ |
|
|
name: 'FeatureDefinitionTable', |
|
|
name: 'FeatureDefinitionTable', |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
interface PermissionVo { |
|
|
interface FeatureVo { |
|
|
children: PermissionVo[]; |
|
|
children: FeatureVo[]; |
|
|
displayName: string; |
|
|
displayName: string; |
|
|
groupName: string; |
|
|
groupName: string; |
|
|
isEnabled: boolean; |
|
|
isEnabled: boolean; |
|
|
@ -46,30 +47,24 @@ interface PermissionVo { |
|
|
providers: string[]; |
|
|
providers: string[]; |
|
|
stateCheckers: string[]; |
|
|
stateCheckers: string[]; |
|
|
} |
|
|
} |
|
|
interface PermissionGroupVo { |
|
|
interface FeatureGroupVo { |
|
|
displayName: string; |
|
|
displayName: string; |
|
|
|
|
|
features: FeatureVo[]; |
|
|
name: string; |
|
|
name: string; |
|
|
permissions: PermissionVo[]; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const permissionGroups = ref<PermissionGroupVo[]>([]); |
|
|
const featureGroups = ref<FeatureGroupVo[]>([]); |
|
|
const pageState = reactive({ |
|
|
|
|
|
current: 1, |
|
|
|
|
|
size: 10, |
|
|
|
|
|
total: 0, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const { Lr } = useLocalization(); |
|
|
const { Lr } = useLocalization(); |
|
|
const { deserialize } = useLocalizationSerializer(); |
|
|
const { deserialize } = useLocalizationSerializer(); |
|
|
const { getListApi: getGroupsApi } = useFeatureGroupDefinitionsApi(); |
|
|
const { getListApi: getGroupsApi } = useFeatureGroupDefinitionsApi(); |
|
|
const { deleteApi, getListApi: getPermissionsApi } = useFeatureDefinitionsApi(); |
|
|
const { deleteApi, getListApi: getFeaturesApi } = useFeatureDefinitionsApi(); |
|
|
|
|
|
|
|
|
const formOptions: VbenFormProps = { |
|
|
const formOptions: VbenFormProps = { |
|
|
// 默认展开 |
|
|
// 默认展开 |
|
|
collapsed: false, |
|
|
collapsed: false, |
|
|
handleReset: onReset, |
|
|
handleReset: onReset, |
|
|
async handleSubmit(params) { |
|
|
async handleSubmit(params) { |
|
|
pageState.current = 1; |
|
|
|
|
|
await onGet(params); |
|
|
await onGet(params); |
|
|
}, |
|
|
}, |
|
|
schema: [ |
|
|
schema: [ |
|
|
@ -104,12 +99,14 @@ const gridOptions: VxeGridProps<FeatureGroupDefinitionDto> = { |
|
|
align: 'left', |
|
|
align: 'left', |
|
|
field: 'name', |
|
|
field: 'name', |
|
|
minWidth: 150, |
|
|
minWidth: 150, |
|
|
|
|
|
sortable: true, |
|
|
title: $t('AbpFeatureManagement.DisplayName:Name'), |
|
|
title: $t('AbpFeatureManagement.DisplayName:Name'), |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
align: 'left', |
|
|
align: 'left', |
|
|
field: 'displayName', |
|
|
field: 'displayName', |
|
|
minWidth: 150, |
|
|
minWidth: 150, |
|
|
|
|
|
sortable: true, |
|
|
title: $t('AbpFeatureManagement.DisplayName:DisplayName'), |
|
|
title: $t('AbpFeatureManagement.DisplayName:DisplayName'), |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
@ -119,6 +116,30 @@ const gridOptions: VxeGridProps<FeatureGroupDefinitionDto> = { |
|
|
}, |
|
|
}, |
|
|
exportConfig: {}, |
|
|
exportConfig: {}, |
|
|
keepSource: true, |
|
|
keepSource: true, |
|
|
|
|
|
proxyConfig: { |
|
|
|
|
|
ajax: { |
|
|
|
|
|
query: async ({ page, sort }) => { |
|
|
|
|
|
let items = sortby(featureGroups.value, sort.field); |
|
|
|
|
|
if (sort.order === 'desc') { |
|
|
|
|
|
items = items.reverse(); |
|
|
|
|
|
} |
|
|
|
|
|
const result = { |
|
|
|
|
|
totalCount: featureGroups.value.length, |
|
|
|
|
|
items: items.slice( |
|
|
|
|
|
(page.currentPage - 1) * page.pageSize, |
|
|
|
|
|
page.currentPage * page.pageSize, |
|
|
|
|
|
), |
|
|
|
|
|
}; |
|
|
|
|
|
return new Promise((resolve) => { |
|
|
|
|
|
resolve(result); |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
response: { |
|
|
|
|
|
total: 'totalCount', |
|
|
|
|
|
list: 'items', |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
toolbarConfig: { |
|
|
toolbarConfig: { |
|
|
custom: true, |
|
|
custom: true, |
|
|
export: true, |
|
|
export: true, |
|
|
@ -136,6 +157,7 @@ const subGridColumns: VxeGridProps<FeatureDefinitionDto>['columns'] = [ |
|
|
align: 'left', |
|
|
align: 'left', |
|
|
field: 'name', |
|
|
field: 'name', |
|
|
minWidth: 150, |
|
|
minWidth: 150, |
|
|
|
|
|
sortable: true, |
|
|
title: $t('AbpFeatureManagement.DisplayName:Name'), |
|
|
title: $t('AbpFeatureManagement.DisplayName:Name'), |
|
|
treeNode: true, |
|
|
treeNode: true, |
|
|
}, |
|
|
}, |
|
|
@ -143,12 +165,14 @@ const subGridColumns: VxeGridProps<FeatureDefinitionDto>['columns'] = [ |
|
|
align: 'left', |
|
|
align: 'left', |
|
|
field: 'displayName', |
|
|
field: 'displayName', |
|
|
minWidth: 120, |
|
|
minWidth: 120, |
|
|
|
|
|
sortable: true, |
|
|
title: $t('AbpFeatureManagement.DisplayName:DisplayName'), |
|
|
title: $t('AbpFeatureManagement.DisplayName:DisplayName'), |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
align: 'left', |
|
|
align: 'left', |
|
|
field: 'description', |
|
|
field: 'description', |
|
|
minWidth: 120, |
|
|
minWidth: 120, |
|
|
|
|
|
sortable: true, |
|
|
title: $t('AbpFeatureManagement.DisplayName:Description'), |
|
|
title: $t('AbpFeatureManagement.DisplayName:Description'), |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -156,6 +180,7 @@ const subGridColumns: VxeGridProps<FeatureDefinitionDto>['columns'] = [ |
|
|
field: 'isVisibleToClients', |
|
|
field: 'isVisibleToClients', |
|
|
minWidth: 120, |
|
|
minWidth: 120, |
|
|
slots: { default: 'isVisibleToClients' }, |
|
|
slots: { default: 'isVisibleToClients' }, |
|
|
|
|
|
sortable: true, |
|
|
title: $t('AbpFeatureManagement.DisplayName:IsVisibleToClients'), |
|
|
title: $t('AbpFeatureManagement.DisplayName:IsVisibleToClients'), |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -163,6 +188,7 @@ const subGridColumns: VxeGridProps<FeatureDefinitionDto>['columns'] = [ |
|
|
field: 'isAvailableToHost', |
|
|
field: 'isAvailableToHost', |
|
|
minWidth: 120, |
|
|
minWidth: 120, |
|
|
slots: { default: 'isAvailableToHost' }, |
|
|
slots: { default: 'isAvailableToHost' }, |
|
|
|
|
|
sortable: true, |
|
|
title: $t('AbpFeatureManagement.DisplayName:IsAvailableToHost'), |
|
|
title: $t('AbpFeatureManagement.DisplayName:IsAvailableToHost'), |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
@ -175,10 +201,8 @@ const subGridColumns: VxeGridProps<FeatureDefinitionDto>['columns'] = [ |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
const gridEvents: VxeGridListeners<FeatureGroupDefinitionDto> = { |
|
|
const gridEvents: VxeGridListeners<FeatureGroupDefinitionDto> = { |
|
|
pageChange(params) { |
|
|
sortChange: () => { |
|
|
pageState.current = params.currentPage; |
|
|
gridApi.query(); |
|
|
pageState.size = params.pageSize; |
|
|
|
|
|
onPageChange(); |
|
|
|
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@ -198,17 +222,16 @@ async function onGet(input?: Record<string, string>) { |
|
|
try { |
|
|
try { |
|
|
gridApi.setLoading(true); |
|
|
gridApi.setLoading(true); |
|
|
const groupRes = await getGroupsApi(input); |
|
|
const groupRes = await getGroupsApi(input); |
|
|
const permissionRes = await getPermissionsApi(input); |
|
|
const featureRes = await getFeaturesApi(input); |
|
|
pageState.total = groupRes.items.length; |
|
|
featureGroups.value = groupRes.items.map((group) => { |
|
|
permissionGroups.value = groupRes.items.map((group) => { |
|
|
|
|
|
const localizableGroup = deserialize(group.displayName); |
|
|
const localizableGroup = deserialize(group.displayName); |
|
|
const permissions = permissionRes.items |
|
|
const features = featureRes.items |
|
|
.filter((permission) => permission.groupName === group.name) |
|
|
.filter((feature) => feature.groupName === group.name) |
|
|
.map((permission) => { |
|
|
.map((feature) => { |
|
|
const displayName = deserialize(permission.displayName); |
|
|
const displayName = deserialize(feature.displayName); |
|
|
const description = deserialize(permission.displayName); |
|
|
const description = deserialize(feature.displayName); |
|
|
return { |
|
|
return { |
|
|
...permission, |
|
|
...feature, |
|
|
description: Lr(description.resourceName, description.name), |
|
|
description: Lr(description.resourceName, description.name), |
|
|
displayName: Lr(displayName.resourceName, displayName.name), |
|
|
displayName: Lr(displayName.resourceName, displayName.name), |
|
|
}; |
|
|
}; |
|
|
@ -216,13 +239,13 @@ async function onGet(input?: Record<string, string>) { |
|
|
return { |
|
|
return { |
|
|
...group, |
|
|
...group, |
|
|
displayName: Lr(localizableGroup.resourceName, localizableGroup.name), |
|
|
displayName: Lr(localizableGroup.resourceName, localizableGroup.name), |
|
|
permissions: listToTree(permissions, { |
|
|
features: listToTree(features, { |
|
|
id: 'name', |
|
|
id: 'name', |
|
|
pid: 'parentName', |
|
|
pid: 'parentName', |
|
|
}), |
|
|
}), |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
onPageChange(); |
|
|
setTimeout(() => gridApi.reload(), 100); |
|
|
} finally { |
|
|
} finally { |
|
|
gridApi.setLoading(false); |
|
|
gridApi.setLoading(false); |
|
|
} |
|
|
} |
|
|
@ -234,21 +257,6 @@ async function onReset() { |
|
|
await onGet(input); |
|
|
await onGet(input); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function onPageChange() { |
|
|
|
|
|
const items = permissionGroups.value.slice( |
|
|
|
|
|
(pageState.current - 1) * pageState.size, |
|
|
|
|
|
pageState.current * pageState.size, |
|
|
|
|
|
); |
|
|
|
|
|
gridApi.setGridOptions({ |
|
|
|
|
|
data: items, |
|
|
|
|
|
pagerConfig: { |
|
|
|
|
|
currentPage: pageState.current, |
|
|
|
|
|
pageSize: pageState.size, |
|
|
|
|
|
total: pageState.total, |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onCreate() { |
|
|
function onCreate() { |
|
|
modalApi.setData({}); |
|
|
modalApi.setData({}); |
|
|
modalApi.open(); |
|
|
modalApi.open(); |
|
|
@ -290,7 +298,7 @@ onMounted(onGet); |
|
|
<template #group="{ row: group }"> |
|
|
<template #group="{ row: group }"> |
|
|
<VxeGrid |
|
|
<VxeGrid |
|
|
:columns="subGridColumns" |
|
|
:columns="subGridColumns" |
|
|
:data="group.permissions" |
|
|
:data="group.features" |
|
|
:tree-config="{ |
|
|
:tree-config="{ |
|
|
trigger: 'row', |
|
|
trigger: 'row', |
|
|
rowField: 'name', |
|
|
rowField: 'name', |
|
|
|