@steedos/process 2.2.55-beta.7 → 2.3.0-beta.3
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/lib/approve.js +7 -7
- package/lib/approve.js.map +1 -1
- package/lib/express-middleware.js +0 -1
- package/lib/express-middleware.js.map +1 -1
- package/lib/notifications.js +6 -6
- package/lib/notifications.js.map +1 -1
- package/lib/permission.js +17 -17
- package/lib/permission.js.map +1 -1
- package/lib/permission_manager.js +17 -30
- package/lib/permission_manager.js.map +1 -1
- package/lib/platform_action_manager.js +24 -24
- package/lib/platform_action_manager.js.map +1 -1
- package/lib/process_manager.js +183 -236
- package/lib/process_manager.js.map +1 -1
- package/lib/reassign.js +7 -7
- package/lib/reassign.js.map +1 -1
- package/lib/recall.js +10 -10
- package/lib/recall.js.map +1 -1
- package/lib/reject.js +7 -7
- package/lib/reject.js.map +1 -1
- package/lib/submit.js +5 -5
- package/lib/submit.js.map +1 -1
- package/package.json +4 -4
package/lib/process_manager.js
CHANGED
|
@@ -46,20 +46,20 @@ var _ = require("underscore");
|
|
|
46
46
|
var lockObjectRecord = function (objectName, reocrdId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
47
|
return __generator(this, function (_a) {
|
|
48
48
|
switch (_a.label) {
|
|
49
|
-
case 0: return [4
|
|
49
|
+
case 0: return [4, objectql.getObject(objectName).directUpdate(reocrdId, { locked: true })];
|
|
50
50
|
case 1:
|
|
51
51
|
_a.sent();
|
|
52
|
-
return [2
|
|
52
|
+
return [2];
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
}); };
|
|
56
56
|
var unlockObjectRecord = function (objectName, reocrdId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
57
|
return __generator(this, function (_a) {
|
|
58
58
|
switch (_a.label) {
|
|
59
|
-
case 0: return [4
|
|
59
|
+
case 0: return [4, objectql.getObject(objectName).directUpdate(reocrdId, { locked: false })];
|
|
60
60
|
case 1:
|
|
61
61
|
_a.sent();
|
|
62
|
-
return [2
|
|
62
|
+
return [2];
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
}); };
|
|
@@ -69,39 +69,39 @@ var getProcessNodeApprover = function (instanceId, processNode, userSession, cho
|
|
|
69
69
|
switch (_c.label) {
|
|
70
70
|
case 0:
|
|
71
71
|
nodeApprover = [];
|
|
72
|
-
if (!isBack) return [3
|
|
73
|
-
return [4
|
|
72
|
+
if (!isBack) return [3, 4];
|
|
73
|
+
return [4, objectql.getObject("process_instance_node").find({ filters: [['process_instance', '=', instanceId], ['process_node', '=', processNode._id]], sort: "created desc" })];
|
|
74
74
|
case 1:
|
|
75
75
|
processInstanceNodes = _c.sent();
|
|
76
|
-
if (!!_.isEmpty(processInstanceNodes)) return [3
|
|
76
|
+
if (!!_.isEmpty(processInstanceNodes)) return [3, 3];
|
|
77
77
|
lastProcessInstanceNode = processInstanceNodes[0];
|
|
78
|
-
return [4
|
|
78
|
+
return [4, objectql.getObject("process_instance_history").find({ filters: ['process_instance_node', '=', lastProcessInstanceNode._id] })];
|
|
79
79
|
case 2:
|
|
80
80
|
nodeHistroy = _c.sent();
|
|
81
81
|
_.each(nodeHistroy, function (item) {
|
|
82
82
|
nodeApprover.push(item.original_actor);
|
|
83
83
|
});
|
|
84
84
|
_c.label = 3;
|
|
85
|
-
case 3: return [3
|
|
85
|
+
case 3: return [3, 27];
|
|
86
86
|
case 4:
|
|
87
87
|
approver = processNode.approver;
|
|
88
|
-
if (!(approver === 'auto_assign')) return [3
|
|
88
|
+
if (!(approver === 'auto_assign')) return [3, 26];
|
|
89
89
|
if (!_.isEmpty(processNode.assigned_approver_users)) {
|
|
90
90
|
nodeApprover = nodeApprover.concat(processNode.assigned_approver_users);
|
|
91
91
|
}
|
|
92
|
-
if (!!_.isEmpty(processNode.assigned_approver_roles)) return [3
|
|
92
|
+
if (!!_.isEmpty(processNode.assigned_approver_roles)) return [3, 10];
|
|
93
93
|
_i = 0, _a = processNode.assigned_approver_roles;
|
|
94
94
|
_c.label = 5;
|
|
95
95
|
case 5:
|
|
96
|
-
if (!(_i < _a.length)) return [3
|
|
96
|
+
if (!(_i < _a.length)) return [3, 10];
|
|
97
97
|
roleId = _a[_i];
|
|
98
|
-
return [4
|
|
98
|
+
return [4, objectql.getObject("roles").find({ filters: ['api_name', '=', roleId] })];
|
|
99
99
|
case 6:
|
|
100
100
|
dbRoles = _c.sent();
|
|
101
|
-
if (!(dbRoles && dbRoles.length > 0 && !_.isEmpty(dbRoles[0].users))) return [3
|
|
101
|
+
if (!(dbRoles && dbRoles.length > 0 && !_.isEmpty(dbRoles[0].users))) return [3, 7];
|
|
102
102
|
nodeApprover = nodeApprover.concat(dbRoles[0].users);
|
|
103
|
-
return [3
|
|
104
|
-
case 7: return [4
|
|
103
|
+
return [3, 9];
|
|
104
|
+
case 7: return [4, objectql.getObject('roles').findOne(roleId)];
|
|
105
105
|
case 8:
|
|
106
106
|
role = _c.sent();
|
|
107
107
|
if (role && !_.isEmpty(role.users)) {
|
|
@@ -110,13 +110,13 @@ var getProcessNodeApprover = function (instanceId, processNode, userSession, cho
|
|
|
110
110
|
_c.label = 9;
|
|
111
111
|
case 9:
|
|
112
112
|
_i++;
|
|
113
|
-
return [3
|
|
113
|
+
return [3, 5];
|
|
114
114
|
case 10:
|
|
115
|
-
if (!!_.isEmpty(processNode.assigned_approver_flow_roles)) return [3
|
|
115
|
+
if (!!_.isEmpty(processNode.assigned_approver_flow_roles)) return [3, 21];
|
|
116
116
|
submitted_by_1 = userSession.userId;
|
|
117
117
|
spaceId_1 = userSession.spaceId;
|
|
118
|
-
if (!instanceId) return [3
|
|
119
|
-
return [4
|
|
118
|
+
if (!instanceId) return [3, 12];
|
|
119
|
+
return [4, objectql.getObject("process_instance").findOne(instanceId)];
|
|
120
120
|
case 11:
|
|
121
121
|
processInstance = _c.sent();
|
|
122
122
|
submitted_by_1 = processInstance.submitted_by;
|
|
@@ -127,16 +127,16 @@ var getProcessNodeApprover = function (instanceId, processNode, userSession, cho
|
|
|
127
127
|
_b = 0, flowRoleKeys_1 = flowRoleKeys;
|
|
128
128
|
_c.label = 13;
|
|
129
129
|
case 13:
|
|
130
|
-
if (!(_b < flowRoleKeys_1.length)) return [3
|
|
130
|
+
if (!(_b < flowRoleKeys_1.length)) return [3, 19];
|
|
131
131
|
flowRoleKey = flowRoleKeys_1[_b];
|
|
132
132
|
dbFlowRole = void 0;
|
|
133
|
-
return [4
|
|
133
|
+
return [4, objectql.getObject("flow_roles").find({ filters: ['api_name', '=', flowRoleKey] })];
|
|
134
134
|
case 14:
|
|
135
135
|
dbFlowRoles = _c.sent();
|
|
136
|
-
if (!(dbFlowRoles && dbFlowRoles.length == 1)) return [3
|
|
136
|
+
if (!(dbFlowRoles && dbFlowRoles.length == 1)) return [3, 15];
|
|
137
137
|
dbFlowRole = dbFlowRoles[0];
|
|
138
|
-
return [3
|
|
139
|
-
case 15: return [4
|
|
138
|
+
return [3, 17];
|
|
139
|
+
case 15: return [4, objectql.getObject("flow_roles").findOne(flowRoleKey)];
|
|
140
140
|
case 16:
|
|
141
141
|
dbFlowRole = _c.sent();
|
|
142
142
|
_c.label = 17;
|
|
@@ -145,8 +145,8 @@ var getProcessNodeApprover = function (instanceId, processNode, userSession, cho
|
|
|
145
145
|
_c.label = 18;
|
|
146
146
|
case 18:
|
|
147
147
|
_b++;
|
|
148
|
-
return [3
|
|
149
|
-
case 19: return [4
|
|
148
|
+
return [3, 13];
|
|
149
|
+
case 19: return [4, new Promise(function (resolve, reject) {
|
|
150
150
|
Fiber(function () {
|
|
151
151
|
try {
|
|
152
152
|
var handlers_1 = getHandlersManager.getHandlersByUserAndRoles(submitted_by_1, assigned_approver_flow_role_ids_1, spaceId_1);
|
|
@@ -162,12 +162,12 @@ var getProcessNodeApprover = function (instanceId, processNode, userSession, cho
|
|
|
162
162
|
nodeApprover = nodeApprover.concat(handlers);
|
|
163
163
|
_c.label = 21;
|
|
164
164
|
case 21:
|
|
165
|
-
if (!!_.isEmpty(processNode.assigned_approver_user_field)) return [3
|
|
166
|
-
if (!instanceId) return [3
|
|
167
|
-
return [4
|
|
165
|
+
if (!!_.isEmpty(processNode.assigned_approver_user_field)) return [3, 25];
|
|
166
|
+
if (!instanceId) return [3, 24];
|
|
167
|
+
return [4, objectql.getObject("process_instance").findOne(instanceId)];
|
|
168
168
|
case 22:
|
|
169
169
|
processInstance = _c.sent();
|
|
170
|
-
return [4
|
|
170
|
+
return [4, objectql.getObject(processInstance.target_object.o).findOne(processInstance.target_object.ids[0])];
|
|
171
171
|
case 23:
|
|
172
172
|
record = _c.sent();
|
|
173
173
|
_c.label = 24;
|
|
@@ -184,15 +184,15 @@ var getProcessNodeApprover = function (instanceId, processNode, userSession, cho
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
_c.label = 25;
|
|
187
|
-
case 25: return [3
|
|
187
|
+
case 25: return [3, 27];
|
|
188
188
|
case 26:
|
|
189
189
|
if (approver === 'submitter_choose') {
|
|
190
190
|
if (chooseApprover) {
|
|
191
191
|
if (_.isString(chooseApprover)) {
|
|
192
|
-
return [2
|
|
192
|
+
return [2, [chooseApprover]];
|
|
193
193
|
}
|
|
194
194
|
else if (_.isArray(chooseApprover)) {
|
|
195
|
-
return [2
|
|
195
|
+
return [2, _.uniq(_.compact(chooseApprover))];
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
198
|
throw new objectql_1.SteedosError('process_approval_error_invalidChooseApprover');
|
|
@@ -203,15 +203,15 @@ var getProcessNodeApprover = function (instanceId, processNode, userSession, cho
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
_c.label = 27;
|
|
206
|
-
case 27: return [2
|
|
206
|
+
case 27: return [2, _.uniq(_.compact(nodeApprover))];
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
209
|
}); };
|
|
210
210
|
var getProcessNodes = function (processDefinitionId, spaceId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
211
211
|
return __generator(this, function (_a) {
|
|
212
212
|
switch (_a.label) {
|
|
213
|
-
case 0: return [4
|
|
214
|
-
case 1: return [2
|
|
213
|
+
case 0: return [4, objectql.getObject('process_node').find({ filters: [['process_definition', '=', processDefinitionId], ['space', '=', spaceId]], sort: "order asc" })];
|
|
214
|
+
case 1: return [2, _a.sent()];
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
}); };
|
|
@@ -219,19 +219,19 @@ var addInstanceHistory = function (spaceId, instanceId, status, comment, options
|
|
|
219
219
|
var instance, name, node, instanceHistory;
|
|
220
220
|
return __generator(this, function (_a) {
|
|
221
221
|
switch (_a.label) {
|
|
222
|
-
case 0: return [4
|
|
222
|
+
case 0: return [4, objectql.getObject("process_instance").findOne(instanceId)];
|
|
223
223
|
case 1:
|
|
224
224
|
instance = _a.sent();
|
|
225
225
|
name = '';
|
|
226
|
-
if (!options.nodeId) return [3
|
|
227
|
-
return [4
|
|
226
|
+
if (!options.nodeId) return [3, 3];
|
|
227
|
+
return [4, objectql.getObject("process_node").findOne(options.nodeId)];
|
|
228
228
|
case 2:
|
|
229
229
|
node = _a.sent();
|
|
230
230
|
if (node) {
|
|
231
231
|
name = node.label;
|
|
232
232
|
}
|
|
233
233
|
_a.label = 3;
|
|
234
|
-
case 3: return [4
|
|
234
|
+
case 3: return [4, objectql.getObject("process_instance_history").insert({
|
|
235
235
|
name: name,
|
|
236
236
|
process_instance: instanceId,
|
|
237
237
|
target_object: instance.target_object,
|
|
@@ -246,18 +246,18 @@ var addInstanceHistory = function (spaceId, instanceId, status, comment, options
|
|
|
246
246
|
})];
|
|
247
247
|
case 4:
|
|
248
248
|
instanceHistory = _a.sent();
|
|
249
|
-
if (!(status === 'approved' || status === 'rejected')) return [3
|
|
250
|
-
return [4
|
|
249
|
+
if (!(status === 'approved' || status === 'rejected')) return [3, 6];
|
|
250
|
+
return [4, handleProcessInstance(instanceHistory.process_instance, status, userSession)];
|
|
251
251
|
case 5:
|
|
252
252
|
_a.sent();
|
|
253
253
|
_a.label = 6;
|
|
254
254
|
case 6:
|
|
255
|
-
if (!(status === 'pending')) return [3
|
|
256
|
-
return [4
|
|
255
|
+
if (!(status === 'pending')) return [3, 8];
|
|
256
|
+
return [4, (0, notifications_1.sendNotifications)(instance.created_by, options.actor, { instanceHistory: instanceHistory, status: status, instance: instance })];
|
|
257
257
|
case 7:
|
|
258
258
|
_a.sent();
|
|
259
259
|
_a.label = 8;
|
|
260
|
-
case 8: return [2
|
|
260
|
+
case 8: return [2];
|
|
261
261
|
}
|
|
262
262
|
});
|
|
263
263
|
}); };
|
|
@@ -268,7 +268,7 @@ var addInstanceNode = function (instanceId, node, userSession, nodeApprover) { r
|
|
|
268
268
|
case 0:
|
|
269
269
|
nodeId = node._id;
|
|
270
270
|
nodeName = node.label;
|
|
271
|
-
return [4
|
|
271
|
+
return [4, objectql.getObject("process_instance_node").insert({
|
|
272
272
|
process_instance: instanceId,
|
|
273
273
|
process_node: nodeId,
|
|
274
274
|
process_node_name: nodeName,
|
|
@@ -281,16 +281,16 @@ var addInstanceNode = function (instanceId, node, userSession, nodeApprover) { r
|
|
|
281
281
|
_i = 0, nodeApprover_1 = nodeApprover;
|
|
282
282
|
_a.label = 2;
|
|
283
283
|
case 2:
|
|
284
|
-
if (!(_i < nodeApprover_1.length)) return [3
|
|
284
|
+
if (!(_i < nodeApprover_1.length)) return [3, 5];
|
|
285
285
|
actor = nodeApprover_1[_i];
|
|
286
|
-
return [4
|
|
286
|
+
return [4, addInstanceHistory(userSession.spaceId, instanceId, 'pending', null, { nodeId: nodeId, actor: actor, originalActor: actor, submitted_by: userSession.userId, instanceNodeId: instanceNode._id }, userSession)];
|
|
287
287
|
case 3:
|
|
288
288
|
_a.sent();
|
|
289
289
|
_a.label = 4;
|
|
290
290
|
case 4:
|
|
291
291
|
_i++;
|
|
292
|
-
return [3
|
|
293
|
-
case 5: return [2
|
|
292
|
+
return [3, 2];
|
|
293
|
+
case 5: return [2];
|
|
294
294
|
}
|
|
295
295
|
});
|
|
296
296
|
}); };
|
|
@@ -304,27 +304,27 @@ var getNextNode = function (nodes, index, objectName, recordId, userSession) {
|
|
|
304
304
|
spaceId = userSession.spaceId;
|
|
305
305
|
currentUserId = userSession.userId;
|
|
306
306
|
node = nodes[index];
|
|
307
|
-
if (!node) return [3
|
|
308
|
-
if (!node.filtrad) return [3
|
|
309
|
-
return [2
|
|
310
|
-
case 1: return [4
|
|
307
|
+
if (!node) return [3, 6];
|
|
308
|
+
if (!node.filtrad) return [3, 1];
|
|
309
|
+
return [2, node];
|
|
310
|
+
case 1: return [4, objectql.computeFormula(node.entry_criteria, objectName, recordId, currentUserId, spaceId)];
|
|
311
311
|
case 2:
|
|
312
312
|
canEntry = _a.sent();
|
|
313
|
-
if (!canEntry) return [3
|
|
314
|
-
return [2
|
|
313
|
+
if (!canEntry) return [3, 3];
|
|
314
|
+
return [2, node];
|
|
315
315
|
case 3:
|
|
316
|
-
if (!(node.if_criteria_not_met === 'skip')) return [3
|
|
317
|
-
return [4
|
|
318
|
-
case 4: return [2
|
|
316
|
+
if (!(node.if_criteria_not_met === 'skip')) return [3, 5];
|
|
317
|
+
return [4, getNextNode(nodes, index + 1, objectName, recordId, userSession)];
|
|
318
|
+
case 4: return [2, _a.sent()];
|
|
319
319
|
case 5:
|
|
320
320
|
if (node.if_criteria_not_met === 'reject') {
|
|
321
|
-
return [2
|
|
321
|
+
return [2, { to_final_rejection: true }];
|
|
322
322
|
}
|
|
323
323
|
else if (node.if_criteria_not_met === 'approve') {
|
|
324
|
-
return [2
|
|
324
|
+
return [2, { to_final_approval: true }];
|
|
325
325
|
}
|
|
326
326
|
_a.label = 6;
|
|
327
|
-
case 6: return [2
|
|
327
|
+
case 6: return [2];
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
});
|
|
@@ -333,70 +333,32 @@ var toNextNode = function (instanceId, node, nextApprovers, userSession) { retur
|
|
|
333
333
|
return __generator(this, function (_a) {
|
|
334
334
|
switch (_a.label) {
|
|
335
335
|
case 0:
|
|
336
|
-
if (!node) return [3
|
|
337
|
-
return [4
|
|
336
|
+
if (!node) return [3, 2];
|
|
337
|
+
return [4, addInstanceNode(instanceId, node, userSession, nextApprovers)];
|
|
338
338
|
case 1:
|
|
339
339
|
_a.sent();
|
|
340
340
|
_a.label = 2;
|
|
341
|
-
case 2: return [2
|
|
341
|
+
case 2: return [2];
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
}); };
|
|
345
|
-
//TODO nextApprovers
|
|
346
|
-
// const toNextNode = async (instanceId: string, comment: string, nodes: any, index: number = 0, objectName: string, recordId: string, userSession: any, nextApprovers?)=>{
|
|
347
|
-
// let spaceId = userSession.spaceId;
|
|
348
|
-
// let currentUserId = userSession.userId;
|
|
349
|
-
// let node = nodes[index];
|
|
350
|
-
// if(node){
|
|
351
|
-
// if(node.filtrad){
|
|
352
|
-
// await addInstanceNode(instanceId, node, userSession);
|
|
353
|
-
// }else{
|
|
354
|
-
// const canEntry = await objectql.computeFormula(node.entry_criteria, objectName, recordId, currentUserId, spaceId);
|
|
355
|
-
// if(canEntry){
|
|
356
|
-
// await addInstanceNode(instanceId, node, userSession);
|
|
357
|
-
// }else{
|
|
358
|
-
// if(node.if_criteria_not_met === 'skip'){
|
|
359
|
-
// await toNextNode(instanceId, comment, nodes, index + 1, objectName, recordId, userSession)
|
|
360
|
-
// }else{
|
|
361
|
-
// let options = {actor: currentUserId}
|
|
362
|
-
// if(node.if_criteria_not_met === 'reject'){
|
|
363
|
-
// await addInstanceHistory(userSession.spaceId, instanceId, "rejected", comment, options, userSession)
|
|
364
|
-
// }else if(node.if_criteria_not_met === 'approve'){
|
|
365
|
-
// // await addInstanceHistory(userSession.spaceId, instanceId, "approved", comment, options)
|
|
366
|
-
// }
|
|
367
|
-
// }
|
|
368
|
-
// }
|
|
369
|
-
// }
|
|
370
|
-
// }
|
|
371
|
-
// }
|
|
372
345
|
var getPreviousNode = function (instanceId, currentNode, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
373
346
|
var previousInstanceNodes, previousInstanceNode, previousNode;
|
|
374
347
|
return __generator(this, function (_a) {
|
|
375
348
|
switch (_a.label) {
|
|
376
|
-
case 0: return [4
|
|
349
|
+
case 0: return [4, objectql.getObject("process_instance_node").find({ filters: [['process_instance', '=', instanceId], ['process_node', '!=', currentNode._id]], sort: 'created desc' })];
|
|
377
350
|
case 1:
|
|
378
351
|
previousInstanceNodes = _a.sent();
|
|
379
|
-
if (!!_.isEmpty(previousInstanceNodes)) return [3
|
|
352
|
+
if (!!_.isEmpty(previousInstanceNodes)) return [3, 3];
|
|
380
353
|
previousInstanceNode = previousInstanceNodes[0];
|
|
381
|
-
return [4
|
|
354
|
+
return [4, objectql.getObject("process_node").findOne(previousInstanceNode.process_node)];
|
|
382
355
|
case 2:
|
|
383
356
|
previousNode = _a.sent();
|
|
384
|
-
return [2
|
|
357
|
+
return [2, previousNode];
|
|
385
358
|
case 3: throw new objectql_1.SteedosError('not find previous node');
|
|
386
359
|
}
|
|
387
360
|
});
|
|
388
361
|
}); };
|
|
389
|
-
// const toPreviousNode = async (instanceId: string, currentNode: any, userSession: any)=>{
|
|
390
|
-
// const previousInstanceNodes = await objectql.getObject("process_instance_node").find({filters: [['process_instance', '=', instanceId], ['process_node', '!=', currentNode._id]], sort: 'created desc'});
|
|
391
|
-
// if(!_.isEmpty(previousInstanceNodes)){
|
|
392
|
-
// const previousInstanceNode = previousInstanceNodes[0];
|
|
393
|
-
// const previousNode = await objectql.getObject("process_node").findOne(previousInstanceNode.process_node)
|
|
394
|
-
// await addInstanceNode(instanceId, previousNode, userSession, true);
|
|
395
|
-
// }else{
|
|
396
|
-
// throw new SteedosError('not find previous node')
|
|
397
|
-
// }
|
|
398
|
-
// }
|
|
399
|
-
//TODO 处理提交权限
|
|
400
362
|
var getObjectProcessDefinition = function (objectName, recordId, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
401
363
|
var spaceId, currentUserId, processes, process, _i, processes_1, _process, canEntry;
|
|
402
364
|
return __generator(this, function (_a) {
|
|
@@ -404,30 +366,30 @@ var getObjectProcessDefinition = function (objectName, recordId, userSession) {
|
|
|
404
366
|
case 0:
|
|
405
367
|
spaceId = userSession.spaceId;
|
|
406
368
|
currentUserId = userSession.userId;
|
|
407
|
-
return [4
|
|
369
|
+
return [4, objectql.getObject('process_definition').find({ filters: [['object_name', '=', objectName], ['space', '=', spaceId], ['active', '=', true]], sort: "order asc" })];
|
|
408
370
|
case 1:
|
|
409
371
|
processes = _a.sent();
|
|
410
372
|
if (processes.length < 1) {
|
|
411
|
-
return [2
|
|
373
|
+
return [2, null];
|
|
412
374
|
}
|
|
413
375
|
process = null;
|
|
414
376
|
_i = 0, processes_1 = processes;
|
|
415
377
|
_a.label = 2;
|
|
416
378
|
case 2:
|
|
417
|
-
if (!(_i < processes_1.length)) return [3
|
|
379
|
+
if (!(_i < processes_1.length)) return [3, 5];
|
|
418
380
|
_process = processes_1[_i];
|
|
419
|
-
return [4
|
|
381
|
+
return [4, objectql.computeFormula(_process.entry_criteria, objectName, recordId, currentUserId, spaceId)];
|
|
420
382
|
case 3:
|
|
421
383
|
canEntry = _a.sent();
|
|
422
384
|
if (canEntry) {
|
|
423
385
|
process = _process;
|
|
424
|
-
return [3
|
|
386
|
+
return [3, 5];
|
|
425
387
|
}
|
|
426
388
|
_a.label = 4;
|
|
427
389
|
case 4:
|
|
428
390
|
_i++;
|
|
429
|
-
return [3
|
|
430
|
-
case 5: return [2
|
|
391
|
+
return [3, 2];
|
|
392
|
+
case 5: return [2, process];
|
|
431
393
|
}
|
|
432
394
|
});
|
|
433
395
|
}); };
|
|
@@ -436,16 +398,16 @@ var recordSubmit = function (processDefinitionId, objectName, recordId, userSess
|
|
|
436
398
|
var pendingInstanceCount, nodes, nextNode, to_final_rejection, to_final_approval, approver, record, instance, options, options;
|
|
437
399
|
return __generator(this, function (_a) {
|
|
438
400
|
switch (_a.label) {
|
|
439
|
-
case 0: return [4
|
|
401
|
+
case 0: return [4, objectql.getObject("process_instance").count({ filters: [['target_object.o', '=', objectName], ['target_object.ids', '=', recordId], ['status', '=', 'pending']] })];
|
|
440
402
|
case 1:
|
|
441
403
|
pendingInstanceCount = _a.sent();
|
|
442
404
|
if (pendingInstanceCount > 0) {
|
|
443
405
|
throw new objectql_1.SteedosError('process_approval_error_processInstancePending');
|
|
444
406
|
}
|
|
445
|
-
return [4
|
|
407
|
+
return [4, getProcessNodes(processDefinitionId, userSession.spaceId)];
|
|
446
408
|
case 2:
|
|
447
409
|
nodes = _a.sent();
|
|
448
|
-
return [4
|
|
410
|
+
return [4, getNextNode(nodes, 0, objectName, recordId, userSession)];
|
|
449
411
|
case 3:
|
|
450
412
|
nextNode = _a.sent();
|
|
451
413
|
to_final_rejection = false;
|
|
@@ -457,15 +419,15 @@ var recordSubmit = function (processDefinitionId, objectName, recordId, userSess
|
|
|
457
419
|
to_final_approval = true;
|
|
458
420
|
}
|
|
459
421
|
approver = null;
|
|
460
|
-
if (!(!to_final_rejection && !to_final_rejection)) return [3
|
|
461
|
-
return [4
|
|
422
|
+
if (!(!to_final_rejection && !to_final_rejection)) return [3, 6];
|
|
423
|
+
return [4, objectql.getObject(objectName).findOne(recordId)];
|
|
462
424
|
case 4:
|
|
463
425
|
record = _a.sent();
|
|
464
|
-
return [4
|
|
426
|
+
return [4, getProcessNodeApprover(null, nextNode, userSession, chooseApprover, false, record)];
|
|
465
427
|
case 5:
|
|
466
428
|
approver = _a.sent();
|
|
467
429
|
_a.label = 6;
|
|
468
|
-
case 6: return [4
|
|
430
|
+
case 6: return [4, objectql.getObject("process_instance").insert({
|
|
469
431
|
process_definition: processDefinitionId,
|
|
470
432
|
target_object: {
|
|
471
433
|
"o": objectName,
|
|
@@ -478,33 +440,33 @@ var recordSubmit = function (processDefinitionId, objectName, recordId, userSess
|
|
|
478
440
|
})];
|
|
479
441
|
case 7:
|
|
480
442
|
instance = _a.sent();
|
|
481
|
-
return [4
|
|
443
|
+
return [4, lockObjectRecord(objectName, recordId)];
|
|
482
444
|
case 8:
|
|
483
445
|
_a.sent();
|
|
484
|
-
return [4
|
|
446
|
+
return [4, (0, platform_action_manager_1.runProcessAction)(processDefinitionId, 'initial_submission', recordId, userSession)];
|
|
485
447
|
case 9:
|
|
486
448
|
_a.sent();
|
|
487
|
-
return [4
|
|
449
|
+
return [4, addInstanceHistory(userSession.spaceId, instance._id, "started", comment, { actor: userSession.userId }, userSession)];
|
|
488
450
|
case 10:
|
|
489
451
|
_a.sent();
|
|
490
|
-
if (!to_final_rejection) return [3
|
|
452
|
+
if (!to_final_rejection) return [3, 12];
|
|
491
453
|
options = { actor: userSession.userId };
|
|
492
|
-
return [4
|
|
454
|
+
return [4, addInstanceHistory(userSession.spaceId, instance._id, "rejected", comment, options, userSession)];
|
|
493
455
|
case 11:
|
|
494
456
|
_a.sent();
|
|
495
|
-
return [3
|
|
457
|
+
return [3, 16];
|
|
496
458
|
case 12:
|
|
497
|
-
if (!to_final_approval) return [3
|
|
459
|
+
if (!to_final_approval) return [3, 14];
|
|
498
460
|
options = { actor: userSession.userId };
|
|
499
|
-
return [4
|
|
461
|
+
return [4, addInstanceHistory(userSession.spaceId, instance._id, "approved", comment, options, userSession)];
|
|
500
462
|
case 13:
|
|
501
463
|
_a.sent();
|
|
502
|
-
return [3
|
|
503
|
-
case 14: return [4
|
|
464
|
+
return [3, 16];
|
|
465
|
+
case 14: return [4, toNextNode(instance._id, nextNode, approver, userSession)];
|
|
504
466
|
case 15:
|
|
505
467
|
_a.sent();
|
|
506
468
|
_a.label = 16;
|
|
507
|
-
case 16: return [2
|
|
469
|
+
case 16: return [2];
|
|
508
470
|
}
|
|
509
471
|
});
|
|
510
472
|
}); };
|
|
@@ -515,8 +477,8 @@ var getReocrdProcessInstance = function (objectName, recordId, status, userSessi
|
|
|
515
477
|
switch (_a.label) {
|
|
516
478
|
case 0:
|
|
517
479
|
spaceId = userSession.spaceId;
|
|
518
|
-
return [4
|
|
519
|
-
case 1: return [2
|
|
480
|
+
return [4, objectql.getObject("process_instance").find({ filters: [['space', '=', spaceId], ['status', '=', status], ['target_object.o', '=', objectName], ['target_object.ids', '=', recordId]] })];
|
|
481
|
+
case 1: return [2, _a.sent()];
|
|
520
482
|
}
|
|
521
483
|
});
|
|
522
484
|
}); };
|
|
@@ -528,13 +490,13 @@ var getProcessInstanceWorkitem = function (instanceHistoryId, userSession) { ret
|
|
|
528
490
|
case 0:
|
|
529
491
|
spaceId = userSession.spaceId;
|
|
530
492
|
userId = userSession.userId;
|
|
531
|
-
return [4
|
|
493
|
+
return [4, objectql.getObject("process_instance_history").find({ filters: [['_id', '=', instanceHistoryId], ['step_status', '=', 'pending'], ['actor', '=', userId], ['space', '=', spaceId]] })];
|
|
532
494
|
case 1:
|
|
533
495
|
workitme = _a.sent();
|
|
534
496
|
if (workitme.length > 0) {
|
|
535
|
-
return [2
|
|
497
|
+
return [2, workitme[0]];
|
|
536
498
|
}
|
|
537
|
-
return [2
|
|
499
|
+
return [2];
|
|
538
500
|
}
|
|
539
501
|
});
|
|
540
502
|
}); };
|
|
@@ -562,75 +524,61 @@ var getProcessNodeActionWhenByStatus = function (processStatus) {
|
|
|
562
524
|
}
|
|
563
525
|
return when;
|
|
564
526
|
};
|
|
565
|
-
// export const getProcessInstanceWorkitem = async (objectName: string, recordId: string, userSession: any)=>{
|
|
566
|
-
// let spaceId = userSession.spaceId;
|
|
567
|
-
// let userId = userSession.userId; //TODO 代理
|
|
568
|
-
// const instances = await objectql.getObject("process_instance").find({filters: [['space', '=', spaceId], ['status', '=', 'pending'], ['target_object.o', '=', objectName], ['target_object.ids', '=', recordId]]});
|
|
569
|
-
// if(instances.length < 1){
|
|
570
|
-
// return
|
|
571
|
-
// }
|
|
572
|
-
// const instance = instances[0];
|
|
573
|
-
// const workitme = await objectql.getObject("process_instance_history").find({filters: [['process_instance', '=', instance._id], ['step_status', '=', 'pending'], ['actor', '=', userId]]})
|
|
574
|
-
// if(workitme.length > 0){
|
|
575
|
-
// return workitme[0];
|
|
576
|
-
// }
|
|
577
|
-
// }
|
|
578
|
-
//TODO 编写trigger 处理elapsed_time
|
|
579
527
|
var handleProcessInstance = function (instanceId, processStatus, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
580
528
|
var otherPendingInstanceNodeCount, pInstance, process_1, when;
|
|
581
529
|
return __generator(this, function (_a) {
|
|
582
530
|
switch (_a.label) {
|
|
583
|
-
case 0: return [4
|
|
531
|
+
case 0: return [4, objectql.getObject("process_instance_node").count({ filters: [['process_instance', '=', instanceId], ['node_status', '=', 'pending']] })];
|
|
584
532
|
case 1:
|
|
585
533
|
otherPendingInstanceNodeCount = _a.sent();
|
|
586
|
-
if (!(otherPendingInstanceNodeCount === 0)) return [3
|
|
587
|
-
return [4
|
|
534
|
+
if (!(otherPendingInstanceNodeCount === 0)) return [3, 18];
|
|
535
|
+
return [4, objectql.getObject("process_instance").update(instanceId, { status: processStatus, completed_date: new Date(), last_actor: userSession.userId })];
|
|
588
536
|
case 2:
|
|
589
537
|
pInstance = _a.sent();
|
|
590
|
-
if (!(processStatus === 'removed')) return [3
|
|
591
|
-
return [4
|
|
538
|
+
if (!(processStatus === 'removed')) return [3, 4];
|
|
539
|
+
return [4, unlockObjectRecord(pInstance.target_object.o, pInstance.target_object.ids[0])];
|
|
592
540
|
case 3:
|
|
593
541
|
_a.sent();
|
|
594
|
-
return [3
|
|
595
|
-
case 4: return [4
|
|
542
|
+
return [3, 14];
|
|
543
|
+
case 4: return [4, objectql.getObject("process_definition").findOne(pInstance.process_definition)];
|
|
596
544
|
case 5:
|
|
597
545
|
process_1 = _a.sent();
|
|
598
|
-
if (!(processStatus === 'approved')) return [3
|
|
599
|
-
if (!(process_1.final_approval_record_lock === 'unlock')) return [3
|
|
600
|
-
return [4
|
|
546
|
+
if (!(processStatus === 'approved')) return [3, 10];
|
|
547
|
+
if (!(process_1.final_approval_record_lock === 'unlock')) return [3, 7];
|
|
548
|
+
return [4, unlockObjectRecord(pInstance.target_object.o, pInstance.target_object.ids[0])];
|
|
601
549
|
case 6:
|
|
602
550
|
_a.sent();
|
|
603
|
-
return [3
|
|
604
|
-
case 7: return [4
|
|
551
|
+
return [3, 9];
|
|
552
|
+
case 7: return [4, lockObjectRecord(pInstance.target_object.o, pInstance.target_object.ids[0])];
|
|
605
553
|
case 8:
|
|
606
554
|
_a.sent();
|
|
607
555
|
_a.label = 9;
|
|
608
|
-
case 9: return [3
|
|
556
|
+
case 9: return [3, 14];
|
|
609
557
|
case 10:
|
|
610
|
-
if (!(processStatus === 'rejected')) return [3
|
|
611
|
-
if (!(process_1.final_rejection_record_lock === 'unlock')) return [3
|
|
612
|
-
return [4
|
|
558
|
+
if (!(processStatus === 'rejected')) return [3, 14];
|
|
559
|
+
if (!(process_1.final_rejection_record_lock === 'unlock')) return [3, 12];
|
|
560
|
+
return [4, unlockObjectRecord(pInstance.target_object.o, pInstance.target_object.ids[0])];
|
|
613
561
|
case 11:
|
|
614
562
|
_a.sent();
|
|
615
|
-
return [3
|
|
616
|
-
case 12: return [4
|
|
563
|
+
return [3, 14];
|
|
564
|
+
case 12: return [4, lockObjectRecord(pInstance.target_object.o, pInstance.target_object.ids[0])];
|
|
617
565
|
case 13:
|
|
618
566
|
_a.sent();
|
|
619
567
|
_a.label = 14;
|
|
620
568
|
case 14:
|
|
621
569
|
when = getProcessActionWhenByStatus(processStatus);
|
|
622
|
-
if (!when) return [3
|
|
623
|
-
return [4
|
|
570
|
+
if (!when) return [3, 16];
|
|
571
|
+
return [4, (0, platform_action_manager_1.runProcessAction)(pInstance.process_definition, when, pInstance.target_object.ids[0], userSession)];
|
|
624
572
|
case 15:
|
|
625
573
|
_a.sent();
|
|
626
574
|
_a.label = 16;
|
|
627
575
|
case 16:
|
|
628
|
-
if (!(['approved', 'rejected'].indexOf(processStatus) > -1)) return [3
|
|
629
|
-
return [4
|
|
576
|
+
if (!(['approved', 'rejected'].indexOf(processStatus) > -1)) return [3, 18];
|
|
577
|
+
return [4, (0, notifications_1.sendNotifications)(pInstance.created_by, pInstance.created_by, { status: processStatus, instance: pInstance })];
|
|
630
578
|
case 17:
|
|
631
579
|
_a.sent();
|
|
632
580
|
_a.label = 18;
|
|
633
|
-
case 18: return [2
|
|
581
|
+
case 18: return [2];
|
|
634
582
|
}
|
|
635
583
|
});
|
|
636
584
|
}); };
|
|
@@ -638,57 +586,56 @@ var getCurrentInstanceNode = function (instanceId) { return __awaiter(void 0, vo
|
|
|
638
586
|
var pendingNodes, currentNode;
|
|
639
587
|
return __generator(this, function (_a) {
|
|
640
588
|
switch (_a.label) {
|
|
641
|
-
case 0: return [4
|
|
589
|
+
case 0: return [4, objectql.getObject("process_instance_node").find({ filters: [['process_instance', '=', instanceId], ['node_status', '=', 'pending']] })];
|
|
642
590
|
case 1:
|
|
643
591
|
pendingNodes = _a.sent();
|
|
644
592
|
currentNode = null;
|
|
645
593
|
if (pendingNodes.length > 0) {
|
|
646
594
|
currentNode = pendingNodes[0];
|
|
647
595
|
}
|
|
648
|
-
return [2
|
|
596
|
+
return [2, currentNode];
|
|
649
597
|
}
|
|
650
598
|
});
|
|
651
599
|
}); };
|
|
652
600
|
var getProcessInstance = function (instanceId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
653
601
|
return __generator(this, function (_a) {
|
|
654
602
|
switch (_a.label) {
|
|
655
|
-
case 0: return [4
|
|
656
|
-
case 1: return [2
|
|
603
|
+
case 0: return [4, objectql.getObject("process_instance").findOne(instanceId)];
|
|
604
|
+
case 1: return [2, _a.sent()];
|
|
657
605
|
}
|
|
658
606
|
});
|
|
659
607
|
}); };
|
|
660
608
|
var getProcessNode = function (processNodeId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
661
609
|
return __generator(this, function (_a) {
|
|
662
610
|
switch (_a.label) {
|
|
663
|
-
case 0: return [4
|
|
664
|
-
case 1: return [2
|
|
611
|
+
case 0: return [4, objectql.getObject("process_node").findOne(processNodeId)];
|
|
612
|
+
case 1: return [2, _a.sent()];
|
|
665
613
|
}
|
|
666
614
|
});
|
|
667
615
|
}); };
|
|
668
|
-
//TODO 编写trigger 处理elapsed_time
|
|
669
616
|
var handleProcessInstanceNode = function (instanceId, currentInstanceNode, processStatus, nextNodeOptions, userSession) { return __awaiter(void 0, void 0, void 0, function () {
|
|
670
617
|
var otherPendingInstanceHistoryCount, finalProcessStatus, when, instance, to_final_rejection, to_final_approval;
|
|
671
618
|
return __generator(this, function (_a) {
|
|
672
619
|
switch (_a.label) {
|
|
673
|
-
case 0: return [4
|
|
620
|
+
case 0: return [4, objectql.getObject("process_instance_history").count({ filters: [['process_instance', '=', instanceId], ['step_status', '=', 'pending']] })];
|
|
674
621
|
case 1:
|
|
675
622
|
otherPendingInstanceHistoryCount = _a.sent();
|
|
676
|
-
if (!(otherPendingInstanceHistoryCount === 0)) return [3
|
|
623
|
+
if (!(otherPendingInstanceHistoryCount === 0)) return [3, 11];
|
|
677
624
|
finalProcessStatus = processStatus;
|
|
678
|
-
return [4
|
|
625
|
+
return [4, objectql.getObject("process_instance_node").updateMany([['process_instance', '=', instanceId], ['node_status', '=', 'pending']], { node_status: processStatus, completed_date: new Date(), last_actor: userSession.userId })];
|
|
679
626
|
case 2:
|
|
680
627
|
_a.sent();
|
|
681
628
|
when = getProcessNodeActionWhenByStatus(processStatus);
|
|
682
|
-
if (!when) return [3
|
|
683
|
-
return [4
|
|
629
|
+
if (!when) return [3, 5];
|
|
630
|
+
return [4, objectql.getObject("process_instance").findOne(instanceId)];
|
|
684
631
|
case 3:
|
|
685
632
|
instance = _a.sent();
|
|
686
|
-
return [4
|
|
633
|
+
return [4, (0, platform_action_manager_1.runProcessNodeAction)(currentInstanceNode.process_node, when, instance.target_object.ids[0], userSession)];
|
|
687
634
|
case 4:
|
|
688
635
|
_a.sent();
|
|
689
636
|
_a.label = 5;
|
|
690
637
|
case 5:
|
|
691
|
-
if (!nextNodeOptions) return [3
|
|
638
|
+
if (!nextNodeOptions) return [3, 9];
|
|
692
639
|
to_final_rejection = false;
|
|
693
640
|
to_final_approval = false;
|
|
694
641
|
if (nextNodeOptions.node.to_final_rejection) {
|
|
@@ -699,36 +646,36 @@ var handleProcessInstanceNode = function (instanceId, currentInstanceNode, proce
|
|
|
699
646
|
to_final_approval = true;
|
|
700
647
|
finalProcessStatus = 'approved';
|
|
701
648
|
}
|
|
702
|
-
if (!to_final_rejection) return [3
|
|
703
|
-
return [3
|
|
649
|
+
if (!to_final_rejection) return [3, 6];
|
|
650
|
+
return [3, 9];
|
|
704
651
|
case 6:
|
|
705
|
-
if (!to_final_approval) return [3
|
|
706
|
-
return [3
|
|
707
|
-
case 7: return [4
|
|
652
|
+
if (!to_final_approval) return [3, 7];
|
|
653
|
+
return [3, 9];
|
|
654
|
+
case 7: return [4, toNextNode(instanceId, nextNodeOptions.node, nextNodeOptions.approve, userSession)];
|
|
708
655
|
case 8:
|
|
709
656
|
_a.sent();
|
|
710
657
|
_a.label = 9;
|
|
711
|
-
case 9: return [4
|
|
658
|
+
case 9: return [4, handleProcessInstance(instanceId, finalProcessStatus, userSession)];
|
|
712
659
|
case 10:
|
|
713
660
|
_a.sent();
|
|
714
661
|
_a.label = 11;
|
|
715
|
-
case 11: return [2
|
|
662
|
+
case 11: return [2];
|
|
716
663
|
}
|
|
717
664
|
});
|
|
718
665
|
}); };
|
|
719
666
|
var getInstanceHistory = function (instanceHistoryId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
720
667
|
return __generator(this, function (_a) {
|
|
721
668
|
switch (_a.label) {
|
|
722
|
-
case 0: return [4
|
|
723
|
-
case 1: return [2
|
|
669
|
+
case 0: return [4, objectql.getObject("process_instance_history").findOne(instanceHistoryId)];
|
|
670
|
+
case 1: return [2, _a.sent()];
|
|
724
671
|
}
|
|
725
672
|
});
|
|
726
673
|
}); };
|
|
727
674
|
var getPendingInstanceHistoryCount = function (instanceId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
728
675
|
return __generator(this, function (_a) {
|
|
729
676
|
switch (_a.label) {
|
|
730
|
-
case 0: return [4
|
|
731
|
-
case 1: return [2
|
|
677
|
+
case 0: return [4, objectql.getObject("process_instance_history").count({ filters: [['process_instance', '=', instanceId], ['step_status', '=', 'pending']] })];
|
|
678
|
+
case 1: return [2, _a.sent()];
|
|
732
679
|
}
|
|
733
680
|
});
|
|
734
681
|
}); };
|
|
@@ -736,16 +683,16 @@ var handleProcessInstanceWorkitem = function (currentInstanceNode, processStatus
|
|
|
736
683
|
var instanceHistory, when_multiple_approvers, processNode;
|
|
737
684
|
return __generator(this, function (_a) {
|
|
738
685
|
switch (_a.label) {
|
|
739
|
-
case 0: return [4
|
|
686
|
+
case 0: return [4, getInstanceHistory(instanceHistoryId)];
|
|
740
687
|
case 1:
|
|
741
688
|
instanceHistory = _a.sent();
|
|
742
|
-
if (!(processStatus === 'rejected' || processStatus === 'approved')) return [3
|
|
743
|
-
return [4
|
|
689
|
+
if (!(processStatus === 'rejected' || processStatus === 'approved')) return [3, 6];
|
|
690
|
+
return [4, objectql.getObject("process_instance_history").update(instanceHistoryId, { step_status: processStatus, comments: comment, actor: userSession.userId })];
|
|
744
691
|
case 2:
|
|
745
692
|
_a.sent();
|
|
746
693
|
when_multiple_approvers = 'first_response';
|
|
747
|
-
if (!instanceHistory.step_node) return [3
|
|
748
|
-
return [4
|
|
694
|
+
if (!instanceHistory.step_node) return [3, 4];
|
|
695
|
+
return [4, objectql.getObject("process_node").findOne(instanceHistory.step_node)];
|
|
749
696
|
case 3:
|
|
750
697
|
processNode = _a.sent();
|
|
751
698
|
if (processNode && processNode.when_multiple_approvers) {
|
|
@@ -753,15 +700,15 @@ var handleProcessInstanceWorkitem = function (currentInstanceNode, processStatus
|
|
|
753
700
|
}
|
|
754
701
|
_a.label = 4;
|
|
755
702
|
case 4:
|
|
756
|
-
if (!(when_multiple_approvers === 'first_response' || (when_multiple_approvers === 'unanimous' && processStatus === 'rejected'))) return [3
|
|
757
|
-
return [4
|
|
703
|
+
if (!(when_multiple_approvers === 'first_response' || (when_multiple_approvers === 'unanimous' && processStatus === 'rejected'))) return [3, 6];
|
|
704
|
+
return [4, objectql.getObject("process_instance_history").updateMany([['_id', '!=', instanceHistory._id], ['process_instance', '=', instanceHistory.process_instance], ['step_status', '=', 'pending']], { step_status: 'no_response' })];
|
|
758
705
|
case 5:
|
|
759
706
|
_a.sent();
|
|
760
707
|
_a.label = 6;
|
|
761
|
-
case 6: return [4
|
|
708
|
+
case 6: return [4, handleProcessInstanceNode(instanceHistory.process_instance, currentInstanceNode, processStatus, nextNodeOptions, userSession)];
|
|
762
709
|
case 7:
|
|
763
710
|
_a.sent();
|
|
764
|
-
return [2
|
|
711
|
+
return [2];
|
|
765
712
|
}
|
|
766
713
|
});
|
|
767
714
|
}); };
|
|
@@ -771,46 +718,46 @@ var processInstanceWorkitemApprove = function (instanceHistoryId, userSession, c
|
|
|
771
718
|
switch (_c.label) {
|
|
772
719
|
case 0:
|
|
773
720
|
nextNodeOptions = null;
|
|
774
|
-
return [4
|
|
721
|
+
return [4, getInstanceHistory(instanceHistoryId)];
|
|
775
722
|
case 1:
|
|
776
723
|
instanceHistory = _c.sent();
|
|
777
724
|
instanceId = instanceHistory.process_instance;
|
|
778
|
-
return [4
|
|
725
|
+
return [4, getCurrentInstanceNode(instanceId)];
|
|
779
726
|
case 2:
|
|
780
727
|
currentInstanceNode = _c.sent();
|
|
781
|
-
return [4
|
|
728
|
+
return [4, getProcessInstance(instanceId)];
|
|
782
729
|
case 3:
|
|
783
730
|
instance = _c.sent();
|
|
784
|
-
return [4
|
|
731
|
+
return [4, getProcessNode(instanceHistory.step_node)];
|
|
785
732
|
case 4:
|
|
786
733
|
currentProcessNode = _c.sent();
|
|
787
|
-
return [4
|
|
734
|
+
return [4, getProcessNodes(instance.process_definition, userSession.spaceId)];
|
|
788
735
|
case 5:
|
|
789
736
|
nodes = _c.sent();
|
|
790
737
|
index = _.findIndex(nodes, function (item) { return item._id === currentInstanceNode.process_node; });
|
|
791
738
|
_a = currentProcessNode.when_multiple_approvers === 'first_response';
|
|
792
|
-
if (_a) return [3
|
|
793
|
-
return [4
|
|
739
|
+
if (_a) return [3, 7];
|
|
740
|
+
return [4, getPendingInstanceHistoryCount(instanceId)];
|
|
794
741
|
case 6:
|
|
795
742
|
_a = (_c.sent()) < 2;
|
|
796
743
|
_c.label = 7;
|
|
797
744
|
case 7:
|
|
798
|
-
if (!_a) return [3
|
|
799
|
-
return [4
|
|
745
|
+
if (!_a) return [3, 10];
|
|
746
|
+
return [4, getNextNode(nodes, index + 1, instance.target_object.o, instance.target_object.ids[0], userSession)];
|
|
800
747
|
case 8:
|
|
801
748
|
nextNode = _c.sent();
|
|
802
|
-
if (!nextNode) return [3
|
|
749
|
+
if (!nextNode) return [3, 10];
|
|
803
750
|
nextNodeOptions = {};
|
|
804
751
|
nextNodeOptions.node = nextNode;
|
|
805
752
|
_b = nextNodeOptions;
|
|
806
|
-
return [4
|
|
753
|
+
return [4, getProcessNodeApprover(instanceId, nextNodeOptions.node, userSession, chooseApprover, false)];
|
|
807
754
|
case 9:
|
|
808
755
|
_b.approve = _c.sent();
|
|
809
756
|
_c.label = 10;
|
|
810
|
-
case 10: return [4
|
|
757
|
+
case 10: return [4, handleProcessInstanceWorkitem(currentInstanceNode, 'approved', instanceHistoryId, userSession, comment, nextNodeOptions)];
|
|
811
758
|
case 11:
|
|
812
759
|
_c.sent();
|
|
813
|
-
return [2
|
|
760
|
+
return [2];
|
|
814
761
|
}
|
|
815
762
|
});
|
|
816
763
|
}); };
|
|
@@ -821,31 +768,31 @@ var processInstanceWorkitemReject = function (instanceHistoryId, userSession, co
|
|
|
821
768
|
switch (_c.label) {
|
|
822
769
|
case 0:
|
|
823
770
|
nextNodeOptions = null;
|
|
824
|
-
return [4
|
|
771
|
+
return [4, getInstanceHistory(instanceHistoryId)];
|
|
825
772
|
case 1:
|
|
826
773
|
instanceHistory = _c.sent();
|
|
827
774
|
instanceId = instanceHistory.process_instance;
|
|
828
|
-
return [4
|
|
775
|
+
return [4, getCurrentInstanceNode(instanceId)];
|
|
829
776
|
case 2:
|
|
830
777
|
currentInstanceNode = _c.sent();
|
|
831
|
-
return [4
|
|
778
|
+
return [4, getProcessNode(instanceHistory.step_node)];
|
|
832
779
|
case 3:
|
|
833
780
|
currentProcessNode = _c.sent();
|
|
834
|
-
if (!(currentProcessNode.reject_behavior === 'back_to_previous')) return [3
|
|
781
|
+
if (!(currentProcessNode.reject_behavior === 'back_to_previous')) return [3, 6];
|
|
835
782
|
nextNodeOptions = {};
|
|
836
783
|
_a = nextNodeOptions;
|
|
837
|
-
return [4
|
|
784
|
+
return [4, getPreviousNode(instanceId, currentProcessNode, userSession)];
|
|
838
785
|
case 4:
|
|
839
786
|
_a.node = _c.sent();
|
|
840
787
|
_b = nextNodeOptions;
|
|
841
|
-
return [4
|
|
788
|
+
return [4, getProcessNodeApprover(instanceId, nextNodeOptions.node, userSession, null, true)];
|
|
842
789
|
case 5:
|
|
843
790
|
_b.approve = _c.sent();
|
|
844
791
|
_c.label = 6;
|
|
845
|
-
case 6: return [4
|
|
792
|
+
case 6: return [4, handleProcessInstanceWorkitem(currentInstanceNode, 'rejected', instanceHistoryId, userSession, comment, nextNodeOptions)];
|
|
846
793
|
case 7:
|
|
847
794
|
_c.sent();
|
|
848
|
-
return [2
|
|
795
|
+
return [2];
|
|
849
796
|
}
|
|
850
797
|
});
|
|
851
798
|
}); };
|
|
@@ -861,17 +808,17 @@ var processInstanceWorkitemReassign = function (instanceHistoryId, userSession,
|
|
|
861
808
|
if (!_.isString(chooseApprover)) {
|
|
862
809
|
throw new objectql_1.SteedosError('process_approval_error_reassign_approver_mustBeString');
|
|
863
810
|
}
|
|
864
|
-
return [4
|
|
811
|
+
return [4, objectql.getObject("process_instance_history").update(instanceHistoryId, {
|
|
865
812
|
step_status: "reassigned",
|
|
866
813
|
actor: chooseApprover,
|
|
867
814
|
comments: comment
|
|
868
815
|
})];
|
|
869
816
|
case 1:
|
|
870
817
|
history = _a.sent();
|
|
871
|
-
return [4
|
|
818
|
+
return [4, addInstanceHistory(userSession.spaceId, history.process_instance, 'pending', null, { nodeId: history.step_node, actor: chooseApprover, originalActor: history.original_actor, submitted_by: userSession.userId }, userSession)];
|
|
872
819
|
case 2:
|
|
873
820
|
_a.sent();
|
|
874
|
-
return [2
|
|
821
|
+
return [2];
|
|
875
822
|
}
|
|
876
823
|
});
|
|
877
824
|
}); };
|
|
@@ -882,13 +829,13 @@ var processInstanceWorkitemRemovebyInstance = function (instanceId, userSession,
|
|
|
882
829
|
switch (_a.label) {
|
|
883
830
|
case 0:
|
|
884
831
|
processStatus = 'removed';
|
|
885
|
-
return [4
|
|
832
|
+
return [4, objectql.getObject("process_instance_history").updateMany([['process_instance', '=', instanceId], ['step_status', '=', 'pending']], { step_status: processStatus, comments: comment })];
|
|
886
833
|
case 1:
|
|
887
834
|
_a.sent();
|
|
888
|
-
return [4
|
|
835
|
+
return [4, handleProcessInstanceNode(instanceId, null, processStatus, null, userSession)];
|
|
889
836
|
case 2:
|
|
890
837
|
_a.sent();
|
|
891
|
-
return [2
|
|
838
|
+
return [2];
|
|
892
839
|
}
|
|
893
840
|
});
|
|
894
841
|
}); };
|