Skip to content

Commit 5b97427

Browse files
authored
Merge pull request #83 from codingapi/dev
Dev
2 parents 3b5ccdb + eb3fb9a commit 5b97427

File tree

78 files changed

+2033
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2033
-388
lines changed

admin-ui/src/components/Flow/flow/FlowChart.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ import Circulate from "@/components/Flow/nodes/Circulate";
99
import '@logicflow/core/es/index.css';
1010
import '@logicflow/extension/lib/style/index.css';
1111
import "./FlowChart.scss";
12+
import {EdgeType} from "@/components/Flow/flow/types";
1213

1314
interface FlowChartProps {
14-
flowData: FlowData
15+
flowData: FlowData;
16+
edgeType?: EdgeType;
1517
}
1618

1719
const FlowChart: React.FC<FlowChartProps> = (props) => {
1820

1921
const flowData = props.flowData;
20-
22+
const edgeType = props.edgeType || 'polyline';
2123
const container = useRef<HTMLDivElement>(null);
2224
const lfRef = useRef<LogicFlow>(null);
2325

@@ -40,14 +42,22 @@ const FlowChart: React.FC<FlowChartProps> = (props) => {
4042
},
4143
plugins: [Menu, DndPanel, MiniMap, Snapshot],
4244
grid: false,
43-
edgeType: 'bezier',
45+
edgeType: edgeType,
4446
});
4547

4648
lfRef.current.setTheme({
4749
bezier: {
4850
stroke: '#8f94e3',
4951
strokeWidth: 1,
5052
},
53+
polyline: {
54+
stroke: '#8f94e3',
55+
strokeWidth: 1,
56+
},
57+
line: {
58+
stroke: '#8f94e3',
59+
strokeWidth: 1,
60+
},
5161
});
5262
lfRef.current.register(Start);
5363
lfRef.current.register(Node);

admin-ui/src/components/Flow/flow/FlowDetail.tsx

+43-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import React from "react";
2-
import { Divider, Result } from "antd";
3-
import { ProForm, ProFormTextArea } from "@ant-design/pro-components";
1+
import React, {useEffect} from "react";
2+
import {Divider, Result} from "antd";
3+
import {ProForm, ProFormTextArea} from "@ant-design/pro-components";
44
import {CustomButtonType, FlowFormView, FlowFormViewProps} from "@/components/Flow/flow/types";
5-
import { FlowData } from "@/components/Flow/flow/data";
5+
import {FlowData} from "@/components/Flow/flow/data";
66
import {useDispatch, useSelector} from "react-redux";
7-
import {clearTriggerClick, FlowReduxState} from "@/components/Flow/store/FlowSlice";
7+
import {FlowReduxState, hideOpinionEditor, showOpinionEditor} from "@/components/Flow/store/FlowSlice";
8+
import {FormInstance} from "antd/es/form/hooks/useForm";
89

910
interface FlowDetailProps {
1011
view: React.ComponentType<FlowFormViewProps> | FlowFormView;
11-
visible: boolean;
12-
form: any;
13-
adviceForm: any;
12+
form: FormInstance<any>;
13+
adviceForm: FormInstance<any>;
1414
review?: boolean;
1515
flowData: FlowData;
16+
// 请求数据加载
17+
requestLoading: boolean;
18+
// 设置请求数据加载状态
19+
setRequestLoading: (loading: boolean) => void;
1620
// 流程交互操作
1721
handlerClick: (data: {
1822
type: CustomButtonType;
@@ -25,28 +29,51 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
2529

2630
const FlowFormView = flowData.getFlowFormView(props.view) as React.ComponentType<FlowFormViewProps>;
2731

28-
// 触发点击事件
29-
const triggerClickVisible = useSelector((state: FlowReduxState) => state.flow.triggerClickVisible);
32+
// 触发点击事件Key
33+
const eventKey = useSelector((state: FlowReduxState) => state.flow.eventKey);
34+
35+
// 审批意见输入框
36+
const opinionEditorVisible = useSelector((state: FlowReduxState) => state.flow.opinionEditorVisible);
37+
38+
// 流程视图内容
39+
const flowViewVisible = useSelector((state: FlowReduxState) => state.flow.flowViewVisible);
3040

3141
// flow store redux
3242
const dispatch = useDispatch();
3343

44+
useEffect(() => {
45+
if (flowViewVisible) {
46+
const advice = flowData.getOpinionAdvice();
47+
props.adviceForm.setFieldsValue({
48+
advice: advice
49+
});
50+
}
51+
}, [flowViewVisible]);
52+
3453
return (
3554
<>
3655
<div className="flowApprovalViewBox">
3756
{FlowFormView && (
38-
<div className="flowViewDetail" style={{ height: !FlowFormView || flowData.isStartFlow() ? '85vh' : '68vh' }}>
57+
<div className="flowViewDetail"
58+
style={{height: !FlowFormView || flowData.isStartFlow() ? '85vh' : '68vh'}}>
3959
<FlowFormView
4060
handlerClick={props.handlerClick}
4161
data={flowData.getFlowData()}
4262
form={props.form}
4363
flowData={flowData}
44-
visible={props.visible}
64+
visible={flowViewVisible}
65+
opinions={flowData.getOpinions()}
4566
editable={!flowData.isDone() && flowData.getFlowNodeEditable()}
4667
compare={!flowData.isStartFlow()}
47-
triggerClickVisible={triggerClickVisible}
48-
clearTriggerClick={() => {
49-
dispatch(clearTriggerClick());
68+
eventKey={eventKey}
69+
requestLoading={props.requestLoading}
70+
setRequestLoading={props.setRequestLoading}
71+
opinionEditorVisible={(visible) => {
72+
if (visible) {
73+
dispatch(showOpinionEditor());
74+
} else {
75+
dispatch(hideOpinionEditor());
76+
}
5077
}}
5178
/>
5279
</div>
@@ -61,7 +88,7 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
6188
)}
6289

6390
{/*仅当非发起流程时再展示审批意见框*/}
64-
{FlowFormView && flowData.showOpinion() && (
91+
{FlowFormView && opinionEditorVisible && (
6592
<div className="opinionForm">
6693
<div>
6794
<Divider>
@@ -74,7 +101,6 @@ const FlowDetail: React.FC<FlowDetailProps> = (props) => {
74101
>
75102
<ProFormTextArea
76103
disabled={props.review}
77-
label={""}
78104
placeholder={'请输入审批意见'}
79105
name={"advice"}
80106
/>

admin-ui/src/components/Flow/flow/FlowTabs.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ import {FormInstance} from "antd/es/form/hooks/useForm";
66
import FlowHistory from "@/components/Flow/flow/FlowHistory";
77
import FlowChart from "@/components/Flow/flow/FlowChart";
88
import FlowDetail from "@/components/Flow/flow/FlowDetail";
9+
import {useSelector} from "react-redux";
10+
import {FlowReduxState} from "@/components/Flow/store/FlowSlice";
911

1012

1113
interface FlowTabsProps {
1214
flowData: FlowData;
1315
view: React.ComponentType<FlowFormViewProps> | FlowFormView;
14-
visible: boolean;
1516
form: FormInstance<any>;
1617
adviceForm: FormInstance<any>;
1718
// 预览模式
1819
review?: boolean;
20+
// 请求数据加载
21+
requestLoading: boolean;
22+
// 设置请求数据加载状态
23+
setRequestLoading: (loading: boolean) => void;
1924

2025
// 流程交互操作
2126
handlerClick: (data: {
@@ -76,7 +81,8 @@ const FlowTabs: React.FC<FlowTabsProps> = (props) => {
7681
flowData={flowData}
7782
adviceForm={props.adviceForm}
7883
form={props.form}
79-
visible={props.visible}
84+
requestLoading={props.requestLoading}
85+
setRequestLoading={props.setRequestLoading}
8086
view={props.view}/>
8187
),
8288
},

admin-ui/src/components/Flow/flow/FlowTitle.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import React from "react";
22
import {Button, Space} from "antd";
33
import {FlowData} from "@/components/Flow/flow/data";
44
import FlowButtons from "@/components/Flow/flow/FlowButtons";
5+
import {useDispatch} from "react-redux";
6+
import {hideFlowView} from "@/components/Flow/store/FlowSlice";
57

68
interface FlowTitleProps {
7-
setVisible: (visible: boolean) => void;
89
flowData: FlowData;
910
requestLoading: boolean;
1011
setRequestLoading: (loading: boolean) => void;
@@ -17,6 +18,9 @@ const FlowTitle: React.FC<FlowTitleProps> = (props) => {
1718

1819
const title = flowData.getCurrentNodeTitle();
1920

21+
// flow store redux
22+
const dispatch = useDispatch();
23+
2024
return (
2125
<div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
2226
<h3 style={{margin: 0}}>{title}</h3>
@@ -31,7 +35,7 @@ const FlowTitle: React.FC<FlowTitleProps> = (props) => {
3135

3236
<Button
3337
onClick={() => {
34-
props.setVisible(false);
38+
dispatch(hideFlowView());
3539
}}
3640
>
3741
关闭

admin-ui/src/components/Flow/flow/data.ts

+49-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,24 @@ export class FlowData extends FlowWorkData {
121121
// 获取当前节点的按钮
122122
getNodeButtons = () => {
123123
if (this.data) {
124-
return this.data.flowNode.buttons;
124+
const buttons = this.data.flowNode.buttons;
125+
if(buttons){
126+
return buttons.sort((item1:any, item2:any) => {
127+
return item1.order - item2.order;
128+
})
129+
}
130+
return [];
131+
}
132+
return null;
133+
}
134+
135+
// 获取当前节点的按钮
136+
getNodeButton = (buttonId: string) => {
137+
if (this.data) {
138+
const buttons = this.data.flowNode.buttons;
139+
if(buttons){
140+
return buttons.find((item:any) => item.id === buttonId);
141+
}
125142
}
126143
return null;
127144
}
@@ -169,20 +186,23 @@ export class FlowData extends FlowWorkData {
169186
getNodeState = (code: string) => {
170187
const historyRecords = this.data.historyRecords || [];
171188

172-
173-
if (this.isFinished()) {
189+
if (code==='over' && this.isFinished()) {
174190
return "done";
175191
}
176192

177193
for (const record of historyRecords) {
178194
if (record.nodeCode === code) {
179195
if (record.flowType === 'TODO') {
180-
return "wait";
196+
return "current";
181197
}
182198
return "done";
183199
}
184200
}
185201

202+
if(this.isFinished()){
203+
return "undone";
204+
}
205+
186206
return "wait";
187207
}
188208

@@ -211,6 +231,30 @@ export class FlowData extends FlowWorkData {
211231
return this.data.flowRecord;
212232
}
213233

234+
// 获取审批意见
235+
getOpinionAdvice = () => {
236+
if(this.data.flowRecord){
237+
if(this.data.flowRecord.opinion){
238+
return this.data.flowRecord.opinion.advice;
239+
}
240+
}
241+
return null;
242+
}
243+
244+
245+
// 获取历史审批意见
246+
getOpinions() {
247+
if(this.data.opinions){
248+
return this.data.opinions.filter((item:any)=>{
249+
if(!item.opinion){
250+
return false;
251+
}
252+
return item.opinion.result!==0;
253+
});
254+
}
255+
return [];
256+
}
257+
214258
// 获取历史记录
215259
getHistoryRecords = () => {
216260
return this.data.historyRecords;
@@ -244,5 +288,6 @@ export class FlowData extends FlowWorkData {
244288
showOpinion() {
245289
return this.canHandle() && !this.isStartFlow();
246290
}
291+
247292
}
248293

0 commit comments

Comments
 (0)