Merge branch 'dev-sugx-20250424' into 'dev'

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

See merge request itc-framework/ma/2024/front!67
This commit is contained in:
890147
2025-04-24 08:11:42 +00:00
6 changed files with 120 additions and 22 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

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

View File

@ -25,9 +25,21 @@
<a-button type="primary" @click="handleStepNext" v-show="current < 5">
{{ t('下一步') }}
</a-button>
<a-button type="primary" @click="handleCodeGenerator" v-show="current === 5">
{{ t('完成') }}
</a-button>
<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>
@ -57,6 +69,7 @@
getCodeTemplateInfo,
saveDraftGeneratorCode,
updateDraftGeneratorCode,
downloadCodes,
} from '/@/api/system/generator';
import { FormProps } from '/@/components/Form';
import { buildOption } from '/@/utils/helper/designHelper';
@ -73,6 +86,9 @@
import DesignLogo from '/@/components/ModalPanel/src/DesignLogo.vue';
import AjaxErrorIcon from '/@/components/SecondDev/AjaxErrorIcon.vue';
import useGlobalFlag from '/@/hooks/core/useGlobalFlag';
import { downloadByData } from '/@/utils/file/download';
import { dateUtil } from '/@/utils/dateUtil';
const { t } = useI18n();
const StructureConfigStep = defineAsyncComponent({
loader: () => import('/@/components/CreateCodeStep/src/StructureConfigStep.vue'),
@ -114,7 +130,6 @@
const widgetForm = ref(JSON.parse(JSON.stringify(antd.widgetForm))); //FormDesignStep -> designer和StructureConfigStep页面使用
const mainTableName = ref('table_' + random(10000, 99999));
const emit = defineEmits(['close', 'register', 'success']);
watch(current, () => {
isEditorOpen.value = current.value === 0;
});
@ -245,7 +260,7 @@
handleClose();
emit('success');
}
async function handleCodeGenerator() {
async function handleCodeGenerator(actionType:String) {
const isOk = await stepValidate[5]();
if (
generatorConfig.formJson?.hiddenComponent &&
@ -268,9 +283,16 @@
// await appGeneratorCode(
// buildAppCode(generatorConfig, buildAppFormProps(generatorConfig.formJson)),
// );
await codeFirstGeneratorCode(data);
data.actionType=actionType;
const result =await codeFirstGeneratorCode(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');
}

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">
{{ t('完成') }}
</a-button>
<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');
}

View File

@ -24,9 +24,21 @@
<a-button type="primary" @click="handleStepNext" v-show="current < 5">
{{ t('下一步') }}
</a-button>
<a-button type="primary" @click="handleCodeGenerator" v-show="current === 5">
{{ t('完成') }}
</a-button>
<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>
@ -57,6 +69,7 @@
saveDraftGeneratorCode,
updateDraftGeneratorCode,
getMasterInfo,
downloadCodes,
} from '/@/api/system/generator';
import { FormProps } from '/@/components/Form';
import { buildOption } from '/@/utils/helper/designHelper';
@ -71,6 +84,8 @@
import { MenuConfig } from '/@/model/generator/menuConfig';
import { FormEventColumnConfig } from '/@/model/generator/formEventConfig';
import DesignLogo from '/@/components/ModalPanel/src/DesignLogo.vue';
import { downloadByData } from '/@/utils/file/download';
import { dateUtil } from '/@/utils/dateUtil';
const { t } = useI18n();
const StructureConfigStep = defineAsyncComponent({
@ -244,7 +259,7 @@
handleClose();
emit('success');
}
async function handleCodeGenerator() {
async function handleCodeGenerator(actionType:String) {
const isOk = await stepValidate[5]();
if (
generatorConfig.formJson?.hiddenComponent &&
@ -263,7 +278,16 @@
buildOption(generatorConfig.formJson) as FormProps,
);
if (templateId.value) data.id = templateId.value;
await codeFirstGeneratorCode(data);
data.actionType=actionType;
const result =await codeFirstGeneratorCode(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');
}