|
| 1 | +import React from "react"; |
| 2 | +import {FlowData} from "@/components/Flow/flow/data"; |
| 3 | +import {Skeleton, Tabs} from "antd"; |
| 4 | +import {FlowFormView, FlowFormViewProps} from "@/components/Flow/flow/types"; |
| 5 | +import {FormInstance} from "antd/es/form/hooks/useForm"; |
| 6 | +import FlowHistory from "@/components/Flow/flow/FlowHistory"; |
| 7 | +import FlowChart from "@/components/Flow/flow/FlowChart"; |
| 8 | +import FlowDetail from "@/components/Flow/flow/FlowDetail"; |
| 9 | + |
| 10 | + |
| 11 | +interface FlowTabsProps { |
| 12 | + flowData: FlowData; |
| 13 | + view: React.ComponentType<FlowFormViewProps> | FlowFormView; |
| 14 | + visible: boolean; |
| 15 | + form: FormInstance<any>; |
| 16 | + adviceForm: FormInstance<any>; |
| 17 | + // 预览模式 |
| 18 | + review?: boolean; |
| 19 | +} |
| 20 | + |
| 21 | +const FlowTabs: React.FC<FlowTabsProps> = (props) => { |
| 22 | + |
| 23 | + const flowData = props.flowData; |
| 24 | + |
| 25 | + if (!flowData.hasData()) { |
| 26 | + return ( |
| 27 | + <Tabs |
| 28 | + className="view-flow-tabs" |
| 29 | + items={[ |
| 30 | + { |
| 31 | + key: 'flow', |
| 32 | + label: '流程详情', |
| 33 | + children: ( |
| 34 | + <Skeleton loading={true}> |
| 35 | + <></> |
| 36 | + </Skeleton> |
| 37 | + ), |
| 38 | + }, |
| 39 | + { |
| 40 | + key: 'history', |
| 41 | + label: '流程历史', |
| 42 | + children: ( |
| 43 | + <Skeleton loading={true}> |
| 44 | + <></> |
| 45 | + </Skeleton> |
| 46 | + ), |
| 47 | + }, |
| 48 | + { |
| 49 | + key: 'chart', |
| 50 | + label: '流程图', |
| 51 | + children: ( |
| 52 | + <Skeleton loading={true}> |
| 53 | + <></> |
| 54 | + </Skeleton> |
| 55 | + ), |
| 56 | + } |
| 57 | + ]} |
| 58 | + /> |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | + |
| 63 | + const items = [ |
| 64 | + { |
| 65 | + key: 'flow', |
| 66 | + label: '流程详情', |
| 67 | + children: ( |
| 68 | + <FlowDetail |
| 69 | + flowData={flowData} |
| 70 | + adviceForm={props.adviceForm} |
| 71 | + form={props.form} |
| 72 | + visible={props.visible} |
| 73 | + view={props.view}/> |
| 74 | + ), |
| 75 | + }, |
| 76 | + !flowData.isStartFlow() && { |
| 77 | + key: 'history', |
| 78 | + label: '流程历史', |
| 79 | + children: <FlowHistory flowData={flowData}/>, |
| 80 | + }, |
| 81 | + { |
| 82 | + key: 'chart', |
| 83 | + label: '流程图', |
| 84 | + children: <FlowChart flowData={flowData}/>, |
| 85 | + } |
| 86 | + ] as any[]; |
| 87 | + |
| 88 | + return ( |
| 89 | + <Tabs |
| 90 | + className="view-flow-tabs" |
| 91 | + items={items} |
| 92 | + /> |
| 93 | + ) |
| 94 | +} |
| 95 | + |
| 96 | +export default FlowTabs; |
0 commit comments