增加审批组件

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: () => { // 确认取消
formRef.current?.reset(); const confirmCancel = () => {
onClose(); formRef.current?.reset();
}, setShowCancelConfirm(false);
}); onClose();
}; };
// 处理表单提交触发 // 处理表单提交触发
@ -87,50 +100,72 @@ const StartWorkflowModal: React.FC<StartWorkflowModalProps> = ({
const { schema } = formDefinition; const { schema } = formDefinition;
return ( return (
<Modal <>
title={`启动工作流:${workflowDefinition.name}`} <Modal
open={open} title={formDefinition.name || `启动工作流:${workflowDefinition.name}`}
onCancel={handleCancel} open={open}
width={schema.formConfig.formWidth || 600} onCancel={handleCancel}
footer={[ width={schema.formConfig.formWidth || 600}
<Button key="reset" variant="outline" onClick={() => formRef.current?.reset()}> footer={
<div style={{ display: 'flex', gap: '8px', justifyContent: 'flex-end' }}>
</Button>, <Button variant="outline" onClick={() => formRef.current?.reset()}>
<Button key="cancel" variant="outline" onClick={handleCancel}>
</Button>
</Button>, <Button variant="outline" onClick={handleCancel}>
<Button
key="submit" </Button>
onClick={handleTriggerSubmit} <Button
disabled={loading} onClick={handleTriggerSubmit}
> disabled={loading}
{loading ? '启动中...' : '启动工作流'} >
</Button>, {loading ? '启动中...' : '启动工作流'}
]} </Button>
destroyOnClose </div>
> }
<FormRenderer destroyOnClose
ref={formRef} >
fields={schema.fields} <FormRenderer
formConfig={schema.formConfig} ref={formRef}
onSubmit={handleSubmit} fields={schema.fields}
/> formConfig={schema.formConfig}
onSubmit={handleSubmit}
/>
{/* 表单元信息 */} {/* 表单元信息 */}
<div style={{ <div style={{
marginTop: 16, marginTop: 16,
padding: 12, padding: 12,
background: '#f5f5f5', background: '#f5f5f5',
borderRadius: 4, borderRadius: 4,
fontSize: 12, fontSize: 12,
color: '#666' color: '#666'
}}> }}>
<div><strong></strong>{workflowDefinition.key}</div> <div><strong></strong>{workflowDefinition.key}</div>
<div><strong></strong>v{workflowDefinition.flowVersion}</div> <div><strong></strong>v{workflowDefinition.flowVersion}</div>
<div><strong></strong>{formDefinition.key}</div> <div><strong></strong>{formDefinition.key}</div>
<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>
</>
); );
}; };