1.数据优先模板:代码生成器增加打包下载功能。 2.表单设计:历史版本列表中增加版本号

This commit is contained in:
suguangxu
2025-04-24 11:58:04 +08:00
parent bae3257764
commit 56ea74d365
4 changed files with 61 additions and 9 deletions

View File

@ -22,6 +22,7 @@ enum Api {
App = '/system/generator/generator-app-code',
Master = '/system/databaselink/master-info',
Batch = '/system/generator/generator-code/batch',
DownloadCodes='/system/generator/downloadCodes',
}
/**
@ -251,3 +252,23 @@ export async function batchGeneratorCode(data: GeneratorModel, mode: ErrorMessag
},
);
}
/**
* @description: 根据uuid(目录名称)下载代码
*/
export async function downloadCodes(
params?: object,
mode: ErrorMessageMode = 'modal'
) {
return defHttp.download(
{
url: Api.DownloadCodes+"/"+params.uuid,
method: 'GET',
responseType: 'blob',
},
{
errorMessageMode: mode,
},
);
}

View File

@ -4,6 +4,7 @@ import { TableStructureConfig } from '/@/model/generator/tableStructureConfig';
export interface GeneratorModel extends GeneratorConfig {
frontCode: FrontCode;
id?: string;
actionType?: string;
}
export interface GeneratorAppModel extends FrontCode {

View File

@ -34,10 +34,15 @@
const columns: BasicColumn[] = [
{
dataIndex: 'activityFlag',
title: t('版本'),
title: t('状态'),
customRender: ({ record }) =>
`${record.activityFlag === 1 ? t('当前版本') : t('非当前版本')}`, //1-当前版本 0-非当前版本
},
{
dataIndex: 'version',
title: t('版本'),
},
{
dataIndex: 'createUserName',
title: t('创建人'),

View File

@ -24,9 +24,22 @@
<a-button type="primary" @click="handleStepNext" v-show="current < 5">
{{ t('下一步') }}
</a-button>
<a-button type="primary" @click="handleCodeGenerator" v-show="current === 5">
<a-dropdown placement="bottom" :arrow="{ pointAtCenter: true }">
<a-button type="primary" v-show="current === 5">
{{ t('完成') }}
</a-button>
<template #overlay>
<a-menu>
<a-menu-item>
<a href="javascript:;" @click="handleCodeGenerator('packAndDownload')">打包下载</a>
</a-menu-item>
<a-menu-item>
<a href="javascript:;" @click="handleCodeGenerator('genCodeToProject')">生成到项目中</a>
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
<a-button type="primary" danger @click="handleClose">{{ t('关闭') }}</a-button>
</div>
</div>
@ -51,6 +64,7 @@
getCodeTemplateInfo,
saveDraftGeneratorCode,
updateDraftGeneratorCode,
downloadCodes,
} from '/@/api/system/generator';
import { FormProps } from '/@/components/Form';
import { buildOption } from '/@/utils/helper/designHelper';
@ -66,6 +80,8 @@
import DesignLogo from '/@/components/ModalPanel/src/DesignLogo.vue';
import useGlobalFlag from '/@/hooks/core/useGlobalFlag';
import AjaxErrorIcon from '/@/components/SecondDev/AjaxErrorIcon.vue';
import { downloadByData } from '/@/utils/file/download';
import { dateUtil } from '/@/utils/dateUtil';
const { t } = useI18n();
const TableConfigStep = defineAsyncComponent({
@ -240,7 +256,7 @@
handleClose();
emit('success');
}
async function handleCodeGenerator() {
async function handleCodeGenerator(actionType:String) {
const isOk = await stepValidate[5]();
if (
generatorConfig.formJson?.hiddenComponent &&
@ -259,7 +275,16 @@
buildOption(generatorConfig.formJson) as FormProps,
);
if (templateId.value) data.id = templateId.value;
await dataFirstGeneratorCode(data);
data.actionType=actionType;
const result = await dataFirstGeneratorCode(data);
if(data.actionType=="packAndDownload"&&result){
const fileName=data.outputConfig.className+'_'+dateUtil(new Date()).format('YYYY-MM-DD_HH_mm_ss');
const res = await downloadCodes({uuid:result});
downloadByData(
res.data,
fileName+".zip"
);
}
handleClose();
emit('success');
}