@hzab/flowlong-designer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +67 -0
- package/package.json +51 -0
- package/src/common/flowData.ts +42 -0
- package/src/components/NodeWrap/Nodes/AddNode/index.less +38 -0
- package/src/components/NodeWrap/Nodes/AddNode/index.tsx +119 -0
- package/src/components/NodeWrap/Nodes/Approver/index.less +72 -0
- package/src/components/NodeWrap/Nodes/Approver/index.tsx +385 -0
- package/src/components/NodeWrap/Nodes/Approver/options.ts +44 -0
- package/src/components/NodeWrap/Nodes/Branch/index.less +319 -0
- package/src/components/NodeWrap/Nodes/Branch/index.tsx +387 -0
- package/src/components/NodeWrap/Nodes/Promoter/index.less +10 -0
- package/src/components/NodeWrap/Nodes/Promoter/index.tsx +178 -0
- package/src/components/NodeWrap/Nodes/Send/index.less +7 -0
- package/src/components/NodeWrap/Nodes/Send/index.tsx +201 -0
- package/src/components/NodeWrap/index.less +29 -0
- package/src/components/NodeWrap/index.tsx +30 -0
- package/src/components/ScWorkflow/index.tsx +23 -0
- package/src/components/Selector/SelectContext.tsx +32 -0
- package/src/components/Selector/index.less +139 -0
- package/src/components/Selector/index.tsx +240 -0
- package/src/index.less +466 -0
- package/src/index.tsx +134 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { useRef, useState, useContext } from "react";
|
|
2
|
+
import { Drawer, Input, Button, Form, Select, Tag, InputNumber, Radio, Checkbox, Switch } from "antd";
|
|
3
|
+
import { UserOutlined, DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons";
|
|
4
|
+
|
|
5
|
+
import AddNode from "../AddNode";
|
|
6
|
+
import { setTypeOptions, selectModeOptions, directorModeOptions, termModeOptions, examineModeOptions } from "./options";
|
|
7
|
+
|
|
8
|
+
import { SelectContext } from "../../../Selector/SelectContext";
|
|
9
|
+
|
|
10
|
+
import "./index.less";
|
|
11
|
+
|
|
12
|
+
export const Approver = (props) => {
|
|
13
|
+
const { modelValue = {}, onChange } = props;
|
|
14
|
+
const [form, setForm] = useState({
|
|
15
|
+
nodeName: "",
|
|
16
|
+
setType: undefined,
|
|
17
|
+
nodeAssigneeList: [],
|
|
18
|
+
directorMode: undefined,
|
|
19
|
+
termAuto: false,
|
|
20
|
+
examineLevel: undefined,
|
|
21
|
+
selectMode: undefined,
|
|
22
|
+
directorLevel: undefined,
|
|
23
|
+
term: undefined,
|
|
24
|
+
termMode: undefined,
|
|
25
|
+
examineMode: undefined,
|
|
26
|
+
});
|
|
27
|
+
const [drawer, setDrawer] = useState(false);
|
|
28
|
+
const [isEditTitle, setIsEditTitle] = useState(false);
|
|
29
|
+
|
|
30
|
+
const selectorCtx = useContext(SelectContext);
|
|
31
|
+
|
|
32
|
+
const formRef = useRef();
|
|
33
|
+
const nodeTitleRef = useRef();
|
|
34
|
+
|
|
35
|
+
function onShow() {
|
|
36
|
+
setDrawer(true);
|
|
37
|
+
setForm(JSON.parse(JSON.stringify(modelValue)));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function onNodeDel(e) {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
onChange && onChange(modelValue.childNode);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function toText(nodeConf) {
|
|
46
|
+
if (nodeConf.setType == 1) {
|
|
47
|
+
if (nodeConf.nodeAssigneeList && nodeConf.nodeAssigneeList.length > 0) {
|
|
48
|
+
const users = nodeConf.nodeAssigneeList.map((item) => item.name).join("、");
|
|
49
|
+
return users;
|
|
50
|
+
} else {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
} else if (nodeConf.setType == 2) {
|
|
54
|
+
return nodeConf.examineLevel == 1 ? "直接主管" : `发起人的第${nodeConf.examineLevel}级主管`;
|
|
55
|
+
} else if (nodeConf.setType == 3) {
|
|
56
|
+
if (nodeConf.nodeAssigneeList && nodeConf.nodeAssigneeList.length > 0) {
|
|
57
|
+
const roles = nodeConf.nodeAssigneeList.map((item) => item.name).join("、");
|
|
58
|
+
return "角色-" + roles;
|
|
59
|
+
} else {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
} else if (nodeConf.setType == 4) {
|
|
63
|
+
return "发起人自选";
|
|
64
|
+
} else if (nodeConf.setType == 5) {
|
|
65
|
+
return "发起人自己";
|
|
66
|
+
} else if (nodeConf.setType == 7) {
|
|
67
|
+
return "连续多级主管";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function onSaveTitle(e) {
|
|
72
|
+
setForm((f) => {
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
f.nodeName = nodeTitleRef.current?.input?.value;
|
|
75
|
+
return { ...f };
|
|
76
|
+
});
|
|
77
|
+
setIsEditTitle(false);
|
|
78
|
+
}
|
|
79
|
+
function onEditTitle() {
|
|
80
|
+
setIsEditTitle(true);
|
|
81
|
+
if (nodeTitleRef.current) {
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
nodeTitleRef.current?.focus();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function onDrawerSave() {
|
|
88
|
+
// 强制更新数据
|
|
89
|
+
onChange && onChange(form);
|
|
90
|
+
onDrawerClose();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function onDrawerClose() {
|
|
94
|
+
setDrawer(false);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function onUserDel(idx) {
|
|
98
|
+
setForm((f) => {
|
|
99
|
+
f.nodeAssigneeList.splice(idx, 1);
|
|
100
|
+
return { ...f };
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function onRoleDel(idx) {
|
|
105
|
+
setForm((f) => {
|
|
106
|
+
f.nodeAssigneeList.splice(idx, 1);
|
|
107
|
+
return { ...f };
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<div className="approver-wrap">
|
|
113
|
+
<div className="node-wrap">
|
|
114
|
+
<div className="node-wrap-box" onClick={onShow}>
|
|
115
|
+
<div className="title" style={{ background: "#ff943e" }}>
|
|
116
|
+
<UserOutlined />
|
|
117
|
+
<span>{modelValue?.nodeName}</span>
|
|
118
|
+
<DeleteOutlined className="node-close-btn" onClick={onNodeDel} />
|
|
119
|
+
</div>
|
|
120
|
+
<div className="content">
|
|
121
|
+
{toText(modelValue) ? <span>{toText(modelValue)}</span> : <span className="placeholder">请选择</span>}
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<AddNode
|
|
126
|
+
modelValue={modelValue?.childNode}
|
|
127
|
+
onChange={(val) => {
|
|
128
|
+
modelValue.childNode = val;
|
|
129
|
+
// 强制更新数据
|
|
130
|
+
onChange && onChange({ ...modelValue });
|
|
131
|
+
}}
|
|
132
|
+
></AddNode>
|
|
133
|
+
|
|
134
|
+
<Drawer
|
|
135
|
+
width={600}
|
|
136
|
+
title={
|
|
137
|
+
<div className="node-wrap-drawer-title">
|
|
138
|
+
{isEditTitle ? (
|
|
139
|
+
<Input
|
|
140
|
+
ref={nodeTitleRef}
|
|
141
|
+
autoFocus
|
|
142
|
+
defaultValue={form.nodeName}
|
|
143
|
+
onBlur={onSaveTitle}
|
|
144
|
+
onPressEnter={onSaveTitle}
|
|
145
|
+
/>
|
|
146
|
+
) : (
|
|
147
|
+
<div className="drawer-title">
|
|
148
|
+
{form.nodeName || "审批人设置"}
|
|
149
|
+
<EditOutlined className="node-wrap-drawer__title-edit" onClick={onEditTitle} />
|
|
150
|
+
</div>
|
|
151
|
+
)}
|
|
152
|
+
</div>
|
|
153
|
+
}
|
|
154
|
+
open={drawer}
|
|
155
|
+
onClose={onDrawerClose}
|
|
156
|
+
destroyOnClose
|
|
157
|
+
getContainer="body"
|
|
158
|
+
footer={
|
|
159
|
+
<div className="approver-drawer-footer">
|
|
160
|
+
<Button type="primary" onClick={onDrawerSave}>
|
|
161
|
+
保存
|
|
162
|
+
</Button>
|
|
163
|
+
<Button onClick={onDrawerClose}>取消</Button>
|
|
164
|
+
</div>
|
|
165
|
+
}
|
|
166
|
+
>
|
|
167
|
+
<Form
|
|
168
|
+
ref={formRef}
|
|
169
|
+
name="approverForm"
|
|
170
|
+
labelCol={{ span: 8 }}
|
|
171
|
+
wrapperCol={{ span: 16 }}
|
|
172
|
+
initialValues={form}
|
|
173
|
+
autoComplete="off"
|
|
174
|
+
>
|
|
175
|
+
<Form.Item label="审批人员类型" name="setType">
|
|
176
|
+
<Select
|
|
177
|
+
options={setTypeOptions}
|
|
178
|
+
value={form.setType}
|
|
179
|
+
onSelect={(val) => {
|
|
180
|
+
setForm((f) => {
|
|
181
|
+
// 清空 人员、角色 列表数组
|
|
182
|
+
f.nodeAssigneeList = [];
|
|
183
|
+
f.setType = val;
|
|
184
|
+
return { ...f };
|
|
185
|
+
});
|
|
186
|
+
}}
|
|
187
|
+
/>
|
|
188
|
+
</Form.Item>
|
|
189
|
+
|
|
190
|
+
{form.setType === 1 ? (
|
|
191
|
+
<Form.Item label="选择成员" name="nodeAssigneeList">
|
|
192
|
+
<Button
|
|
193
|
+
type="primary"
|
|
194
|
+
icon={<PlusOutlined />}
|
|
195
|
+
onClick={() =>
|
|
196
|
+
selectorCtx.setSelectHandler(1, form.nodeAssigneeList, (selected) => {
|
|
197
|
+
setForm((f) => {
|
|
198
|
+
// 设置 人员、角色 列表数组
|
|
199
|
+
f.nodeAssigneeList = selected;
|
|
200
|
+
return { ...f };
|
|
201
|
+
});
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
>
|
|
205
|
+
选择人员
|
|
206
|
+
</Button>
|
|
207
|
+
<div className="tags-list">
|
|
208
|
+
{form.nodeAssigneeList?.map((user, idx) => {
|
|
209
|
+
return (
|
|
210
|
+
<Tag
|
|
211
|
+
key={user.id || idx}
|
|
212
|
+
className="node-assignee-item"
|
|
213
|
+
closable
|
|
214
|
+
onClose={() => {
|
|
215
|
+
onUserDel(idx);
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
{user.name}
|
|
219
|
+
</Tag>
|
|
220
|
+
);
|
|
221
|
+
})}
|
|
222
|
+
</div>
|
|
223
|
+
</Form.Item>
|
|
224
|
+
) : null}
|
|
225
|
+
|
|
226
|
+
{form.setType === 2 ? (
|
|
227
|
+
<Form.Item label="指定主管" name="aaa">
|
|
228
|
+
发起人的第
|
|
229
|
+
<InputNumber
|
|
230
|
+
min={1}
|
|
231
|
+
value={form.examineLevel}
|
|
232
|
+
onChange={(val) => {
|
|
233
|
+
setForm((f) => {
|
|
234
|
+
form.examineLevel = val;
|
|
235
|
+
return { ...f };
|
|
236
|
+
});
|
|
237
|
+
}}
|
|
238
|
+
/>
|
|
239
|
+
级主管
|
|
240
|
+
</Form.Item>
|
|
241
|
+
) : null}
|
|
242
|
+
|
|
243
|
+
{form.setType === 3 ? (
|
|
244
|
+
<Form.Item label="选择角色" name="nodeAssigneeList">
|
|
245
|
+
<Button
|
|
246
|
+
type="primary"
|
|
247
|
+
icon={<PlusOutlined />}
|
|
248
|
+
onClick={() =>
|
|
249
|
+
selectorCtx.setSelectHandler(2, form.nodeAssigneeList, (selected) => {
|
|
250
|
+
setForm((f) => {
|
|
251
|
+
// 设置 人员、角色 列表数组
|
|
252
|
+
f.nodeAssigneeList = selected;
|
|
253
|
+
return { ...f };
|
|
254
|
+
});
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
>
|
|
258
|
+
选择角色
|
|
259
|
+
</Button>
|
|
260
|
+
<div className="tags-list">
|
|
261
|
+
{form.nodeAssigneeList?.map((it, idx) => {
|
|
262
|
+
return (
|
|
263
|
+
<Tag
|
|
264
|
+
key={it.id || idx}
|
|
265
|
+
className="node-assignee-item"
|
|
266
|
+
closable
|
|
267
|
+
onClose={() => {
|
|
268
|
+
onRoleDel(idx);
|
|
269
|
+
}}
|
|
270
|
+
>
|
|
271
|
+
{it.name}
|
|
272
|
+
</Tag>
|
|
273
|
+
);
|
|
274
|
+
})}
|
|
275
|
+
</div>
|
|
276
|
+
</Form.Item>
|
|
277
|
+
) : null}
|
|
278
|
+
|
|
279
|
+
{form.setType === 4 ? (
|
|
280
|
+
<Form.Item label="指定主管" name="selectMode">
|
|
281
|
+
<Radio.Group
|
|
282
|
+
options={selectModeOptions}
|
|
283
|
+
value={form.selectMode}
|
|
284
|
+
onChange={(e) => {
|
|
285
|
+
setForm((f) => {
|
|
286
|
+
form.selectMode = e.target.value;
|
|
287
|
+
return { ...f };
|
|
288
|
+
});
|
|
289
|
+
}}
|
|
290
|
+
/>
|
|
291
|
+
</Form.Item>
|
|
292
|
+
) : null}
|
|
293
|
+
|
|
294
|
+
{form.setType === 7 ? (
|
|
295
|
+
<Form.Item label="指定主管" name="directorMode">
|
|
296
|
+
<Radio.Group
|
|
297
|
+
options={directorModeOptions}
|
|
298
|
+
value={form.directorMode}
|
|
299
|
+
onChange={(e) => {
|
|
300
|
+
setForm((f) => {
|
|
301
|
+
form.directorMode = e.target.value;
|
|
302
|
+
return { ...f };
|
|
303
|
+
});
|
|
304
|
+
}}
|
|
305
|
+
/>
|
|
306
|
+
</Form.Item>
|
|
307
|
+
) : null}
|
|
308
|
+
|
|
309
|
+
{form.directorMode === 1 ? (
|
|
310
|
+
<Form.Item label="直到发起人的第" name="directorLevel">
|
|
311
|
+
<InputNumber
|
|
312
|
+
min={1}
|
|
313
|
+
value={form.directorLevel}
|
|
314
|
+
onChange={(val) => {
|
|
315
|
+
setForm((f) => {
|
|
316
|
+
form.directorLevel = val;
|
|
317
|
+
return { ...f };
|
|
318
|
+
});
|
|
319
|
+
}}
|
|
320
|
+
/>{" "}
|
|
321
|
+
级主管
|
|
322
|
+
</Form.Item>
|
|
323
|
+
) : null}
|
|
324
|
+
|
|
325
|
+
<Form.Item label="超时自动审批" name="termAuto">
|
|
326
|
+
<Switch
|
|
327
|
+
checked={form.termAuto}
|
|
328
|
+
onChange={(val) => {
|
|
329
|
+
setForm((f) => {
|
|
330
|
+
form.termAuto = val;
|
|
331
|
+
return { ...f };
|
|
332
|
+
});
|
|
333
|
+
}}
|
|
334
|
+
></Switch>
|
|
335
|
+
</Form.Item>
|
|
336
|
+
|
|
337
|
+
{form.termAuto ? (
|
|
338
|
+
<>
|
|
339
|
+
<Form.Item label="审批期限(为 0 则不生效)" name="term">
|
|
340
|
+
<InputNumber
|
|
341
|
+
min={0}
|
|
342
|
+
value={form.term}
|
|
343
|
+
onChange={(val) => {
|
|
344
|
+
setForm((f) => {
|
|
345
|
+
form.term = val;
|
|
346
|
+
return { ...f };
|
|
347
|
+
});
|
|
348
|
+
}}
|
|
349
|
+
/>
|
|
350
|
+
</Form.Item>
|
|
351
|
+
<Form.Item label="审批期限超时后执行" name="termMode">
|
|
352
|
+
<Radio.Group
|
|
353
|
+
options={termModeOptions}
|
|
354
|
+
value={form.termMode}
|
|
355
|
+
onChange={(e) => {
|
|
356
|
+
setForm((f) => {
|
|
357
|
+
form.termMode = e.target.value;
|
|
358
|
+
return { ...f };
|
|
359
|
+
});
|
|
360
|
+
}}
|
|
361
|
+
/>
|
|
362
|
+
</Form.Item>
|
|
363
|
+
</>
|
|
364
|
+
) : null}
|
|
365
|
+
|
|
366
|
+
<Form.Item label="多人审批时审批方式" name="examineMode">
|
|
367
|
+
<Radio.Group
|
|
368
|
+
options={examineModeOptions}
|
|
369
|
+
value={form.examineMode}
|
|
370
|
+
onChange={(e) => {
|
|
371
|
+
setForm((f) => {
|
|
372
|
+
form.examineMode = e.target.value;
|
|
373
|
+
return { ...f };
|
|
374
|
+
});
|
|
375
|
+
}}
|
|
376
|
+
/>
|
|
377
|
+
</Form.Item>
|
|
378
|
+
</Form>
|
|
379
|
+
</Drawer>
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
382
|
+
);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
export default Approver;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 审批人员类型
|
|
3
|
+
*/
|
|
4
|
+
export const setTypeOptions = [
|
|
5
|
+
{ label: "指定成员", value: 1 },
|
|
6
|
+
{ label: "主管", value: 2 },
|
|
7
|
+
{ label: "角色", value: 3 },
|
|
8
|
+
{ label: "发起人自选", value: 4 },
|
|
9
|
+
{ label: "发起人自己", value: 5 },
|
|
10
|
+
{ label: "连续多级主管", value: 7 },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 发起人自选
|
|
15
|
+
*/
|
|
16
|
+
export const selectModeOptions = [
|
|
17
|
+
{ label: "自选一个人", value: 1 },
|
|
18
|
+
{ label: "自选多个人", value: 2 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 连续主管审批终点
|
|
23
|
+
*/
|
|
24
|
+
export const directorModeOptions = [
|
|
25
|
+
{ label: "直到最上层主管", value: 0 },
|
|
26
|
+
{ label: "自定义审批终点", value: 1 },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 审批期限超时后执行
|
|
31
|
+
*/
|
|
32
|
+
export const termModeOptions = [
|
|
33
|
+
{ label: "自动通过", value: 0 },
|
|
34
|
+
{ label: "自动拒绝", value: 1 },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 多人审批时审批方式
|
|
39
|
+
*/
|
|
40
|
+
export const examineModeOptions = [
|
|
41
|
+
{ label: "按顺序依次审批", value: 1 },
|
|
42
|
+
{ label: "会签 (可同时审批,每个人必须审批通过)", value: 2 },
|
|
43
|
+
{ label: "或签 (有一人审批通过即可)", value: 3 },
|
|
44
|
+
];
|