@hzab/flowlong-designer 0.2.0 → 0.2.2

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
@@ -1,3 +1,13 @@
1
+ # @hzab/flowlong-designer@0.2.2
2
+
3
+ fix:其他条件文案修改
4
+
5
+ # @hzab/flowlong-designer@0.2.1
6
+
7
+ fix:审批人详情
8
+ fix:条件节点-用户字段替换
9
+ fix:每次新增节点刷新 nodeKey
10
+
1
11
  # @hzab/flowlong-designer@0.2.0
2
12
 
3
13
  fix:图片引用改为相对路径
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/flowlong-designer",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "自定义审批流配置组件",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -60,7 +60,7 @@ export const typeDataEnum = {
60
60
  conditionList: [],
61
61
  },
62
62
  {
63
- nodeName: "条件2",
63
+ nodeName: "其他条件",
64
64
  nodeKey: getNodeKey(),
65
65
  type: 3,
66
66
  priorityLevel: 2,
@@ -79,9 +79,20 @@ export function getNodeKey() {
79
79
 
80
80
  export const AddNode = (props) => {
81
81
  const { modelValue, onChange, disable } = props;
82
-
82
+ /**重置nodeKey */
83
+ const resetNodeKey = (item) => {
84
+ if (item?.nodeKey) {
85
+ item.nodeKey = getNodeKey();
86
+ if (item?.conditionNodes?.length > 0) {
87
+ item?.conditionNodes?.forEach((el) => {
88
+ resetNodeKey(el);
89
+ });
90
+ }
91
+ }
92
+ };
83
93
  function addType(type) {
84
94
  const data = _.cloneDeep(typeDataEnum[type]);
95
+ resetNodeKey(data);
85
96
  data.childNode = modelValue;
86
97
  delete data._Icon;
87
98
  onChange && onChange(data);
@@ -93,7 +104,7 @@ export const AddNode = (props) => {
93
104
  <Popover
94
105
  open={disable ? false : undefined}
95
106
  className="popover"
96
- trigger="click"
107
+ trigger="focus"
97
108
  placement="bottom"
98
109
  content={
99
110
  <div className="add-node-popover-body">
@@ -123,11 +123,7 @@ export const Approver = (props) => {
123
123
  <div className="title" style={{ background: "#ff943e" }}>
124
124
  <UserOutlined />
125
125
  <span>{modelValue?.nodeName}</span>
126
- <DeleteOutlined
127
- className="node-close-btn"
128
- onClick={onNodeDel}
129
- style={disable ? { cursor: "not-allowed" } : {}}
130
- />
126
+ {!disable && <DeleteOutlined className="node-close-btn" onClick={onNodeDel} />}
131
127
  </div>
132
128
  <div className="content">
133
129
  {toText(modelValue) ? <span>{toText(modelValue)}</span> : <span className="placeholder">请选择</span>}
@@ -20,7 +20,7 @@ const Field = (props: FormMapProps) => {
20
20
  }}
21
21
  ></Input>
22
22
  )}
23
- {["dept", "useId"].includes(type) && (
23
+ {["dept", "assignee"].includes(type) && (
24
24
  <GroupUserSelectorModal type={type} onChange={onChange} value={value}></GroupUserSelectorModal>
25
25
  )}
26
26
  </>
@@ -5,11 +5,11 @@ import { useEffect, useMemo, useRef, useState } from "react";
5
5
  import "./index.less";
6
6
  const fieldMap = {
7
7
  dept: "deptList",
8
- useId: "userNameVos",
8
+ assignee: "userNameVos",
9
9
  };
10
10
  const titleMap = {
11
11
  dept: "部门",
12
- useId: "用户",
12
+ assignee: "用户",
13
13
  };
14
14
  const GroupUserSelectorModal = (props) => {
15
15
  const { type, onChange, value = [] } = props;
@@ -36,7 +36,7 @@ const GroupUserSelectorModal = (props) => {
36
36
  if (type === "dept") {
37
37
  return deptModel;
38
38
  }
39
- if (type === "useId") {
39
+ if (type === "assignee") {
40
40
  return userModel;
41
41
  }
42
42
  }, [type]);
@@ -52,7 +52,7 @@ const GroupUserSelectorModal = (props) => {
52
52
  deptUserLabel: groupUserSelectorRef.current?.selectedList?.map((item) => item?.label)?.join(","),
53
53
  };
54
54
  }
55
- if (type === "useId") {
55
+ if (type === "assignee") {
56
56
  onOkValue = {
57
57
  value: groupUserSelectorRef.current?.selectedList?.map((item) => item?.userId)?.join(","),
58
58
  deptUserLabel: groupUserSelectorRef.current?.selectedList?.map((item) => item?.name)?.join(","),
@@ -71,14 +71,14 @@ const GroupUserSelectorModal = (props) => {
71
71
  const groupUserSelectorValue = useMemo(() => {
72
72
  const deptUserLabelArr = value?.deptUserLabel?.split(",") || [];
73
73
  let valueArr = value?.value?.split(",");
74
- if (type === "useId") {
74
+ if (type === "assignee") {
75
75
  valueArr = value?.value?.split(",")?.map((el) => Number(el)) || [];
76
76
  }
77
77
 
78
78
  if (!value) {
79
79
  return [];
80
80
  }
81
- if (type === "useId") {
81
+ if (type === "assignee") {
82
82
  return deptUserLabelArr?.map((item, index) => ({
83
83
  name: item,
84
84
  id: valueArr?.length && valueArr[index],
@@ -120,7 +120,7 @@ const GroupUserSelectorModal = (props) => {
120
120
  ref={groupUserSelectorRef}
121
121
  model={model}
122
122
  searchModel={model}
123
- {...(type === "useId" ? userListConfig : {})}
123
+ {...(type === "assignee" ? userListConfig : {})}
124
124
  ></GroupUserSelector>
125
125
  </div>
126
126
  </Modal>
@@ -20,13 +20,7 @@ export const operatorOptions = [
20
20
  { label: "包含", value: "include" },
21
21
  { label: "不包含", value: "notinclude" },
22
22
  ];
23
- /**条件字段下拉数据 */
24
- // const conditionOption = [
25
- // { label: "天", value: "day" },
26
- // { label: "小时", value: "hour" },
27
- // { label: "部门", value: "dept" },
28
- // { label: "用户id", value: "useId" },
29
- // ];
23
+
30
24
  /**描述下拉字段 */
31
25
  const descOption = [
32
26
  {
@@ -41,7 +35,7 @@ const descOption = [
41
35
  /** 时间类型 */
42
36
  const timeType = ["day", "hour"];
43
37
  /** 部门或用户 */
44
- const deptUserType = ["dept", "useId"];
38
+ const deptUserType = ["dept", "assignee"];
45
39
  export const Branch = (props) => {
46
40
  const { modelValue: nodeConfig, onChange, ItemSlot, disable } = props;
47
41
  const [form, setForm] = useState({
@@ -87,8 +81,11 @@ export const Branch = (props) => {
87
81
  nodeConfig.conditionNodes = swapLastTwo(nodeConfig.conditionNodes);
88
82
 
89
83
  nodeConfig.conditionNodes.forEach((el, index) => {
90
- el.priorityLevel = index;
84
+ el.priorityLevel = index + 1;
91
85
  el.nodeName = el.nodeName ? el.nodeName : "条件" + (index + 1);
86
+ if (index === nodeConfig.conditionNodes.length - 1) {
87
+ el.nodeName = "其他条件";
88
+ }
92
89
  });
93
90
  onChange && onChange({ ...nodeConfig });
94
91
  }
@@ -143,7 +140,7 @@ export const Branch = (props) => {
143
140
  .map((conditionGroup) =>
144
141
  conditionGroup.map((item) => {
145
142
  const el = operatorOptions?.find((el) => el?.value === item?.operator);
146
- if (["dept", "useId"].includes(item?.field)) {
143
+ if (["dept", "assignee"].includes(item?.field)) {
147
144
  return `${item.label}${el?.label}${item?.deptUserLabel}`;
148
145
  }
149
146
  return `${item.label}${el?.label}${item.value}`;
@@ -253,7 +250,7 @@ export const Branch = (props) => {
253
250
  if (condition?.field === "dept") {
254
251
  operatorOptions = [{ label: "包含", value: "include" }];
255
252
  }
256
- if (condition?.field === "useId") {
253
+ if (condition?.field === "assignee") {
257
254
  operatorOptions = [
258
255
  { label: "等于", value: "==" },
259
256
  { label: "包含", value: "include" },
@@ -263,7 +260,7 @@ export const Branch = (props) => {
263
260
  if (condition?.label === "发起人") {
264
261
  conditionOption = [
265
262
  { label: "部门", value: "dept" },
266
- { label: "用户id", value: "useId" },
263
+ { label: "用户id", value: "assignee" },
267
264
  ];
268
265
  }
269
266
  return {
@@ -352,6 +349,7 @@ export const Branch = (props) => {
352
349
  </div>
353
350
  {item.childNode && ItemSlot ? (
354
351
  <ItemSlot
352
+ {...props}
355
353
  modelValue={item}
356
354
  onChange={(val) => {
357
355
  // 数据保存到指定对象中
@@ -125,11 +125,7 @@ export const Approver = (props) => {
125
125
  <div className="title send-title">
126
126
  <UserOutlined />
127
127
  <span>{modelValue?.nodeName}</span>
128
- <DeleteOutlined
129
- className="node-close-btn"
130
- onClick={onNodeDel}
131
- style={disable ? { cursor: "not-allowed" } : {}}
132
- />
128
+ {!disable && <DeleteOutlined className="node-close-btn" onClick={onNodeDel} />}
133
129
  </div>
134
130
  <div className="content">
135
131
  {toText(modelValue) ? <span>{toText(modelValue)}</span> : <span className="placeholder">请选择</span>}
@@ -5,6 +5,7 @@ import Branch from "./Nodes/Branch";
5
5
 
6
6
  export const NodeWrap = (props) => {
7
7
  const { modelValue: nodeConfig, onChange } = props;
8
+
8
9
  return (
9
10
  <div className="node-wrap">
10
11
  {nodeConfig.type == 0 ? <Promoter {...props} modelValue={nodeConfig} onChange={onChange}></Promoter> : null}
@@ -4,8 +4,7 @@ import NodeWrap from "../NodeWrap";
4
4
  import Selector from "../Selector";
5
5
 
6
6
  export const ScWorkflow = (props) => {
7
- const { modelValue: nodeConfig, onChange, disable } = props;
8
-
7
+ const { modelValue: nodeConfig, onChange } = props;
9
8
  return (
10
9
  <div className="sc-workflow-design">
11
10
  <div className="box-scale">