@hzab/flowlong-designer 0.1.4 → 0.1.5
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
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import DataModel from "@hzab/data-model";
|
|
2
2
|
import GroupUserSelector from "@hzab/group-user-selector";
|
|
3
3
|
import { Input, Modal } from "antd";
|
|
4
|
-
import { useMemo, useRef, useState } from "react";
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import "./index.less";
|
|
6
6
|
const fieldMap = {
|
|
7
7
|
dept: "deptList",
|
|
@@ -40,28 +40,61 @@ const GroupUserSelectorModal = (props) => {
|
|
|
40
40
|
return userModel;
|
|
41
41
|
}
|
|
42
42
|
}, [type]);
|
|
43
|
+
|
|
43
44
|
const onOk = () => {
|
|
44
|
-
|
|
45
|
+
let onOkValue = {
|
|
46
|
+
value: null,
|
|
47
|
+
deptUserLabel: null,
|
|
48
|
+
};
|
|
49
|
+
if (type === "dept") {
|
|
50
|
+
onOkValue = {
|
|
51
|
+
value: groupUserSelectorRef.current?.selectedList?.map((item) => item?.value)?.join(","),
|
|
52
|
+
deptUserLabel: groupUserSelectorRef.current?.selectedList?.map((item) => item?.label)?.join(","),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (type === "useId") {
|
|
56
|
+
onOkValue = {
|
|
57
|
+
value: groupUserSelectorRef.current?.selectedList?.map((item) => item?.userId)?.join(","),
|
|
58
|
+
deptUserLabel: groupUserSelectorRef.current?.selectedList?.map((item) => item?.name)?.join(","),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
onChange(onOkValue);
|
|
45
62
|
setOpen(false);
|
|
46
63
|
};
|
|
47
64
|
|
|
48
|
-
const inputValue = useMemo(() => {
|
|
49
|
-
if (type === "dept" && value) {
|
|
50
|
-
return value?.map((item) => item?.label)?.join(",");
|
|
51
|
-
}
|
|
52
|
-
if (type === "useId" && value) {
|
|
53
|
-
return value?.map((item) => item?.name)?.join(",");
|
|
54
|
-
}
|
|
55
|
-
}, [value, type]);
|
|
56
65
|
const userListConfig = {
|
|
57
66
|
searchQueryKey: "userName",
|
|
58
67
|
labelKey: "name",
|
|
59
68
|
valueKey: "id",
|
|
60
69
|
};
|
|
70
|
+
/**选择组件回显 */
|
|
71
|
+
const groupUserSelectorValue = useMemo(() => {
|
|
72
|
+
const deptUserLabelArr = value?.deptUserLabel?.split(",") || [];
|
|
73
|
+
let valueArr = value?.value?.split(",");
|
|
74
|
+
if (type === "useId") {
|
|
75
|
+
valueArr = value?.value?.split(",")?.map((el) => Number(el)) || [];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!value) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
if (type === "useId") {
|
|
82
|
+
return deptUserLabelArr?.map((item, index) => ({
|
|
83
|
+
name: item,
|
|
84
|
+
id: valueArr?.length && valueArr[index],
|
|
85
|
+
isUser: true,
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
return deptUserLabelArr?.map((item, index) => ({
|
|
89
|
+
label: item,
|
|
90
|
+
value: valueArr?.length && valueArr[index],
|
|
91
|
+
}));
|
|
92
|
+
}, [value, type]);
|
|
93
|
+
|
|
61
94
|
return (
|
|
62
95
|
<div>
|
|
63
96
|
<Input
|
|
64
|
-
value={
|
|
97
|
+
value={value?.deptUserLabel || null}
|
|
65
98
|
readOnly
|
|
66
99
|
onClick={() => {
|
|
67
100
|
setOpen(true);
|
|
@@ -84,7 +117,7 @@ const GroupUserSelectorModal = (props) => {
|
|
|
84
117
|
>
|
|
85
118
|
<div className="groupUserSelectorModal">
|
|
86
119
|
<GroupUserSelector
|
|
87
|
-
value={
|
|
120
|
+
value={groupUserSelectorValue || []}
|
|
88
121
|
ref={groupUserSelectorRef}
|
|
89
122
|
model={model}
|
|
90
123
|
{...(type === "useId" ? userListConfig : {})}
|
|
@@ -27,7 +27,10 @@ const conditionOption = [
|
|
|
27
27
|
{ label: "部门", value: "dept" },
|
|
28
28
|
{ label: "用户id", value: "useId" },
|
|
29
29
|
];
|
|
30
|
-
|
|
30
|
+
/** 时间类型 */
|
|
31
|
+
const timeType = ["day", "hour"];
|
|
32
|
+
/** 部门或用户 */
|
|
33
|
+
const deptUserType = ["dept", "useId"];
|
|
31
34
|
export const Branch = (props) => {
|
|
32
35
|
const { modelValue: nodeConfig, onChange, ItemSlot } = props;
|
|
33
36
|
const [form, setForm] = useState({
|
|
@@ -113,11 +116,8 @@ export const Branch = (props) => {
|
|
|
113
116
|
const text = conditionList
|
|
114
117
|
.map((conditionGroup) =>
|
|
115
118
|
conditionGroup.map((item) => {
|
|
116
|
-
if (item?.field
|
|
117
|
-
return `${item.label}${item.operator}${item
|
|
118
|
-
}
|
|
119
|
-
if (item?.field === "useId") {
|
|
120
|
-
return `${item.label}${item.operator}${item.values?.map((el) => el?.userName)}`;
|
|
119
|
+
if (["dept", "useId"].includes(item?.field)) {
|
|
120
|
+
return `${item.label}${item.operator}${item?.deptUserLabel}`;
|
|
121
121
|
}
|
|
122
122
|
return `${item.label}${item.operator}${item.value}`;
|
|
123
123
|
}),
|
|
@@ -350,6 +350,17 @@ export const Branch = (props) => {
|
|
|
350
350
|
<div>值</div>
|
|
351
351
|
</div>
|
|
352
352
|
{conditionGroup?.map((condition, idx) => {
|
|
353
|
+
/**值 */
|
|
354
|
+
let fieldValue = null;
|
|
355
|
+
if (timeType.includes(condition?.field)) {
|
|
356
|
+
fieldValue = condition?.value;
|
|
357
|
+
}
|
|
358
|
+
if (deptUserType.includes(condition?.field)) {
|
|
359
|
+
fieldValue = {
|
|
360
|
+
value: condition?.value,
|
|
361
|
+
deptUserLabel: condition?.deptUserLabel,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
353
364
|
return (
|
|
354
365
|
<div className="condition-content" key={idx}>
|
|
355
366
|
<div className="condition-relation">
|
|
@@ -376,6 +387,9 @@ export const Branch = (props) => {
|
|
|
376
387
|
onChange={(e) => {
|
|
377
388
|
condition.field = e;
|
|
378
389
|
condition.value = null;
|
|
390
|
+
if (deptUserType.includes(condition?.field)) {
|
|
391
|
+
condition.deptUserLabel = null;
|
|
392
|
+
}
|
|
379
393
|
// 更新数据
|
|
380
394
|
setForm((f) => ({ ...f }));
|
|
381
395
|
}}
|
|
@@ -394,11 +408,16 @@ export const Branch = (props) => {
|
|
|
394
408
|
className="condition-content-box-item"
|
|
395
409
|
></Select>
|
|
396
410
|
<Field
|
|
397
|
-
value={
|
|
411
|
+
value={fieldValue}
|
|
398
412
|
type={condition.field}
|
|
399
413
|
onChange={(e) => {
|
|
400
|
-
|
|
401
|
-
|
|
414
|
+
if (timeType.includes(condition?.field)) {
|
|
415
|
+
condition.value = e;
|
|
416
|
+
}
|
|
417
|
+
if (deptUserType?.includes(condition?.field)) {
|
|
418
|
+
condition.value = e?.value;
|
|
419
|
+
condition.deptUserLabel = e?.deptUserLabel;
|
|
420
|
+
}
|
|
402
421
|
// 更新数据
|
|
403
422
|
setForm((f) => ({ ...f }));
|
|
404
423
|
}}
|