From 120417b792576d87f1b94b27340d351bc47b2c79 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Sun, 13 Nov 2022 13:16:11 +0800 Subject: [PATCH 001/418] refactor: vxe crud --- .../src/api/system/menu/index.ts | 23 +++++- .../src/api/system/menu/types.ts | 15 ---- .../src/api/system/notice/index.ts | 20 +++++- .../src/api/system/notice/types.ts | 12 ---- .../src/api/system/post/index.ts | 24 ++++++- .../src/api/system/post/types.ts | 24 ------- .../src/components/DictTag/src/DictTag.vue | 2 +- .../src/hooks/web/useMessage.ts | 12 ++++ .../src/hooks/web/useVxeGrid.ts | 20 ++++++ yudao-ui-admin-vue3/src/store/modules/dict.ts | 2 +- yudao-ui-admin-vue3/src/utils/dict.ts | 6 +- .../src/views/system/menu/index.vue | 71 ++++++++++--------- .../src/views/system/notice/index.vue | 31 ++++---- .../src/views/system/notice/notice.data.ts | 3 +- .../src/views/system/post/index.vue | 34 ++++++--- yudao-ui-admin-vue3/types/global.d.ts | 10 +++ 16 files changed, 190 insertions(+), 119 deletions(-) delete mode 100644 yudao-ui-admin-vue3/src/api/system/menu/types.ts delete mode 100644 yudao-ui-admin-vue3/src/api/system/notice/types.ts delete mode 100644 yudao-ui-admin-vue3/src/api/system/post/types.ts diff --git a/yudao-ui-admin-vue3/src/api/system/menu/index.ts b/yudao-ui-admin-vue3/src/api/system/menu/index.ts index 92ec2301e..b4442b81e 100644 --- a/yudao-ui-admin-vue3/src/api/system/menu/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/menu/index.ts @@ -1,13 +1,32 @@ import request from '@/config/axios' -import type { MenuVO } from './types' +export interface MenuVO { + id: number + name: string + permission: string + type: number + sort: number + parentId: number + path: string + icon: string + component: string + status: number + visible: boolean + keepAlive: boolean + createTime: string +} + +export interface MenuPageReqVO { + name?: string + status?: number +} // 查询菜单(精简)列表 export const listSimpleMenusApi = () => { return request.get({ url: '/system/menu/list-all-simple' }) } // 查询菜单列表 -export const getMenuListApi = (params) => { +export const getMenuListApi = (params: MenuPageReqVO) => { return request.get({ url: '/system/menu/list', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/menu/types.ts b/yudao-ui-admin-vue3/src/api/system/menu/types.ts deleted file mode 100644 index 1506e87aa..000000000 --- a/yudao-ui-admin-vue3/src/api/system/menu/types.ts +++ /dev/null @@ -1,15 +0,0 @@ -export type MenuVO = { - id: number - name: string - permission: string - type: number - sort: number - parentId: number - path: string - icon: string - component: string - status: number - visible: boolean - keepAlive: boolean - createTime: string -} diff --git a/yudao-ui-admin-vue3/src/api/system/notice/index.ts b/yudao-ui-admin-vue3/src/api/system/notice/index.ts index 7ccafad4a..c344603e9 100644 --- a/yudao-ui-admin-vue3/src/api/system/notice/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/notice/index.ts @@ -1,8 +1,24 @@ import request from '@/config/axios' -import type { NoticeVO } from './types' +export interface NoticeVO { + id: number + title: string + type: number + content: string + status: number + remark: string + creator: string + createTime: string + updater: string + updateTime: string +} + +export interface NoticePageReqVO extends BasePage { + title?: string + status?: number +} // 查询公告列表 -export const getNoticePageApi = (params) => { +export const getNoticePageApi = (params: NoticePageReqVO) => { return request.get({ url: '/system/notice/page', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/notice/types.ts b/yudao-ui-admin-vue3/src/api/system/notice/types.ts deleted file mode 100644 index 0e0bb43ec..000000000 --- a/yudao-ui-admin-vue3/src/api/system/notice/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -export type NoticeVO = { - id: number - title: string - type: number - content: string - status: number - remark: string - creator: string - createTime: string - updater: string - updateTime: string -} diff --git a/yudao-ui-admin-vue3/src/api/system/post/index.ts b/yudao-ui-admin-vue3/src/api/system/post/index.ts index 3401359da..5f2557cab 100644 --- a/yudao-ui-admin-vue3/src/api/system/post/index.ts +++ b/yudao-ui-admin-vue3/src/api/system/post/index.ts @@ -1,5 +1,26 @@ import request from '@/config/axios' -import type { PostVO, PostPageReqVO, PostExportReqVO } from './types' + +export interface PostVO { + id?: number + name: string + code: string + sort: number + status: number + remark: string + createTime?: string +} + +export interface PostPageReqVO extends BasePage { + code?: string + name?: string + status?: number +} + +export interface PostExportReqVO { + code?: string + name?: string + status?: number +} // 查询岗位列表 export const getPostPageApi = async (params: PostPageReqVO) => { @@ -31,7 +52,6 @@ export const deletePostApi = async (id: number) => { } // 导出岗位 -// TODO @星语:导出这块,咱怎么弄哈 export const exportPostApi = async (params: PostExportReqVO) => { return await request.download({ url: '/system/post/export', params }) } diff --git a/yudao-ui-admin-vue3/src/api/system/post/types.ts b/yudao-ui-admin-vue3/src/api/system/post/types.ts deleted file mode 100644 index fc239e30e..000000000 --- a/yudao-ui-admin-vue3/src/api/system/post/types.ts +++ /dev/null @@ -1,24 +0,0 @@ -export type PostVO = { - id?: number - name: string - code: string - sort: number - status: number - remark: string - createTime?: string -} - -// TODO @星语:要不要搞个 Page 基类呀?和后端对应 -export type PostPageReqVO = { - code: string - name: string - status?: number - pageSize?: number - pageNo?: number -} - -export type PostExportReqVO = { - code: string - name: string - status?: number -} diff --git a/yudao-ui-admin-vue3/src/components/DictTag/src/DictTag.vue b/yudao-ui-admin-vue3/src/components/DictTag/src/DictTag.vue index 5bbb9104c..321107695 100644 --- a/yudao-ui-admin-vue3/src/components/DictTag/src/DictTag.vue +++ b/yudao-ui-admin-vue3/src/components/DictTag/src/DictTag.vue @@ -38,7 +38,7 @@ onUpdated(() => { dictData?.colorType === '' || dictData?.colorType === undefined " - :key="dictData?.value" + :key="dictData?.value.toString()" :class="dictData?.cssClass" > {{ dictData?.label }} diff --git a/yudao-ui-admin-vue3/src/hooks/web/useMessage.ts b/yudao-ui-admin-vue3/src/hooks/web/useMessage.ts index c9879aedf..ac2b552e0 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useMessage.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useMessage.ts @@ -71,6 +71,18 @@ export const useMessage = () => { } ) }, + // 导出窗体 + exportConfirm(content?: string, tip?: string) { + return ElMessageBox.confirm( + content ? content : t('common.exportMessage'), + tip ? tip : t('common.confirmTitle'), + { + confirmButtonText: t('common.ok'), + cancelButtonText: t('common.cancel'), + type: 'warning' + } + ) + }, // 提交内容 prompt(content: string, tip: string) { return ElMessageBox.prompt(content, tip, { diff --git a/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts b/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts index b297cf704..b7941f16e 100644 --- a/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts +++ b/yudao-ui-admin-vue3/src/hooks/web/useVxeGrid.ts @@ -13,6 +13,7 @@ interface UseVxeGridConfig { getListApi: (option: any) => Promise delListApi?: (option: any) => Promise exportListApi?: (option: any) => Promise + exportName?: string } const appStore = useAppStore() @@ -88,10 +89,29 @@ export const useVxeGrid = (config?: UseVxeGridConfig) => { return new Promise(async (resolve) => { resolve(await config?.getListApi(queryParams)) }) + }, + queryAll: ({ form }) => { + const queryParams = Object.assign({}, JSON.parse(JSON.stringify(form))) + return new Promise(async (resolve) => { + if (config?.exportListApi) { + resolve(await config?.exportListApi(queryParams)) + } else { + resolve(await config?.getListApi(queryParams)) + } + }) } } + }, + exportConfig: { + filename: config?.exportName, + // 默认选中类型 + type: 'csv', + // 自定义数据量列表 + modes: ['current', 'all'], + columns: config?.allSchemas.printSchema } }) + const delList = (ids: string | number | string[] | number[]) => { return new Promise(async () => { message.delConfirm().then(() => { diff --git a/yudao-ui-admin-vue3/src/store/modules/dict.ts b/yudao-ui-admin-vue3/src/store/modules/dict.ts index 56547ff55..5e3722950 100644 --- a/yudao-ui-admin-vue3/src/store/modules/dict.ts +++ b/yudao-ui-admin-vue3/src/store/modules/dict.ts @@ -3,7 +3,7 @@ import { store } from '../index' import { DictDataVO } from '@/api/system/dict/types' export interface DictValueType { - value: string + value: string | number | boolean label: string clorType: string cssClass: string diff --git a/yudao-ui-admin-vue3/src/utils/dict.ts b/yudao-ui-admin-vue3/src/utils/dict.ts index 5050d2e7b..2cab7e176 100644 --- a/yudao-ui-admin-vue3/src/utils/dict.ts +++ b/yudao-ui-admin-vue3/src/utils/dict.ts @@ -15,7 +15,7 @@ const dictStore = useDictStoreWithOut() export interface DictDataType { dictType: string label: string - value: string | number + value: string | number | boolean colorType: ElementPlusInfoType | '' | 'default' | 'primary' cssClass: string } @@ -34,10 +34,10 @@ export const getDictOptions = (dictType: string) => { export const getIntDictOptions = (dictType: string) => { const dictOptions: DictDataType[] = [] dictStore.getDictMap.forEach((dict: DictDataType) => { - if (dict.dictType + '' === dictType) { + if (dict.dictType.toString() === dictType) { dictOptions.push({ ...dict, - value: parseInt(dict.value + '') + value: dict.value }) } }) diff --git a/yudao-ui-admin-vue3/src/views/system/menu/index.vue b/yudao-ui-admin-vue3/src/views/system/menu/index.vue index e1bd5c15c..ed3c71114 100644 --- a/yudao-ui-admin-vue3/src/views/system/menu/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/menu/index.vue @@ -42,7 +42,6 @@ - @@ -102,6 +101,7 @@