diff --git a/apps/vben5/apps/app-antd/src/api/core/abp.ts b/apps/vben5/apps/app-antd/src/api/core/abp.ts deleted file mode 100644 index e5fba68f5..000000000 --- a/apps/vben5/apps/app-antd/src/api/core/abp.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { - ApplicationConfigurationDto, - ApplicationLocalizationDto, -} from '@abp/core'; - -import { requestClient } from '@abp/request'; - -/** - * 获取应用程序配置信息 - */ -export function getConfigApi(options?: { - includeLocalizationResources?: boolean; -}): Promise { - return requestClient.get( - '/api/abp/application-configuration', - { - params: options, - }, - ); -} - -/** - * 获取应用程序语言 - * @returns 本地化配置 - */ -export function getLocalizationApi(options: { - cultureName: string; - onlyDynamics?: boolean; -}): Promise { - return requestClient.get( - '/api/abp/application-localization', - { - params: options, - }, - ); -} diff --git a/apps/vben5/apps/app-antd/src/api/core/index.ts b/apps/vben5/apps/app-antd/src/api/core/index.ts index 5fe53ee1e..93c65bd62 100644 --- a/apps/vben5/apps/app-antd/src/api/core/index.ts +++ b/apps/vben5/apps/app-antd/src/api/core/index.ts @@ -1,2 +1,2 @@ -export * from './abp'; export * from './menu'; +export { useAbpConfigApi } from './useAbpConfigApi'; diff --git a/apps/vben5/apps/app-antd/src/api/core/useAbpConfigApi.ts b/apps/vben5/apps/app-antd/src/api/core/useAbpConfigApi.ts new file mode 100644 index 000000000..39715ab18 --- /dev/null +++ b/apps/vben5/apps/app-antd/src/api/core/useAbpConfigApi.ts @@ -0,0 +1,48 @@ +import type { + ApplicationConfigurationDto, + ApplicationLocalizationDto, +} from '@abp/core'; + +import { useRequest } from '@abp/request'; + +export function useAbpConfigApi() { + const { cancel, request } = useRequest(); + + /** + * 获取应用程序配置信息 + */ + function getConfigApi(options?: { + includeLocalizationResources?: boolean; + }): Promise { + return request( + '/api/abp/application-configuration', + { + params: options, + method: 'GET', + }, + ); + } + + /** + * 获取应用程序语言 + * @returns 本地化配置 + */ + function getLocalizationApi(options: { + cultureName: string; + onlyDynamics?: boolean; + }): Promise { + return request( + '/api/abp/application-localization', + { + params: options, + method: 'GET', + }, + ); + } + + return { + cancel, + getConfigApi, + getLocalizationApi, + }; +} diff --git a/apps/vben5/apps/app-antd/src/store/auth.ts b/apps/vben5/apps/app-antd/src/store/auth.ts index 6ff7c5e47..1953c88f0 100644 --- a/apps/vben5/apps/app-antd/src/store/auth.ts +++ b/apps/vben5/apps/app-antd/src/store/auth.ts @@ -11,12 +11,13 @@ import { useAbpStore } from '@abp/core'; import { notification } from 'ant-design-vue'; import { defineStore } from 'pinia'; -import { getConfigApi } from '#/api/core/abp'; +import { useAbpConfigApi } from '#/api/core/useAbpConfigApi'; import { $t } from '#/locales'; export const useAuthStore = defineStore('auth', () => { const { loginApi } = useTokenApi(); const { getUserInfoApi } = useUserInfoApi(); + const { getConfigApi } = useAbpConfigApi(); const accessStore = useAccessStore(); const userStore = useUserStore(); const abpStore = useAbpStore(); diff --git a/apps/vben5/packages/@abp/auditing/src/api/audit-logs.ts b/apps/vben5/packages/@abp/auditing/src/api/audit-logs.ts deleted file mode 100644 index d400b91a1..000000000 --- a/apps/vben5/packages/@abp/auditing/src/api/audit-logs.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { PagedResultDto } from '@abp/core'; - -import type { AuditLogDto, AuditLogGetListInput } from '../types/audit-logs'; - -import { requestClient } from '@abp/request'; - -/** - * 获取审计日志 - * @param id 日志id - */ -export function getApi(id: string): Promise { - return requestClient.get(`/api/auditing/audit-log/${id}`); -} - -/** - * 获取审计日志分页列表 - * @param input 参数 - */ -export function getPagedListApi( - input: AuditLogGetListInput, -): Promise> { - return requestClient.get>( - '/api/auditing/audit-log', - { - params: input, - }, - ); -} - -/** - * 删除审计日志 - * @param id 日志id - */ -export function deleteApi(id: string): Promise { - return requestClient.delete(`/api/auditing/audit-log/${id}`); -} diff --git a/apps/vben5/packages/@abp/auditing/src/api/entity-changes.ts b/apps/vben5/packages/@abp/auditing/src/api/entity-changes.ts deleted file mode 100644 index b80499d61..000000000 --- a/apps/vben5/packages/@abp/auditing/src/api/entity-changes.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { ListResultDto } from '@abp/core'; - -import type { - EntityChangeGetWithUsernameInput, - EntityChangeWithUsernameDto, -} from '../types/entity-changes'; - -import { requestClient } from '@abp/request'; - -/** - * 获取包含用户名称的实体变更列表 - * @param input 参数 - */ -export function getListWithUsernameApi( - input: EntityChangeGetWithUsernameInput, -): Promise> { - return requestClient.get>( - '/api/auditing/entity-changes/with-username', - { - params: input, - }, - ); -} diff --git a/apps/vben5/packages/@abp/auditing/src/api/index.ts b/apps/vben5/packages/@abp/auditing/src/api/index.ts index 8b3cb8830..8613244d7 100644 --- a/apps/vben5/packages/@abp/auditing/src/api/index.ts +++ b/apps/vben5/packages/@abp/auditing/src/api/index.ts @@ -1,2 +1,2 @@ -export * as auditLogsApi from './audit-logs'; -export * as entityChangesApi from './entity-changes'; +export { useAuditLogsApi } from './useAuditLogsApi'; +export { useEntityChangesApi } from './useEntityChangesApi'; diff --git a/apps/vben5/packages/@abp/auditing/src/api/useAuditLogsApi.ts b/apps/vben5/packages/@abp/auditing/src/api/useAuditLogsApi.ts new file mode 100644 index 000000000..fb63f8429 --- /dev/null +++ b/apps/vben5/packages/@abp/auditing/src/api/useAuditLogsApi.ts @@ -0,0 +1,65 @@ +import type { PagedResultDto } from '@abp/core'; + +import type { + AuditLogDeleteManyInput, + AuditLogDto, + AuditLogGetListInput, +} from '../types/audit-logs'; + +import { useRequest } from '@abp/request'; + +export function useAuditLogsApi() { + const { cancel, request } = useRequest(); + + /** + * 获取审计日志 + * @param id 日志id + */ + function getApi(id: string): Promise { + return request(`/api/auditing/audit-log/${id}`, { + method: 'GET', + }); + } + + /** + * 获取审计日志分页列表 + * @param input 参数 + */ + function getPagedListApi( + input: AuditLogGetListInput, + ): Promise> { + return request>('/api/auditing/audit-log', { + method: 'GET', + params: input, + }); + } + + /** + * 删除审计日志 + * @param id 日志id + */ + function deleteApi(id: string): Promise { + return request(`/api/auditing/audit-log/${id}`, { + method: 'DELETE', + }); + } + + /** + * 批量删除审计日志 + * @param input 参数 + */ + function deleteManyApi(input: AuditLogDeleteManyInput): Promise { + return request(`/api/auditing/audit-log/bulk`, { + data: input, + method: 'DELETE', + }); + } + + return { + cancel, + deleteApi, + deleteManyApi, + getApi, + getPagedListApi, + }; +} diff --git a/apps/vben5/packages/@abp/auditing/src/api/useEntityChangesApi.ts b/apps/vben5/packages/@abp/auditing/src/api/useEntityChangesApi.ts new file mode 100644 index 000000000..0ca12d55a --- /dev/null +++ b/apps/vben5/packages/@abp/auditing/src/api/useEntityChangesApi.ts @@ -0,0 +1,33 @@ +import type { ListResultDto } from '@abp/core'; + +import type { + EntityChangeGetWithUsernameInput, + EntityChangeWithUsernameDto, +} from '../types/entity-changes'; + +import { useRequest } from '@abp/request'; + +export function useEntityChangesApi() { + const { cancel, request } = useRequest(); + + /** + * 获取包含用户名称的实体变更列表 + * @param input 参数 + */ + function getListWithUsernameApi( + input: EntityChangeGetWithUsernameInput, + ): Promise> { + return request>( + '/api/auditing/entity-changes/with-username', + { + method: 'GET', + params: input, + }, + ); + } + + return { + cancel, + getListWithUsernameApi, + }; +} diff --git a/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogDrawer.vue b/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogDrawer.vue index 80f441f92..95f0b7162 100644 --- a/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogDrawer.vue +++ b/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogDrawer.vue @@ -12,7 +12,7 @@ import { formatToDateTime } from '@abp/core'; import { CodeEditor, MODE, useVbenVxeGrid } from '@abp/ui'; import { Descriptions, Tabs, Tag } from 'ant-design-vue'; -import { getApi } from '../../api/audit-logs'; +import { useAuditLogsApi } from '../../api/useAuditLogsApi'; import { useAuditlogs } from '../../hooks/useAuditlogs'; import EntityChangeTable from '../entity-changes/EntityChangeTable.vue'; @@ -26,13 +26,16 @@ const DescriptionsItem = Descriptions.Item; const activedTab = ref('basic'); const auditLogModel = ref({} as AuditLogDto); +const { getApi } = useAuditLogsApi(); const { getHttpMethodColor, getHttpStatusCodeColor } = useAuditlogs(); const [Drawer, drawerApi] = useVbenDrawer({ class: 'w-auto', onCancel() { drawerApi.close(); }, - onConfirm: async () => {}, + onConfirm: async () => { + drawerApi.close(); + }, onOpenChange: async (isOpen: boolean) => { if (isOpen) { try { diff --git a/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue b/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue index 451b900e6..5c2e29ad6 100644 --- a/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue +++ b/apps/vben5/packages/@abp/auditing/src/components/audit-logs/AuditLogTable.vue @@ -4,7 +4,7 @@ import type { VbenFormProps, VxeGridListeners, VxeGridProps } from '@abp/ui'; import type { AuditLogDto } from '../../types/audit-logs'; -import { defineAsyncComponent, h } from 'vue'; +import { defineAsyncComponent, h, ref, toValue } from 'vue'; import { useVbenDrawer } from '@vben/common-ui'; import { $t } from '@vben/locales'; @@ -14,7 +14,7 @@ import { useVbenVxeGrid } from '@abp/ui'; import { DeleteOutlined, EditOutlined } from '@ant-design/icons-vue'; import { Button, message, Modal, Tag } from 'ant-design-vue'; -import { deleteApi, getPagedListApi } from '../../api/audit-logs'; +import { useAuditLogsApi } from '../../api/useAuditLogsApi'; import { AuditLogPermissions } from '../../constants/permissions'; import { useAuditlogs } from '../../hooks/useAuditlogs'; import { httpMethodOptions, httpStatusCodeOptions } from './mapping'; @@ -22,7 +22,9 @@ import { httpMethodOptions, httpStatusCodeOptions } from './mapping'; defineOptions({ name: 'AuditLogTable', }); +const { deleteApi, deleteManyApi, getPagedListApi } = useAuditLogsApi(); +const selectedKeys = ref([]); const formOptions: VbenFormProps = { // 默认展开 collapsed: true, @@ -121,6 +123,10 @@ const formOptions: VbenFormProps = { const gridOptions: VxeGridProps = { columns: [ + { + align: 'center', + type: 'checkbox', + }, { align: 'left', field: 'url', @@ -234,6 +240,12 @@ const gridOptions: VxeGridProps = { }; const gridEvents: VxeGridListeners = { + checkboxAll: (params) => { + selectedKeys.value = params.records.map((x) => x.id); + }, + checkboxChange: (params) => { + selectedKeys.value = params.records.map((x) => x.id); + }, sortChange: onSort, }; @@ -268,6 +280,22 @@ async function onDelete(row: AuditLogDto) { }); } +function onBulkDelete() { + Modal.confirm({ + centered: true, + content: $t('component.table.selectedItemWellBeDeleted'), + onOk: async () => { + await deleteManyApi({ + ids: toValue(selectedKeys), + }); + selectedKeys.value = []; + message.success($t('AbpUi.SuccessfullyDeleted')); + gridApi.query(); + }, + title: $t('AbpUi.AreYouSure'), + }); +} + function onSort(params: { field: string; order: SortOrder }) { const sorting = params.order ? `${params.field} ${params.order}` : undefined; gridApi.query({ sorting }); @@ -281,6 +309,19 @@ function onFilter(field: string, value: any) {