增加审批组件

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 },
transform: (data: any[]) => {
return data.map((item: any) => ({
label: item.name,
value: item.id,
code: item.code,
label: item.appName, // ✅ 修正:使用 appName
value: item.appCode,
code: item.appCode, // ✅ 修正:使用 appCode
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 { Modal } from 'antd';
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 type { FormDefinitionResponse } from '@/pages/Form/Definition/types';
import type { WorkflowDefinition } from '../types';
@ -32,6 +44,7 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
}) => {
const formRef = useRef<FormRendererRef>(null);
const [loading, setLoading] = useState(false);
const [showCancelConfirm, setShowCancelConfirm] = useState(false);
// 处理提交
const handleSubmit = async (formData: Record<string, any>) => {
@ -58,14 +71,14 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
// 处理取消
const handleCancel = () => {
Modal.confirm({
title: '确认取消',
content: '工作流将不会启动,确定要取消吗?',
onOk: () => {
formRef.current?.reset();
onClose();
},
});
setShowCancelConfirm(true);
};
// 确认取消
const confirmCancel = () => {
formRef.current?.reset();
setShowCancelConfirm(false);
onClose();
};
// 处理表单提交触发
@ -87,50 +100,72 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
const { schema } = formDefinition;
return (
<Modal
title={`启动工作流:${workflowDefinition.name}`}
open={open}
onCancel={handleCancel}
width={schema.formConfig.formWidth || 600}
footer={[
<Button key="reset" variant="outline" onClick={() => formRef.current?.reset()}>
</Button>,
<Button key="cancel" variant="outline" onClick={handleCancel}>
</Button>,
<Button
key="submit"
onClick={handleTriggerSubmit}
disabled={loading}
>
{loading ? '启动中...' : '启动工作流'}
</Button>,
]}
destroyOnClose
>
<FormRenderer
ref={formRef}
fields={schema.fields}
formConfig={schema.formConfig}
onSubmit={handleSubmit}
/>
<>
<Modal
title={formDefinition.name || `启动工作流:${workflowDefinition.name}`}
open={open}
onCancel={handleCancel}
width={schema.formConfig.formWidth || 600}
footer={
<div style={{ display: 'flex', gap: '8px', justifyContent: 'flex-end' }}>
<Button variant="outline" onClick={() => formRef.current?.reset()}>
</Button>
<Button variant="outline" onClick={handleCancel}>
</Button>
<Button
onClick={handleTriggerSubmit}
disabled={loading}
>
{loading ? '启动中...' : '启动工作流'}
</Button>
</div>
}
destroyOnClose
>
<FormRenderer
ref={formRef}
fields={schema.fields}
formConfig={schema.formConfig}
onSubmit={handleSubmit}
/>
{/* 表单元信息 */}
<div style={{
marginTop: 16,
padding: 12,
background: '#f5f5f5',
borderRadius: 4,
fontSize: 12,
color: '#666'
}}>
<div><strong></strong>{workflowDefinition.key}</div>
<div><strong></strong>v{workflowDefinition.flowVersion}</div>
<div><strong></strong>{formDefinition.key}</div>
<div><strong></strong>v{formDefinition.formVersion}</div>
</div>
</Modal>
{/* 表单元信息 */}
<div style={{
marginTop: 16,
padding: 12,
background: '#f5f5f5',
borderRadius: 4,
fontSize: 12,
color: '#666'
}}>
<div><strong></strong>{workflowDefinition.key}</div>
<div><strong></strong>v{workflowDefinition.flowVersion}</div>
<div><strong></strong>{formDefinition.key}</div>
<div><strong></strong>v{formDefinition.formVersion}</div>
</div>
</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>
</>
);
};