|
|
|
@ -1,16 +1,25 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import type { VbenFormProps, VxeGridListeners, VxeGridProps } from '@abp/ui'; |
|
|
|
import type { MenuInfo } from 'ant-design-vue/es/menu/src/interface'; |
|
|
|
|
|
|
|
import type { IdentityRoleDto } from '../../types/roles'; |
|
|
|
|
|
|
|
import { defineAsyncComponent, h } from 'vue'; |
|
|
|
|
|
|
|
import { useAccess } from '@vben/access'; |
|
|
|
import { useVbenModal } from '@vben/common-ui'; |
|
|
|
import { createIconifyIcon } from '@vben/icons'; |
|
|
|
import { $t } from '@vben/locales'; |
|
|
|
|
|
|
|
import { useAbpStore } from '@abp/core'; |
|
|
|
import { PermissionModal } from '@abp/permission'; |
|
|
|
import { useVbenVxeGrid } from '@abp/ui'; |
|
|
|
import { DeleteOutlined, EditOutlined } from '@ant-design/icons-vue'; |
|
|
|
import { Button, Modal, Tag } from 'ant-design-vue'; |
|
|
|
import { |
|
|
|
DeleteOutlined, |
|
|
|
EditOutlined, |
|
|
|
EllipsisOutlined, |
|
|
|
} from '@ant-design/icons-vue'; |
|
|
|
import { Button, Dropdown, Menu, Modal, Tag } from 'ant-design-vue'; |
|
|
|
|
|
|
|
import { deleteApi, getPagedListApi } from '../../api/roles'; |
|
|
|
|
|
|
|
@ -18,8 +27,18 @@ defineOptions({ |
|
|
|
name: 'RoleTable', |
|
|
|
}); |
|
|
|
|
|
|
|
const MenuItem = Menu.Item; |
|
|
|
const MenuOutlined = createIconifyIcon('heroicons-outline:menu-alt-3'); |
|
|
|
const ClaimOutlined = createIconifyIcon('la:id-card-solid'); |
|
|
|
const PermissionsOutlined = createIconifyIcon('icon-park-outline:permissions'); |
|
|
|
const RoleModal = defineAsyncComponent(() => import('./RoleModal.vue')); |
|
|
|
|
|
|
|
const abpStore = useAbpStore(); |
|
|
|
const { hasAccessByCodes } = useAccess(); |
|
|
|
const [RolePermissionModal, permissionModalApi] = useVbenModal({ |
|
|
|
connectedComponent: PermissionModal, |
|
|
|
}); |
|
|
|
|
|
|
|
const formOptions: VbenFormProps = { |
|
|
|
// 默认展开 |
|
|
|
collapsed: false, |
|
|
|
@ -50,7 +69,7 @@ const gridOptions: VxeGridProps<IdentityRoleDto> = { |
|
|
|
fixed: 'right', |
|
|
|
slots: { default: 'action' }, |
|
|
|
title: $t('AbpUi.Actions'), |
|
|
|
width: 180, |
|
|
|
width: 220, |
|
|
|
}, |
|
|
|
], |
|
|
|
exportConfig: {}, |
|
|
|
@ -113,6 +132,22 @@ const handleDelete = (row: IdentityRoleDto) => { |
|
|
|
title: $t('AbpUi.AreYouSure'), |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const handleMenuClick = async (row: IdentityRoleDto, info: MenuInfo) => { |
|
|
|
switch (info.key) { |
|
|
|
case 'permissions': { |
|
|
|
const roles = abpStore.application?.currentUser.roles ?? []; |
|
|
|
permissionModalApi.setData({ |
|
|
|
displayName: row.name, |
|
|
|
providerKey: row.name, |
|
|
|
providerName: 'R', |
|
|
|
readonly: roles.includes(row.name), |
|
|
|
}); |
|
|
|
permissionModalApi.open(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
@ -140,7 +175,7 @@ const handleDelete = (row: IdentityRoleDto) => { |
|
|
|
</template> |
|
|
|
<template #action="{ row }"> |
|
|
|
<div class="flex flex-row"> |
|
|
|
<div class="basis-1/2"> |
|
|
|
<div class="basis-1/3"> |
|
|
|
<Button |
|
|
|
:icon="h(EditOutlined)" |
|
|
|
block |
|
|
|
@ -151,7 +186,7 @@ const handleDelete = (row: IdentityRoleDto) => { |
|
|
|
{{ $t('AbpUi.Edit') }} |
|
|
|
</Button> |
|
|
|
</div> |
|
|
|
<div class="basis-1/2"> |
|
|
|
<div class="basis-1/3"> |
|
|
|
<Button |
|
|
|
:icon="h(DeleteOutlined)" |
|
|
|
block |
|
|
|
@ -163,10 +198,43 @@ const handleDelete = (row: IdentityRoleDto) => { |
|
|
|
{{ $t('AbpUi.Delete') }} |
|
|
|
</Button> |
|
|
|
</div> |
|
|
|
<div class="basis-1/3"> |
|
|
|
<Dropdown> |
|
|
|
<template #overlay> |
|
|
|
<Menu @click="(info) => handleMenuClick(row, info)"> |
|
|
|
<MenuItem |
|
|
|
v-if=" |
|
|
|
hasAccessByCodes(['AbpIdentity.Roles.ManagePermissions']) |
|
|
|
" |
|
|
|
key="permissions" |
|
|
|
:icon="h(PermissionsOutlined)" |
|
|
|
> |
|
|
|
{{ $t('AbpPermissionManagement.Permissions') }} |
|
|
|
</MenuItem> |
|
|
|
<MenuItem |
|
|
|
v-if="hasAccessByCodes(['AbpIdentity.Roles.ManageClaims'])" |
|
|
|
key="claims" |
|
|
|
:icon="h(ClaimOutlined)" |
|
|
|
> |
|
|
|
{{ $t('AbpIdentity.ManageClaim') }} |
|
|
|
</MenuItem> |
|
|
|
<MenuItem |
|
|
|
v-if="hasAccessByCodes(['Platform.Menu.ManageRoles'])" |
|
|
|
key="menus" |
|
|
|
:icon="h(MenuOutlined)" |
|
|
|
> |
|
|
|
{{ $t('AppPlatform.Menu:Manage') }} |
|
|
|
</MenuItem> |
|
|
|
</Menu> |
|
|
|
</template> |
|
|
|
<Button :icon="h(EllipsisOutlined)" type="link" /> |
|
|
|
</Dropdown> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</Grid> |
|
|
|
<RoleEditModal @change="() => query()" /> |
|
|
|
<RolePermissionModal /> |
|
|
|
</template> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
|