|
|
|
@ -1,25 +1,26 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
import type { VbenFormProps, VxeGridProps } from '@abp/ui'; |
|
|
|
import type { SelectValue } from 'ant-design-vue/es/select'; |
|
|
|
|
|
|
|
import type { OpenIddictApplicationDto } from '../../types'; |
|
|
|
import type { OpenIddictAuthorizationDto } from '../../types/authorizations'; |
|
|
|
|
|
|
|
import { defineAsyncComponent, h } from 'vue'; |
|
|
|
import { defineAsyncComponent, h, onMounted, ref } from 'vue'; |
|
|
|
|
|
|
|
import { useAccess } from '@vben/access'; |
|
|
|
import { useVbenModal } from '@vben/common-ui'; |
|
|
|
import { createIconifyIcon } from '@vben/icons'; |
|
|
|
import { $t } from '@vben/locales'; |
|
|
|
|
|
|
|
import { formatToDateTime } from '@abp/core'; |
|
|
|
import { useVbenVxeGrid } from '@abp/ui'; |
|
|
|
import { |
|
|
|
DeleteOutlined, |
|
|
|
EditOutlined, |
|
|
|
PlusOutlined, |
|
|
|
} from '@ant-design/icons-vue'; |
|
|
|
import { Button, message, Modal } from 'ant-design-vue'; |
|
|
|
import { DeleteOutlined, EditOutlined } from '@ant-design/icons-vue'; |
|
|
|
import { Button, message, Modal, Select } from 'ant-design-vue'; |
|
|
|
import debounce from 'lodash.debounce'; |
|
|
|
|
|
|
|
import { getPagedListApi as getApplications } from '../../api/applications'; |
|
|
|
import { deleteApi, getPagedListApi } from '../../api/authorizations'; |
|
|
|
import { ApplicationsPermissions } from '../../constants/permissions'; |
|
|
|
import { AuthorizationsPermissions } from '../../constants/permissions'; |
|
|
|
|
|
|
|
defineOptions({ |
|
|
|
name: 'AuthorizationTable', |
|
|
|
@ -30,10 +31,55 @@ const CloseIcon = createIconifyIcon('ant-design:close-outlined'); |
|
|
|
|
|
|
|
const { hasAccessByCodes } = useAccess(); |
|
|
|
|
|
|
|
const applications = ref<OpenIddictApplicationDto[]>([]); |
|
|
|
const formOptions: VbenFormProps = { |
|
|
|
// 默认展开 |
|
|
|
collapsed: false, |
|
|
|
collapsed: true, |
|
|
|
collapsedRows: 2, |
|
|
|
// 所有表单项共用,可单独在表单内覆盖 |
|
|
|
commonConfig: { |
|
|
|
// 在label后显示一个冒号 |
|
|
|
colon: true, |
|
|
|
// 所有表单项 |
|
|
|
componentProps: { |
|
|
|
class: 'w-full', |
|
|
|
}, |
|
|
|
}, |
|
|
|
fieldMappingTime: [ |
|
|
|
['creationTime', ['beginCreationTime', 'endCreationTime'], 'YYYY-MM-DD'], |
|
|
|
], |
|
|
|
handleReset: onFormReset, |
|
|
|
schema: [ |
|
|
|
{ |
|
|
|
component: 'Select', |
|
|
|
fieldName: 'clientId', |
|
|
|
formItemClass: 'col-span-1/3 items-baseline', |
|
|
|
label: $t('AbpOpenIddict.DisplayName:ClientId'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
component: 'RangePicker', |
|
|
|
fieldName: 'creationTime', |
|
|
|
formItemClass: 'col-span-2 items-baseline', |
|
|
|
label: $t('AbpOpenIddict.DisplayName:CreationTime'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
component: 'Input', |
|
|
|
fieldName: 'subject', |
|
|
|
formItemClass: 'col-span-1/3 items-baseline', |
|
|
|
label: $t('AbpOpenIddict.DisplayName:Subject'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
component: 'Input', |
|
|
|
fieldName: 'status', |
|
|
|
formItemClass: 'col-span-1/3 items-baseline', |
|
|
|
label: $t('AbpOpenIddict.DisplayName:Status'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
component: 'Input', |
|
|
|
fieldName: 'type', |
|
|
|
formItemClass: 'col-span-1/3 items-baseline', |
|
|
|
label: $t('AbpOpenIddict.DisplayName:Type'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
component: 'Input', |
|
|
|
fieldName: 'filter', |
|
|
|
@ -51,55 +97,43 @@ const gridOptions: VxeGridProps<OpenIddictAuthorizationDto> = { |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
align: 'left', |
|
|
|
field: 'clientId', |
|
|
|
minWidth: 150, |
|
|
|
title: $t('AbpOpenIddict.DisplayName:ClientId'), |
|
|
|
field: 'applicationId', |
|
|
|
minWidth: 300, |
|
|
|
title: $t('AbpOpenIddict.DisplayName:ApplicationId'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
align: 'left', |
|
|
|
field: 'displayName', |
|
|
|
minWidth: 150, |
|
|
|
title: $t('AbpOpenIddict.DisplayName:DisplayName'), |
|
|
|
field: 'subject', |
|
|
|
minWidth: 300, |
|
|
|
title: $t('AbpOpenIddict.DisplayName:Subject'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
align: 'center', |
|
|
|
field: 'consentType', |
|
|
|
title: $t('AbpOpenIddict.DisplayName:ConsentType'), |
|
|
|
width: 200, |
|
|
|
}, |
|
|
|
{ |
|
|
|
align: 'center', |
|
|
|
field: 'clientType', |
|
|
|
title: $t('AbpOpenIddict.DisplayName:ClientType'), |
|
|
|
width: 120, |
|
|
|
}, |
|
|
|
{ |
|
|
|
align: 'center', |
|
|
|
field: 'applicationType', |
|
|
|
title: $t('AbpOpenIddict.DisplayName:ApplicationType'), |
|
|
|
width: 150, |
|
|
|
align: 'left', |
|
|
|
field: 'type', |
|
|
|
minWidth: 150, |
|
|
|
title: $t('AbpOpenIddict.DisplayName:Type'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
align: 'left', |
|
|
|
field: 'clientUri', |
|
|
|
title: $t('AbpOpenIddict.DisplayName:ClientUri'), |
|
|
|
width: 150, |
|
|
|
field: 'status', |
|
|
|
minWidth: 150, |
|
|
|
title: $t('AbpOpenIddict.DisplayName:Status'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
align: 'left', |
|
|
|
field: 'logoUri', |
|
|
|
title: $t('AbpOpenIddict.DisplayName:LogoUri'), |
|
|
|
width: 120, |
|
|
|
field: 'creationDate', |
|
|
|
formatter: ({ cellValue }) => { |
|
|
|
return cellValue ? formatToDateTime(cellValue) : cellValue; |
|
|
|
}, |
|
|
|
minWidth: 200, |
|
|
|
title: $t('AbpOpenIddict.DisplayName:CreationDate'), |
|
|
|
}, |
|
|
|
{ |
|
|
|
field: 'action', |
|
|
|
fixed: 'right', |
|
|
|
slots: { default: 'action' }, |
|
|
|
title: $t('AbpUi.Actions'), |
|
|
|
visible: hasAccessByCodes([ |
|
|
|
ApplicationsPermissions.Update, |
|
|
|
ApplicationsPermissions.Delete, |
|
|
|
]), |
|
|
|
visible: hasAccessByCodes([AuthorizationsPermissions.Delete]), |
|
|
|
width: 220, |
|
|
|
}, |
|
|
|
], |
|
|
|
@ -134,47 +168,65 @@ const [AuthorizationModal, modalApi] = useVbenModal({ |
|
|
|
), |
|
|
|
}); |
|
|
|
|
|
|
|
const [Grid, { query }] = useVbenVxeGrid({ |
|
|
|
const [Grid, gridApi] = useVbenVxeGrid({ |
|
|
|
formOptions, |
|
|
|
gridOptions, |
|
|
|
}); |
|
|
|
|
|
|
|
const onCreate = () => { |
|
|
|
modalApi.setData({}); |
|
|
|
modalApi.open(); |
|
|
|
}; |
|
|
|
const onSearchClient = debounce(async (filter?: string) => { |
|
|
|
const { items } = await getApplications({ |
|
|
|
filter, |
|
|
|
maxResultCount: 25, |
|
|
|
}); |
|
|
|
applications.value = items; |
|
|
|
}, 500); |
|
|
|
|
|
|
|
const onUpdate = (row: OpenIddictAuthorizationDto) => { |
|
|
|
function onChangeClient(value?: SelectValue) { |
|
|
|
gridApi.formApi.setFieldValue('clientId', value); |
|
|
|
} |
|
|
|
|
|
|
|
function onUpdate(row: OpenIddictAuthorizationDto) { |
|
|
|
modalApi.setData(row); |
|
|
|
modalApi.open(); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
const onDelete = (row: OpenIddictAuthorizationDto) => { |
|
|
|
function onDelete(row: OpenIddictAuthorizationDto) { |
|
|
|
Modal.confirm({ |
|
|
|
centered: true, |
|
|
|
content: `${$t('AbpUi.ItemWillBeDeletedMessageWithFormat')}`, |
|
|
|
content: `${$t('AbpUi.ItemWillBeDeletedMessage')}`, |
|
|
|
onOk: () => { |
|
|
|
return deleteApi(row.id).then(() => { |
|
|
|
message.success($t('AbpUi.SuccessfullyDeleted')); |
|
|
|
query(); |
|
|
|
gridApi.query(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
title: $t('AbpUi.AreYouSure'), |
|
|
|
}); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function onFormReset() { |
|
|
|
gridApi.formApi.resetForm(); |
|
|
|
gridApi.formApi.submitForm(); |
|
|
|
} |
|
|
|
onMounted(onSearchClient); |
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
|
<Grid :table-title="$t('AbpOpenIddict.Applications')"> |
|
|
|
<template #toolbar-tools> |
|
|
|
<Button |
|
|
|
:icon="h(PlusOutlined)" |
|
|
|
type="primary" |
|
|
|
v-access:code="[ApplicationsPermissions.Create]" |
|
|
|
@click="onCreate" |
|
|
|
> |
|
|
|
{{ $t('AbpOpenIddict.Applications:AddNew') }} |
|
|
|
</Button> |
|
|
|
<Grid :table-title="$t('AbpOpenIddict.Authorizations')"> |
|
|
|
<template #form-clientId="{ modelValue }"> |
|
|
|
<Select |
|
|
|
:default-active-first-option="false" |
|
|
|
:field-names="{ label: 'clientId', value: 'id' }" |
|
|
|
:filter-option="false" |
|
|
|
:options="applications" |
|
|
|
:placeholder="$t('ui.placeholder.select')" |
|
|
|
:value="modelValue" |
|
|
|
allow-clear |
|
|
|
class="w-full" |
|
|
|
show-search |
|
|
|
@change="onChangeClient" |
|
|
|
@search="onSearchClient" |
|
|
|
/> |
|
|
|
</template> |
|
|
|
<template #required="{ row }"> |
|
|
|
<div class="flex flex-row justify-center"> |
|
|
|
@ -195,7 +247,6 @@ const onDelete = (row: OpenIddictAuthorizationDto) => { |
|
|
|
:icon="h(EditOutlined)" |
|
|
|
block |
|
|
|
type="link" |
|
|
|
v-access:code="[ApplicationsPermissions.Update]" |
|
|
|
@click="onUpdate(row)" |
|
|
|
> |
|
|
|
{{ $t('AbpUi.Edit') }} |
|
|
|
@ -207,7 +258,7 @@ const onDelete = (row: OpenIddictAuthorizationDto) => { |
|
|
|
block |
|
|
|
danger |
|
|
|
type="link" |
|
|
|
v-access:code="[ApplicationsPermissions.Delete]" |
|
|
|
v-access:code="[AuthorizationsPermissions.Delete]" |
|
|
|
@click="onDelete(row)" |
|
|
|
> |
|
|
|
{{ $t('AbpUi.Delete') }} |
|
|
|
@ -216,7 +267,7 @@ const onDelete = (row: OpenIddictAuthorizationDto) => { |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</Grid> |
|
|
|
<AuthorizationModal @change="() => query()" /> |
|
|
|
<AuthorizationModal @change="() => gridApi.query()" /> |
|
|
|
</template> |
|
|
|
|
|
|
|
<style lang="scss" scoped></style> |
|
|
|
|