From 8ec9a28d7caea60a1e0ca0b5cd118bc4db108bea Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 24 Apr 2025 17:27:23 +0800 Subject: [PATCH] feat(vben5): Realize the item management of the data dictionary --- .../vben5/packages/@abp/platform/package.json | 4 + .../DataDictionaryItemDrawer.vue | 49 ++- .../DataDictionaryItemModal.vue | 293 ++++++++++++++++++ 3 files changed, 339 insertions(+), 7 deletions(-) create mode 100644 apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemModal.vue diff --git a/apps/vben5/packages/@abp/platform/package.json b/apps/vben5/packages/@abp/platform/package.json index d7f491d4c..59c6ac156 100644 --- a/apps/vben5/packages/@abp/platform/package.json +++ b/apps/vben5/packages/@abp/platform/package.json @@ -32,7 +32,11 @@ "@vben/layouts": "workspace:*", "@vben/locales": "workspace:*", "ant-design-vue": "catalog:", + "lodash.clonedeep": "catalog:", "vue": "catalog:*", "vxe-table": "catalog:" + }, + "devDependencies": { + "@types/lodash.clonedeep": "catalog:" } } diff --git a/apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemDrawer.vue b/apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemDrawer.vue index 124c8ebe0..c6c1f05d7 100644 --- a/apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemDrawer.vue +++ b/apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemDrawer.vue @@ -3,9 +3,9 @@ import type { VxeGridListeners, VxeGridProps } from '@abp/ui'; import type { DataDto, DataItemDto } from '../../types/dataDictionaries'; -import { h, reactive, ref } from 'vue'; +import { defineAsyncComponent, h, reactive, ref } from 'vue'; -import { useVbenDrawer } from '@vben/common-ui'; +import { useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; import { isNullOrWhiteSpace } from '@abp/core'; @@ -17,12 +17,12 @@ import { EditOutlined, PlusOutlined, } from '@ant-design/icons-vue'; -import { Button } from 'ant-design-vue'; +import { Button, message, Modal } from 'ant-design-vue'; import { useDataDictionariesApi } from '../../api'; import { ValueType } from '../../types/dataDictionaries'; -const { getApi } = useDataDictionariesApi(); +const { deleteItemApi, getApi } = useDataDictionariesApi(); const dataItems = ref([]); const pageState = reactive({ @@ -140,6 +140,12 @@ const [Grid, gridApi] = useVbenVxeGrid({ gridOptions, }); +const [DataDictionaryItemModal, itemModalApi] = useVbenModal({ + connectedComponent: defineAsyncComponent( + () => import('./DataDictionaryItemModal.vue'), + ), +}); + async function onGet() { const { id } = drawerApi.getData(); if (isNullOrWhiteSpace(id)) { @@ -173,11 +179,39 @@ function onPageChange() { }); } -function onCreate() {} +function onCreate() { + const data = drawerApi.getData(); + itemModalApi.setData({ data }); + itemModalApi.open(); +} -function onUpdate(_row: DataItemDto) {} +function onUpdate(row: DataItemDto) { + const data = drawerApi.getData(); + itemModalApi.setData({ data, item: row }); + itemModalApi.open(); +} -function onDelete(_row: DataItemDto) {} +function onDelete(row: DataItemDto) { + Modal.confirm({ + afterClose: () => { + gridApi.setLoading(false); + }, + centered: true, + content: `${$t('AbpUi.ItemWillBeDeletedMessage')}`, + onOk: async () => { + try { + gridApi.setLoading(true); + const { id } = drawerApi.getData(); + await deleteItemApi(id, row.name); + message.success($t('AbpUi.DeletedSuccessfully')); + onGet(); + } finally { + gridApi.setLoading(false); + } + }, + title: $t('AbpUi.AreYouSure'), + }); +} + diff --git a/apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemModal.vue b/apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemModal.vue new file mode 100644 index 000000000..2c7eeb55c --- /dev/null +++ b/apps/vben5/packages/@abp/platform/src/components/data-dictionaries/DataDictionaryItemModal.vue @@ -0,0 +1,293 @@ + + + + +