@cloudbase/weda-ui 3.4.4 → 3.4.6

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.
Files changed (147) hide show
  1. package/dist/configs/components/chart/bar.json +113 -8
  2. package/dist/configs/components/chart/line.js +113 -8
  3. package/dist/configs/components/chart/pie.json +113 -8
  4. package/dist/configs/components/chart/statisticsCard.json +57 -0
  5. package/dist/configs/components/dataView.js +7 -7
  6. package/dist/configs/components/form/input.json +48 -2
  7. package/dist/configs/components/form/richText.json +2 -1
  8. package/dist/configs/components/form/uploader.json +62 -14
  9. package/dist/configs/components/graphicCard.json +1 -1
  10. package/dist/configs/components/grid/col.js +4 -1
  11. package/dist/configs/components/grid/grid.js +8 -3
  12. package/dist/configs/components/grid/row.js +51 -3
  13. package/dist/configs/components/listView.js +113 -9
  14. package/dist/configs/components/navLayout.json +1 -1
  15. package/dist/configs/components/repeater.js +4 -1
  16. package/dist/configs/components/table.json +125 -9
  17. package/dist/configs/components/wd-bubble.js +6 -0
  18. package/dist/configs/components/wd-button.js +6 -0
  19. package/dist/configs/components/wd-divider.js +7 -18
  20. package/dist/configs/components/wd-icon.js +7 -0
  21. package/dist/configs/components/wd-image.js +7 -0
  22. package/dist/configs/components/wd-link.js +7 -2
  23. package/dist/configs/components/wd-text.js +14 -6
  24. package/dist/configs/index.js +0 -2
  25. package/dist/docs/common/componentList.js +1 -1
  26. package/dist/style/index.scss +1 -1
  27. package/dist/web/actions/showModal/index.js +1 -1
  28. package/dist/web/components/calendar/index.js +2 -2
  29. package/dist/web/components/chart/common/data-transform.js +1 -1
  30. package/dist/web/components/chart/statisticsCard/index.js +1 -1
  31. package/dist/web/components/flow/components/index.js +0 -4
  32. package/dist/web/components/flow/frame/index.js +4 -3
  33. package/dist/web/components/flow/frame/types.js +11 -5
  34. package/dist/web/components/flow/frame/utils.js +60 -1
  35. package/dist/web/components/flow/modules/chart/Chart.js +2 -3
  36. package/dist/web/components/flow/modules/chart/index.css +0 -3
  37. package/dist/web/components/flow/modules/combination/index.js +1 -1
  38. package/dist/web/components/flow/modules/operations/components/button/index.js +11 -0
  39. package/dist/web/components/flow/modules/operations/components/button/style.css +5 -0
  40. package/dist/web/components/flow/modules/operations/components/index.js +6 -0
  41. package/dist/web/components/flow/modules/operations/components/popup/index.js +100 -0
  42. package/dist/web/components/flow/modules/operations/components/popup/style.css +154 -0
  43. package/dist/web/components/flow/modules/operations/components/popup/types.js +1 -0
  44. package/dist/web/components/flow/modules/operations/components/user-select/index.js +43 -0
  45. package/dist/web/components/flow/modules/operations/components/user-select/style.css +4 -0
  46. package/dist/web/components/flow/modules/operations/components/user-select/types.js +1 -0
  47. package/dist/web/components/flow/modules/operations/config/approval-form-config.js +140 -0
  48. package/dist/web/components/flow/modules/operations/config/control-config.js +218 -0
  49. package/dist/web/components/flow/modules/operations/config/index.js +2 -0
  50. package/dist/web/components/flow/modules/operations/config/types.js +1 -0
  51. package/dist/web/components/flow/modules/operations/control.js +26 -0
  52. package/dist/web/components/flow/modules/operations/controls-items/add-assignee-btn.js +33 -0
  53. package/dist/web/components/flow/modules/operations/controls-items/apply-cc-btn.js +12 -0
  54. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/comment/index.js +188 -0
  55. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/comment/style.css +51 -0
  56. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/drawer-form/index.js +64 -0
  57. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/drawer-form/types.js +1 -0
  58. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/drawer-form/view-model.js +83 -0
  59. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/field/index.js +16 -0
  60. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/field/style.css +56 -0
  61. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/index.js +47 -0
  62. package/dist/web/components/flow/modules/operations/controls-items/approval-drawer/style.css +60 -0
  63. package/dist/web/components/flow/modules/operations/controls-items/cancel-apply-btn.js +15 -0
  64. package/dist/web/components/flow/modules/operations/controls-items/check-list-popup/index.js +11 -0
  65. package/dist/web/components/flow/modules/operations/controls-items/check-list-popup/style.css +26 -0
  66. package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +98 -0
  67. package/dist/web/components/flow/modules/operations/controls-items/index.js +18 -0
  68. package/dist/web/components/flow/modules/operations/controls-items/initiation-btn.js +25 -0
  69. package/dist/web/components/flow/modules/operations/controls-items/revoke-modal/index.js +50 -0
  70. package/dist/web/components/flow/modules/operations/controls-items/revoke-modal/style.css +28 -0
  71. package/dist/web/components/flow/modules/operations/controls-items/roll-back-modal.js +104 -0
  72. package/dist/web/components/flow/modules/operations/controls-items/types.js +1 -0
  73. package/dist/web/components/flow/modules/operations/index.js +2 -0
  74. package/dist/web/components/flow/modules/operations/style.css +20 -0
  75. package/dist/web/components/flow/modules/operations/view-model.js +137 -0
  76. package/dist/web/components/flow/services/ideData/instance.js +2 -2
  77. package/dist/web/components/flow/services/ideData/pageDetail.js +1 -0
  78. package/dist/web/components/form/select/dropdown-select/h5.js +1 -1
  79. package/dist/web/components/form/select/dropdown-select/index.css +7 -0
  80. package/dist/web/components/form/select/index.js +2 -7
  81. package/dist/web/components/form/textarea/index.js +1 -1
  82. package/dist/web/components/form/uploader/index.css +19 -0
  83. package/dist/web/components/form/uploader/index.js +21 -3
  84. package/dist/web/components/form/uploader/uploader.h5.js +14 -8
  85. package/dist/web/components/form/uploader/uploader.pc.js +29 -16
  86. package/dist/web/components/form/uploaderFile/index.css +9 -5
  87. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +23 -21
  88. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +14 -10
  89. package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +0 -1
  90. package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +1 -1
  91. package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +43 -22
  92. package/dist/web/components/form/userOrgSelect/component/user-select-h5/user-select-h5.js +15 -4
  93. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -2
  94. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +4 -2
  95. package/dist/web/components/grid/col.js +81 -18
  96. package/dist/web/components/grid/grid.js +1 -1
  97. package/dist/web/components/grid/row.js +4 -2
  98. package/dist/web/components/index.js +1 -1
  99. package/dist/web/components/listView/index.js +98 -100
  100. package/dist/web/components/lottery/index.js +122 -123
  101. package/dist/web/components/richTextView/index.css +2 -0
  102. package/dist/web/components/swiper/index.js +14 -8
  103. package/dist/web/components/table/BaseTable.js +3 -3
  104. package/dist/web/components/table/ExportFileModalByApi/index.js +1 -1
  105. package/dist/web/components/table/ImportFileModal/index.js +1 -1
  106. package/dist/web/components/table/ImportFileModalByApi/index.js +1 -1
  107. package/dist/web/components/wd-bubble/wd-bubble.js +11 -3
  108. package/dist/web/components/wd-button/wd-button.js +22 -13
  109. package/dist/web/components/wd-divider/wd-divider.js +10 -7
  110. package/dist/web/components/wd-icon/wd-icon.js +12 -3
  111. package/dist/web/components/wd-image/index.js +12 -5
  112. package/dist/web/components/wd-link/wd-link.js +11 -3
  113. package/dist/web/components/wd-text/wd-text.js +15 -3
  114. package/dist/web/utils/hooks/use-cloud-id-temp-url.js +7 -2
  115. package/dist/web/utils/platform.js +9 -2
  116. package/dist/web/utils/tool.js +11 -0
  117. package/dist/web/utils/widget-api/index.js +3 -0
  118. package/package.json +7 -5
  119. package/dist/configs/components/auth.json +0 -17
  120. package/dist/web/components/flow/components/FlowUserSelect/index.css +0 -116
  121. package/dist/web/components/flow/components/FlowUserSelect/index.js +0 -115
  122. package/dist/web/components/flow/components/HighlightTextarea/index.css +0 -42
  123. package/dist/web/components/flow/components/HighlightTextarea/index.js +0 -131
  124. package/dist/web/components/flow/components/UserSelectModel/UserSelect.js +0 -74
  125. package/dist/web/components/flow/components/UserSelectModel/UserSelectMobile.css +0 -8
  126. package/dist/web/components/flow/components/UserSelectModel/UserSelectMobile.js +0 -86
  127. package/dist/web/components/flow/components/UserSelectModel/index.js +0 -18
  128. package/dist/web/components/flow/components/WedaUserTransfer/index.css +0 -3
  129. package/dist/web/components/flow/components/WedaUserTransfer/index.js +0 -162
  130. package/dist/web/components/flow/modules/control/ApprovalDrawer.css +0 -144
  131. package/dist/web/components/flow/modules/control/ApprovalDrawer.js +0 -178
  132. package/dist/web/components/flow/modules/control/ApprovalPopup.css +0 -115
  133. package/dist/web/components/flow/modules/control/ApprovalPopup.js +0 -241
  134. package/dist/web/components/flow/modules/control/Control.css +0 -29
  135. package/dist/web/components/flow/modules/control/Control.js +0 -93
  136. package/dist/web/components/flow/modules/control/ControlMobile.css +0 -69
  137. package/dist/web/components/flow/modules/control/ControlMobile.js +0 -133
  138. package/dist/web/components/flow/modules/control/FlowTaskInfoModal.css +0 -3
  139. package/dist/web/components/flow/modules/control/FlowTaskInfoModal.js +0 -31
  140. package/dist/web/components/flow/modules/control/constants/index.js +0 -35
  141. package/dist/web/components/flow/modules/control/index.js +0 -15
  142. package/dist/web/components/flow/modules/control/provider/index.js +0 -17
  143. package/dist/web/components/flow/modules/control/provider/useControlModel.js +0 -256
  144. package/dist/web/components/flow/modules/control/provider/useMobileModel.js +0 -86
  145. package/dist/web/components/flow/modules/control/provider/useRevokeAndBackHook.js +0 -82
  146. package/dist/web/components/flow/modules/control/utils/ControlModelUtils.js +0 -57
  147. package/dist/web/components/flow/modules/control/utils/index.js +0 -2
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { Button } from 'tea-component';
3
+ import { WdDivider } from '../../../wd-divider';
4
+ import { createModuleFrame } from '../../frame';
5
+ import { getControlConfig } from './config';
6
+ import { useFlowControlModel } from './view-model';
7
+ import { CONTROL_COMPONENT } from './controls-items';
8
+ import './style.css';
9
+ /** 流程控制组件 */
10
+ const FlowControl = (props) => {
11
+ const controlModel = useFlowControlModel(props);
12
+ const configs = getControlConfig(props);
13
+ /** 已回退之后不显示任何操作按钮 */
14
+ if (controlModel.hasGoBack)
15
+ return null;
16
+ return (React.createElement("div", { className: `weda-flow-control ${props.flowLocalProps.isH5 ? 'weda-flow-h5-control' : ''}` }, configs.map((config) => {
17
+ const { component, props, visible, actionKey } = config;
18
+ const Component = CONTROL_COMPONENT[component] || Button;
19
+ if (!visible)
20
+ return null;
21
+ return (React.createElement(React.Fragment, null,
22
+ React.createElement(Component, { ...props, key: config.actionKey, actionKey: actionKey, flowControlModel: controlModel }),
23
+ !(config === null || config === void 0 ? void 0 : config.hideDivider) && (React.createElement(WdDivider, { type: "solid", className: "weda-flow-control-divider" }))));
24
+ })));
25
+ };
26
+ export const ModelFlowControl = createModuleFrame(FlowControl, 'flow-control');
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { message } from 'tea-component';
3
+ import { FlowUserSelectBtn } from '../components';
4
+ /**
5
+ * 提交申请抄送按钮
6
+ */
7
+ export function AddAssigneeBtn(props) {
8
+ const { flowControlModel, flowFrameCommonProps } = props;
9
+ const { flowRequest } = flowFrameCommonProps.flowLocalProps;
10
+ const { flowDetail } = flowFrameCommonProps.commonFlowData;
11
+ const onUserChange = (user) => {
12
+ addCounterSignAssignee(user.userIds);
13
+ };
14
+ /** 加签请求 */
15
+ const addCounterSignAssignee = async (assigneeIds) => {
16
+ const result = await flowRequest({
17
+ action: 'AddCounterSignAssignee',
18
+ data: {
19
+ instanceId: flowDetail.instanceId,
20
+ nodeId: flowDetail.currentNodeId,
21
+ taskId: flowDetail.taskId,
22
+ assigneeIds,
23
+ },
24
+ });
25
+ if (result === null || result === void 0 ? void 0 : result.status) {
26
+ message.success({
27
+ content: `${props.label}成功`,
28
+ });
29
+ flowControlModel.onAfterFinishFlowAction(props.actionKey, props.afterAction);
30
+ }
31
+ };
32
+ return (React.createElement(FlowUserSelectBtn, { buttonProps: { ...props.buttonProps, id: props.id }, buttonText: props.label, onChange: onUserChange, isH5: props.flowFrameCommonProps.flowLocalProps.isH5, multiple: true }));
33
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { FlowUserSelectBtn } from '../components';
3
+ /**
4
+ * 提交申请抄送按钮
5
+ */
6
+ export function ApplyCcBtn(props) {
7
+ var _a, _b;
8
+ const onUserChange = (user) => {
9
+ props.flowControlModel.setApplyCcUser(user.userIds);
10
+ };
11
+ return (React.createElement(FlowUserSelectBtn, { buttonProps: { ...props.buttonProps, id: props.id }, buttonText: `${props.label}(${(_b = (_a = props.flowControlModel.applyCcUser) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0})`, onChange: onUserChange, isH5: props.flowFrameCommonProps.flowLocalProps.isH5, multiple: true }));
12
+ }
@@ -0,0 +1,188 @@
1
+ import React, { useState, useRef } from 'react';
2
+ // eslint-disable-next-line import/no-named-as-default
3
+ import HighlightWithinTextarea from 'react-highlight-within-textarea';
4
+ import { Button } from 'tea-component';
5
+ import { FlowUserSelect } from '../../../components';
6
+ import './style.css';
7
+ export function FlowComment(props) {
8
+ const { placeholder = '请输入评论,可@通知他人', isH5 = false, bordered = true, } = props;
9
+ const [commentValue, setCommentValue] = useState('');
10
+ /** 高亮位置数组 */
11
+ const [highlightPositions, setHighlightPositions] = useState([]);
12
+ /** 用户弹窗是否显示 */
13
+ const [userModalVisible, setUserModalVisible] = useState(false);
14
+ /** 存储同事用户的对象 */
15
+ const opinionUserMapRef = useRef({});
16
+ /** 输入框实例对象 */
17
+ const textAreaRef = useRef();
18
+ /** 记录上一次的评论内容状态,用于统计 @ 符号 useKeyboardEventModel - countAtSignal*/
19
+ const prevCommentValue = useRef('');
20
+ const rangeModel = useRangeModel();
21
+ const keyboardModel = useKeyboardEventModel({
22
+ commentValue,
23
+ isH5,
24
+ atEvent: onPressAtSingle,
25
+ });
26
+ /** @ 按键事件 */
27
+ function onPressAtSingle() {
28
+ setUserModalVisible(true);
29
+ rangeModel.getRange(isH5);
30
+ }
31
+ /** 评论内容变更 */
32
+ const onCommentChange = (value) => {
33
+ rangeModel.getRange(!isH5);
34
+ // 防止因setHighlightPositions导致onChange重复执行
35
+ if (value === prevCommentValue.current && value !== '')
36
+ return;
37
+ prevCommentValue.current = value;
38
+ setCommentValue(value);
39
+ handleCommentValueChange(value);
40
+ };
41
+ /** 用户选择变更 */
42
+ const onUserChange = ({ users }) => {
43
+ let value = isH5 ? '@' : '';
44
+ users.forEach((user, index) => {
45
+ const name = `@${user.userName}`;
46
+ value = `${value + user.userName} `;
47
+ if (index < users.length - 1) {
48
+ value = `${value}@`;
49
+ }
50
+ if (!opinionUserMapRef.current[user.userId]) {
51
+ opinionUserMapRef.current[user.userId] = name;
52
+ }
53
+ });
54
+ const insertResult = rangeModel.insertValue(value);
55
+ const newValue = textAreaRef.current.editor.innerText;
56
+ setCommentValue(insertResult ? newValue : value);
57
+ handleCommentValueChange(insertResult ? newValue : value);
58
+ };
59
+ /** 处理评论内容变更 */
60
+ const handleCommentValueChange = (comment) => {
61
+ var _a, _b;
62
+ if (!comment) {
63
+ const values = {
64
+ operationComment: '',
65
+ opinionUserMap: {},
66
+ highlightPositionList: '{}',
67
+ };
68
+ opinionUserMapRef.current = {};
69
+ (_a = props === null || props === void 0 ? void 0 : props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values);
70
+ setHighlightPositions([]);
71
+ return;
72
+ }
73
+ const { res: highlightPositions, obj: highlightPositionObj } = checkHighlight(comment, opinionUserMapRef.current);
74
+ const opinionUserMap = checkOpinionUserMap(opinionUserMapRef.current, comment);
75
+ const newValues = {
76
+ operationComment: comment,
77
+ opinionUserMap: opinionUserMap,
78
+ highlightPositionList: JSON.stringify(highlightPositionObj),
79
+ };
80
+ (_b = props === null || props === void 0 ? void 0 : props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, newValues);
81
+ setHighlightPositions(highlightPositions);
82
+ };
83
+ return (React.createElement(React.Fragment, null,
84
+ React.createElement("div", { className: `weda-flow-comment ${bordered ? 'bordered' : ''}`, onKeyUp: keyboardModel.onKeyUp },
85
+ React.createElement(HighlightWithinTextarea, { value: commentValue, onChange: onCommentChange, highlight: highlightPositions, placeholder: placeholder, ref: textAreaRef, onFocus: () => rangeModel.getRange(!isH5), onBlur: () => rangeModel.getRange(!isH5) }),
86
+ React.createElement(FlowUserSelect, { visible: userModalVisible, multiple: true, onChange: onUserChange, onClose: () => setUserModalVisible(false), defaultValue: [], isH5: props.isH5 })),
87
+ isH5 ? (React.createElement(Button, { type: "link", onClick: onPressAtSingle, style: props.atButtonStyle }, "@\u67D0\u4EBA")) : null));
88
+ }
89
+ /** 处理评论框光标hook */
90
+ function useRangeModel() {
91
+ const range = useRef();
92
+ const getRange = (stop = false) => {
93
+ var _a;
94
+ if (stop)
95
+ return;
96
+ // 获取光标位置
97
+ const selection = window.getSelection();
98
+ if ((selection === null || selection === void 0 ? void 0 : selection.rangeCount) === 0)
99
+ return;
100
+ const currentRange = (selection === null || selection === void 0 ? void 0 : selection.rangeCount) !== 0 ? (_a = selection === null || selection === void 0 ? void 0 : selection.getRangeAt) === null || _a === void 0 ? void 0 : _a.call(selection, 0) : null;
101
+ range.current = currentRange;
102
+ };
103
+ const insertValue = (addValue) => {
104
+ var _a, _b;
105
+ if (range.current) {
106
+ (_b = (_a = range.current) === null || _a === void 0 ? void 0 : _a.insertNode) === null || _b === void 0 ? void 0 : _b.call(_a, document.createTextNode(addValue));
107
+ return true;
108
+ }
109
+ return false;
110
+ };
111
+ return {
112
+ getRange,
113
+ insertValue,
114
+ };
115
+ }
116
+ /** 处理评论框键盘事件hook */
117
+ function useKeyboardEventModel({ commentValue, isH5, atEvent, }) {
118
+ const prevCommentValueRef = useRef(commentValue);
119
+ /** 统计'@'符号个数 */
120
+ const countAtSignal = (currentValue) => {
121
+ let count1 = 0;
122
+ let count2 = 0;
123
+ for (const v of currentValue) {
124
+ if (v === '@') {
125
+ count1 += 1;
126
+ }
127
+ }
128
+ for (const v of prevCommentValueRef.current) {
129
+ if (v === '@') {
130
+ count2 += 1;
131
+ }
132
+ }
133
+ return count1 === count2;
134
+ };
135
+ /** 评论框KeyUp事件 */
136
+ const onKeyUp = (e) => {
137
+ if (!isH5 && e.shiftKey && (e.key === '@' || e.keyCode === 50)) {
138
+ atEvent === null || atEvent === void 0 ? void 0 : atEvent();
139
+ return;
140
+ }
141
+ // 判断当下value值是否存在2
142
+ if (!isH5 && e.keyCode === 50 && !countAtSignal(commentValue)) {
143
+ atEvent === null || atEvent === void 0 ? void 0 : atEvent();
144
+ }
145
+ prevCommentValueRef.current = commentValue;
146
+ };
147
+ return {
148
+ onKeyUp,
149
+ };
150
+ }
151
+ /** 检查高亮位置数据 */
152
+ function checkHighlight(text, opinionUserMap) {
153
+ const highlightList = Object.values(opinionUserMap);
154
+ const len = highlightList.length;
155
+ let v = text;
156
+ let res = [];
157
+ // 回显时使用,必须顺序排列
158
+ let obj = {};
159
+ for (let i = 0; i < len; i++) {
160
+ const indexof = v.indexOf(highlightList[i]);
161
+ const itemLen = highlightList[i].length;
162
+ if (indexof !== -1) {
163
+ const endIndex = indexof + itemLen;
164
+ res.push([indexof, endIndex]);
165
+ obj[indexof] = endIndex;
166
+ const fillText = new Array(itemLen).fill(' ').join(''); // 空格填充
167
+ v = v.substring(0, indexof) + fillText + v.substring(endIndex);
168
+ }
169
+ }
170
+ if (res.length > 0 && v.includes('@')) {
171
+ // 继续检查剩下文本,是否存在重复@
172
+ const { res: arr, obj: objCopy } = checkHighlight(v, opinionUserMap);
173
+ res = res.concat(arr);
174
+ obj = { ...obj, ...objCopy };
175
+ }
176
+ return { res, obj };
177
+ }
178
+ /** 检查通知用户Map */
179
+ function checkOpinionUserMap(currentOpinionUserMap, commentValue) {
180
+ const newOpinionUserMap = {};
181
+ // value每次change后需要再次检查opinionUserMap
182
+ for (const [id, name] of Object.entries(currentOpinionUserMap)) {
183
+ if (commentValue.indexOf(name) !== -1) {
184
+ newOpinionUserMap[id] = name;
185
+ }
186
+ }
187
+ return newOpinionUserMap;
188
+ }
@@ -0,0 +1,51 @@
1
+ .weda-flow-comment {
2
+ position: relative;
3
+ height: 100px;
4
+ text-align: left;
5
+ overflow: auto;
6
+ display: inline-block;
7
+ width: 100%;
8
+ border-radius: 3px;
9
+ }
10
+
11
+ .weda-flow-comment.bordered {
12
+ border: 1px solid #dcdee6;
13
+ }
14
+
15
+ .weda-flow-comment .DraftEditor-root {
16
+ position: absolute;
17
+ width: 100%;
18
+ z-index: 1;
19
+ height: 100%;
20
+ }
21
+ .weda-flow-comment .public-DraftEditorPlaceholder-root {
22
+ position: absolute;
23
+ z-index: 0;
24
+ margin: 5px;
25
+ color: #999999;
26
+ font-size: 12px;
27
+ left: 5px;
28
+ width: 90%;
29
+ pointer-events: none;
30
+ }
31
+
32
+ .weda-flow-comment .DraftEditor-root .DraftEditor-editorContainer {
33
+ padding: 5px;
34
+ height: 100%;
35
+ }
36
+ .weda-flow-comment
37
+ .DraftEditor-root
38
+ .DraftEditor-editorContainer
39
+ .public-DraftEditor-content {
40
+ height: 100%;
41
+ }
42
+ .weda-flow-comment .DraftEditor-root .DraftEditor-editorContainer mark {
43
+ color: #888888;
44
+ background: transparent;
45
+ }
46
+ .weda-flow-comment .highlight-textarea-placeholder {
47
+ position: absolute;
48
+ z-index: 0;
49
+ margin: 5px;
50
+ color: #999999;
51
+ }
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { Drawer, Button, Form } from 'tea-component';
3
+ import { FlowPopup, FlowUserSelect } from '../../../components';
4
+ import { FlowField } from '../field';
5
+ import { FlowComment } from '../comment';
6
+ import { useDrawerFormModel } from './view-model';
7
+ const FormComponents = {
8
+ FlowComment,
9
+ FlowUserSelect,
10
+ };
11
+ export * from './types';
12
+ /** 抽屉表单 */
13
+ export const DrawerForm = (props) => {
14
+ const drawerFormModel = useDrawerFormModel(props.formInfo, props.submit);
15
+ const commonProps = {
16
+ formInfo: props.formInfo,
17
+ drawerFormModel,
18
+ submitLoading: props.submitLoading,
19
+ visible: props.visible,
20
+ onClose: props.onClose,
21
+ };
22
+ if (props.isH5) {
23
+ return React.createElement(DrawerFormH5View, { ...commonProps });
24
+ }
25
+ return React.createElement(DrawerFormPCView, { ...commonProps });
26
+ };
27
+ DrawerForm.displayName = 'DrawerForm';
28
+ /** 抽屉表单PC视图 */
29
+ function DrawerFormPCView(props) {
30
+ const { drawerFormModel, formInfo, visible, onClose } = props;
31
+ return (React.createElement(Drawer, { showMask: true, destroyOnClose: true, size: "l", outerClickClosable: false, visible: visible, onClose: onClose, title: formInfo.formTitle, className: "weda-flow-approval-drawer", footer: React.createElement(React.Fragment, null,
32
+ React.createElement(Button, { type: "primary", onClick: drawerFormModel.onSubmitForm, loading: props.submitLoading }, "\u63D0\u4EA4"),
33
+ React.createElement(Button, { onClick: onClose }, "\u53D6\u6D88")) },
34
+ React.createElement(Form, null, formInfo.formItems.map((formItem) => {
35
+ var _a, _b;
36
+ if (formItem.hidden)
37
+ return;
38
+ if (formItem.readonly) {
39
+ return (React.createElement(Form.Item, { key: formItem.field, label: formItem.label },
40
+ React.createElement(Form.Text, null, formItem.content)));
41
+ }
42
+ const Component = FormComponents[formItem.component];
43
+ return (React.createElement(Form.Item, { label: formItem.label, key: formItem.field, required: formItem.required, showStatusIcon: false, message: ((_a = drawerFormModel.errorMap) === null || _a === void 0 ? void 0 : _a[formItem.field]) ||
44
+ formItem.help ||
45
+ '', status: ((_b = drawerFormModel.errorMap) === null || _b === void 0 ? void 0 : _b[formItem.field]) ? 'error' : 'success' },
46
+ React.createElement(Component, { ...formItem.props, onChange: (value) => drawerFormModel.onFormItemChange(value, formItem) })));
47
+ }))));
48
+ }
49
+ /** 抽屉表单H5视图 */
50
+ function DrawerFormH5View(props) {
51
+ const { drawerFormModel, formInfo, visible, onClose } = props;
52
+ return (React.createElement(FlowPopup, { destroyOnClose: true, closeable: true, position: "bottom", className: "weda-flow-approval-drawer-mobile", overlayStyle: { zIndex: 998 }, height: 550, visible: visible, onClose: onClose, title: formInfo.formTitle },
53
+ formInfo.formItems.map((formItem, index) => {
54
+ var _a, _b;
55
+ if (formItem.hidden)
56
+ return;
57
+ if (formItem.readonly) {
58
+ return (React.createElement(FlowField, { key: formItem.field, content: formItem.content, label: formItem.label, bordered: index !== formInfo.formItems.length - 1 }));
59
+ }
60
+ const Component = FormComponents[formItem.component];
61
+ return (React.createElement(FlowField, { key: formItem.field, label: formItem.label, required: formItem.required, errorMessage: ((_a = drawerFormModel.errorMap) === null || _a === void 0 ? void 0 : _a[formItem.field]) || '', bordered: index !== formInfo.formItems.length - 1, layout: ((_b = formItem === null || formItem === void 0 ? void 0 : formItem.extra) === null || _b === void 0 ? void 0 : _b.isH5Vertical) ? 'vertical' : 'horizontal', content: React.createElement(Component, { ...formItem.props, onChange: (value) => drawerFormModel.onFormItemChange(value, formItem) }) }));
62
+ }),
63
+ React.createElement(Button, { type: "primary", onClick: drawerFormModel.onSubmitForm, className: "submit", loading: props.submitLoading }, "\u63D0\u4EA4")));
64
+ }
@@ -0,0 +1,83 @@
1
+ import { useEffect, useState, useRef } from 'react';
2
+ /** 审批表单model */
3
+ export function useDrawerFormModel(formInfo, submit) {
4
+ const [visible, setVisible] = useState(false);
5
+ const onOpenDrawer = () => setVisible(true);
6
+ const onCloseDrawer = () => {
7
+ resetFormStatus();
8
+ setVisible(false);
9
+ };
10
+ /** 错误信息Map */
11
+ const [errorMap, setErrorMap] = useState({});
12
+ /** 存储表单值的对象 */
13
+ const formValueRef = useRef({});
14
+ useEffect(() => {
15
+ var _a;
16
+ // 初始化默认值
17
+ visible &&
18
+ ((_a = formInfo === null || formInfo === void 0 ? void 0 : formInfo.formItems) === null || _a === void 0 ? void 0 : _a.forEach((formItem) => {
19
+ var _a;
20
+ if (formItem.readonly)
21
+ return;
22
+ formValueRef.current[formItem.field] =
23
+ (_a = formItem === null || formItem === void 0 ? void 0 : formItem.defaultValue) !== null && _a !== void 0 ? _a : undefined;
24
+ }));
25
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
+ }, [visible]);
27
+ /** 提交表单值 */
28
+ const onSubmitForm = () => {
29
+ const { errorMap, hasError } = validateFormValues();
30
+ setErrorMap(errorMap);
31
+ if (hasError)
32
+ return;
33
+ submit === null || submit === void 0 ? void 0 : submit({
34
+ ...formValueRef.current,
35
+ ...(formInfo.submitDefaultValues || {}),
36
+ });
37
+ };
38
+ /** 表单项值变更 */
39
+ const onFormItemChange = (value, formItem) => {
40
+ const { field, transform, validate } = formItem;
41
+ const itemValue = { [field]: transform ? transform === null || transform === void 0 ? void 0 : transform(value) : value };
42
+ formValueRef.current = {
43
+ ...formValueRef.current,
44
+ ...itemValue,
45
+ };
46
+ setErrorMap({
47
+ ...errorMap,
48
+ [field]: (validate === null || validate === void 0 ? void 0 : validate(value)) || undefined,
49
+ });
50
+ };
51
+ /** 验证表单所有值 */
52
+ const validateFormValues = () => {
53
+ let newErrorMap = {};
54
+ let hasError = false;
55
+ formInfo.formItems.forEach((config) => {
56
+ var _a, _b;
57
+ if (config.readonly)
58
+ return;
59
+ const currentFieldValue = (_a = formValueRef.current) === null || _a === void 0 ? void 0 : _a[config.field];
60
+ const checkResult = (_b = config.validate) === null || _b === void 0 ? void 0 : _b.call(config, currentFieldValue);
61
+ newErrorMap = {
62
+ ...errorMap,
63
+ [config.field]: checkResult || '',
64
+ };
65
+ hasError = !!checkResult;
66
+ });
67
+ return { errorMap: newErrorMap, hasError };
68
+ };
69
+ /** 重置表单状态 */
70
+ const resetFormStatus = () => {
71
+ setErrorMap({});
72
+ formValueRef.current = {};
73
+ };
74
+ return {
75
+ visible,
76
+ errorMap,
77
+ onOpenDrawer,
78
+ onCloseDrawer,
79
+ resetFormStatus,
80
+ onSubmitForm,
81
+ onFormItemChange,
82
+ };
83
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import classNames from '../../../../../../../utils/classnames';
3
+ import './style.css';
4
+ export function FlowField(props) {
5
+ const { label = '', content = '', required = false, errorMessage = '', className = '', layout = 'horizontal', bordered = true, } = props;
6
+ const outerClassNames = classNames('weda-flow-field', className, {
7
+ ['bordered']: bordered,
8
+ ['vertical']: layout === 'vertical',
9
+ ['horizontal']: layout === 'horizontal',
10
+ });
11
+ return (React.createElement("div", { className: outerClassNames },
12
+ React.createElement("div", { className: `weda-flow-field-label ${required ? 'required' : ''}` }, label),
13
+ React.createElement("div", { className: "weda-flow-field-content" },
14
+ content,
15
+ errorMessage ? (React.createElement("div", { className: "weda-flow-field-error" }, errorMessage)) : null)));
16
+ }
@@ -0,0 +1,56 @@
1
+ .weda-flow-field {
2
+ padding: 12px 24px;
3
+ position: relative;
4
+ display: flex;
5
+ }
6
+
7
+ .weda-flow-field.bordered::after {
8
+ content: '';
9
+ border-bottom: 1px solid #dcdee6;
10
+ position: absolute;
11
+ box-sizing: border-box;
12
+ content: ' ';
13
+ pointer-events: none;
14
+ right: 16px;
15
+ bottom: 0;
16
+ left: 16px;
17
+ border-bottom: 1px solid #dcdee6;
18
+ transform: scaleY(0.5);
19
+ }
20
+
21
+ .weda-flow-field.vertical {
22
+ flex-direction: column;
23
+ }
24
+
25
+ .weda-flow-field.horizontal {
26
+ align-items: flex-start;
27
+ }
28
+
29
+ .weda-flow-field-label {
30
+ text-align: left;
31
+ word-wrap: break-word;
32
+ width: 6em;
33
+ color: #646566;
34
+ margin-right: 12px;
35
+ display: flex;
36
+ align-items: center;
37
+ position: relative;
38
+ }
39
+
40
+ .weda-flow-field-label.required::before {
41
+ position: absolute;
42
+ left: -7px;
43
+ color: #f44336;
44
+ font-size: 14px;
45
+ content: '*';
46
+ }
47
+
48
+ .weda-flow-field-content {
49
+ display: flex;
50
+ flex-direction: column;
51
+ }
52
+
53
+ .weda-flow-field-error {
54
+ color: #f44336;
55
+ font-size: 12px;
56
+ }
@@ -0,0 +1,47 @@
1
+ import React, { useState } from 'react';
2
+ import { message } from 'tea-component';
3
+ import { FlowButton } from '../../components';
4
+ import { DrawerForm } from './drawer-form';
5
+ import './style.css';
6
+ /**
7
+ * 审批类型弹窗 可用于同意、拒绝、处理、转办 这几个操作
8
+ */
9
+ export function ApprovalDrawer(props) {
10
+ const { isH5 } = props.flowFrameCommonProps.flowLocalProps;
11
+ const [submitLoading, setSubmitLoading] = useState(false);
12
+ const [visible, setVisible] = useState(false);
13
+ const onOpenDrawerForm = () => setVisible(true);
14
+ const onCloseDrawerForm = () => setVisible(false);
15
+ const onDrawerFormSubmit = (formValues) => {
16
+ let values = {};
17
+ Object.keys(formValues).forEach((key) => {
18
+ if (key === 'comment') {
19
+ values = {
20
+ ...values,
21
+ ...formValues.comment,
22
+ };
23
+ }
24
+ else {
25
+ values[key] = formValues[key];
26
+ }
27
+ });
28
+ props.flowControlModel.completeTask({
29
+ actionKey: props.actionKey,
30
+ afterAction: props.afterAction,
31
+ buttonAction: props.buttonAction,
32
+ data: values,
33
+ setLoadingState(state) {
34
+ setSubmitLoading(state);
35
+ },
36
+ successCallback() {
37
+ onCloseDrawerForm();
38
+ message.success({
39
+ content: `${props.label}成功`,
40
+ });
41
+ },
42
+ });
43
+ };
44
+ return (React.createElement(React.Fragment, null,
45
+ React.createElement(FlowButton, { ...props.buttonProps, buttonIcon: props.buttonIcon, id: props.id, onClick: onOpenDrawerForm }, props.label),
46
+ React.createElement(DrawerForm, { visible: visible, formInfo: props.approvalFormInfo, submit: onDrawerFormSubmit, isH5: isH5, submitLoading: submitLoading, onClose: onCloseDrawerForm })));
47
+ }
@@ -0,0 +1,60 @@
1
+ .weda-flow-approval-drawer.wedatea2td-drawer {
2
+ width: 500px !important;
3
+ top: 0 !important;
4
+ background-color: #fff;
5
+ }
6
+
7
+ .weda-flow-approval-drawer .wedatea2td-form {
8
+ display: block;
9
+ }
10
+
11
+ .weda-flow-approval-drawer .wedatea2td-form .wedatea2td-form__controls {
12
+ font-size: 12px;
13
+ }
14
+ .weda-flow-approval-drawer .wedatea2td-form .wedatea2td-form__label label {
15
+ color: #666;
16
+ }
17
+
18
+ .weda-flow-approval-drawer .wedatea2td-drawer__footer {
19
+ flex: 0 0 76px;
20
+ padding: 20px;
21
+ display: flex;
22
+ gap: 10px;
23
+ }
24
+
25
+ .weda-flow-approval-drawer .wedatea2td-drawer__footer button {
26
+ height: 36px;
27
+ width: 106px;
28
+ }
29
+ .weda-flow-approval-user-select .wedatea2td-form__label {
30
+ display: none;
31
+ }
32
+ .weda-flow-approval-user-select .wedatea2td-form__controls {
33
+ padding-top: 0;
34
+ }
35
+ .weda-flow-approval-user-select .wedatea2td-dropdown__header {
36
+ width: 100% !important;
37
+ }
38
+
39
+ /* 以下为移动视图样式 */
40
+
41
+ .weda-flow-approval-drawer-mobile {
42
+ z-index: 998 !important;
43
+ }
44
+
45
+ .weda-flow-approval-drawer-mobile .weda-flow-field {
46
+ margin-top: 12px;
47
+ }
48
+ .weda-flow-approval-drawer-mobile .weda-ui-user-select-input {
49
+ padding: 0;
50
+ }
51
+
52
+ .weda-flow-approval-drawer-mobile .submit {
53
+ position: absolute;
54
+ bottom: 30px;
55
+ height: 40px;
56
+ line-height: 40px;
57
+ width: 80%;
58
+ left: 50%;
59
+ transform: translateX(-50%);
60
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { getPageQuery } from '../../../../../utils/getPageQuery';
3
+ import { FlowButton } from '../components';
4
+ /**
5
+ * 取消申请
6
+ */
7
+ export function CancelApplyBtn(props) {
8
+ return (React.createElement(FlowButton, { ...props.buttonProps, buttonIcon: props.buttonIcon, id: props.id, onClick: navigateToFlowCenter }, props.label));
9
+ }
10
+ /** 返回流程中心 */
11
+ function navigateToFlowCenter() {
12
+ const { origin, pathname } = location;
13
+ const { envType } = getPageQuery();
14
+ window.location.href = `${origin}${pathname}#/flowCenter?envType=${envType}`;
15
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Button } from 'tea-component';
3
+ import { FlowPopup } from '../../components';
4
+ import './style.css';
5
+ /** 单双选弹窗(Popup)容器 */
6
+ export function FlowCheckListPopup(props) {
7
+ const { confirmButtonProps, confirmButtonText = '确认', ...restProps } = props;
8
+ return (React.createElement(FlowPopup, { position: "bottom", closeable: true, className: "weda-flow-checklist-popup", closeContentPosition: "top-left", closeContent: "\u53D6\u6D88", ...restProps },
9
+ React.createElement("div", { className: "weda-flow-checklist-body" }, props.children || null),
10
+ React.createElement(Button, { type: "link", className: "weda-flow-checklist-confirm", ...confirmButtonProps }, confirmButtonText)));
11
+ }