Merge branch 'dev' into dev-cjw

This commit is contained in:
chen_junior
2025-04-25 08:34:55 +08:00
11 changed files with 246 additions and 35 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

@ -74,12 +74,14 @@ export async function postDraft(
schemaId: string,
formData: Array<Recordable>,
dataId?: string,
processId='',
taskId='',
mode: ErrorMessageMode = 'modal',
) {
return defHttp.post<boolean>(
{
url: Api.Draft,
params: { formData, schemaId, dataId },
params: { formData, schemaId, dataId, processId, taskId },
},
{
errorMessageMode: mode,
@ -109,12 +111,14 @@ export async function putDraft(
formData: Array<Recordable>,
id: string,
dataId?: string,
processId='',
taskId='',
mode: ErrorMessageMode = 'modal',
) {
return defHttp.put<boolean>(
{
url: Api.Draft,
params: { formData, schemaId, id, dataId },
params: { formData, schemaId, id, dataId, processId, taskId },
},
{
errorMessageMode: mode,
@ -139,7 +143,7 @@ export async function deleteDraft(ids: string[], mode: ErrorMessageMode = 'modal
/**
* @description: 获取草稿详情
*/
export async function getDraftInfo(id: string, mode: ErrorMessageMode = 'modal') {
export async function getDraftInfo(id: string, taskId, userId, mode: ErrorMessageMode = 'modal') {
return defHttp.get<{
formData: string;
name: string;
@ -148,7 +152,7 @@ export async function getDraftInfo(id: string, mode: ErrorMessageMode = 'modal')
}>(
{
url: Api.DraftInfo,
params: { id },
params: { id, taskId, userId },
},
{
errorMessageMode: mode,

View File

@ -150,6 +150,8 @@
});
folderId.value = fileList.value[0].folderId;
}
} else {
folderId.value = '';
}
if (!val) {
fileList.value = [];

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');
}

View File

@ -10,6 +10,12 @@
</slot>
关闭
</a-button>
<a-button @click="saveDraft" v-if="!readonly">
暂存
</a-button>
<a-button @click="setDraft" v-if="rDraftsId && !readonly">
从草稿导入
</a-button>
<a-button v-if="!readonly && hasBtnApprove" type="primary" @click="onApproveClick()">
<slot name="icon">
<check-circle-outlined />
@ -86,6 +92,9 @@
import { useI18n } from '/@/hooks/web/useI18n';
import { useMessage } from '/@/hooks/web/useMessage';
import { useUserStore } from '/@/store/modules/user';
import { deleteDraft, postDraft, putDraft, getDraftInfo } from '/@/api/workflow/process';
import { TaskTypeUrl } from '/@/enums/workflowEnum';
const spinning = ref(false);
const userStore = useUserStore();
@ -105,6 +114,7 @@
const taskId = ref(rQuery.taskId);
const processId = ref(rParams.arg2);
const readonly = ref(!!rQuery.readonly); // 查看流程会触发只读模式
const rDraftsId = ref(rQuery.draftId || '')
const renderKey = ref('');
const formConfigs = ref();
const opinionDlg = ref();
@ -115,7 +125,13 @@
const hasBtnApprove = ref(true);
const hasBtnReject = ref(false);
const hasBtnFinish = ref(false);
let draftData = {}
const drawNode = ref('');
const props = defineProps({
rowKeyData: {
type: String
}
});
let approvalData = reactive({
isCountersign: false,
@ -135,7 +151,6 @@
nextTaskUser: {} // 格式为taskKey: 用户id逗号分隔
});
let approvedType = ref(ApproveType.AGREE);
function onMoreClick(e) {
const key = e.key;
if (key === 'flowchart') {
@ -194,6 +209,56 @@
function close() {
tabStore.closeTab(currentRoute, router);
}
async function setDraft(needModal = true) {
let formData = [];
let params = {
taskId: taskId.value,
userId: userStore.getUserInfo.id,
}
let res = await getDraftInfo('', taskId.value, userStore.getUserInfo.id)
if(res) {
draftData = JSON.parse(res.formData)
rDraftsId.value = res.id
if(!needModal) return
Modal.confirm({
title: () => '提示',
content: () => '确认使用草稿覆盖当前数据?',
onOk: async () => {
data.formInfos.forEach((item) => {
if (draftData && item.formConfig && item.formConfig.key && draftData[item.formConfig.key]) {
formData.push(item.formConfig.key ? draftData[item.formConfig.key] : {});
}
});
await formInformation.value.setFormData(formData);
}
});
}
}
async function saveDraft() {
try {
spinning.value = true;
let formModels = await formInformation.value.saveDraftData();
if (rDraftsId.value) {
let res = await putDraft(schemaId.value, formModels, rDraftsId.value, props.rowKeyData, processId.value, taskId.value);
showResult(res, '保存草稿');
} else {
let res = await postDraft(schemaId.value, formModels, props.rowKeyData, processId.value, taskId.value );
showResult(res, '保存草稿');
}
setDraft(false)
spinning.value = false;
} catch (error) {
spinning.value = false;
notificationError('保存草稿');
}
}
function showResult(res, title) {
if (res) {
notificationSuccess(title);
} else {
notificationError(title);
}
}
async function onApproveClick(isAutoAgreeBreak = false) {
openSpinning();
@ -360,6 +425,7 @@
}
renderKey.value = Math.random() + '';
getBackNode();
setDraft()
} catch (error) {}
});

View File

@ -707,6 +707,9 @@ const columns = ref([
]);
const addGlobalStartEvent = () => {
if(!processInfo.value.globalStartEventConfigs) {
processInfo.value.globalStartEventConfigs = [];
}
processInfo.value.globalStartEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -717,6 +720,9 @@ const deleteStartEvent = (index) => {
processInfo.value.globalStartEventConfigs.splice(index, 1);
};
const addGlobalEndEvent = () => {
if(!processInfo.value.globalEndEventConfigs) {
processInfo.value.globalEndEventConfigs = [];
}
processInfo.value.globalEndEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -728,6 +734,9 @@ const deleteEndEvent = (index) => {
};
const addGlobalPrequalifyBeforeEvent = () => {
if(!processInfo.value.globalPrequalifyBeforeEventConfigs) {
processInfo.value.globalPrequalifyBeforeEventConfigs = [];
}
processInfo.value.globalPrequalifyBeforeEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -739,6 +748,9 @@ const deletePrequalifyBeforeEvent = (index) => {
};
const addGlobalPrequalifyAfterEvent = () => {
if(!processInfo.value.globalPrequalifyAfterEventConfigs) {
processInfo.value.globalPrequalifyAfterEventConfigs = [];
}
processInfo.value.globalPrequalifyAfterEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -750,6 +762,9 @@ const deletePrequalifyAfterEvent = (index) => {
};
const addGlobalFinishBeforeEvent = () => {
if(!processInfo.value.globalFinishBeforeEventConfigs) {
processInfo.value.globalFinishBeforeEventConfigs = [];
}
processInfo.value.globalFinishBeforeEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -761,6 +776,9 @@ const deleteFinishBeforeEvent = (index) => {
};
const addGlobalRejectAfterEvent = () => {
if(!processInfo.value.globalRejectAfterEventConfigs) {
processInfo.value.globalRejectAfterEventConfigs = [];
}
processInfo.value.globalRejectAfterEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -772,6 +790,9 @@ const deleteRejectAfterEvent = (index) => {
};
const addGlobalAgreeAfterEvent = () => {
if(!processInfo.value.globalAgreeAfterEventConfigs) {
processInfo.value.globalAgreeAfterEventConfigs = [];
}
processInfo.value.globalAgreeAfterEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -783,6 +804,9 @@ const deleteAgreeAfterEvent = (index) => {
};
const addGlobalSuspendedBeforeEvent = () => {
if(!processInfo.value.globalSuspendedBeforeEventConfigs) {
processInfo.value.globalSuspendedBeforeEventConfigs = [];
}
processInfo.value.globalSuspendedBeforeEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -794,6 +818,9 @@ const deleteSuspendedBeforeEvent = (index) => {
};
const addGlobalRestoreAfterEvent = () => {
if(!processInfo.value.globalRestoreAfterEventConfigs) {
processInfo.value.globalRestoreAfterEventConfigs = [];
}
processInfo.value.globalRestoreAfterEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},
@ -805,6 +832,9 @@ const deleteRestoreAfterEvent = (index) => {
};
// 全局会签事件添加
const addGlobalSetSignAfterEvent = () => {
if(!processInfo.value.globalSetSignAfterEventConfigs) {
processInfo.value.globalSetSignAfterEventConfigs = [];
}
processInfo.value.globalSetSignAfterEventConfigs.push({
type: NodeEventExType.API,
apiConfig: {},

View File

@ -97,18 +97,29 @@ function tableActions(record) {
async function handleEdit(record) {
try {
let res = await getDraftInfo(record.id);
/*processData.draftsId = record.id;
processData.schemaId = res.schemaId;
processData.draftsJsonStr = res.formData;
processData.visible = true;*/
localStorage.setItem('draftsJsonStr', res.formData);
router.push({
path: `/flow/${res.schemaId}/${record.id}/createFlow`,
query: {
createType: 'drafts'
}
});
const { schemaId, processId, taskId, id } = record;
if(taskId){
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskId,
draftId: id,
}
});
} else {
let res = await getDraftInfo(record.id);
localStorage.setItem('draftsJsonStr', res.formData);
router.push({
path: `/flow/${schemaId}/${id}/createFlow`,
query: {
createType: 'drafts'
}
});
}
} catch (error) { }
}