From 0e2e512eda45ed9042f5125206771a738a883111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=B0=B8=E6=98=A5?= Date: Tue, 2 Dec 2025 00:25:16 +0800 Subject: [PATCH] =?UTF-8?q?feat-wip(components):=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=9B=B8=E5=85=B3=E9=A1=B5=E9=9D=A2=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advanced/table-header-operation.vue | 3 +- src/constants/sys/core/dictionary.ts | 8 + src/hooks/common/table.ts | 8 +- src/locales/langs/en-us.ts | 9 + src/locales/langs/zh-cn.ts | 9 + src/service/api/index.ts | 1 + src/service/api/sys/core/dictionary.ts | 45 ++++ src/typings/api/common.d.ts | 51 ++-- src/typings/api/sys/core.d.ts | 40 +++ src/typings/app.d.ts | 9 + src/typings/components.d.ts | 28 +++ src/views/sys/core/dictionary/index.vue | 155 +++++++++++- .../modules/dictionary-operate-drawer.vue | 233 ++++++++++++++++++ .../dictionary/modules/dictionary-search.vue | 89 +++++++ 14 files changed, 644 insertions(+), 44 deletions(-) create mode 100644 src/constants/sys/core/dictionary.ts create mode 100644 src/service/api/sys/core/dictionary.ts create mode 100644 src/typings/api/sys/core.d.ts create mode 100644 src/views/sys/core/dictionary/modules/dictionary-operate-drawer.vue create mode 100644 src/views/sys/core/dictionary/modules/dictionary-search.vue diff --git a/src/components/advanced/table-header-operation.vue b/src/components/advanced/table-header-operation.vue index 7ca287fd..a1916c51 100644 --- a/src/components/advanced/table-header-operation.vue +++ b/src/components/advanced/table-header-operation.vue @@ -8,6 +8,7 @@ defineOptions({ interface Props { itemAlign?: NaiveUI.Align; disabledDelete?: boolean; + disabledAdd?: boolean; loading?: boolean; } @@ -42,7 +43,7 @@ function refresh() { - + diff --git a/src/constants/sys/core/dictionary.ts b/src/constants/sys/core/dictionary.ts new file mode 100644 index 00000000..d56432e3 --- /dev/null +++ b/src/constants/sys/core/dictionary.ts @@ -0,0 +1,8 @@ +import { transformRecordToOption } from '@/utils/common'; + +export const dictionaryTypeRecord: Record = { + enum: 'page.sys.core.dictionary.options.type.enum', + tree: 'page.sys.core.dictionary.options.type.tree' +}; + +export const dictionaryTypeOptions = transformRecordToOption(dictionaryTypeRecord); diff --git a/src/hooks/common/table.ts b/src/hooks/common/table.ts index 0c943f58..a0fb6984 100644 --- a/src/hooks/common/table.ts +++ b/src/hooks/common/table.ts @@ -230,17 +230,17 @@ export function useTableOperate( } export function defaultTransform( - response: FlatResponseData> + response: FlatResponseData> ): PaginationData { const { data, error } = response; if (!error) { - const { records, current, size, total } = data; + const { records, pageNumber, pageSize, total } = data; return { data: records, - pageNum: current, - pageSize: size, + pageNum: pageNumber, + pageSize, total }; } diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index 68ef1baa..8ffee9d0 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -320,6 +320,15 @@ const local: App.I18n.Schema = { description: 'Description', createTime: 'Create Time', updateTime: 'Update Time' + }, + options: { + type: { + enum: 'Enum', + tree: 'Tree' + } + }, + item: { + title: 'Item' } } }, diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index abc16ccc..d6518d46 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -317,6 +317,15 @@ const local: App.I18n.Schema = { description: '描述', createTime: '创建时间', updateTime: '修改时间' + }, + options: { + type: { + enum: '枚举', + tree: '数型' + } + }, + item: { + title: '字典项' } } }, diff --git a/src/service/api/index.ts b/src/service/api/index.ts index 89f4e581..eade4ef9 100644 --- a/src/service/api/index.ts +++ b/src/service/api/index.ts @@ -1,2 +1,3 @@ export * from './auth'; export * from './route'; +export * from './sys/core/dictionary'; diff --git a/src/service/api/sys/core/dictionary.ts b/src/service/api/sys/core/dictionary.ts new file mode 100644 index 00000000..241e60f1 --- /dev/null +++ b/src/service/api/sys/core/dictionary.ts @@ -0,0 +1,45 @@ +import { request } from '../../../request'; + +export function fetchPageDictionary(pageRequest: Api.Sys.Core.DictionaryQueryPageRequest) { + return request>({ + url: '/dictionary/page', + method: 'post', + data: pageRequest + }); +} + +export function fetchDictionaryAdd(dictionaryOp: Api.Sys.Core.DictionaryOp) { + return request({ + url: '/dictionary/add', + method: 'post', + data: dictionaryOp + }); +} + +export function fetchDictionaryEdit(dictionaryOp: Api.Sys.Core.DictionaryOp) { + return request({ + url: '/dictionary/edit', + method: 'post', + data: dictionaryOp + }); +} + +export function fetchDictionaryDelete(id: string) { + return request({ + url: '/dictionary/delete', + method: 'post', + data: { + id + } + }); +} + +export function fetchDictionaryDeleteBatch(ids: string[]) { + return request({ + url: '/dictionary/deleteBatch', + method: 'post', + data: { + ids + } + }); +} diff --git a/src/typings/api/common.d.ts b/src/typings/api/common.d.ts index 6b6633df..fd338efd 100644 --- a/src/typings/api/common.d.ts +++ b/src/typings/api/common.d.ts @@ -5,46 +5,23 @@ */ declare namespace Api { namespace Common { - /** common params of paginating */ - interface PaginatingCommonParams { - /** current page number */ - current: number; - /** page size */ - size: number; - /** total count */ - total: number; + /** 分页请求 */ + interface PageRequest { + pageNumber: number; + pageSize: number; } - /** common params of paginating query list data */ - interface PaginatingQueryRecord extends PaginatingCommonParams { + /** 带查询参数的分页请求 */ + interface QueryPageRequest extends PageRequest { + query: T; + } + + /** 分页响应 */ + interface PageResponse { + total: number; + pageNumber: number; + pageSize: number; records: T[]; } - - /** common search params of table */ - type CommonSearchParams = Pick; - - /** - * enable status - * - * - "1": enabled - * - "2": disabled - */ - type EnableStatus = '1' | '2'; - - /** common record */ - type CommonRecord = { - /** record id */ - id: number; - /** record creator */ - createBy: string; - /** record create time */ - createTime: string; - /** record updater */ - updateBy: string; - /** record update time */ - updateTime: string; - /** record status */ - status: EnableStatus | null; - } & T; } } diff --git a/src/typings/api/sys/core.d.ts b/src/typings/api/sys/core.d.ts new file mode 100644 index 00000000..4f8d9c80 --- /dev/null +++ b/src/typings/api/sys/core.d.ts @@ -0,0 +1,40 @@ +declare namespace Api { + namespace Sys { + namespace Core { + // ******************** sys_core_dictionary ******************** + type DictionaryType = 'enum' | 'tree'; + interface Dictionary { + id: string; + name: string; + code: string; + type: DictionaryType; + description: string | null; + createTime: string; + updateTime: string; + } + interface DictionaryQuery { + name: string | null; + code: string | null; + type: string | null; + } + type DictionaryQueryPageRequest = Api.Common.QueryPageRequest; + interface DictionaryOp { + id: string | null; + name: string; + code: string; + type: DictionaryType; + description: string | null; + } + interface DictionaryItem { + id: string; + name: string; + code: string; + sort: number; + description: string | null; + createTime: string | null; + updateTime: string | null; + children: DictionaryItem[]; + } + } + } +} diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts index c6c0cc81..019d839e 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -559,6 +559,15 @@ declare namespace App { createTime: string; updateTime: string; }; + options: { + type: { + enum: string; + tree: string; + }; + }; + item: { + title: string; + }; }; }; rbac: { diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index 615dbf28..fbf95912 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -21,14 +21,21 @@ declare module 'vue' { FullScreen: typeof import('./../components/common/full-screen.vue')['default'] IconAntDesignEnterOutlined: typeof import('~icons/ant-design/enter-outlined')['default'] IconAntDesignReloadOutlined: typeof import('~icons/ant-design/reload-outlined')['default'] + IconAntDesignSettingOutlined: typeof import('~icons/ant-design/setting-outlined')['default'] IconGridiconsFullscreen: typeof import('~icons/gridicons/fullscreen')['default'] IconGridiconsFullscreenExit: typeof import('~icons/gridicons/fullscreen-exit')['default'] + IconIcRoundDelete: typeof import('~icons/ic/round-delete')['default'] + IconIcRoundPlus: typeof import('~icons/ic/round-plus')['default'] + IconIcRoundRefresh: typeof import('~icons/ic/round-refresh')['default'] + IconIcRoundSearch: typeof import('~icons/ic/round-search')['default'] IconLocalBanner: typeof import('~icons/local/banner')['default'] IconLocalLogo: typeof import('~icons/local/logo')['default'] IconMdiArrowDownThin: typeof import('~icons/mdi/arrow-down-thin')['default'] IconMdiArrowUpThin: typeof import('~icons/mdi/arrow-up-thin')['default'] + IconMdiDrag: typeof import('~icons/mdi/drag')['default'] IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default'] IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default'] + IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] IconTooltip: typeof import('./../components/common/icon-tooltip.vue')['default'] IconUilSearch: typeof import('~icons/uil/search')['default'] LangSwitch: typeof import('./../components/common/lang-switch.vue')['default'] @@ -41,7 +48,10 @@ declare module 'vue' { NButton: typeof import('naive-ui')['NButton'] NCard: typeof import('naive-ui')['NCard'] NCheckbox: typeof import('naive-ui')['NCheckbox'] + NCollapse: typeof import('naive-ui')['NCollapse'] + NCollapseItem: typeof import('naive-ui')['NCollapseItem'] NColorPicker: typeof import('naive-ui')['NColorPicker'] + NDataTable: typeof import('naive-ui')['NDataTable'] NDialogProvider: typeof import('naive-ui')['NDialogProvider'] NDivider: typeof import('naive-ui')['NDivider'] NDrawer: typeof import('naive-ui')['NDrawer'] @@ -50,6 +60,7 @@ declare module 'vue' { NEmpty: typeof import('naive-ui')['NEmpty'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] + NFormItemGi: typeof import('naive-ui')['NFormItemGi'] NGi: typeof import('naive-ui')['NGi'] NGrid: typeof import('naive-ui')['NGrid'] NInput: typeof import('naive-ui')['NInput'] @@ -62,7 +73,10 @@ declare module 'vue' { NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NModal: typeof import('naive-ui')['NModal'] NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] + NPopconfirm: typeof import('naive-ui')['NPopconfirm'] NPopover: typeof import('naive-ui')['NPopover'] + NRadio: typeof import('naive-ui')['NRadio'] + NRadioGroup: typeof import('naive-ui')['NRadioGroup'] NScrollbar: typeof import('naive-ui')['NScrollbar'] NSelect: typeof import('naive-ui')['NSelect'] NSpace: typeof import('naive-ui')['NSpace'] @@ -98,14 +112,21 @@ declare global { const FullScreen: typeof import('./../components/common/full-screen.vue')['default'] const IconAntDesignEnterOutlined: typeof import('~icons/ant-design/enter-outlined')['default'] const IconAntDesignReloadOutlined: typeof import('~icons/ant-design/reload-outlined')['default'] + const IconAntDesignSettingOutlined: typeof import('~icons/ant-design/setting-outlined')['default'] const IconGridiconsFullscreen: typeof import('~icons/gridicons/fullscreen')['default'] const IconGridiconsFullscreenExit: typeof import('~icons/gridicons/fullscreen-exit')['default'] + const IconIcRoundDelete: typeof import('~icons/ic/round-delete')['default'] + const IconIcRoundPlus: typeof import('~icons/ic/round-plus')['default'] + const IconIcRoundRefresh: typeof import('~icons/ic/round-refresh')['default'] + const IconIcRoundSearch: typeof import('~icons/ic/round-search')['default'] const IconLocalBanner: typeof import('~icons/local/banner')['default'] const IconLocalLogo: typeof import('~icons/local/logo')['default'] const IconMdiArrowDownThin: typeof import('~icons/mdi/arrow-down-thin')['default'] const IconMdiArrowUpThin: typeof import('~icons/mdi/arrow-up-thin')['default'] + const IconMdiDrag: typeof import('~icons/mdi/drag')['default'] const IconMdiKeyboardEsc: typeof import('~icons/mdi/keyboard-esc')['default'] const IconMdiKeyboardReturn: typeof import('~icons/mdi/keyboard-return')['default'] + const IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] const IconTooltip: typeof import('./../components/common/icon-tooltip.vue')['default'] const IconUilSearch: typeof import('~icons/uil/search')['default'] const LangSwitch: typeof import('./../components/common/lang-switch.vue')['default'] @@ -118,7 +139,10 @@ declare global { const NButton: typeof import('naive-ui')['NButton'] const NCard: typeof import('naive-ui')['NCard'] const NCheckbox: typeof import('naive-ui')['NCheckbox'] + const NCollapse: typeof import('naive-ui')['NCollapse'] + const NCollapseItem: typeof import('naive-ui')['NCollapseItem'] const NColorPicker: typeof import('naive-ui')['NColorPicker'] + const NDataTable: typeof import('naive-ui')['NDataTable'] const NDialogProvider: typeof import('naive-ui')['NDialogProvider'] const NDivider: typeof import('naive-ui')['NDivider'] const NDrawer: typeof import('naive-ui')['NDrawer'] @@ -127,6 +151,7 @@ declare global { const NEmpty: typeof import('naive-ui')['NEmpty'] const NForm: typeof import('naive-ui')['NForm'] const NFormItem: typeof import('naive-ui')['NFormItem'] + const NFormItemGi: typeof import('naive-ui')['NFormItemGi'] const NGi: typeof import('naive-ui')['NGi'] const NGrid: typeof import('naive-ui')['NGrid'] const NInput: typeof import('naive-ui')['NInput'] @@ -139,7 +164,10 @@ declare global { const NMessageProvider: typeof import('naive-ui')['NMessageProvider'] const NModal: typeof import('naive-ui')['NModal'] const NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] + const NPopconfirm: typeof import('naive-ui')['NPopconfirm'] const NPopover: typeof import('naive-ui')['NPopover'] + const NRadio: typeof import('naive-ui')['NRadio'] + const NRadioGroup: typeof import('naive-ui')['NRadioGroup'] const NScrollbar: typeof import('naive-ui')['NScrollbar'] const NSelect: typeof import('naive-ui')['NSelect'] const NSpace: typeof import('naive-ui')['NSpace'] diff --git a/src/views/sys/core/dictionary/index.vue b/src/views/sys/core/dictionary/index.vue index d9e2e7ce..59c2ec4e 100644 --- a/src/views/sys/core/dictionary/index.vue +++ b/src/views/sys/core/dictionary/index.vue @@ -1,15 +1,166 @@ - diff --git a/src/views/sys/core/dictionary/modules/dictionary-operate-drawer.vue b/src/views/sys/core/dictionary/modules/dictionary-operate-drawer.vue new file mode 100644 index 00000000..a5a4d3f8 --- /dev/null +++ b/src/views/sys/core/dictionary/modules/dictionary-operate-drawer.vue @@ -0,0 +1,233 @@ + + + + + diff --git a/src/views/sys/core/dictionary/modules/dictionary-search.vue b/src/views/sys/core/dictionary/modules/dictionary-search.vue new file mode 100644 index 00000000..574c76b7 --- /dev/null +++ b/src/views/sys/core/dictionary/modules/dictionary-search.vue @@ -0,0 +1,89 @@ + + + + +