@steedos-labs/plugin-workflow 3.0.0-beta.9 → 3.0.1-beta.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/main/default/client/instance.client.js +6 -6
- package/main/default/client/object_workflows.client.js +8 -7
- package/main/default/client/socket.client.js +46 -3
- package/main/default/manager/import.js +17 -1
- package/main/default/manager/instance_manager.js +20 -6
- package/main/default/manager/push_manager.js +20 -12
- package/main/default/manager/uuflowManagerForInitApproval.js +794 -0
- package/main/default/manager/uuflow_manager.js +53 -4
- package/main/default/manager/workflow_manager.js +1 -1
- package/main/default/methods/instance_approve.js +258 -0
- package/main/default/methods/trace_approve_cc.js +571 -0
- package/main/default/objectTranslations/flows.en/flows.en.objectTranslation.yml +19 -0
- package/main/default/objectTranslations/flows.zh-CN/flows.zh-CN.objectTranslation.yml +19 -0
- package/main/default/objectTranslations/forms.en/forms.en.objectTranslation.yml +191 -0
- package/main/default/objectTranslations/forms.zh-CN/forms.zh-CN.objectTranslation.yml +246 -0
- package/main/default/objectTranslations/instance_tasks.en/instance_tasks.en.objectTranslation.yml +213 -0
- package/main/default/objectTranslations/instance_tasks.zh-CN/instance_tasks.zh-CN.objectTranslation.yml +213 -0
- package/main/default/objectTranslations/instances.en/instances.en.objectTranslation.yml +212 -0
- package/main/default/objectTranslations/instances.zh-CN/instances.zh-CN.objectTranslation.yml +209 -0
- package/main/default/objects/categories.object.yml +1 -0
- package/main/default/objects/flows/buttons/del.button.yml +7 -10
- package/main/default/objects/flows/buttons/design_form_layout.button.js +5 -2
- package/main/default/objects/flows/buttons/distributeAdmin.button.yml +5 -5
- package/main/default/objects/flows/buttons/newexport.button.yml +1 -1
- package/main/default/objects/flows/buttons/newimport.button.yml +2 -1
- package/main/default/objects/flows/flows.object.yml +12 -4
- package/main/default/objects/forms/forms.object.yml +85 -0
- package/main/default/objects/instance_tasks/buttons/instance_new.button.yml +3 -5
- package/main/default/objects/instances/buttons/instance_cc.button.yml +7 -7
- package/main/default/objects/instances/buttons/instance_delete.button.yml +2 -2
- package/main/default/objects/instances/buttons/instance_delete_many.button.yml +6 -6
- package/main/default/objects/instances/buttons/instance_distribute.button.yml +14 -13
- package/main/default/objects/instances/buttons/instance_flow_chart.button.yml +1 -1
- package/main/default/objects/instances/buttons/instance_forward.button.yml +8 -8
- package/main/default/objects/instances/buttons/instance_new.button.yml +3 -5
- package/main/default/objects/instances/buttons/instance_reassign.button.yml +1 -16
- package/main/default/objects/instances/buttons/instance_related.button.yml +4 -4
- package/main/default/objects/instances/buttons/instance_relocate.button.yml +9 -12
- package/main/default/objects/instances/buttons/instance_retrieve.button.yml +106 -2
- package/main/default/objects/instances/buttons/instance_save.button.yml +3 -9
- package/main/default/objects/instances/buttons/instance_submit.button.yml +1 -1
- package/main/default/objects/instances/buttons/instance_terminate.button.yml +7 -10
- package/main/default/objects/instances/listviews/monitor.listview.yml +0 -1
- package/main/default/pages/flowdetail.page.amis.json +11 -11
- package/main/default/pages/instance_detail.page.amis.json +25 -37
- package/main/default/pages/instance_tasks_detail.page.amis.json +21 -5
- package/main/default/pages/instance_tasks_list.page.amis.json +147 -110
- package/main/default/pages/instances_list.page.amis.json +146 -110
- package/main/default/routes/afterHook.js +34 -0
- package/main/default/routes/am.router.js +49 -2
- package/main/default/routes/api_cc.router.js +5 -12
- package/main/default/routes/api_flow_permission.router.js +7 -2
- package/main/default/routes/api_get_object_workflows.router.js +79 -22
- package/main/default/routes/api_have_read.router.js +73 -0
- package/main/default/routes/api_object_workflow_drafts.router.js +18 -19
- package/main/default/routes/api_workflow_approve_save.router.js +2 -1
- package/main/default/routes/api_workflow_chart.router.js +682 -0
- package/main/default/routes/api_workflow_engine.router.js +4 -4
- package/main/default/routes/api_workflow_flow_version.router.js +61 -0
- package/main/default/routes/api_workflow_form_version.router.js +61 -0
- package/main/default/routes/api_workflow_instance_return.router.js +164 -167
- package/main/default/routes/api_workflow_next_step_users.router.js +13 -8
- package/main/default/routes/api_workflow_reassign.router.js +200 -196
- package/main/default/routes/api_workflow_relocate.router.js +4 -3
- package/main/default/routes/api_workflow_retrieve.router.js +246 -237
- package/main/default/routes/export.router.js +5 -4
- package/main/default/routes/flow_form_design.ejs +33 -8
- package/main/default/routes/flow_form_design.router.js +4 -3
- package/main/default/routes/import.router.js +6 -7
- package/main/default/services/flows.service.js +1 -1
- package/main/default/translations/en.translation.yml +5 -0
- package/main/default/translations/zh-CN.translation.yml +2 -1
- package/main/default/triggers/amis_form_design.trigger.js +27 -5
- package/main/default/triggers/instances.trigger.js +9 -7
- package/main/default/utils/designerManager.js +12 -5
- package/package.json +4 -4
- package/package.service.js +21 -7
- package/public/workflow/index.css +4 -0
- package/src/instance_record_queue.js +1 -3
- package/src/rests/api_workflow_instance_batch_remove.js +4 -3
- package/src/webhook_queue.js +283 -0
- package/main/default/manager/index.js +0 -23
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 2022-12-24 14:52:54
|
|
4
|
-
* @LastEditors: sunhaolin@
|
|
5
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditors: 孙浩林 sunhaolin@steedos.com
|
|
5
|
+
* @LastEditTime: 2025-10-05 16:12:03
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
'use strict';
|
|
@@ -11,7 +11,6 @@ const express = require('express');
|
|
|
11
11
|
const router = express.Router();
|
|
12
12
|
const { requireAuthentication } = require("@steedos/auth");
|
|
13
13
|
const _ = require('underscore');
|
|
14
|
-
const Fiber = function(fun){console.log('TODO Fiber...')}
|
|
15
14
|
const {
|
|
16
15
|
insert_instance_tasks,
|
|
17
16
|
update_instance_tasks,
|
|
@@ -19,6 +18,7 @@ const {
|
|
|
19
18
|
} = require('../manager/instance_tasks_manager')
|
|
20
19
|
const UUFlowManager = require('../manager/uuflow_manager');
|
|
21
20
|
const pushManager = require('../manager/push_manager');
|
|
21
|
+
const { getCollection, _makeNewID } = require('../utils/collection');
|
|
22
22
|
/**
|
|
23
23
|
@api {post} /api/workflow/retrieve 取回
|
|
24
24
|
@apiVersion 0.0.0
|
|
@@ -41,253 +41,262 @@ router.post('/api/workflow/retrieve', requireAuthentication, async function (req
|
|
|
41
41
|
const spaceId = userSession.spaceId;
|
|
42
42
|
const userId = userSession.userId;
|
|
43
43
|
const isSpaceAdmin = userSession.is_space_admin;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
44
|
+
|
|
45
|
+
const instancesCollection = await getCollection('instances');
|
|
46
|
+
const usersCollection = await getCollection('users');
|
|
47
|
+
const spaceUsersCollection = await getCollection('space_users');
|
|
48
|
+
const organizationsCollection = await getCollection('organizations');
|
|
49
|
+
|
|
50
|
+
var current_user, current_user_info, e, hashData;
|
|
51
|
+
current_user_info = Object.assign({}, userSession, { _id: userSession.userId })
|
|
52
|
+
current_user = current_user_info._id;
|
|
53
|
+
hashData = req.body;
|
|
54
|
+
var cc_users, flow, handler_info, i, ins, instance, instance_id, last_trace, last_trace_id, newApprove, newTrace, now, old_inbox_users, org_info, previous_step, previous_trace, previous_trace_approves, previous_trace_id, previous_trace_name, previous_trace_step_id, r, retrieve_approve, retrieve_comment, retrieve_type, setObj, space_id, space_user, the_trace, traces;
|
|
55
|
+
instance = await UUFlowManager.getInstance(hashData["_id"]);
|
|
56
|
+
retrieve_comment = hashData['retrieve_comment'];
|
|
57
|
+
// 验证instance为审核中状态
|
|
58
|
+
// UUFlowManager.isInstancePending(instance)
|
|
59
|
+
// 校验申请单是当前用户已审核过的单子或者当前用户是提交人或申请人
|
|
60
|
+
if ((!instance.outbox_users.includes(current_user)) && (instance.submitter !== current_user && instance.applicant !== current_user)) {
|
|
61
|
+
throw new Error('当前用户不符合取回条件');
|
|
62
|
+
}
|
|
63
|
+
retrieve_type = "";
|
|
64
|
+
traces = instance.traces;
|
|
65
|
+
//获取最新的trace, 即取回步骤
|
|
66
|
+
last_trace = _.last(traces);
|
|
67
|
+
last_trace_id = last_trace._id;
|
|
68
|
+
previous_trace_id = last_trace.previous_trace_ids[0];
|
|
69
|
+
previous_trace = _.find(traces, function (t) {
|
|
70
|
+
return t._id === previous_trace_id;
|
|
71
|
+
});
|
|
72
|
+
previous_trace_step_id = previous_trace.step;
|
|
73
|
+
previous_trace_name = previous_trace.name;
|
|
74
|
+
flow = await UUFlowManager.getFlow(instance.flow);
|
|
75
|
+
previous_step = await UUFlowManager.getStep(instance, flow, previous_trace_step_id);
|
|
76
|
+
if (previous_step.step_type === "counterSign") {
|
|
77
|
+
throw new Error('会签不能取回');
|
|
78
|
+
}
|
|
79
|
+
// 取回步骤的前一个步骤处理人唯一(即排除掉传阅和转发的approve后,剩余的approve只有一个)并且是当前用户
|
|
80
|
+
previous_trace_approves = _.filter(previous_trace.approves, function (a) {
|
|
81
|
+
return a.type !== 'cc' && a.type !== 'distribute' && a.type !== 'forward' && ['approved', 'submitted', 'rejected'].includes(a.judge);
|
|
82
|
+
});
|
|
83
|
+
if (previous_trace_approves.length === 1 && (previous_trace_approves[0].user === current_user || previous_trace_approves[0].handler === current_user)) {
|
|
84
|
+
retrieve_type = 'normal'; // 申请单正常流转的取回,即非传阅取回
|
|
85
|
+
}
|
|
86
|
+
i = traces.length;
|
|
87
|
+
retrieve_approve = {};
|
|
88
|
+
while (i > 0) {
|
|
89
|
+
_.each(traces[i - 1].approves, function (a) {
|
|
90
|
+
if (a.type === 'cc' && a.is_finished === true && a.user === current_user) {
|
|
91
|
+
retrieve_type = 'cc';
|
|
92
|
+
return retrieve_approve = a;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
if (retrieve_type === 'cc') {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
i--;
|
|
99
|
+
}
|
|
100
|
+
if (retrieve_type === 'normal') {
|
|
101
|
+
// 获取一个flow
|
|
102
|
+
flow = await UUFlowManager.getFlow(instance.flow);
|
|
103
|
+
previous_step = await UUFlowManager.getStep(instance, flow, previous_trace_step_id);
|
|
104
|
+
space_id = instance.space;
|
|
105
|
+
instance_id = instance._id;
|
|
106
|
+
old_inbox_users = instance.inbox_users;
|
|
107
|
+
setObj = new Object;
|
|
108
|
+
now = new Date;
|
|
109
|
+
const finishedApproveIds = []
|
|
110
|
+
let retrieve_appr_id = ''
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
for (const t of traces) {
|
|
114
|
+
var current_space_user, current_user_organization, retrieve_appr;
|
|
115
|
+
if (t._id === last_trace_id) {
|
|
116
|
+
if (!t.approves) {
|
|
117
|
+
t.approves = new Array;
|
|
75
118
|
}
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
119
|
+
// 更新当前trace.approve记录
|
|
120
|
+
_.each(t.approves, function (appr) {
|
|
121
|
+
if (appr.is_finished === false && appr.type !== "cc") {
|
|
122
|
+
appr.start_date = now;
|
|
123
|
+
appr.finish_date = now;
|
|
124
|
+
appr.read_date = now;
|
|
125
|
+
appr.is_error = false;
|
|
126
|
+
appr.is_read = true;
|
|
127
|
+
appr.is_finished = true;
|
|
128
|
+
appr.judge = "terminated";
|
|
129
|
+
appr.cost_time = appr.finish_date - appr.start_date;
|
|
130
|
+
|
|
131
|
+
finishedApproveIds.push(appr._id)
|
|
132
|
+
}
|
|
79
133
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (a.type === 'cc' && a.is_finished === true && a.user === current_user) {
|
|
88
|
-
retrieve_type = 'cc';
|
|
89
|
-
return retrieve_approve = a;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
if (retrieve_type === 'cc') {
|
|
93
|
-
break;
|
|
134
|
+
// 在同一trace下插入取回操作者的approve记录
|
|
135
|
+
current_space_user = await UUFlowManager.getSpaceUser(space_id, current_user);
|
|
136
|
+
|
|
137
|
+
current_user_organization = await organizationsCollection.findOne({ _id: current_space_user.organization }, {
|
|
138
|
+
projection: {
|
|
139
|
+
name: 1,
|
|
140
|
+
fullname: 1
|
|
94
141
|
}
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
if (retrieve_type === 'normal') {
|
|
98
|
-
// 获取一个flow
|
|
99
|
-
flow = UUFlowManager.getFlow(instance.flow);
|
|
100
|
-
previous_step = UUFlowManager.getStep(instance, flow, previous_trace_step_id);
|
|
101
|
-
space_id = instance.space;
|
|
102
|
-
instance_id = instance._id;
|
|
103
|
-
old_inbox_users = instance.inbox_users;
|
|
104
|
-
setObj = new Object;
|
|
105
|
-
now = new Date;
|
|
106
|
-
const finishedApproveIds = []
|
|
107
|
-
let retrieve_appr_id = ''
|
|
108
|
-
_.each(traces, function (t) {
|
|
109
|
-
var current_space_user, current_user_organization, retrieve_appr;
|
|
110
|
-
if (t._id === last_trace_id) {
|
|
111
|
-
if (!t.approves) {
|
|
112
|
-
t.approves = new Array;
|
|
113
|
-
}
|
|
114
|
-
// 更新当前trace.approve记录
|
|
115
|
-
_.each(t.approves, function (appr) {
|
|
116
|
-
if (appr.is_finished === false && appr.type !== "cc") {
|
|
117
|
-
appr.start_date = now;
|
|
118
|
-
appr.finish_date = now;
|
|
119
|
-
appr.read_date = now;
|
|
120
|
-
appr.is_error = false;
|
|
121
|
-
appr.is_read = true;
|
|
122
|
-
appr.is_finished = true;
|
|
123
|
-
appr.judge = "terminated";
|
|
124
|
-
appr.cost_time = appr.finish_date - appr.start_date;
|
|
142
|
+
})
|
|
125
143
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
newTrace.name = previous_trace_name;
|
|
174
|
-
newTrace.start_date = now;
|
|
175
|
-
newTrace.due_date = UUFlowManager.getDueDate(previous_step.timeout_hours, space_id);
|
|
176
|
-
newTrace.approves = [];
|
|
177
|
-
// 插入下一步trace.approve记录
|
|
178
|
-
newApprove = new Object;
|
|
179
|
-
newApprove._id = _makeNewID();
|
|
180
|
-
newApprove.instance = instance_id;
|
|
181
|
-
newApprove.trace = newTrace._id;
|
|
182
|
-
newApprove.is_finished = false;
|
|
183
|
-
newApprove.user = current_user;
|
|
184
|
-
handler_info = db.users.findOne(current_user, {
|
|
185
|
-
fields: {
|
|
186
|
-
name: 1
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
newApprove.user_name = handler_info.name;
|
|
190
|
-
newApprove.handler = current_user;
|
|
191
|
-
newApprove.handler_name = handler_info.name;
|
|
192
|
-
space_user = UUFlowManager.getSpaceUser(space_id, current_user);
|
|
193
|
-
// 获取next_step_user所在的部门信息
|
|
194
|
-
org_info = UUFlowManager.getSpaceUserOrgInfo(space_user);
|
|
195
|
-
newApprove.handler_organization = org_info["organization"];
|
|
196
|
-
newApprove.handler_organization_name = org_info["organization_name"];
|
|
197
|
-
newApprove.handler_organization_fullname = org_info["organization_fullname"];
|
|
198
|
-
newApprove.start_date = now;
|
|
199
|
-
newApprove.due_date = newTrace.due_date;
|
|
200
|
-
newApprove.is_read = false;
|
|
201
|
-
newApprove.is_error = false;
|
|
202
|
-
newApprove.values = new Object;
|
|
203
|
-
UUFlowManager.setRemindInfo(instance.values, newApprove);
|
|
204
|
-
newTrace.approves.push(newApprove);
|
|
205
|
-
setObj.inbox_users = [current_user];
|
|
206
|
-
setObj.modified = now;
|
|
207
|
-
setObj.modified_by = current_user;
|
|
208
|
-
traces.push(newTrace);
|
|
209
|
-
setObj.traces = traces;
|
|
210
|
-
setObj.state = "pending";
|
|
211
|
-
setObj.is_archived = false;
|
|
212
|
-
setObj.current_step_name = previous_trace_name;
|
|
213
|
-
setObj.current_step_auto_submit = UUFlowManager.getCurrentStepAutoSubmit(flow.timeout_auto_submit, previous_step.lines);
|
|
214
|
-
r = db.instances.update({
|
|
215
|
-
_id: instance_id
|
|
216
|
-
}, {
|
|
217
|
-
$set: setObj
|
|
218
|
-
});
|
|
144
|
+
retrieve_appr = new Object;
|
|
145
|
+
retrieve_appr._id = _makeNewID();
|
|
146
|
+
retrieve_appr.instance = instance_id;
|
|
147
|
+
retrieve_appr.trace = t._id;
|
|
148
|
+
retrieve_appr.is_finished = true;
|
|
149
|
+
retrieve_appr.user = current_user;
|
|
150
|
+
retrieve_appr.user_name = current_user_info.name;
|
|
151
|
+
retrieve_appr.handler = current_user;
|
|
152
|
+
retrieve_appr.handler_name = current_user_info.name;
|
|
153
|
+
retrieve_appr.handler_organization = current_space_user.organization;
|
|
154
|
+
retrieve_appr.handler_organization_name = current_user_organization.name;
|
|
155
|
+
retrieve_appr.handler_organization_fullname = current_user_organization.fullname;
|
|
156
|
+
retrieve_appr.start_date = now;
|
|
157
|
+
retrieve_appr.finish_date = now;
|
|
158
|
+
retrieve_appr.due_date = t.due_date;
|
|
159
|
+
retrieve_appr.read_date = now;
|
|
160
|
+
retrieve_appr.judge = "retrieved";
|
|
161
|
+
retrieve_appr.is_read = true;
|
|
162
|
+
retrieve_appr.description = retrieve_comment;
|
|
163
|
+
retrieve_appr.is_error = false;
|
|
164
|
+
retrieve_appr.values = new Object;
|
|
165
|
+
retrieve_appr.cost_time = retrieve_appr.finish_date - retrieve_appr.start_date;
|
|
166
|
+
t.approves.push(retrieve_appr);
|
|
167
|
+
// 更新当前trace记录
|
|
168
|
+
t.is_finished = true;
|
|
169
|
+
t.finish_date = now;
|
|
170
|
+
t.judge = "retrieved";
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
// 插入下一步trace记录
|
|
174
|
+
newTrace = new Object;
|
|
175
|
+
newTrace._id = _makeNewID();
|
|
176
|
+
newTrace.instance = instance_id;
|
|
177
|
+
newTrace.previous_trace_ids = [last_trace_id];
|
|
178
|
+
newTrace.is_finished = false;
|
|
179
|
+
newTrace.step = previous_trace_step_id;
|
|
180
|
+
newTrace.name = previous_trace_name;
|
|
181
|
+
newTrace.start_date = now;
|
|
182
|
+
newTrace.due_date = await UUFlowManager.getDueDate(previous_step.timeout_hours, space_id);
|
|
183
|
+
newTrace.approves = [];
|
|
184
|
+
// 插入下一步trace.approve记录
|
|
185
|
+
newApprove = new Object;
|
|
186
|
+
newApprove._id = _makeNewID();
|
|
187
|
+
newApprove.instance = instance_id;
|
|
188
|
+
newApprove.trace = newTrace._id;
|
|
189
|
+
newApprove.is_finished = false;
|
|
190
|
+
newApprove.user = current_user;
|
|
219
191
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
insert_instance_tasks(instance_id, newTrace._id, newApprove._id)
|
|
192
|
+
handler_info = await usersCollection.findOne({ _id: current_user }, {
|
|
193
|
+
projection: {
|
|
194
|
+
name: 1
|
|
195
|
+
}
|
|
196
|
+
})
|
|
226
197
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
cc_users = instance.cc_users;
|
|
255
|
-
cc_users.push(current_user);
|
|
256
|
-
setObj.modified = now;
|
|
257
|
-
setObj.modified_by = current_user;
|
|
258
|
-
setObj.state = "pending";
|
|
259
|
-
setObj.is_archived = false;
|
|
260
|
-
setObj.cc_users = cc_users;
|
|
261
|
-
setObj['traces.$.approves'] = the_trace.approves;
|
|
262
|
-
r = db.instances.update({
|
|
263
|
-
_id: instance_id,
|
|
264
|
-
'traces._id': retrieve_approve.trace
|
|
265
|
-
}, {
|
|
266
|
-
$set: setObj
|
|
267
|
-
});
|
|
198
|
+
newApprove.user_name = handler_info.name;
|
|
199
|
+
newApprove.handler = current_user;
|
|
200
|
+
newApprove.handler_name = handler_info.name;
|
|
201
|
+
space_user = await UUFlowManager.getSpaceUser(space_id, current_user);
|
|
202
|
+
// 获取next_step_user所在的部门信息
|
|
203
|
+
org_info = await UUFlowManager.getSpaceUserOrgInfo(space_user);
|
|
204
|
+
newApprove.handler_organization = org_info["organization"];
|
|
205
|
+
newApprove.handler_organization_name = org_info["organization_name"];
|
|
206
|
+
newApprove.handler_organization_fullname = org_info["organization_fullname"];
|
|
207
|
+
newApprove.start_date = now;
|
|
208
|
+
newApprove.due_date = newTrace.due_date;
|
|
209
|
+
newApprove.is_read = false;
|
|
210
|
+
newApprove.is_error = false;
|
|
211
|
+
newApprove.values = new Object;
|
|
212
|
+
await UUFlowManager.setRemindInfo(instance.values, newApprove);
|
|
213
|
+
newTrace.approves.push(newApprove);
|
|
214
|
+
setObj.inbox_users = [current_user];
|
|
215
|
+
setObj.modified = now;
|
|
216
|
+
setObj.modified_by = current_user;
|
|
217
|
+
traces.push(newTrace);
|
|
218
|
+
setObj.traces = traces;
|
|
219
|
+
setObj.state = "pending";
|
|
220
|
+
setObj.is_archived = false;
|
|
221
|
+
setObj.current_step_name = previous_trace_name;
|
|
222
|
+
setObj.current_step_auto_submit = await UUFlowManager.getCurrentStepAutoSubmit(flow.timeout_auto_submit, previous_step.lines);
|
|
268
223
|
|
|
269
|
-
|
|
224
|
+
r = await instancesCollection.updateOne({
|
|
225
|
+
_id: instance_id,
|
|
226
|
+
}, {
|
|
227
|
+
$set: setObj,
|
|
228
|
+
});
|
|
270
229
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
230
|
+
// 更新被取回的approve
|
|
231
|
+
await update_many_instance_tasks(instance_id, last_trace_id, finishedApproveIds)
|
|
232
|
+
// 插入取回操作的approve
|
|
233
|
+
await insert_instance_tasks(instance_id, last_trace_id, retrieve_appr_id)
|
|
234
|
+
// 插入新步骤的approve
|
|
235
|
+
await insert_instance_tasks(instance_id, newTrace._id, newApprove._id)
|
|
236
|
+
|
|
237
|
+
if (r) {
|
|
238
|
+
// 给被删除的inbox_users 和 当前用户 发送push
|
|
239
|
+
await pushManager.send_message_current_user(current_user_info);
|
|
240
|
+
for (const user_id of old_inbox_users) {
|
|
241
|
+
if (user_id !== current_user) {
|
|
242
|
+
await pushManager.send_message_to_specifyUser("current_user", user_id);
|
|
277
243
|
}
|
|
278
|
-
}
|
|
244
|
+
};
|
|
245
|
+
ins = await UUFlowManager.getInstance(instance_id);
|
|
246
|
+
// 如果已经配置webhook并已激活则触发
|
|
247
|
+
await pushManager.triggerWebhook(ins.flow, ins, {}, 'retrieve', current_user, ins.inbox_users);
|
|
248
|
+
}
|
|
249
|
+
} else if (retrieve_type === 'cc') {
|
|
250
|
+
setObj = new Object;
|
|
251
|
+
now = new Date;
|
|
252
|
+
instance_id = instance._id;
|
|
253
|
+
the_trace = _.find(traces, function (t) {
|
|
254
|
+
return t._id === retrieve_approve.trace;
|
|
255
|
+
});
|
|
256
|
+
_.each(the_trace.approves, function (a) {
|
|
257
|
+
if (a._id === retrieve_approve._id) {
|
|
258
|
+
a.is_finished = false;
|
|
259
|
+
a.finish_date = void 0;
|
|
260
|
+
a.judge = void 0;
|
|
261
|
+
return a.cost_time = void 0;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
cc_users = instance.cc_users;
|
|
265
|
+
cc_users.push(current_user);
|
|
266
|
+
setObj.modified = now;
|
|
267
|
+
setObj.modified_by = current_user;
|
|
268
|
+
setObj.state = "pending";
|
|
269
|
+
setObj.is_archived = false;
|
|
270
|
+
setObj.cc_users = cc_users;
|
|
271
|
+
setObj['traces.$.approves'] = the_trace.approves;
|
|
272
|
+
r = await instancesCollection.updateOne({
|
|
273
|
+
_id: instance_id,
|
|
274
|
+
'traces._id': retrieve_approve.trace
|
|
275
|
+
}, {
|
|
276
|
+
$set: setObj,
|
|
277
|
+
});
|
|
279
278
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
errors: [{ errorMessage: e.message }]
|
|
285
|
-
});
|
|
279
|
+
await update_instance_tasks(instance_id, retrieve_approve.trace, retrieve_approve._id)
|
|
280
|
+
|
|
281
|
+
if (r) {
|
|
282
|
+
await pushManager.send_message_current_user(current_user_info);
|
|
286
283
|
}
|
|
287
|
-
|
|
284
|
+
ins = UUFlowManager.getInstance(instance_id);
|
|
285
|
+
// 如果已经配置webhook并已激活则触发
|
|
286
|
+
await pushManager.triggerWebhook(ins.flow, ins, {}, 'retrieve', current_user, [current_user]);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
res.status(200).send({
|
|
290
|
+
status: 0,
|
|
291
|
+
data: {}
|
|
292
|
+
});
|
|
293
|
+
|
|
288
294
|
} catch (e) {
|
|
295
|
+
console.log(e);
|
|
289
296
|
res.status(200).send({
|
|
290
|
-
|
|
297
|
+
status: -1,
|
|
298
|
+
msg: e.message,
|
|
299
|
+
data: {}
|
|
291
300
|
});
|
|
292
301
|
}
|
|
293
302
|
});
|
|
@@ -18,8 +18,9 @@ const { getCollection } = require('../utils/collection');
|
|
|
18
18
|
|
|
19
19
|
const exportByFlowIds = async function (flowIds, res) {
|
|
20
20
|
const db = {
|
|
21
|
-
forms: getCollection('forms'),
|
|
22
|
-
|
|
21
|
+
forms: await getCollection('forms'),
|
|
22
|
+
flows: await getCollection('flows'),
|
|
23
|
+
spaces: await getCollection('spaces')
|
|
23
24
|
}
|
|
24
25
|
var fileNames, flows, zip;
|
|
25
26
|
flows = await db.flows.find({
|
|
@@ -47,12 +48,12 @@ const exportByFlowIds = async function (flowIds, res) {
|
|
|
47
48
|
} else {
|
|
48
49
|
fileNames[fileName] = 1;
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
+
zip.file(`${fileName}.json`, new Buffer(JSON.stringify(data), 'utf-8'));
|
|
51
52
|
}
|
|
52
53
|
res.setHeader('Content-type', 'application/octet-stream');
|
|
53
54
|
res.setHeader('Content-Disposition', 'attachment;filename=' + encodeURI('导出的流程文件') + '.zip');
|
|
54
55
|
return zip.generateNodeStream().pipe(res).on('finish', function () {
|
|
55
|
-
|
|
56
|
+
console.log("text file written.");
|
|
56
57
|
});
|
|
57
58
|
};
|
|
58
59
|
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
<link href="/toast/toastr.min.css" rel="stylesheet" />
|
|
10
10
|
<script src="/jquery.min.js"></script>
|
|
11
11
|
<script src="/toast/toastr.min.js"></script>
|
|
12
|
+
<script>
|
|
13
|
+
window._disabledFields = [
|
|
14
|
+
'autonumber', 'formula', 'summary'
|
|
15
|
+
]
|
|
16
|
+
</script>
|
|
12
17
|
<style>
|
|
13
18
|
#toast-container.toast-bottom-center>div,
|
|
14
19
|
#toast-container.toast-top-center>div {
|
|
@@ -61,7 +66,10 @@
|
|
|
61
66
|
useOpenAPI: useOpenAPI,
|
|
62
67
|
id: "<%=id%>",
|
|
63
68
|
pageId: "<%=id%>",
|
|
64
|
-
hiddenDeploy: true
|
|
69
|
+
hiddenDeploy: true,
|
|
70
|
+
title: "<%=locale%>" === 'zh-CN' ? '流程表单设计器': 'Flow Form Designer',
|
|
71
|
+
saveText: "<%=locale%>" === 'zh-CN' ? '保存': 'Save',
|
|
72
|
+
deployText: "<%=locale%>" === 'zh-CN' ? '发布': 'Deploy',
|
|
65
73
|
};
|
|
66
74
|
|
|
67
75
|
let comp = document.querySelector("builder-fiddle");
|
|
@@ -110,6 +118,12 @@
|
|
|
110
118
|
tenantId,
|
|
111
119
|
authToken,
|
|
112
120
|
},
|
|
121
|
+
global: {
|
|
122
|
+
userId: userId,
|
|
123
|
+
spaceId: tenantId,
|
|
124
|
+
user: <%- JSON.stringify(userSession) %>,
|
|
125
|
+
now: new Date(),
|
|
126
|
+
}
|
|
113
127
|
},
|
|
114
128
|
};
|
|
115
129
|
|
|
@@ -122,6 +136,8 @@
|
|
|
122
136
|
{
|
|
123
137
|
record:forms__findOne(id: "${id}"){
|
|
124
138
|
_id,
|
|
139
|
+
name,
|
|
140
|
+
description,
|
|
125
141
|
amis_schema,
|
|
126
142
|
current
|
|
127
143
|
}
|
|
@@ -139,14 +155,14 @@
|
|
|
139
155
|
|
|
140
156
|
if (!schema) {
|
|
141
157
|
//进if说明schema字段为空 说明为旧表单 对schema重新赋值
|
|
142
|
-
schema =
|
|
143
|
-
|
|
144
|
-
type: "form",
|
|
158
|
+
schema = {
|
|
159
|
+
type: 'steedos-flow-form',
|
|
145
160
|
id: "instanceForm",
|
|
146
|
-
name:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
"
|
|
161
|
+
name: result.data.data.record.name,
|
|
162
|
+
label: result.data.data.record.name,
|
|
163
|
+
description: result.data.data.record.description,
|
|
164
|
+
className: "steedos-flow-form steedos-flow-layout-page",
|
|
165
|
+
body: []
|
|
150
166
|
}
|
|
151
167
|
if (result.data.data.record.current.fields) {
|
|
152
168
|
for (let i = 0; i < result.data.data.record.current.fields.length; i++) {
|
|
@@ -185,6 +201,14 @@
|
|
|
185
201
|
schema.data.context.tenantId = tenantId;
|
|
186
202
|
schema.data.context.userId = userId;
|
|
187
203
|
schema.data.context.authToken = authToken;
|
|
204
|
+
|
|
205
|
+
schema.data.global = {
|
|
206
|
+
userId: userId,
|
|
207
|
+
spaceId: tenantId,
|
|
208
|
+
user: <%- JSON.stringify(userSession) %>,
|
|
209
|
+
now: new Date(),
|
|
210
|
+
}
|
|
211
|
+
|
|
188
212
|
return schema || initialContent
|
|
189
213
|
}
|
|
190
214
|
} else {
|
|
@@ -457,6 +481,7 @@
|
|
|
457
481
|
);
|
|
458
482
|
if (schema.data && typeof schema.data.context === 'object') {
|
|
459
483
|
delete schema.data.context
|
|
484
|
+
delete schema.data.global
|
|
460
485
|
}
|
|
461
486
|
|
|
462
487
|
return await axios.post(
|