1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
import React, { useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { reloadFlows, removeFlowExtend } from '@/services/flow/flow';
import { Card, Space, Table, Popconfirm, Spin, Tooltip, notification, message, Button } from 'antd';
import {
DoubleLeftOutlined,
DoubleRightOutlined,
EditTwoTone,
ApartmentOutlined,
DeleteOutlined,
OrderedListOutlined,
ControlOutlined,
} from '@ant-design/icons';
import classnames from 'classnames';
import PageContainer from '@/components/BasePageContainer';
import ProcessConfig from './flowComponents/ProcessConfig';
import Order from './flowComponents/Order';
import Timelimit from './flowComponents/Timelimit';
import styles from './flow.less';
const Flow = () => {
const history = useHistory();
const [tableData, setTableData] = useState([]); // 流程对应的回显的表格
const [processData, setProcessData] = useState([]); // 流程列表总
const [dataSource, setDataSource] = useState(''); // 是否是返回获取数据
const [processMsg, setProcessMsg] = useState({}); // 流程配置回显信息
const [treeLoading, setTreeLoading] = useState(false);
const [treeVisible, setTreeVisible] = useState(true);
const [pickItemIndex, setPickItemIndex] = useState(0); // 选中流程索引
const [hoverItemIndex, setHoverItemIndex] = useState(0); // hover流程索引
const [visible, setVisible] = useState({
processConfig: false,
order: false,
auxiliaryView: false,
}); // 弹窗显示
// 初始化
useEffect(() => {
// 初始化流程列表
getProcessData();
if (history.location.state && history.location.state.pickItemIndex) {
setDataSource('back');
}
}, []);
// 表格数据改变后处理
useEffect(() => {
// 判断是否是返回回来的页面
if (processData.length === 0) {
return;
}
if (dataSource === 'back') {
setPickItemIndex(history.location.state.pickItemIndex);
setTableData(processData[history.location.state.pickItemIndex].root);
} else {
setTableData(processData[pickItemIndex].root);
}
}, [processData]);
// 弹窗显示控制
const showModal = (key, value) => {
setVisible({ ...visible, [key]: value });
};
// 初始化流程列表
const getProcessData = () => {
setTreeLoading(true);
reloadFlows()
.then(res => {
setTreeLoading(false);
if (res.code === 0) {
setProcessData(res.data);
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
})
.catch(() => {
setTreeLoading(false);
notification.error({
message: '提示',
duration: 3,
description: '网络异常',
});
});
};
// 删除流程
const delProcess = val => {
removeFlowExtend({ flowIDs: val.extendID })
.then(res => {
if (res.code === 0) {
setDataSource('current');
getProcessData();
notification.success({
message: '提示',
duration: 3,
description: '清除成功',
});
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
}
})
.catch(() => {
notification.error({
message: '提示',
duration: 3,
description: '网络异常',
});
});
};
// 跳转到对应的流程节点
const toNode = flowName => {
console.log(flowName);
history.push({
pathname: '/biz/workflow/caseNode',
state: { flowName, pickItemIndex },
});
};
// 定义表格
const columns = [
{ title: '名称', dataIndex: 'name', width: 150, align: 'center' },
{
title: '前端样式',
dataIndex: 'extendWebPage',
align: 'center',
render: text => (
<span style={{ color: text === '(默认)' ? 'grey' : '000000D9' }}>{text}</span>
),
},
{
title: '手持样式',
dataIndex: 'extendMobilePage',
align: 'center',
render: text => (
<span style={{ color: text === '(默认)' ? 'grey' : '000000D9' }}>{text}</span>
),
},
{
title: '辅助视图',
dataIndex: 'extendPageCount',
align: 'center',
width: 80,
render: text => <span style={{ color: text === '(无)' ? 'grey' : '000000D9' }}>{text}</span>,
},
{
title: '流程结束后',
dataIndex: 'flowEndBehavior',
align: 'center',
render: text => (
<span style={{ color: text === '(不做处理)' ? 'grey' : '000000D9' }}>{text}</span>
),
},
{
title: '12位编码',
dataIndex: 'useFixedCodingRule',
width: 80,
align: 'center',
},
{
title: '异常节点',
dataIndex: 'errorNodes',
align: 'center',
render: text => <span style={{ color: text === '(无)' ? 'grey' : 'red' }}>{text}</span>,
},
{
title: '接口配置',
dataIndex: 'interfaceConfig',
align: 'center',
render: text => <span style={{ color: text === '(无)' ? 'grey' : '000000D9' }}>{text}</span>,
},
{
title: '操作',
align: 'center',
ellipsis: true,
render: record => (
<>
<Space>
<Tooltip title="流程配置">
<EditTwoTone
onClick={() => {
showModal('processConfig', true);
setProcessMsg(record);
}}
style={{ fontSize: '16px', color: '#1890FF' }}
/>
</Tooltip>
<Tooltip title="时限配置">
<ControlOutlined
onClick={() => {
showModal('auxiliaryView', true);
setProcessMsg(record);
}}
style={{ fontSize: '16px', color: '#1890FF' }}
/>
</Tooltip>
<Tooltip title="节点配置">
<ApartmentOutlined
onClick={() => toNode(record.name)}
style={{ fontSize: '16px', color: '#1890FF' }}
/>
</Tooltip>
<Tooltip title="清除流程配置">
<Popconfirm
title="是否清除该流程配置?"
onConfirm={() => delProcess(record)}
onCancel={() => message.error('取消清除')}
okText="是"
cancelText="否"
>
<DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
</Popconfirm>
</Tooltip>
</Space>
</>
),
},
];
return (
<PageContainer>
<div className={styles.flowContainer}>
{/* 左侧事件树 */}
<Spin spinning={treeLoading} tip="loading...">
<Card
className={classnames({
[styles.orgContainer]: true,
[styles.orgContainerHide]: !treeVisible,
})}
>
<div style={{ height: '100%', display: `${treeVisible ? 'block' : 'none'}` }}>
<span className={styles.processTitle}>流程列表</span>
<hr className={styles.splitLine} />
{/* 流程列表 */}
<div style={{ overflowY: 'scroll', height: 'calc(100% - 30px)' }}>
{processData.length > 0 &&
processData.map((item, index) => (
<div
className={classnames({
[styles.listItem]: true,
[styles.pickItem]: index === pickItemIndex,
[styles.listHover]: index !== pickItemIndex && index === hoverItemIndex,
})}
onMouseEnter={() => {
setHoverItemIndex(index);
}}
onMouseLeave={() => {
setHoverItemIndex('');
}}
onClick={() => {
setPickItemIndex(index);
setTableData(item.root);
}}
key={item.goupName}
>
{item.goupName}({item.count ? item.count : ''})
</div>
))}
</div>
</div>
<div className={styles.switcher}>
{treeVisible && (
<Tooltip title="隐藏流程列表">
<DoubleLeftOutlined onClick={() => setTreeVisible(false)} />
</Tooltip>
)}
{!treeVisible && (
<Tooltip title="显示流程列表">
<DoubleRightOutlined onClick={() => setTreeVisible(true)} />
</Tooltip>
)}
</div>
</Card>
</Spin>
{/* 右侧流程表 */}
<div className={styles.processContainer}>
<div className={styles.buttonList}>
<Button
onClick={() => {
showModal('order', true);
}}
>
<OrderedListOutlined />
排序
</Button>
</div>
<Table
dataSource={tableData}
columns={columns}
rowKey={record => record.ID}
bordered
size="small"
scroll={{ x: 'max-content', y: 'calc(100% - 40px)' }}
onRow={record => ({
onDoubleClick: () => {
toNode(record.name);
},
})}
pagination={{
showTotal: (total, range) => `第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 20,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</div>
</div>
{/* 流程配置弹窗 */}
<ProcessConfig
visible={visible.processConfig}
processMsg={processMsg}
handleCancel={() => showModal('processConfig', false)}
onSubumit={() => {
showModal('processConfig', false);
setDataSource('current');
getProcessData();
}}
/>
{/* 排序弹窗 */}
<Order
visible={visible.order}
tableData={tableData}
processData={processData}
handleCancel={() => showModal('order', false)}
submitCallBack={() => {
showModal('order', false);
setDataSource('current');
getProcessData();
}}
/>
{/* 流程时限配置 */}
<Timelimit
visible={visible.auxiliaryView}
msg={processMsg}
handleCancel={() => showModal('auxiliaryView', false)}
/>
</PageContainer>
);
};
export default Flow;