diff --git a/src/api/system/dict/data/types.ts b/src/api/system/dict/data/types.ts index e4abb9ba..6e2113e2 100644 --- a/src/api/system/dict/data/types.ts +++ b/src/api/system/dict/data/types.ts @@ -12,6 +12,7 @@ export interface DictDataVO extends BaseEntity { listClass: ElTagType; dictSort: number; remark: string; + enumName: string; } export interface DictDataForm { @@ -23,4 +24,5 @@ export interface DictDataForm { listClass: ElTagType; dictSort: number; remark: string; + enumName: string; } diff --git a/src/api/system/dict/type/index.ts b/src/api/system/dict/type/index.ts index ca69c59a..1c6362ce 100644 --- a/src/api/system/dict/type/index.ts +++ b/src/api/system/dict/type/index.ts @@ -1,6 +1,9 @@ import type { PageResult } from '@/api/types'; -import type { AxiosPromise } from '@/utils/api-types'; +import errorCode from '@/utils/errorCode'; import request from '@/utils/request'; +import type { AxiosPromise } from '@/utils/api-types'; +import { blobValidate } from '@/utils/ruoyi'; +import { saveBlob } from '@/utils/save'; import type { DictTypeForm, DictTypeQuery, DictTypeVO } from './types'; // 查询字典类型列表 @@ -61,3 +64,29 @@ export function optionselect(): AxiosPromise { method: 'get' }); } + +// 生成字典枚举类压缩包 +export function genEnum(dictTypes: string[]) { + const loading = ElLoading.service({ + text: '正在下载数据,请稍候', + background: 'rgba(0, 0, 0, 0.7)' + }); + return request({ + url: '/system/dict/type/genEnum', + method: 'post', + data: dictTypes, + responseType: 'blob' + }) + .then(async (data: any) => { + if (blobValidate(data)) { + const blob = new Blob([data], { type: 'application/zip' }); + saveBlob(blob, 'dict_enum.zip'); + } else { + const resText = await new Blob([data]).text(); + const rspObj = JSON.parse(resText); + const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']; + ElMessage.error(errMsg); + } + }) + .finally(() => loading.close()); +} diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue index 8b7f84ae..0f713510 100644 --- a/src/views/system/dict/index.vue +++ b/src/views/system/dict/index.vue @@ -81,6 +81,17 @@ > 导出 + + 生成枚举 + + @@ -386,6 +398,9 @@ > + + + @@ -403,17 +418,21 @@