增加审批组件

This commit is contained in:
dengqichen 2025-10-25 01:56:56 +08:00
parent 15d3720f5f
commit 099b979ce7
2 changed files with 90 additions and 55 deletions

View File

@ -44,11 +44,11 @@ export const applicationsConfig: DataSourceConfig = {
params: { enabled: true }, params: { enabled: true },
transform: (data: any[]) => { transform: (data: any[]) => {
return data.map((item: any) => ({ return data.map((item: any) => ({
label: item.name, label: item.appName, // ✅ 修正:使用 appName
value: item.id, value: item.appCode,
code: item.code, code: item.appCode, // ✅ 修正:使用 appCode
projectGroupId: item.projectGroupId, projectGroupId: item.projectGroupId,
description: item.description description: item.appDesc || item.description // ✅ 修正:使用 appDesc
})); }));
} }
}; };

View File

@ -6,6 +6,18 @@
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import { Modal } from 'antd'; import { Modal } from 'antd';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogPortal,
AlertDialogOverlay,
} from '@/components/ui/alert-dialog';
import { FormRenderer, type FormRendererRef } from '@/components/FormDesigner'; import { FormRenderer, type FormRendererRef } from '@/components/FormDesigner';
import type { FormDefinitionResponse } from '@/pages/Form/Definition/types'; import type { FormDefinitionResponse } from '@/pages/Form/Definition/types';
import type { WorkflowDefinition } from '../types'; import type { WorkflowDefinition } from '../types';
@ -32,6 +44,7 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
}) => { }) => {
const formRef = useRef<FormRendererRef>(null); const formRef = useRef<FormRendererRef>(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [showCancelConfirm, setShowCancelConfirm] = useState(false);
// 处理提交 // 处理提交
const handleSubmit = async (formData: Record<string, any>) => { const handleSubmit = async (formData: Record<string, any>) => {
@ -58,14 +71,14 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
// 处理取消 // 处理取消
const handleCancel = () => { const handleCancel = () => {
Modal.confirm({ setShowCancelConfirm(true);
title: '确认取消', };
content: '工作流将不会启动,确定要取消吗?',
onOk: () => { // 确认取消
const confirmCancel = () => {
formRef.current?.reset(); formRef.current?.reset();
setShowCancelConfirm(false);
onClose(); onClose();
},
});
}; };
// 处理表单提交触发 // 处理表单提交触发
@ -87,26 +100,28 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
const { schema } = formDefinition; const { schema } = formDefinition;
return ( return (
<>
<Modal <Modal
title={`启动工作流:${workflowDefinition.name}`} title={formDefinition.name || `启动工作流:${workflowDefinition.name}`}
open={open} open={open}
onCancel={handleCancel} onCancel={handleCancel}
width={schema.formConfig.formWidth || 600} width={schema.formConfig.formWidth || 600}
footer={[ footer={
<Button key="reset" variant="outline" onClick={() => formRef.current?.reset()}> <div style={{ display: 'flex', gap: '8px', justifyContent: 'flex-end' }}>
<Button variant="outline" onClick={() => formRef.current?.reset()}>
</Button>, </Button>
<Button key="cancel" variant="outline" onClick={handleCancel}> <Button variant="outline" onClick={handleCancel}>
</Button>, </Button>
<Button <Button
key="submit"
onClick={handleTriggerSubmit} onClick={handleTriggerSubmit}
disabled={loading} disabled={loading}
> >
{loading ? '启动中...' : '启动工作流'} {loading ? '启动中...' : '启动工作流'}
</Button>, </Button>
]} </div>
}
destroyOnClose destroyOnClose
> >
<FormRenderer <FormRenderer
@ -131,6 +146,26 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
<div><strong></strong>v{formDefinition.formVersion}</div> <div><strong></strong>v{formDefinition.formVersion}</div>
</div> </div>
</Modal> </Modal>
{/* 取消确认对话框 - 设置更高的 z-index 确保在 Modal 之上 */}
<AlertDialog open={showCancelConfirm} onOpenChange={setShowCancelConfirm}>
<AlertDialogPortal>
<AlertDialogOverlay style={{ zIndex: 1050 }} />
<AlertDialogContent style={{ zIndex: 1051 }}>
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel onClick={() => setShowCancelConfirm(false)}></AlertDialogCancel>
<AlertDialogAction onClick={confirmCancel}></AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialogPortal>
</AlertDialog>
</>
); );
}; };