@coding-flow/flow-approval-presenter 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/LICENSE +201 -0
- package/README.md +261 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +12 -0
- package/dist/api/record.d.ts +10 -0
- package/dist/api/record.js +48 -0
- package/dist/api/workflow.d.ts +3 -0
- package/dist/api/workflow.js +7 -0
- package/dist/context/approval.d.ts +13 -0
- package/dist/context/approval.js +26 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +2 -0
- package/dist/context/mock.d.ts +2 -0
- package/dist/context/mock.js +3 -0
- package/dist/favicon.png +0 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/use-approval-context.d.ts +10 -0
- package/dist/hooks/use-approval-context.js +40 -0
- package/dist/hooks/use-mock-context.d.ts +1 -0
- package/dist/hooks/use-mock-context.js +4 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/model/index.d.ts +8 -0
- package/dist/model/index.js +16 -0
- package/dist/plugins/add-audit-type.d.ts +7 -0
- package/dist/plugins/add-audit-type.js +2 -0
- package/dist/plugins/delegate-type.d.ts +7 -0
- package/dist/plugins/delegate-type.js +2 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/return-type.d.ts +7 -0
- package/dist/plugins/return-type.js +2 -0
- package/dist/plugins/sign-key-type.d.ts +10 -0
- package/dist/plugins/sign-key-type.js +2 -0
- package/dist/plugins/transfer-type.d.ts +7 -0
- package/dist/plugins/transfer-type.js +2 -0
- package/dist/presenters/action.d.ts +28 -0
- package/dist/presenters/action.js +126 -0
- package/dist/presenters/index.d.ts +18 -0
- package/dist/presenters/index.js +35 -0
- package/dist/store/index.d.ts +15 -0
- package/dist/store/index.js +24 -0
- package/dist/typings/index.d.ts +21 -0
- package/dist/typings/index.js +2 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025-2026 copyright codingapi
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# @coding-flow/flow-pc-approval
|
|
2
|
+
|
|
3
|
+
Flow Engine PC 端审批组件库,提供待办/已办/审批处理等功能。
|
|
4
|
+
|
|
5
|
+
## 简介
|
|
6
|
+
|
|
7
|
+
`flow-pc-approval` 是 Flow Engine PC 端的审批页面组件库,提供:
|
|
8
|
+
|
|
9
|
+
- 待办列表(我的待办)
|
|
10
|
+
- 已办列表(我的已办)
|
|
11
|
+
- 我发起的(我的申请)
|
|
12
|
+
- 审批处理(审批操作)
|
|
13
|
+
- 流程详情查看
|
|
14
|
+
- 审批记录展示
|
|
15
|
+
|
|
16
|
+
### 依赖关系
|
|
17
|
+
|
|
18
|
+
- **依赖**: `@coding-flow/flow-pc-design`, `@coding-flow/flow-pc-ui`
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
安装依赖:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 开发
|
|
29
|
+
|
|
30
|
+
构建组件库:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm run build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
监听模式构建:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm run dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 核心功能
|
|
43
|
+
|
|
44
|
+
### 待办列表
|
|
45
|
+
|
|
46
|
+
我的待办任务列表:
|
|
47
|
+
|
|
48
|
+
- 任务筛选(按状态、类型、时间等)
|
|
49
|
+
- 任务搜索
|
|
50
|
+
- 批量操作
|
|
51
|
+
- 分页加载
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { TodoList } from '@coding-flow/flow-pc-approval';
|
|
55
|
+
|
|
56
|
+
<TodoList
|
|
57
|
+
filters={filters}
|
|
58
|
+
onTaskClick={handleTaskClick}
|
|
59
|
+
onBatchApprove={handleBatchApprove}
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 已办列表
|
|
64
|
+
|
|
65
|
+
我的已办任务列表:
|
|
66
|
+
|
|
67
|
+
- 历史记录查询
|
|
68
|
+
- 筛选和搜索
|
|
69
|
+
- 查看审批详情
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { DoneList } from '@coding-flow/flow-pc-approval';
|
|
73
|
+
|
|
74
|
+
<DoneList
|
|
75
|
+
filters={filters}
|
|
76
|
+
onTaskClick={handleTaskClick}
|
|
77
|
+
/>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 我发起的
|
|
81
|
+
|
|
82
|
+
我发起的流程列表:
|
|
83
|
+
|
|
84
|
+
- 流程状态查看
|
|
85
|
+
- 流程跟踪
|
|
86
|
+
- 撤回/取消操作
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { MyRequestsList } from '@coding-flow/flow-pc-approval';
|
|
90
|
+
|
|
91
|
+
<MyRequestsList
|
|
92
|
+
filters={filters}
|
|
93
|
+
onFlowClick={handleFlowClick}
|
|
94
|
+
onWithdraw={handleWithdraw}
|
|
95
|
+
/>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 审批处理
|
|
99
|
+
|
|
100
|
+
审批操作组件:
|
|
101
|
+
|
|
102
|
+
- 表单展示(只读/编辑)
|
|
103
|
+
- 审批意见填写
|
|
104
|
+
- 审批操作(通过/拒绝/保存/转交/退回/委托)
|
|
105
|
+
- 附件上传
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { ApprovalForm } from '@coding-flow/flow-pc-approval';
|
|
109
|
+
|
|
110
|
+
<ApprovalForm
|
|
111
|
+
taskId={taskId}
|
|
112
|
+
formSchema={formSchema}
|
|
113
|
+
formValues={formValues}
|
|
114
|
+
permissions={fieldPermissions}
|
|
115
|
+
onApprove={handleApprove}
|
|
116
|
+
onReject={handleReject}
|
|
117
|
+
onSave={handleSave}
|
|
118
|
+
onTransfer={handleTransfer}
|
|
119
|
+
onReturn={handleReturn}
|
|
120
|
+
onDelegate={handleDelegate}
|
|
121
|
+
/>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 流程详情
|
|
125
|
+
|
|
126
|
+
流程详情查看:
|
|
127
|
+
|
|
128
|
+
- 流程基本信息
|
|
129
|
+
- 节点状态展示
|
|
130
|
+
- 审批记录时间轴
|
|
131
|
+
- 表单数据展示
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { FlowDetail } from '@coding-flow/flow-pc-approval';
|
|
135
|
+
|
|
136
|
+
<FlowDetail
|
|
137
|
+
workflowId={workflowId}
|
|
138
|
+
instanceId={instanceId}
|
|
139
|
+
onBack={handleBack}
|
|
140
|
+
/>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 审批记录
|
|
144
|
+
|
|
145
|
+
审批记录展示:
|
|
146
|
+
|
|
147
|
+
- 时间轴展示
|
|
148
|
+
- 审批人信息
|
|
149
|
+
- 审批意见
|
|
150
|
+
- 审批时间
|
|
151
|
+
- 操作记录
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { ApprovalTimeline } from '@coding-flow/flow-pc-approval';
|
|
155
|
+
|
|
156
|
+
<ApprovalTimeline
|
|
157
|
+
records={approvalRecords}
|
|
158
|
+
currentNodeId={currentNodeId}
|
|
159
|
+
/>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 模块结构
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
flow-pc-approval/
|
|
166
|
+
├── src/
|
|
167
|
+
│ ├── todo/ # 待办列表
|
|
168
|
+
│ ├── done/ # 已办列表
|
|
169
|
+
│ ├── my-requests/ # 我发起的
|
|
170
|
+
│ ├── approval-form/ # 审批表单
|
|
171
|
+
│ ├── flow-detail/ # 流程详情
|
|
172
|
+
│ ├── timeline/ # 审批记录时间轴
|
|
173
|
+
│ ├── components/ # 公共组件
|
|
174
|
+
│ └── index.ts # 统一导出
|
|
175
|
+
└── README.md
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 使用示例
|
|
179
|
+
|
|
180
|
+
### 待办页面
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { TodoList, ApprovalModal } from '@coding-flow/flow-pc-approval';
|
|
184
|
+
|
|
185
|
+
const TodoPage = () => {
|
|
186
|
+
const [selectedTask, setSelectedTask] = useState(null);
|
|
187
|
+
const [showApprovalModal, setShowApprovalModal] = useState(false);
|
|
188
|
+
|
|
189
|
+
const handleTaskClick = async (task) => {
|
|
190
|
+
setSelectedTask(task);
|
|
191
|
+
setShowApprovalModal(true);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<>
|
|
196
|
+
<TodoList
|
|
197
|
+
filters={filters}
|
|
198
|
+
onTaskClick={handleTaskClick}
|
|
199
|
+
/>
|
|
200
|
+
{showApprovalModal && (
|
|
201
|
+
<ApprovalModal
|
|
202
|
+
taskId={selectedTask.id}
|
|
203
|
+
onClose={() => setShowApprovalModal(false)}
|
|
204
|
+
onApproved={handleRefresh}
|
|
205
|
+
/>
|
|
206
|
+
)}
|
|
207
|
+
</>
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### 审批操作
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { ApprovalForm } from '@coding-flow/flow-pc-approval';
|
|
216
|
+
|
|
217
|
+
const MyApprovalForm = () => {
|
|
218
|
+
const handleSubmit = async (action, opinion) => {
|
|
219
|
+
await approvalApi.submit({
|
|
220
|
+
taskId,
|
|
221
|
+
action,
|
|
222
|
+
opinion,
|
|
223
|
+
formData
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<ApprovalForm
|
|
229
|
+
taskId={taskId}
|
|
230
|
+
formSchema={formSchema}
|
|
231
|
+
formValues={formValues}
|
|
232
|
+
permissions={permissions}
|
|
233
|
+
onApprove={(opinion) => handleSubmit('PASS', opinion)}
|
|
234
|
+
onReject={(opinion) => handleSubmit('REJECT', opinion)}
|
|
235
|
+
onSave={(data) => handleSubmit('SAVE', data)}
|
|
236
|
+
onTransfer={(userId) => handleSubmit('TRANSFER', { userId })}
|
|
237
|
+
onReturn={(nodeId) => handleSubmit('RETURN', { nodeId })}
|
|
238
|
+
onDelegate={(userId) => handleSubmit('DELEGATE', { userId })}
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
};
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## 审批动作
|
|
245
|
+
|
|
246
|
+
支持以下审批动作:
|
|
247
|
+
|
|
248
|
+
- `PASS` - 通过
|
|
249
|
+
- `REJECT` - 拒绝
|
|
250
|
+
- `SAVE` - 保存
|
|
251
|
+
- `ADD_AUDIT` - 加签
|
|
252
|
+
- `DELEGATE` - 委托
|
|
253
|
+
- `RETURN` - 退回
|
|
254
|
+
- `TRANSFER` - 转交
|
|
255
|
+
- `CUSTOM` - 自定义动作
|
|
256
|
+
|
|
257
|
+
## Learn more
|
|
258
|
+
|
|
259
|
+
- [Rslib documentation](https://lib.rsbuild.io/) - Rslib 特性和 API
|
|
260
|
+
- [Flow Engine Docs](https://github.com/codingapi/flow-engine) - 完整文档
|
|
261
|
+
- [CLAUDE.md](../../../CLAUDE.md) - 开发指南
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpClient } from "@coding-flow/flow-core";
|
|
2
|
+
import { message } from "antd";
|
|
3
|
+
const httpClient = new HttpClient(10000, {
|
|
4
|
+
success: (msg)=>{
|
|
5
|
+
message.success(msg);
|
|
6
|
+
},
|
|
7
|
+
error: (msg)=>{
|
|
8
|
+
console.log(msg);
|
|
9
|
+
message.error(msg);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
export { httpClient };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const detail: (id: string, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
2
|
+
export declare const processNodes: (body: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
3
|
+
export declare const create: (body: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
4
|
+
export declare const action: (body: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
5
|
+
export declare const revoke: (id: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
6
|
+
export declare const urge: (id: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
7
|
+
export declare const list: (request: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
8
|
+
export declare const todo: (request: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
9
|
+
export declare const done: (request: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
10
|
+
export declare const notify: (request: any, mockKey?: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { httpClient } from "./index.js";
|
|
2
|
+
const detail = (id, mockKey)=>{
|
|
3
|
+
const key = mockKey ? mockKey : '';
|
|
4
|
+
return httpClient.get('/api/cmd/record/detail?mockKey=' + key, {
|
|
5
|
+
id
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
const processNodes = (body, mockKey)=>{
|
|
9
|
+
const key = mockKey ? mockKey : '';
|
|
10
|
+
return httpClient.post('/api/cmd/record/processNodes?mockKey=' + key, body);
|
|
11
|
+
};
|
|
12
|
+
const create = (body, mockKey)=>{
|
|
13
|
+
const key = mockKey ? mockKey : '';
|
|
14
|
+
return httpClient.post('/api/cmd/record/create?mockKey=' + key, body);
|
|
15
|
+
};
|
|
16
|
+
const action = (body, mockKey)=>{
|
|
17
|
+
const key = mockKey ? mockKey : '';
|
|
18
|
+
return httpClient.post('/api/cmd/record/action?mockKey=' + key, body);
|
|
19
|
+
};
|
|
20
|
+
const revoke = (id, mockKey)=>{
|
|
21
|
+
const key = mockKey ? mockKey : '';
|
|
22
|
+
return httpClient.post('/api/cmd/record/revoke?mockKey=' + key, {
|
|
23
|
+
id
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const urge = (id, mockKey)=>{
|
|
27
|
+
const key = mockKey ? mockKey : '';
|
|
28
|
+
return httpClient.post('/api/cmd/record/urge?mockKey=' + key, {
|
|
29
|
+
id
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const list = (request, mockKey)=>{
|
|
33
|
+
const key = mockKey ? mockKey : '';
|
|
34
|
+
return httpClient.page('/api/query/record/list?mockKey=' + key, request, {}, {}, []);
|
|
35
|
+
};
|
|
36
|
+
const todo = (request, mockKey)=>{
|
|
37
|
+
const key = mockKey ? mockKey : '';
|
|
38
|
+
return httpClient.page('/api/query/record/todo?mockKey=' + key, request, {}, {}, []);
|
|
39
|
+
};
|
|
40
|
+
const done = (request, mockKey)=>{
|
|
41
|
+
const key = mockKey ? mockKey : '';
|
|
42
|
+
return httpClient.page('/api/query/record/done?mockKey=' + key, request, {}, {}, []);
|
|
43
|
+
};
|
|
44
|
+
const notify = (request, mockKey)=>{
|
|
45
|
+
const key = mockKey ? mockKey : '';
|
|
46
|
+
return httpClient.page('/api/query/record/notify?mockKey=' + key, request, {}, {}, []);
|
|
47
|
+
};
|
|
48
|
+
export { action, create, detail, done, list, notify, processNodes, revoke, todo, urge };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const mock: () => Promise<import("@coding-flow/flow-core").Response>;
|
|
2
|
+
export declare const cleanMock: (id: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
3
|
+
export declare const options: () => Promise<import("@coding-flow/flow-core").Response>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { httpClient } from "./index.js";
|
|
2
|
+
const mock = ()=>httpClient.post('/api/cmd/workflow/mock', {});
|
|
3
|
+
const cleanMock = (id)=>httpClient.post('/api/cmd/workflow/cleanMock', {
|
|
4
|
+
id
|
|
5
|
+
});
|
|
6
|
+
const options = ()=>httpClient.get('/api/query/workflow/options');
|
|
7
|
+
export { cleanMock, mock, options };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ApprovalLayoutProps, ApprovalState } from "../typings";
|
|
3
|
+
import { ApprovalPresenter } from "../presenters";
|
|
4
|
+
export declare class ApprovalContextScope {
|
|
5
|
+
private readonly presenter;
|
|
6
|
+
private readonly props;
|
|
7
|
+
constructor(presenter: ApprovalPresenter, props: ApprovalLayoutProps);
|
|
8
|
+
syncState(state: ApprovalState): void;
|
|
9
|
+
getPresenter(): ApprovalPresenter;
|
|
10
|
+
close(): void;
|
|
11
|
+
initialState(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const ApprovalContext: React.Context<ApprovalContextScope | undefined>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
class ApprovalContextScope {
|
|
3
|
+
presenter;
|
|
4
|
+
props;
|
|
5
|
+
constructor(presenter, props){
|
|
6
|
+
this.presenter = presenter;
|
|
7
|
+
this.props = props;
|
|
8
|
+
}
|
|
9
|
+
syncState(state) {
|
|
10
|
+
this.presenter.syncState(state);
|
|
11
|
+
}
|
|
12
|
+
getPresenter() {
|
|
13
|
+
return this.presenter;
|
|
14
|
+
}
|
|
15
|
+
close() {
|
|
16
|
+
this.props.onClose?.();
|
|
17
|
+
}
|
|
18
|
+
initialState() {
|
|
19
|
+
this.presenter.initialState({
|
|
20
|
+
flow: this.props.content,
|
|
21
|
+
review: this.props.review
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const ApprovalContext = /*#__PURE__*/ react.createContext(void 0);
|
|
26
|
+
export { ApprovalContext, ApprovalContextScope };
|
package/dist/favicon.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApprovalContextScope } from "../context";
|
|
2
|
+
import { ApprovalLayoutProps } from "../typings";
|
|
3
|
+
export declare const useApprovalContext: () => {
|
|
4
|
+
state: import("../typings").ApprovalState;
|
|
5
|
+
context: ApprovalContextScope;
|
|
6
|
+
};
|
|
7
|
+
export declare const createApprovalContext: (props: ApprovalLayoutProps) => {
|
|
8
|
+
state: import("../typings").ApprovalState;
|
|
9
|
+
context: ApprovalContextScope;
|
|
10
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
3
|
+
import { ApprovalContext, ApprovalContextScope } from "../context/index.js";
|
|
4
|
+
import { updateState } from "../store/index.js";
|
|
5
|
+
import { ApprovalPresenter } from "../presenters/index.js";
|
|
6
|
+
import { FlowApprovalApiImpl } from "../model/index.js";
|
|
7
|
+
import { useMockContext } from "./use-mock-context.js";
|
|
8
|
+
const useApprovalContext = ()=>{
|
|
9
|
+
const context = react.useContext(ApprovalContext);
|
|
10
|
+
const state = useSelector((state)=>state.approval);
|
|
11
|
+
if (!context) throw new Error("ApprovalContext must be used within useContext");
|
|
12
|
+
return {
|
|
13
|
+
state,
|
|
14
|
+
context
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const createApprovalContext = (props)=>{
|
|
18
|
+
const ref = react.useRef(void 0);
|
|
19
|
+
const dispatch = useDispatch();
|
|
20
|
+
const state = useSelector((state)=>state.approval);
|
|
21
|
+
const mockKey = useMockContext();
|
|
22
|
+
if (!ref.current) {
|
|
23
|
+
const presenter = new ApprovalPresenter(state, (prevState)=>{
|
|
24
|
+
dispatch(updateState(prevState));
|
|
25
|
+
return prevState;
|
|
26
|
+
}, new FlowApprovalApiImpl(), mockKey);
|
|
27
|
+
ref.current = new ApprovalContextScope(presenter, props);
|
|
28
|
+
ref.current.initialState();
|
|
29
|
+
}
|
|
30
|
+
react.useEffect(()=>{
|
|
31
|
+
if (state.flow) ref.current?.syncState(state);
|
|
32
|
+
}, [
|
|
33
|
+
state
|
|
34
|
+
]);
|
|
35
|
+
return {
|
|
36
|
+
state,
|
|
37
|
+
context: ref.current
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export { createApprovalContext, useApprovalContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMockContext: () => string;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FlowApprovalApi } from "../typings";
|
|
2
|
+
export declare class FlowApprovalApiImpl implements FlowApprovalApi {
|
|
3
|
+
create: (body: Record<string, any>, mockKey: string) => Promise<any>;
|
|
4
|
+
action: (body: Record<string, any>, mockKey: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
5
|
+
processNodes: (body: Record<string, any>, mockKey: string) => Promise<any>;
|
|
6
|
+
revoke: (id: any, mockKey: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
7
|
+
urge: (id: any, mockKey: string) => Promise<import("@coding-flow/flow-core").Response>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { action, create, processNodes, revoke, urge } from "../api/record.js";
|
|
2
|
+
class FlowApprovalApiImpl {
|
|
3
|
+
create = async (body, mockKey)=>{
|
|
4
|
+
const response = await create(body, mockKey);
|
|
5
|
+
if (response.success) return response.data;
|
|
6
|
+
};
|
|
7
|
+
action = async (body, mockKey)=>await action(body, mockKey);
|
|
8
|
+
processNodes = async (body, mockKey)=>{
|
|
9
|
+
const response = await processNodes(body, mockKey);
|
|
10
|
+
if (response.success) return response.data.list;
|
|
11
|
+
return [];
|
|
12
|
+
};
|
|
13
|
+
revoke = async (id, mockKey)=>await revoke(id, mockKey);
|
|
14
|
+
urge = async (id, mockKey)=>await urge(id, mockKey);
|
|
15
|
+
}
|
|
16
|
+
export { FlowApprovalApiImpl };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type AddAuditViewPlugin, VIEW_KEY as AddAuditViewPluginKey } from "./add-audit-type";
|
|
2
|
+
export { type DelegateViewPlugin, VIEW_KEY as DelegateViewPluginKey } from "./delegate-type";
|
|
3
|
+
export { type ReturnViewPlugin, VIEW_KEY as ReturnViewPluginKey } from "./return-type";
|
|
4
|
+
export { type SignKeyViewPlugin, VIEW_KEY as SignKeyViewPluginKey } from "./sign-key-type";
|
|
5
|
+
export { type TransferViewPlugin, VIEW_KEY as TransferViewPluginKey } from "./transfer-type";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { VIEW_KEY } from "./add-audit-type.js";
|
|
2
|
+
import { VIEW_KEY as external_delegate_type_js_VIEW_KEY } from "./delegate-type.js";
|
|
3
|
+
import { VIEW_KEY as external_return_type_js_VIEW_KEY } from "./return-type.js";
|
|
4
|
+
import { VIEW_KEY as external_sign_key_type_js_VIEW_KEY } from "./sign-key-type.js";
|
|
5
|
+
import { VIEW_KEY as external_transfer_type_js_VIEW_KEY } from "./transfer-type.js";
|
|
6
|
+
export { VIEW_KEY as AddAuditViewPluginKey, external_delegate_type_js_VIEW_KEY as DelegateViewPluginKey, external_return_type_js_VIEW_KEY as ReturnViewPluginKey, external_sign_key_type_js_VIEW_KEY as SignKeyViewPluginKey, external_transfer_type_js_VIEW_KEY as TransferViewPluginKey };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FlowOperator } from "@coding-flow/flow-types";
|
|
2
|
+
export declare const VIEW_KEY = "SignKeyViewPlugin";
|
|
3
|
+
export interface SignKeyViewPlugin {
|
|
4
|
+
/** 当前用户 */
|
|
5
|
+
current: FlowOperator;
|
|
6
|
+
/** 返回签名 */
|
|
7
|
+
onChange?: (value: string) => void;
|
|
8
|
+
/** 当前签名 */
|
|
9
|
+
value?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ApprovalState, FlowApprovalApi } from "../typings";
|
|
2
|
+
import { FormActionContext } from "@coding-flow/flow-types";
|
|
3
|
+
export declare class FlowActionPresenter {
|
|
4
|
+
private readonly api;
|
|
5
|
+
private readonly formActionContext;
|
|
6
|
+
private state;
|
|
7
|
+
private readonly mockKey;
|
|
8
|
+
private submitRecordIds;
|
|
9
|
+
constructor(state: ApprovalState, api: FlowApprovalApi, formActionContext: FormActionContext, mockKey: string);
|
|
10
|
+
setSubmitRecordIds(submitRecordIds: number[]): void;
|
|
11
|
+
private clearSubmitRecordIds;
|
|
12
|
+
getSubmitRecordIds(): number[];
|
|
13
|
+
syncState(state: ApprovalState): void;
|
|
14
|
+
processNodes(): Promise<import("@coding-flow/flow-types").ProcessNode[]>;
|
|
15
|
+
/**
|
|
16
|
+
* 是否通过操作
|
|
17
|
+
* @param actionId
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
private isPassAction;
|
|
21
|
+
private submitAction;
|
|
22
|
+
getCurrentFormData(): {};
|
|
23
|
+
private executeAction;
|
|
24
|
+
private getFormDataByRecordId;
|
|
25
|
+
revoke(): Promise<any>;
|
|
26
|
+
urge(): Promise<any>;
|
|
27
|
+
action(actionId: string, params?: any): Promise<any>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { GroovyScriptConvertorUtil } from "@coding-flow/flow-core";
|
|
2
|
+
class FlowActionPresenter {
|
|
3
|
+
api;
|
|
4
|
+
formActionContext;
|
|
5
|
+
state;
|
|
6
|
+
mockKey;
|
|
7
|
+
submitRecordIds;
|
|
8
|
+
constructor(state, api, formActionContext, mockKey){
|
|
9
|
+
this.state = state;
|
|
10
|
+
this.api = api;
|
|
11
|
+
this.formActionContext = formActionContext;
|
|
12
|
+
this.submitRecordIds = [];
|
|
13
|
+
this.mockKey = mockKey;
|
|
14
|
+
}
|
|
15
|
+
setSubmitRecordIds(submitRecordIds) {
|
|
16
|
+
this.submitRecordIds = [];
|
|
17
|
+
this.submitRecordIds = submitRecordIds;
|
|
18
|
+
}
|
|
19
|
+
clearSubmitRecordIds() {
|
|
20
|
+
this.submitRecordIds = [];
|
|
21
|
+
}
|
|
22
|
+
getSubmitRecordIds() {
|
|
23
|
+
return this.submitRecordIds;
|
|
24
|
+
}
|
|
25
|
+
syncState(state) {
|
|
26
|
+
this.state = state;
|
|
27
|
+
}
|
|
28
|
+
async processNodes() {
|
|
29
|
+
const formData = this.formActionContext.save();
|
|
30
|
+
const recordId = formData.recordId || this.state.flow?.recordId;
|
|
31
|
+
if (formData.recordId) delete formData.recordId;
|
|
32
|
+
const id = recordId || this.state.flow?.workId || '';
|
|
33
|
+
return await this.api.processNodes({
|
|
34
|
+
id,
|
|
35
|
+
formData
|
|
36
|
+
}, this.mockKey);
|
|
37
|
+
}
|
|
38
|
+
isPassAction(actionId) {
|
|
39
|
+
const actions = this.state.flow?.actions || [];
|
|
40
|
+
for (const action of actions)if (action.id === actionId) {
|
|
41
|
+
if ('PASS' === action.type) return true;
|
|
42
|
+
if ('CUSTOM' === action.type) {
|
|
43
|
+
const script = action.script || '';
|
|
44
|
+
const returnData = GroovyScriptConvertorUtil.getReturnScript(script);
|
|
45
|
+
if (returnData.includes('PASS')) return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
async submitAction(actionId, formData, params) {
|
|
51
|
+
const recordId = formData.recordId || this.state.flow?.recordId;
|
|
52
|
+
const workId = this.state.flow?.workId;
|
|
53
|
+
if (formData.recordId) delete formData.recordId;
|
|
54
|
+
if (recordId) {
|
|
55
|
+
const request = {
|
|
56
|
+
formData,
|
|
57
|
+
recordId,
|
|
58
|
+
advice: {
|
|
59
|
+
actionId,
|
|
60
|
+
...params
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return await this.api.action(request, this.mockKey);
|
|
64
|
+
}
|
|
65
|
+
{
|
|
66
|
+
const createRequest = {
|
|
67
|
+
workId,
|
|
68
|
+
formData,
|
|
69
|
+
actionId
|
|
70
|
+
};
|
|
71
|
+
const recordId = await this.api.create(createRequest, this.mockKey);
|
|
72
|
+
const actionRequest = {
|
|
73
|
+
formData,
|
|
74
|
+
recordId,
|
|
75
|
+
advice: {
|
|
76
|
+
actionId,
|
|
77
|
+
...params
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return await this.api.action(actionRequest, this.mockKey);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
getCurrentFormData() {
|
|
84
|
+
return this.formActionContext.save();
|
|
85
|
+
}
|
|
86
|
+
async executeAction(actionId, params) {
|
|
87
|
+
let formData;
|
|
88
|
+
formData = this.isPassAction(actionId) ? await this.formActionContext.validate() : this.formActionContext.save();
|
|
89
|
+
return await this.submitAction(actionId, formData, params);
|
|
90
|
+
}
|
|
91
|
+
getFormDataByRecordId(recordId) {
|
|
92
|
+
const todoList = this.state.flow?.todos || [];
|
|
93
|
+
for (const item of todoList)if (item.recordId === recordId) return {
|
|
94
|
+
...item.data,
|
|
95
|
+
recordId
|
|
96
|
+
};
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
async revoke() {
|
|
100
|
+
const recordId = this.state.flow?.recordId;
|
|
101
|
+
if (recordId) return await this.api.revoke(recordId, this.mockKey);
|
|
102
|
+
}
|
|
103
|
+
async urge() {
|
|
104
|
+
const recordId = this.state.flow?.recordId;
|
|
105
|
+
if (recordId) return await this.api.urge(recordId, this.mockKey);
|
|
106
|
+
}
|
|
107
|
+
async action(actionId, params) {
|
|
108
|
+
const mergeable = this.state.flow?.mergeable || false;
|
|
109
|
+
const submitRecordIds = this.submitRecordIds;
|
|
110
|
+
if (!mergeable || !(submitRecordIds.length > 0)) return await this.executeAction(actionId, params);
|
|
111
|
+
{
|
|
112
|
+
const submitRecordIds = this.submitRecordIds;
|
|
113
|
+
for (const recordId of submitRecordIds){
|
|
114
|
+
const formData = this.getFormDataByRecordId(recordId);
|
|
115
|
+
await this.submitAction(actionId, formData, params);
|
|
116
|
+
}
|
|
117
|
+
this.clearSubmitRecordIds();
|
|
118
|
+
return new Promise((resolve)=>{
|
|
119
|
+
resolve({
|
|
120
|
+
success: true
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export { FlowActionPresenter };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FlowApprovalApi, ApprovalState } from "../typings";
|
|
2
|
+
import { Dispatch } from "@coding-flow/flow-core";
|
|
3
|
+
import { FormActionContext } from "@coding-flow/flow-types";
|
|
4
|
+
import { FlowActionPresenter } from "./action";
|
|
5
|
+
export declare class ApprovalPresenter {
|
|
6
|
+
private state;
|
|
7
|
+
private readonly mockKey;
|
|
8
|
+
private readonly dispatch;
|
|
9
|
+
private readonly api;
|
|
10
|
+
private readonly formActionContext;
|
|
11
|
+
private readonly flowActionPresenter;
|
|
12
|
+
constructor(state: ApprovalState, dispatch: Dispatch<ApprovalState>, api: FlowApprovalApi, mockKey: string);
|
|
13
|
+
syncState(state: ApprovalState): void;
|
|
14
|
+
getFormActionContext(): FormActionContext;
|
|
15
|
+
getFlowActionPresenter(): FlowActionPresenter;
|
|
16
|
+
initialState(state: ApprovalState): void;
|
|
17
|
+
processNodes(): Promise<import("@coding-flow/flow-types").ProcessNode[]>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FormActionContext } from "@coding-flow/flow-types";
|
|
2
|
+
import { FlowActionPresenter } from "./action.js";
|
|
3
|
+
class ApprovalPresenter {
|
|
4
|
+
state;
|
|
5
|
+
mockKey;
|
|
6
|
+
dispatch;
|
|
7
|
+
api;
|
|
8
|
+
formActionContext;
|
|
9
|
+
flowActionPresenter;
|
|
10
|
+
constructor(state, dispatch, api, mockKey){
|
|
11
|
+
this.state = state;
|
|
12
|
+
this.dispatch = dispatch;
|
|
13
|
+
this.api = api;
|
|
14
|
+
this.formActionContext = new FormActionContext();
|
|
15
|
+
this.mockKey = mockKey;
|
|
16
|
+
this.flowActionPresenter = new FlowActionPresenter(state, api, this.formActionContext, mockKey);
|
|
17
|
+
}
|
|
18
|
+
syncState(state) {
|
|
19
|
+
this.state = state;
|
|
20
|
+
this.flowActionPresenter.syncState(state);
|
|
21
|
+
}
|
|
22
|
+
getFormActionContext() {
|
|
23
|
+
return this.formActionContext;
|
|
24
|
+
}
|
|
25
|
+
getFlowActionPresenter() {
|
|
26
|
+
return this.flowActionPresenter;
|
|
27
|
+
}
|
|
28
|
+
initialState(state) {
|
|
29
|
+
this.dispatch(state);
|
|
30
|
+
}
|
|
31
|
+
processNodes() {
|
|
32
|
+
return this.flowActionPresenter.processNodes();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export { ApprovalPresenter };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PayloadAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { ApprovalState } from "../typings";
|
|
3
|
+
export type ApprovalStoreAction = {
|
|
4
|
+
updateState: (state: ApprovalState, action: PayloadAction<Partial<ApprovalState> | ((prev: ApprovalState) => Partial<ApprovalState>)>) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const approvalSlice: import("@reduxjs/toolkit").Slice<ApprovalState, ApprovalStoreAction, "approval", "approval", {}>;
|
|
7
|
+
export declare const updateState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<ApprovalState> | ((prev: ApprovalState) => Partial<ApprovalState>), "approval/updateState">;
|
|
8
|
+
export declare const approvalStore: import("@reduxjs/toolkit").EnhancedStore<{
|
|
9
|
+
approval: ApprovalState;
|
|
10
|
+
}, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
11
|
+
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
12
|
+
approval: ApprovalState;
|
|
13
|
+
}, undefined, import("redux").UnknownAction>;
|
|
14
|
+
}>, import("redux").StoreEnhancer]>>;
|
|
15
|
+
export type ApprovalReduxState = ReturnType<typeof approvalStore.getState>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { configureStore, createSlice } from "@reduxjs/toolkit";
|
|
2
|
+
import { initStateData } from "../typings/index.js";
|
|
3
|
+
import { original } from "immer";
|
|
4
|
+
const approvalSlice = createSlice({
|
|
5
|
+
name: 'approval',
|
|
6
|
+
initialState: {
|
|
7
|
+
...initStateData
|
|
8
|
+
},
|
|
9
|
+
reducers: {
|
|
10
|
+
updateState: (state, action)=>{
|
|
11
|
+
if ('function' == typeof action.payload) {
|
|
12
|
+
const currentState = original(state);
|
|
13
|
+
Object.assign(state, action.payload(currentState));
|
|
14
|
+
} else Object.assign(state, action.payload);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const { updateState } = approvalSlice.actions;
|
|
19
|
+
const approvalStore = configureStore({
|
|
20
|
+
reducer: {
|
|
21
|
+
approval: approvalSlice.reducer
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
export { approvalSlice, approvalStore, updateState };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FlowContent, ProcessNode } from "@coding-flow/flow-types";
|
|
2
|
+
/**
|
|
3
|
+
* 流程审批布局组件属性
|
|
4
|
+
*/
|
|
5
|
+
export interface ApprovalLayoutProps {
|
|
6
|
+
content: FlowContent;
|
|
7
|
+
review?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export type ApprovalState = {
|
|
11
|
+
flow?: FlowContent;
|
|
12
|
+
review?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const initStateData: {};
|
|
15
|
+
export interface FlowApprovalApi {
|
|
16
|
+
create(body: Record<string, any>, mockKey: string): Promise<number>;
|
|
17
|
+
processNodes(body: Record<string, any>, mockKey: string): Promise<ProcessNode[]>;
|
|
18
|
+
action(body: Record<string, any>, mockKey: string): Promise<any>;
|
|
19
|
+
revoke(id: any, mockKey: string): Promise<any>;
|
|
20
|
+
urge(id: any, mockKey: string): Promise<any>;
|
|
21
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coding-flow/flow-approval-presenter",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "flow-engine approval presenter framework ",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"coding-flow",
|
|
8
|
+
"flow-engine"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/codingapi/flow-frontend",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/codingapi/flow-frontend/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/codingapi/flow-frontend.git"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"author": "1024lorne@gmail.com",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=18",
|
|
32
|
+
"react-dom": ">=18"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@reduxjs/toolkit": "^2.11.2",
|
|
36
|
+
"dayjs": "^1.11.19",
|
|
37
|
+
"immer": "^11.1.3",
|
|
38
|
+
"react-redux": "^9.2.0",
|
|
39
|
+
"@coding-flow/flow-core": "0.0.1",
|
|
40
|
+
"@coding-flow/flow-types": "0.0.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@coding-flow/flow-types": "0.0.1"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "rslib build",
|
|
47
|
+
"dev": "rslib build --watch",
|
|
48
|
+
"test": "rstest",
|
|
49
|
+
"push": "pnpm run build && pnpm publish --access public"
|
|
50
|
+
}
|
|
51
|
+
}
|