@steedos-labs/content-compliance 0.0.76 → 0.0.77
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/dist/index.js +1 -1
- package/main/default/objects/pepsico_material/buttons/pepsico_onedrive_edit_material.button.yml +1 -1
- package/main/default/objects/pepsico_material/buttons/pepsico_onedrive_review_material.button.yml +1 -1
- package/main/default/objects/pepsico_material/buttons/pepsico_update_material.button.yml +1 -1
- package/main/default/objects/pepsico_material/fields/xml_converted_word.field.yml +6 -0
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_approval.button.yml +70 -0
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_confirm_online.button.yml +1 -1
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_material_upload.button.yml +78 -8
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_postpone_online.button.yml +1 -1
- package/main/default/objects/pepsico_material_approval/fields/material_owner_id.field.yml +7 -0
- package/main/default/objects/pepsico_material_approval/fields/materials_uploaded_to_onedrive_status.field.yml +3 -3
- package/package.json +1 -1
- package/lib/actions/addBulkMaterials.d.ts +0 -7
- package/lib/actions/addBulkMaterials.js +0 -27
- package/lib/actions/addBulkMaterials.js.map +0 -1
- package/lib/actions/confirmDeployment.d.ts +0 -7
- package/lib/actions/confirmDeployment.js +0 -28
- package/lib/actions/confirmDeployment.js.map +0 -1
- package/lib/actions/hasDuplicateMaterials.d.ts +0 -9
- package/lib/actions/hasDuplicateMaterials.js +0 -30
- package/lib/actions/hasDuplicateMaterials.js.map +0 -1
- package/lib/actions/index.d.ts +0 -9
- package/lib/actions/index.js +0 -13
- package/lib/actions/index.js.map +0 -1
- package/lib/actions/postponeDeployment.d.ts +0 -7
- package/lib/actions/postponeDeployment.js +0 -27
- package/lib/actions/postponeDeployment.js.map +0 -1
- package/lib/actions/rule.d.ts +0 -7
- package/lib/actions/rule.js +0 -27
- package/lib/actions/rule.js.map +0 -1
- package/lib/actions/submit.d.ts +0 -7
- package/lib/actions/submit.js +0 -27
- package/lib/actions/submit.js.map +0 -1
- package/lib/actions/submitKids.d.ts +0 -7
- package/lib/actions/submitKids.js +0 -27
- package/lib/actions/submitKids.js.map +0 -1
- package/lib/actions/submitMaterial.d.ts +0 -7
- package/lib/actions/submitMaterial.js +0 -27
- package/lib/actions/submitMaterial.js.map +0 -1
- package/lib/actions/terminate.d.ts +0 -7
- package/lib/actions/terminate.js +0 -27
- package/lib/actions/terminate.js.map +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -387
- package/lib/index.js.map +0 -1
- package/lib/methods/AI.d.ts +0 -1
- package/lib/methods/AI.js +0 -39
- package/lib/methods/AI.js.map +0 -1
- package/lib/methods/approval_engine.d.ts +0 -14
- package/lib/methods/approval_engine.js +0 -1101
- package/lib/methods/approval_engine.js.map +0 -1
- package/lib/methods/consts.d.ts +0 -143
- package/lib/methods/consts.js +0 -40
- package/lib/methods/consts.js.map +0 -1
- package/lib/methods/content_hub.d.ts +0 -1
- package/lib/methods/content_hub.js +0 -194
- package/lib/methods/content_hub.js.map +0 -1
- package/lib/methods/docx.d.ts +0 -3
- package/lib/methods/docx.js +0 -12
- package/lib/methods/docx.js.map +0 -1
- package/lib/methods/index.d.ts +0 -2
- package/lib/methods/index.js +0 -6
- package/lib/methods/index.js.map +0 -1
- package/lib/methods/material.d.ts +0 -13
- package/lib/methods/material.js +0 -544
- package/lib/methods/material.js.map +0 -1
- package/lib/methods/o365.d.ts +0 -5
- package/lib/methods/o365.js +0 -35
- package/lib/methods/o365.js.map +0 -1
- package/lib/methods/oneDrive.d.ts +0 -5
- package/lib/methods/oneDrive.js +0 -39
- package/lib/methods/oneDrive.js.map +0 -1
|
@@ -1,1101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.submitContent = exports.submitKidsContent = exports.rejectContent = exports.approvalContent = exports.postponeDeployment = exports.confirmDeployment = exports.terminate = exports.getApproverStepRule = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var consts_1 = require("./consts");
|
|
6
|
-
var amis_formula_1 = require("amis-formula");
|
|
7
|
-
var lodash_1 = require("lodash");
|
|
8
|
-
var material_1 = require("./material");
|
|
9
|
-
var content_hub_1 = require("./content_hub");
|
|
10
|
-
var AI_1 = require("./AI");
|
|
11
|
-
var getApproverStepRule = function (ctx) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
12
|
-
var rules, rule;
|
|
13
|
-
return tslib_1.__generator(this, function (_a) {
|
|
14
|
-
switch (_a.label) {
|
|
15
|
-
case 0: return [4, ctx.getObject('pepsico_flow_rule').find({
|
|
16
|
-
filters: ['fu5nvp', '=', true], fields: ['_id', 'name']
|
|
17
|
-
})];
|
|
18
|
-
case 1:
|
|
19
|
-
rules = _a.sent();
|
|
20
|
-
rule = rules.length > 0 ? rules[0] : null;
|
|
21
|
-
if (!rule) {
|
|
22
|
-
throw new Error('未找到审批流规则');
|
|
23
|
-
}
|
|
24
|
-
return [2, rule];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}); };
|
|
28
|
-
exports.getApproverStepRule = getApproverStepRule;
|
|
29
|
-
var getApproverStep = function (ctx, materialApproval) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
30
|
-
var rule;
|
|
31
|
-
return tslib_1.__generator(this, function (_a) {
|
|
32
|
-
switch (_a.label) {
|
|
33
|
-
case 0: return [4, (0, exports.getApproverStepRule)(ctx)];
|
|
34
|
-
case 1:
|
|
35
|
-
rule = _a.sent();
|
|
36
|
-
console.log("[getApproverStep]", rule, (0, amis_formula_1.evaluate)(rule.name, materialApproval));
|
|
37
|
-
if ((0, amis_formula_1.evaluate)(rule.name, materialApproval)) {
|
|
38
|
-
return [2, consts_1.Step.personnel_review];
|
|
39
|
-
}
|
|
40
|
-
return [2, consts_1.Step.departmental_review];
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}); };
|
|
44
|
-
var getNextStep = function (ctx, materialApproval, action) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var nextStep, _a, _b;
|
|
46
|
-
return tslib_1.__generator(this, function (_c) {
|
|
47
|
-
switch (_c.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
nextStep = consts_1.Step.draft;
|
|
50
|
-
_a = materialApproval.current_step;
|
|
51
|
-
switch (_a) {
|
|
52
|
-
case consts_1.Step.draft: return [3, 1];
|
|
53
|
-
case consts_1.Step.ai_review: return [3, 2];
|
|
54
|
-
case consts_1.Step.departmental_review: return [3, 6];
|
|
55
|
-
case consts_1.Step.personnel_review: return [3, 6];
|
|
56
|
-
case consts_1.Step.submitter_revisions: return [3, 7];
|
|
57
|
-
case consts_1.Step.awaiting_deployment: return [3, 9];
|
|
58
|
-
}
|
|
59
|
-
return [3, 10];
|
|
60
|
-
case 1:
|
|
61
|
-
nextStep = consts_1.Step.ai_review;
|
|
62
|
-
return [3, 11];
|
|
63
|
-
case 2:
|
|
64
|
-
if (!(action == consts_1.ApprovalStatus.approved)) return [3, 4];
|
|
65
|
-
return [4, getApproverStep(ctx, materialApproval)];
|
|
66
|
-
case 3:
|
|
67
|
-
_b = _c.sent();
|
|
68
|
-
return [3, 5];
|
|
69
|
-
case 4:
|
|
70
|
-
_b = consts_1.Step.draft;
|
|
71
|
-
_c.label = 5;
|
|
72
|
-
case 5:
|
|
73
|
-
nextStep = _b;
|
|
74
|
-
return [3, 11];
|
|
75
|
-
case 6:
|
|
76
|
-
nextStep = action == consts_1.ApprovalStatus.approved ? consts_1.Step.awaiting_deployment : consts_1.Step.submitter_revisions;
|
|
77
|
-
return [3, 11];
|
|
78
|
-
case 7: return [4, getApproverStep(ctx, materialApproval)];
|
|
79
|
-
case 8:
|
|
80
|
-
nextStep = _c.sent();
|
|
81
|
-
return [3, 11];
|
|
82
|
-
case 9:
|
|
83
|
-
nextStep = consts_1.Step.conclusion;
|
|
84
|
-
return [3, 11];
|
|
85
|
-
case 10: return [3, 11];
|
|
86
|
-
case 11:
|
|
87
|
-
console.log('[getNextStep]', JSON.stringify({
|
|
88
|
-
action: action,
|
|
89
|
-
nextStep: nextStep
|
|
90
|
-
}));
|
|
91
|
-
return [2, nextStep];
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}); };
|
|
95
|
-
var getNextApprovers = function (ctx, materialApproval, nextStep) {
|
|
96
|
-
var approves = [];
|
|
97
|
-
switch (nextStep) {
|
|
98
|
-
case consts_1.Step.draft:
|
|
99
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
100
|
-
userIds: [materialApproval.owner],
|
|
101
|
-
type: consts_1.ProcessApprovalType.Others
|
|
102
|
-
});
|
|
103
|
-
break;
|
|
104
|
-
case consts_1.Step.ai_review:
|
|
105
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
106
|
-
userIds: [process.env.PEPSICO_CONTENT_APPROVAL_AI_USERID],
|
|
107
|
-
type: consts_1.ProcessApprovalType.AI
|
|
108
|
-
});
|
|
109
|
-
break;
|
|
110
|
-
case consts_1.Step.departmental_review:
|
|
111
|
-
if (materialApproval.ns_approval_status != true) {
|
|
112
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
113
|
-
userIds: materialApproval.ns_reviewer,
|
|
114
|
-
type: consts_1.ProcessApprovalType.NS
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (materialApproval.legal_approval_status != true) {
|
|
118
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
119
|
-
userIds: materialApproval.legal_reviewer,
|
|
120
|
-
type: consts_1.ProcessApprovalType.Legal
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (materialApproval.sra_approval_status != true) {
|
|
124
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
125
|
-
userIds: materialApproval.sra_reviewer,
|
|
126
|
-
type: consts_1.ProcessApprovalType.SRA
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
if (materialApproval.ca_approval_status != true) {
|
|
130
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
131
|
-
userIds: materialApproval.ca_reviewer,
|
|
132
|
-
type: consts_1.ProcessApprovalType.CA
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (materialApproval.child_files == 'yes' && materialApproval.kids_approval_status != true) {
|
|
136
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
137
|
-
userIds: [materialApproval.kids_reviewer],
|
|
138
|
-
type: consts_1.ProcessApprovalType.Kids
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
case consts_1.Step.personnel_review:
|
|
143
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
144
|
-
userIds: materialApproval.reviewer,
|
|
145
|
-
type: consts_1.ProcessApprovalType.guding
|
|
146
|
-
});
|
|
147
|
-
if (materialApproval.child_files == 'yes' && materialApproval.kids_approval_status != true) {
|
|
148
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
149
|
-
userIds: [materialApproval.kids_reviewer],
|
|
150
|
-
type: consts_1.ProcessApprovalType.Kids
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
case consts_1.Step.submitter_revisions:
|
|
155
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
156
|
-
userIds: [materialApproval.owner],
|
|
157
|
-
type: consts_1.ProcessApprovalType.Others
|
|
158
|
-
});
|
|
159
|
-
break;
|
|
160
|
-
case consts_1.Step.awaiting_deployment:
|
|
161
|
-
approves = (0, lodash_1.concat)(approves, {
|
|
162
|
-
userIds: [materialApproval.owner],
|
|
163
|
-
type: consts_1.ProcessApprovalType.Others
|
|
164
|
-
});
|
|
165
|
-
break;
|
|
166
|
-
default:
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
return (0, lodash_1.uniq)(approves);
|
|
170
|
-
};
|
|
171
|
-
var canSubmit = function (materialApproval) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
172
|
-
return tslib_1.__generator(this, function (_a) {
|
|
173
|
-
if (materialApproval.review_status === consts_1.ReviewStatus.terminated) {
|
|
174
|
-
throw new Error("已终止审核.");
|
|
175
|
-
}
|
|
176
|
-
if (materialApproval.current_step === consts_1.Step.conclusion) {
|
|
177
|
-
throw new Error("已审核完成.");
|
|
178
|
-
}
|
|
179
|
-
return [2, true];
|
|
180
|
-
});
|
|
181
|
-
}); };
|
|
182
|
-
var getReviewStatus = function (nextStep) {
|
|
183
|
-
if (nextStep === consts_1.Step.draft) {
|
|
184
|
-
return consts_1.ReviewStatus.draft;
|
|
185
|
-
}
|
|
186
|
-
else if (nextStep === consts_1.Step.conclusion) {
|
|
187
|
-
return true ? consts_1.ReviewStatus.approved : consts_1.ReviewStatus.rejected;
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
return consts_1.ReviewStatus.under_review;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var sendNotifications = function (ctx, materialApproval, nextApprovers, actionLabel) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
194
|
-
var nextApprovers_1, nextApprovers_1_1, to, e_1_1, spaceUsers, spaceUsers_1, spaceUsers_1_1, spaceUser, error_1, e_2_1, error_2;
|
|
195
|
-
var e_1, _a, e_2, _b;
|
|
196
|
-
return tslib_1.__generator(this, function (_c) {
|
|
197
|
-
switch (_c.label) {
|
|
198
|
-
case 0:
|
|
199
|
-
_c.trys.push([0, 20, , 21]);
|
|
200
|
-
_c.label = 1;
|
|
201
|
-
case 1:
|
|
202
|
-
_c.trys.push([1, 6, 7, 8]);
|
|
203
|
-
nextApprovers_1 = tslib_1.__values(nextApprovers), nextApprovers_1_1 = nextApprovers_1.next();
|
|
204
|
-
_c.label = 2;
|
|
205
|
-
case 2:
|
|
206
|
-
if (!!nextApprovers_1_1.done) return [3, 5];
|
|
207
|
-
to = nextApprovers_1_1.value;
|
|
208
|
-
return [4, ctx.broker.call('notifications.add', {
|
|
209
|
-
message: {
|
|
210
|
-
name: "".concat(actionLabel, ": ").concat(materialApproval.name),
|
|
211
|
-
body: "",
|
|
212
|
-
related_to: {
|
|
213
|
-
o: "pepsico_material_approval",
|
|
214
|
-
ids: [materialApproval._id]
|
|
215
|
-
},
|
|
216
|
-
related_name: materialApproval.name,
|
|
217
|
-
from: materialApproval.owner,
|
|
218
|
-
space: materialApproval.space
|
|
219
|
-
},
|
|
220
|
-
from: materialApproval.owner,
|
|
221
|
-
to: to
|
|
222
|
-
})];
|
|
223
|
-
case 3:
|
|
224
|
-
_c.sent();
|
|
225
|
-
_c.label = 4;
|
|
226
|
-
case 4:
|
|
227
|
-
nextApprovers_1_1 = nextApprovers_1.next();
|
|
228
|
-
return [3, 2];
|
|
229
|
-
case 5: return [3, 8];
|
|
230
|
-
case 6:
|
|
231
|
-
e_1_1 = _c.sent();
|
|
232
|
-
e_1 = { error: e_1_1 };
|
|
233
|
-
return [3, 8];
|
|
234
|
-
case 7:
|
|
235
|
-
try {
|
|
236
|
-
if (nextApprovers_1_1 && !nextApprovers_1_1.done && (_a = nextApprovers_1.return)) _a.call(nextApprovers_1);
|
|
237
|
-
}
|
|
238
|
-
finally { if (e_1) throw e_1.error; }
|
|
239
|
-
return [7];
|
|
240
|
-
case 8: return [4, ctx.getObject('space_users').find({ filters: [['user', '=', nextApprovers], ['space', '=', materialApproval.space]] })];
|
|
241
|
-
case 9:
|
|
242
|
-
spaceUsers = _c.sent();
|
|
243
|
-
_c.label = 10;
|
|
244
|
-
case 10:
|
|
245
|
-
_c.trys.push([10, 17, 18, 19]);
|
|
246
|
-
spaceUsers_1 = tslib_1.__values(spaceUsers), spaceUsers_1_1 = spaceUsers_1.next();
|
|
247
|
-
_c.label = 11;
|
|
248
|
-
case 11:
|
|
249
|
-
if (!!spaceUsers_1_1.done) return [3, 16];
|
|
250
|
-
spaceUser = spaceUsers_1_1.value;
|
|
251
|
-
if (!(spaceUser.email && spaceUser.email_notification)) return [3, 15];
|
|
252
|
-
_c.label = 12;
|
|
253
|
-
case 12:
|
|
254
|
-
_c.trys.push([12, 14, , 15]);
|
|
255
|
-
return [4, ctx.broker.call('@builder6/email.send', {
|
|
256
|
-
to: spaceUser.email,
|
|
257
|
-
subject: "".concat(actionLabel, ": ").concat(materialApproval.name),
|
|
258
|
-
html: "\n <p>\u60A8\u6709\u4E00\u4EFD\u65B0\u7684\u5F85\u5BA1\u6838\u6587\u4EF6\u9700\u8981\u67E5\u770B\u548C\u5904\u7406\u3002\u8BF7\u70B9\u51FB\u4E0B\u9762\u7684\u94FE\u63A5\u6765\u8BBF\u95EE\u8BE5\u6587\u4EF6\uFF1A</p>\n <a href=\"".concat(process.env.ROOT_URL, "/app/pepsico_content_review/pepsico_material_approval/view/").concat(materialApproval._id, "?side_object=pepsico_material_approval&side_listview_id=pending\">").concat(materialApproval.name, "</a>\n ")
|
|
259
|
-
})];
|
|
260
|
-
case 13:
|
|
261
|
-
_c.sent();
|
|
262
|
-
return [3, 15];
|
|
263
|
-
case 14:
|
|
264
|
-
error_1 = _c.sent();
|
|
265
|
-
console.log(error_1);
|
|
266
|
-
return [3, 15];
|
|
267
|
-
case 15:
|
|
268
|
-
spaceUsers_1_1 = spaceUsers_1.next();
|
|
269
|
-
return [3, 11];
|
|
270
|
-
case 16: return [3, 19];
|
|
271
|
-
case 17:
|
|
272
|
-
e_2_1 = _c.sent();
|
|
273
|
-
e_2 = { error: e_2_1 };
|
|
274
|
-
return [3, 19];
|
|
275
|
-
case 18:
|
|
276
|
-
try {
|
|
277
|
-
if (spaceUsers_1_1 && !spaceUsers_1_1.done && (_b = spaceUsers_1.return)) _b.call(spaceUsers_1);
|
|
278
|
-
}
|
|
279
|
-
finally { if (e_2) throw e_2.error; }
|
|
280
|
-
return [7];
|
|
281
|
-
case 19: return [3, 21];
|
|
282
|
-
case 20:
|
|
283
|
-
error_2 = _c.sent();
|
|
284
|
-
console.log(error_2);
|
|
285
|
-
return [3, 21];
|
|
286
|
-
case 21: return [2];
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
}); };
|
|
290
|
-
var updateUserStepStatus = function (ctx, materialApproval, _a) {
|
|
291
|
-
var approvalStatus = _a.approvalStatus;
|
|
292
|
-
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
293
|
-
var user, process, process_1, process_1_1, item, processOthers, processOthers_1, processOthers_1_1, item_1, e_3_1, e_4_1;
|
|
294
|
-
var e_4, _b, e_3, _c;
|
|
295
|
-
return tslib_1.__generator(this, function (_d) {
|
|
296
|
-
switch (_d.label) {
|
|
297
|
-
case 0:
|
|
298
|
-
user = ctx.meta.user;
|
|
299
|
-
return [4, ctx.getObject("pepsico_approval_process").find({
|
|
300
|
-
filters: [
|
|
301
|
-
["owner", "=", user.userId],
|
|
302
|
-
["pepsico_material_approval", "=", materialApproval._id],
|
|
303
|
-
["current_step", "=", materialApproval.current_step],
|
|
304
|
-
["space", "=", materialApproval.space],
|
|
305
|
-
["approved", "=", 'progess']
|
|
306
|
-
],
|
|
307
|
-
top: 1,
|
|
308
|
-
sort: "modified desc"
|
|
309
|
-
})];
|
|
310
|
-
case 1:
|
|
311
|
-
process = _d.sent();
|
|
312
|
-
_d.label = 2;
|
|
313
|
-
case 2:
|
|
314
|
-
_d.trys.push([2, 15, 16, 17]);
|
|
315
|
-
process_1 = tslib_1.__values(process), process_1_1 = process_1.next();
|
|
316
|
-
_d.label = 3;
|
|
317
|
-
case 3:
|
|
318
|
-
if (!!process_1_1.done) return [3, 14];
|
|
319
|
-
item = process_1_1.value;
|
|
320
|
-
return [4, ctx.getObject("pepsico_approval_process").update(item._id, {
|
|
321
|
-
submitted: new Date(),
|
|
322
|
-
modified: new Date(),
|
|
323
|
-
modified_by: user.userId,
|
|
324
|
-
approved: approvalStatus || 'submit'
|
|
325
|
-
})];
|
|
326
|
-
case 4:
|
|
327
|
-
_d.sent();
|
|
328
|
-
return [4, ctx.getObject("pepsico_approval_process").find({
|
|
329
|
-
filters: [
|
|
330
|
-
["owner", "!=", user.userId],
|
|
331
|
-
["pepsico_material_approval", "=", materialApproval._id],
|
|
332
|
-
["current_step", "=", materialApproval.current_step],
|
|
333
|
-
["space", "=", materialApproval.space],
|
|
334
|
-
["approved", "=", 'progess'],
|
|
335
|
-
["type", "=", item.type]
|
|
336
|
-
],
|
|
337
|
-
sort: "modified desc"
|
|
338
|
-
})];
|
|
339
|
-
case 5:
|
|
340
|
-
processOthers = _d.sent();
|
|
341
|
-
_d.label = 6;
|
|
342
|
-
case 6:
|
|
343
|
-
_d.trys.push([6, 11, 12, 13]);
|
|
344
|
-
processOthers_1 = (e_3 = void 0, tslib_1.__values(processOthers)), processOthers_1_1 = processOthers_1.next();
|
|
345
|
-
_d.label = 7;
|
|
346
|
-
case 7:
|
|
347
|
-
if (!!processOthers_1_1.done) return [3, 10];
|
|
348
|
-
item_1 = processOthers_1_1.value;
|
|
349
|
-
return [4, ctx.getObject("pepsico_approval_process").update(item_1._id, {
|
|
350
|
-
modified: new Date(),
|
|
351
|
-
modified_by: user.userId,
|
|
352
|
-
approved: ''
|
|
353
|
-
})];
|
|
354
|
-
case 8:
|
|
355
|
-
_d.sent();
|
|
356
|
-
_d.label = 9;
|
|
357
|
-
case 9:
|
|
358
|
-
processOthers_1_1 = processOthers_1.next();
|
|
359
|
-
return [3, 7];
|
|
360
|
-
case 10: return [3, 13];
|
|
361
|
-
case 11:
|
|
362
|
-
e_3_1 = _d.sent();
|
|
363
|
-
e_3 = { error: e_3_1 };
|
|
364
|
-
return [3, 13];
|
|
365
|
-
case 12:
|
|
366
|
-
try {
|
|
367
|
-
if (processOthers_1_1 && !processOthers_1_1.done && (_c = processOthers_1.return)) _c.call(processOthers_1);
|
|
368
|
-
}
|
|
369
|
-
finally { if (e_3) throw e_3.error; }
|
|
370
|
-
return [7];
|
|
371
|
-
case 13:
|
|
372
|
-
process_1_1 = process_1.next();
|
|
373
|
-
return [3, 3];
|
|
374
|
-
case 14: return [3, 17];
|
|
375
|
-
case 15:
|
|
376
|
-
e_4_1 = _d.sent();
|
|
377
|
-
e_4 = { error: e_4_1 };
|
|
378
|
-
return [3, 17];
|
|
379
|
-
case 16:
|
|
380
|
-
try {
|
|
381
|
-
if (process_1_1 && !process_1_1.done && (_b = process_1.return)) _b.call(process_1);
|
|
382
|
-
}
|
|
383
|
-
finally { if (e_4) throw e_4.error; }
|
|
384
|
-
return [7];
|
|
385
|
-
case 17: return [2];
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
});
|
|
389
|
-
};
|
|
390
|
-
var updateApproveFieldStatus = function (ctx, recordId, approveField, approveFieldValue) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
391
|
-
var _a;
|
|
392
|
-
return tslib_1.__generator(this, function (_b) {
|
|
393
|
-
switch (_b.label) {
|
|
394
|
-
case 0:
|
|
395
|
-
if (!approveField) return [3, 2];
|
|
396
|
-
console.log('[updateApproveFieldStatus]', JSON.stringify({ recordId: recordId, approveField: approveField, approveFieldValue: approveFieldValue }));
|
|
397
|
-
return [4, ctx.getObject('pepsico_material_approval').update(recordId, (_a = {},
|
|
398
|
-
_a[approveField] = approveFieldValue,
|
|
399
|
-
_a))];
|
|
400
|
-
case 1:
|
|
401
|
-
_b.sent();
|
|
402
|
-
_b.label = 2;
|
|
403
|
-
case 2: return [2];
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
}); };
|
|
407
|
-
var changeApprovalProcess = function (ctx, materialApproval, _a) {
|
|
408
|
-
var nextStep = _a.nextStep, nextApprovers = _a.nextApprovers, description = _a.description;
|
|
409
|
-
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
410
|
-
var user, count, now, sUsers, _b, nextApprovers_2, nextApprovers_2_1, nextApprover, _c, _d, userId, spaceUsers, e_5_1, e_6_1;
|
|
411
|
-
var e_6, _e, e_5, _f;
|
|
412
|
-
return tslib_1.__generator(this, function (_g) {
|
|
413
|
-
switch (_g.label) {
|
|
414
|
-
case 0:
|
|
415
|
-
console.log("[changeApprovalProcess]", nextStep, nextApprovers, description);
|
|
416
|
-
user = ctx.meta.user;
|
|
417
|
-
if (!(!materialApproval.current_step || materialApproval.current_step == consts_1.Step.draft)) return [3, 3];
|
|
418
|
-
return [4, ctx.getObject("pepsico_approval_process").count({
|
|
419
|
-
filters: [
|
|
420
|
-
["pepsico_material_approval", "=", materialApproval._id],
|
|
421
|
-
["space", "=", materialApproval.space]
|
|
422
|
-
]
|
|
423
|
-
})];
|
|
424
|
-
case 1:
|
|
425
|
-
count = _g.sent();
|
|
426
|
-
if (!(count == 0)) return [3, 3];
|
|
427
|
-
now = new Date();
|
|
428
|
-
return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
429
|
-
pepsico_material_approval: materialApproval._id,
|
|
430
|
-
owner: user.userId,
|
|
431
|
-
review_department: user.organization._id,
|
|
432
|
-
current_step: consts_1.Step.draft,
|
|
433
|
-
space: materialApproval.space,
|
|
434
|
-
created: now,
|
|
435
|
-
created_by: user.userId,
|
|
436
|
-
modified: now,
|
|
437
|
-
modified_by: user.userId,
|
|
438
|
-
name: description,
|
|
439
|
-
submitted: now,
|
|
440
|
-
approved: 'submit'
|
|
441
|
-
})];
|
|
442
|
-
case 2:
|
|
443
|
-
_g.sent();
|
|
444
|
-
_g.label = 3;
|
|
445
|
-
case 3:
|
|
446
|
-
sUsers = null;
|
|
447
|
-
_b = nextStep;
|
|
448
|
-
switch (_b) {
|
|
449
|
-
case consts_1.Step.draft: return [3, 4];
|
|
450
|
-
case consts_1.Step.ai_review: return [3, 4];
|
|
451
|
-
case consts_1.Step.departmental_review: return [3, 4];
|
|
452
|
-
case consts_1.Step.personnel_review: return [3, 4];
|
|
453
|
-
case consts_1.Step.submitter_revisions: return [3, 4];
|
|
454
|
-
case consts_1.Step.awaiting_deployment: return [3, 4];
|
|
455
|
-
case consts_1.Step.conclusion: return [3, 19];
|
|
456
|
-
}
|
|
457
|
-
return [3, 21];
|
|
458
|
-
case 4:
|
|
459
|
-
_g.trys.push([4, 16, 17, 18]);
|
|
460
|
-
nextApprovers_2 = tslib_1.__values(nextApprovers), nextApprovers_2_1 = nextApprovers_2.next();
|
|
461
|
-
_g.label = 5;
|
|
462
|
-
case 5:
|
|
463
|
-
if (!!nextApprovers_2_1.done) return [3, 15];
|
|
464
|
-
nextApprover = nextApprovers_2_1.value;
|
|
465
|
-
_g.label = 6;
|
|
466
|
-
case 6:
|
|
467
|
-
_g.trys.push([6, 12, 13, 14]);
|
|
468
|
-
_c = (e_5 = void 0, tslib_1.__values(nextApprover.userIds)), _d = _c.next();
|
|
469
|
-
_g.label = 7;
|
|
470
|
-
case 7:
|
|
471
|
-
if (!!_d.done) return [3, 11];
|
|
472
|
-
userId = _d.value;
|
|
473
|
-
return [4, ctx.getObject('space_users').directFind({ filters: [['user', '=', userId], ['space', '=', materialApproval.space]] })];
|
|
474
|
-
case 8:
|
|
475
|
-
spaceUsers = _g.sent();
|
|
476
|
-
return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
477
|
-
pepsico_material_approval: materialApproval._id,
|
|
478
|
-
owner: userId,
|
|
479
|
-
type: nextApprover.type,
|
|
480
|
-
review_department: spaceUsers.length > 0 ? spaceUsers[0].organization : null,
|
|
481
|
-
current_step: nextStep,
|
|
482
|
-
approved: "progess",
|
|
483
|
-
space: materialApproval.space,
|
|
484
|
-
created: new Date(),
|
|
485
|
-
created_by: user.userId,
|
|
486
|
-
modified: new Date(),
|
|
487
|
-
modified_by: user.userId,
|
|
488
|
-
name: description
|
|
489
|
-
})];
|
|
490
|
-
case 9:
|
|
491
|
-
_g.sent();
|
|
492
|
-
_g.label = 10;
|
|
493
|
-
case 10:
|
|
494
|
-
_d = _c.next();
|
|
495
|
-
return [3, 7];
|
|
496
|
-
case 11: return [3, 14];
|
|
497
|
-
case 12:
|
|
498
|
-
e_5_1 = _g.sent();
|
|
499
|
-
e_5 = { error: e_5_1 };
|
|
500
|
-
return [3, 14];
|
|
501
|
-
case 13:
|
|
502
|
-
try {
|
|
503
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
504
|
-
}
|
|
505
|
-
finally { if (e_5) throw e_5.error; }
|
|
506
|
-
return [7];
|
|
507
|
-
case 14:
|
|
508
|
-
nextApprovers_2_1 = nextApprovers_2.next();
|
|
509
|
-
return [3, 5];
|
|
510
|
-
case 15: return [3, 18];
|
|
511
|
-
case 16:
|
|
512
|
-
e_6_1 = _g.sent();
|
|
513
|
-
e_6 = { error: e_6_1 };
|
|
514
|
-
return [3, 18];
|
|
515
|
-
case 17:
|
|
516
|
-
try {
|
|
517
|
-
if (nextApprovers_2_1 && !nextApprovers_2_1.done && (_e = nextApprovers_2.return)) _e.call(nextApprovers_2);
|
|
518
|
-
}
|
|
519
|
-
finally { if (e_6) throw e_6.error; }
|
|
520
|
-
return [7];
|
|
521
|
-
case 18: return [3, 22];
|
|
522
|
-
case 19: return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
523
|
-
pepsico_material_approval: materialApproval._id,
|
|
524
|
-
current_step: consts_1.Step.conclusion,
|
|
525
|
-
space: materialApproval.space,
|
|
526
|
-
created: new Date(),
|
|
527
|
-
created_by: user.userId,
|
|
528
|
-
modified: new Date(),
|
|
529
|
-
modified_by: user.userId,
|
|
530
|
-
name: description
|
|
531
|
-
})];
|
|
532
|
-
case 20:
|
|
533
|
-
_g.sent();
|
|
534
|
-
return [3, 22];
|
|
535
|
-
case 21: return [3, 22];
|
|
536
|
-
case 22: return [2];
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
var setPersonView = function (ctx, materialApproval) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
542
|
-
var personView, approvalType;
|
|
543
|
-
return tslib_1.__generator(this, function (_a) {
|
|
544
|
-
switch (_a.label) {
|
|
545
|
-
case 0:
|
|
546
|
-
personView = (0, lodash_1.concat)(materialApproval.sra_reviewer, materialApproval.ns_reviewer, materialApproval.ca_reviewer, materialApproval.legal_reviewer, materialApproval.reviewer);
|
|
547
|
-
if (materialApproval.child_files == 'yes') {
|
|
548
|
-
personView = (0, lodash_1.concat)(personView, materialApproval.kids_reviewer);
|
|
549
|
-
}
|
|
550
|
-
personView = (0, lodash_1.concat)(personView, materialApproval.sra_assistance, materialApproval.ns_assistance, materialApproval.ca_assistance, materialApproval.legal_assistance, materialApproval.assistance);
|
|
551
|
-
return [4, getApproverStep(ctx, materialApproval)];
|
|
552
|
-
case 1:
|
|
553
|
-
approvalType = _a.sent();
|
|
554
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(materialApproval._id, {
|
|
555
|
-
$push: {
|
|
556
|
-
person_view: {
|
|
557
|
-
$each: (0, lodash_1.compact)((0, lodash_1.uniq)(personView))
|
|
558
|
-
}
|
|
559
|
-
},
|
|
560
|
-
approval_type: approvalType
|
|
561
|
-
})];
|
|
562
|
-
case 2:
|
|
563
|
-
_a.sent();
|
|
564
|
-
return [2];
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
}); };
|
|
568
|
-
var sendToOwner = function (ctx, recordId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
569
|
-
var record, spaceUsers, owner;
|
|
570
|
-
return tslib_1.__generator(this, function (_a) {
|
|
571
|
-
switch (_a.label) {
|
|
572
|
-
case 0: return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
573
|
-
case 1:
|
|
574
|
-
record = _a.sent();
|
|
575
|
-
if (!(record && record.material_owner)) return [3, 5];
|
|
576
|
-
return [4, ctx.getObject('space_users').find({
|
|
577
|
-
filters: [['email', '=', record.material_owner], ['space', '=', record.space]]
|
|
578
|
-
})];
|
|
579
|
-
case 2:
|
|
580
|
-
spaceUsers = _a.sent();
|
|
581
|
-
if (!(spaceUsers && spaceUsers.length > 0)) return [3, 5];
|
|
582
|
-
owner = spaceUsers[0];
|
|
583
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
584
|
-
$push: {
|
|
585
|
-
person_view: owner.user
|
|
586
|
-
}
|
|
587
|
-
})];
|
|
588
|
-
case 3:
|
|
589
|
-
_a.sent();
|
|
590
|
-
return [4, sendNotifications(ctx, record, [owner.user], '内容审批通过待上线')];
|
|
591
|
-
case 4:
|
|
592
|
-
_a.sent();
|
|
593
|
-
_a.label = 5;
|
|
594
|
-
case 5: return [2];
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
}); };
|
|
598
|
-
var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
599
|
-
var actionLabel, user, record, nextStep, nextApprovers, nextApproversUserIds_1, nextApprovers_3, nextApprovers_3_1, nextApprover, e_7_1, error_3;
|
|
600
|
-
var e_7, _a;
|
|
601
|
-
return tslib_1.__generator(this, function (_b) {
|
|
602
|
-
switch (_b.label) {
|
|
603
|
-
case 0:
|
|
604
|
-
_b.trys.push([0, 43, , 44]);
|
|
605
|
-
actionLabel = '请查看';
|
|
606
|
-
user = ctx.meta.user;
|
|
607
|
-
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
608
|
-
case 1:
|
|
609
|
-
record = _b.sent();
|
|
610
|
-
console.log('[advanceApproval]', record.current_step, record.person_pending_approve, user.userId);
|
|
611
|
-
if (record.current_step != consts_1.Step.draft && !(0, lodash_1.includes)(record.person_pending_approve, user.userId)) {
|
|
612
|
-
return [2, {}];
|
|
613
|
-
}
|
|
614
|
-
return [4, canSubmit(record)];
|
|
615
|
-
case 2:
|
|
616
|
-
_b.sent();
|
|
617
|
-
return [4, getNextStep(ctx, record, currentStepApprovalStatus)];
|
|
618
|
-
case 3:
|
|
619
|
-
nextStep = _b.sent();
|
|
620
|
-
return [4, getNextApprovers(ctx, record, nextStep)];
|
|
621
|
-
case 4:
|
|
622
|
-
nextApprovers = _b.sent();
|
|
623
|
-
console.log("[advanceApproval] currentStepApprovalStatus:", currentStepApprovalStatus, " nextStep:", nextStep, " nextApprovers:", nextApprovers);
|
|
624
|
-
nextApproversUserIds_1 = [];
|
|
625
|
-
(0, lodash_1.map)(nextApprovers, function (item) {
|
|
626
|
-
nextApproversUserIds_1 = (0, lodash_1.concat)(nextApproversUserIds_1, item.userIds);
|
|
627
|
-
});
|
|
628
|
-
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
629
|
-
current_step: nextStep,
|
|
630
|
-
review_status: getReviewStatus(nextStep),
|
|
631
|
-
person_pending_approve: nextApproversUserIds_1,
|
|
632
|
-
$push: {
|
|
633
|
-
person_approved: {
|
|
634
|
-
$each: record.person_pending_approve
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
})];
|
|
638
|
-
case 5:
|
|
639
|
-
_b.sent();
|
|
640
|
-
return [4, changeApprovalProcess(ctx, record, {
|
|
641
|
-
nextStep: nextStep,
|
|
642
|
-
nextApprovers: nextApprovers,
|
|
643
|
-
description: ""
|
|
644
|
-
})];
|
|
645
|
-
case 6:
|
|
646
|
-
_b.sent();
|
|
647
|
-
if (!(nextStep === consts_1.Step.ai_review)) return [3, 8];
|
|
648
|
-
return [4, (0, AI_1.callAIReview)(ctx, recordId)];
|
|
649
|
-
case 7:
|
|
650
|
-
_b.sent();
|
|
651
|
-
_b.label = 8;
|
|
652
|
-
case 8:
|
|
653
|
-
_b.trys.push([8, 29, 30, 31]);
|
|
654
|
-
nextApprovers_3 = tslib_1.__values(nextApprovers), nextApprovers_3_1 = nextApprovers_3.next();
|
|
655
|
-
_b.label = 9;
|
|
656
|
-
case 9:
|
|
657
|
-
if (!!nextApprovers_3_1.done) return [3, 28];
|
|
658
|
-
nextApprover = nextApprovers_3_1.value;
|
|
659
|
-
if (!(nextApprover.type === consts_1.ProcessApprovalType.CA)) return [3, 12];
|
|
660
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
661
|
-
ca_approval_status: ''
|
|
662
|
-
})];
|
|
663
|
-
case 10:
|
|
664
|
-
_b.sent();
|
|
665
|
-
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ca_approval_status', '=', false]], {
|
|
666
|
-
ca_approval_status: ''
|
|
667
|
-
})];
|
|
668
|
-
case 11:
|
|
669
|
-
_b.sent();
|
|
670
|
-
_b.label = 12;
|
|
671
|
-
case 12:
|
|
672
|
-
if (!(nextApprover.type === consts_1.ProcessApprovalType.Legal)) return [3, 15];
|
|
673
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
674
|
-
legal_approval_status: ''
|
|
675
|
-
})];
|
|
676
|
-
case 13:
|
|
677
|
-
_b.sent();
|
|
678
|
-
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['legal_approval_status', '=', false]], {
|
|
679
|
-
legal_approval_status: ''
|
|
680
|
-
})];
|
|
681
|
-
case 14:
|
|
682
|
-
_b.sent();
|
|
683
|
-
_b.label = 15;
|
|
684
|
-
case 15:
|
|
685
|
-
if (!(nextApprover.type === consts_1.ProcessApprovalType.NS)) return [3, 18];
|
|
686
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
687
|
-
ns_approval_status: ''
|
|
688
|
-
})];
|
|
689
|
-
case 16:
|
|
690
|
-
_b.sent();
|
|
691
|
-
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ns_approval_status', '=', false]], {
|
|
692
|
-
ns_approval_status: ''
|
|
693
|
-
})];
|
|
694
|
-
case 17:
|
|
695
|
-
_b.sent();
|
|
696
|
-
_b.label = 18;
|
|
697
|
-
case 18:
|
|
698
|
-
if (!(nextApprover.type === consts_1.ProcessApprovalType.SRA)) return [3, 21];
|
|
699
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
700
|
-
sra_approval_status: ''
|
|
701
|
-
})];
|
|
702
|
-
case 19:
|
|
703
|
-
_b.sent();
|
|
704
|
-
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['sra_approval_status', '=', false]], {
|
|
705
|
-
sra_approval_status: ''
|
|
706
|
-
})];
|
|
707
|
-
case 20:
|
|
708
|
-
_b.sent();
|
|
709
|
-
_b.label = 21;
|
|
710
|
-
case 21:
|
|
711
|
-
if (!(nextApprover.type === consts_1.ProcessApprovalType.guding)) return [3, 24];
|
|
712
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
713
|
-
approval_status: ''
|
|
714
|
-
})];
|
|
715
|
-
case 22:
|
|
716
|
-
_b.sent();
|
|
717
|
-
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['approval_status', '=', false]], {
|
|
718
|
-
approval_status: ''
|
|
719
|
-
})];
|
|
720
|
-
case 23:
|
|
721
|
-
_b.sent();
|
|
722
|
-
_b.label = 24;
|
|
723
|
-
case 24:
|
|
724
|
-
if (!(nextApprover.type === consts_1.ProcessApprovalType.Kids)) return [3, 27];
|
|
725
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
726
|
-
kids_approval_status: ''
|
|
727
|
-
})];
|
|
728
|
-
case 25:
|
|
729
|
-
_b.sent();
|
|
730
|
-
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['kids_approval_status', '=', false]], {
|
|
731
|
-
kids_approval_status: ''
|
|
732
|
-
})];
|
|
733
|
-
case 26:
|
|
734
|
-
_b.sent();
|
|
735
|
-
_b.label = 27;
|
|
736
|
-
case 27:
|
|
737
|
-
nextApprovers_3_1 = nextApprovers_3.next();
|
|
738
|
-
return [3, 9];
|
|
739
|
-
case 28: return [3, 31];
|
|
740
|
-
case 29:
|
|
741
|
-
e_7_1 = _b.sent();
|
|
742
|
-
e_7 = { error: e_7_1 };
|
|
743
|
-
return [3, 31];
|
|
744
|
-
case 30:
|
|
745
|
-
try {
|
|
746
|
-
if (nextApprovers_3_1 && !nextApprovers_3_1.done && (_a = nextApprovers_3.return)) _a.call(nextApprovers_3);
|
|
747
|
-
}
|
|
748
|
-
finally { if (e_7) throw e_7.error; }
|
|
749
|
-
return [7];
|
|
750
|
-
case 31:
|
|
751
|
-
if (!(nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) return [3, 33];
|
|
752
|
-
return [4, setPersonView(ctx, record)];
|
|
753
|
-
case 32:
|
|
754
|
-
_b.sent();
|
|
755
|
-
_b.label = 33;
|
|
756
|
-
case 33:
|
|
757
|
-
if (!(record.current_step === consts_1.Step.departmental_review || record.current_step === consts_1.Step.personnel_review)) return [3, 35];
|
|
758
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
759
|
-
materials_remove_share_link_from_onedrive_status: 'pending'
|
|
760
|
-
})];
|
|
761
|
-
case 34:
|
|
762
|
-
_b.sent();
|
|
763
|
-
_b.label = 35;
|
|
764
|
-
case 35:
|
|
765
|
-
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 37];
|
|
766
|
-
return [4, pendingDeployment(ctx, recordId)];
|
|
767
|
-
case 36:
|
|
768
|
-
_b.sent();
|
|
769
|
-
_b.label = 37;
|
|
770
|
-
case 37:
|
|
771
|
-
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 39];
|
|
772
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
773
|
-
materials_download_from_onedrive_status: 'pending'
|
|
774
|
-
})];
|
|
775
|
-
case 38:
|
|
776
|
-
_b.sent();
|
|
777
|
-
_b.label = 39;
|
|
778
|
-
case 39:
|
|
779
|
-
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 41];
|
|
780
|
-
return [4, sendToOwner(ctx, recordId)];
|
|
781
|
-
case 40:
|
|
782
|
-
_b.sent();
|
|
783
|
-
_b.label = 41;
|
|
784
|
-
case 41:
|
|
785
|
-
if (currentStepApprovalStatus === consts_1.ApprovalStatus.rejected) {
|
|
786
|
-
actionLabel = '内容审批被驳回';
|
|
787
|
-
}
|
|
788
|
-
if (currentStepApprovalStatus === consts_1.ApprovalStatus.approved
|
|
789
|
-
&& (nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) {
|
|
790
|
-
actionLabel = '请审批';
|
|
791
|
-
}
|
|
792
|
-
if (nextStep === consts_1.Step.awaiting_deployment) {
|
|
793
|
-
actionLabel = "\u5185\u5BB9\u5BA1\u6279\u5DF2\u901A\u8FC7\u5F85\u4E0A\u7EBF";
|
|
794
|
-
}
|
|
795
|
-
return [4, sendNotifications(ctx, record, nextApproversUserIds_1, actionLabel)];
|
|
796
|
-
case 42:
|
|
797
|
-
_b.sent();
|
|
798
|
-
return [2, {}];
|
|
799
|
-
case 43:
|
|
800
|
-
error_3 = _b.sent();
|
|
801
|
-
return [2, {
|
|
802
|
-
msg: error_3.message,
|
|
803
|
-
status: 500
|
|
804
|
-
}];
|
|
805
|
-
case 44: return [2];
|
|
806
|
-
}
|
|
807
|
-
});
|
|
808
|
-
}); };
|
|
809
|
-
var terminate = function (ctx, recordId, description) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
810
|
-
var user, record;
|
|
811
|
-
return tslib_1.__generator(this, function (_a) {
|
|
812
|
-
switch (_a.label) {
|
|
813
|
-
case 0:
|
|
814
|
-
user = ctx.meta.user;
|
|
815
|
-
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
816
|
-
case 1:
|
|
817
|
-
record = _a.sent();
|
|
818
|
-
if (!(record.owner === user.userId || user.is_space_admin)) return [3, 4];
|
|
819
|
-
return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
820
|
-
pepsico_material_approval: record._id,
|
|
821
|
-
current_step: consts_1.Step.conclusion,
|
|
822
|
-
space: record.space,
|
|
823
|
-
created: new Date(),
|
|
824
|
-
created_by: user.userId,
|
|
825
|
-
modified: new Date(),
|
|
826
|
-
modified_by: user.userId,
|
|
827
|
-
approvalStatus: 'terminate',
|
|
828
|
-
name: description
|
|
829
|
-
})];
|
|
830
|
-
case 2:
|
|
831
|
-
_a.sent();
|
|
832
|
-
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
833
|
-
current_step: consts_1.Step.conclusion,
|
|
834
|
-
review_status: consts_1.ReviewStatus.terminated
|
|
835
|
-
})];
|
|
836
|
-
case 3:
|
|
837
|
-
_a.sent();
|
|
838
|
-
return [2, {}];
|
|
839
|
-
case 4: throw new Error('Sorry, you don’t have permission to terminate the review.');
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
}); };
|
|
843
|
-
exports.terminate = terminate;
|
|
844
|
-
var pendingDeployment = function (ctx, recordId) {
|
|
845
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
846
|
-
return tslib_1.__generator(this, function (_a) {
|
|
847
|
-
switch (_a.label) {
|
|
848
|
-
case 0: return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
849
|
-
launch: 'pending'
|
|
850
|
-
})];
|
|
851
|
-
case 1:
|
|
852
|
-
_a.sent();
|
|
853
|
-
return [2];
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
});
|
|
857
|
-
};
|
|
858
|
-
var confirmDeployment = function (ctx, recordId, data) {
|
|
859
|
-
if (data === void 0) { data = {
|
|
860
|
-
content_rule: null
|
|
861
|
-
}; }
|
|
862
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
863
|
-
var user, record;
|
|
864
|
-
return tslib_1.__generator(this, function (_a) {
|
|
865
|
-
switch (_a.label) {
|
|
866
|
-
case 0:
|
|
867
|
-
user = ctx.meta.user;
|
|
868
|
-
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
869
|
-
case 1:
|
|
870
|
-
record = _a.sent();
|
|
871
|
-
return [4, updateUserStepStatus(ctx, record, { approvalStatus: consts_1.ApprovalStatus.submit })];
|
|
872
|
-
case 2:
|
|
873
|
-
_a.sent();
|
|
874
|
-
if (!(record.current_step === consts_1.Step.awaiting_deployment && (0, lodash_1.includes)(record.person_pending_approve, user.userId))) return [3, 6];
|
|
875
|
-
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
876
|
-
launch: 'launched',
|
|
877
|
-
content_rule: data.content_rule,
|
|
878
|
-
aunch_time: new Date()
|
|
879
|
-
})];
|
|
880
|
-
case 3:
|
|
881
|
-
_a.sent();
|
|
882
|
-
return [4, advanceApproval(ctx, recordId, consts_1.ApprovalStatus.submit)];
|
|
883
|
-
case 4:
|
|
884
|
-
_a.sent();
|
|
885
|
-
return [4, (0, content_hub_1.inventoryApprovalMaterial)(ctx, recordId)];
|
|
886
|
-
case 5:
|
|
887
|
-
_a.sent();
|
|
888
|
-
_a.label = 6;
|
|
889
|
-
case 6: return [2, {}];
|
|
890
|
-
}
|
|
891
|
-
});
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
exports.confirmDeployment = confirmDeployment;
|
|
895
|
-
var postponeDeployment = function (ctx, recordId, data) {
|
|
896
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
897
|
-
var user, record;
|
|
898
|
-
return tslib_1.__generator(this, function (_a) {
|
|
899
|
-
switch (_a.label) {
|
|
900
|
-
case 0:
|
|
901
|
-
user = ctx.meta.user;
|
|
902
|
-
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
903
|
-
case 1:
|
|
904
|
-
record = _a.sent();
|
|
905
|
-
if (!(record.current_step === consts_1.Step.awaiting_deployment && (0, lodash_1.includes)(record.person_pending_approve, user.userId))) return [3, 3];
|
|
906
|
-
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
907
|
-
launch: 'postpone',
|
|
908
|
-
postpone_launch_date: data.postpone_launch_date
|
|
909
|
-
})];
|
|
910
|
-
case 2:
|
|
911
|
-
_a.sent();
|
|
912
|
-
_a.label = 3;
|
|
913
|
-
case 3: return [2, {}];
|
|
914
|
-
}
|
|
915
|
-
});
|
|
916
|
-
});
|
|
917
|
-
};
|
|
918
|
-
exports.postponeDeployment = postponeDeployment;
|
|
919
|
-
var approvalContent = function (ctx, recordId, _a) {
|
|
920
|
-
var approveField = _a.approveField;
|
|
921
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
922
|
-
var approvalNew, currentStepApprovalStatus;
|
|
923
|
-
return tslib_1.__generator(this, function (_b) {
|
|
924
|
-
switch (_b.label) {
|
|
925
|
-
case 0: return [4, updateApproveFieldStatus(ctx, recordId, approveField, true)];
|
|
926
|
-
case 1:
|
|
927
|
-
_b.sent();
|
|
928
|
-
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
929
|
-
case 2:
|
|
930
|
-
approvalNew = _b.sent();
|
|
931
|
-
return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: consts_1.ApprovalStatus.approved })];
|
|
932
|
-
case 3:
|
|
933
|
-
_b.sent();
|
|
934
|
-
currentStepApprovalStatus = consts_1.ApprovalStatus.approved;
|
|
935
|
-
if (approvalNew.current_step === consts_1.Step.departmental_review) {
|
|
936
|
-
if (!hasReviewed(approvalNew.ca_approval_status) || !hasReviewed(approvalNew.ns_approval_status) || !hasReviewed(approvalNew.legal_approval_status) || !hasReviewed(approvalNew.sra_approval_status)) {
|
|
937
|
-
console.log('[approvalContent]: 有其他部门未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
938
|
-
return [2, {}];
|
|
939
|
-
}
|
|
940
|
-
currentStepApprovalStatus = approvalNew.ca_approval_status && approvalNew.ns_approval_status && approvalNew.legal_approval_status && approvalNew.sra_approval_status ? consts_1.ApprovalStatus.approved : consts_1.ApprovalStatus.rejected;
|
|
941
|
-
console.log('[approvalContent]: 部门复审完成, 结果为:', currentStepApprovalStatus);
|
|
942
|
-
}
|
|
943
|
-
else if (approvalNew.current_step === consts_1.Step.personnel_review) {
|
|
944
|
-
if (!hasReviewed(approvalNew.approval_status)) {
|
|
945
|
-
console.log('[approvalContent]: 固定人员未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
946
|
-
return [2, {}];
|
|
947
|
-
}
|
|
948
|
-
currentStepApprovalStatus = approvalNew.approval_status ? consts_1.ApprovalStatus.approved : consts_1.ApprovalStatus.rejected;
|
|
949
|
-
console.log('[approvalContent]: 固定人员复审完成, 结果为:', currentStepApprovalStatus);
|
|
950
|
-
}
|
|
951
|
-
if (approvalNew.child_files == 'yes') {
|
|
952
|
-
if (!hasReviewed(approvalNew.kids_approval_status)) {
|
|
953
|
-
console.log('[approvalContent]: kids审核人未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
954
|
-
return [2, {}];
|
|
955
|
-
}
|
|
956
|
-
if (approvalNew.kids_approval_status == false) {
|
|
957
|
-
currentStepApprovalStatus = consts_1.ApprovalStatus.rejected;
|
|
958
|
-
}
|
|
959
|
-
console.log('[approvalContent]: kids审核完成, 结果为:', currentStepApprovalStatus);
|
|
960
|
-
}
|
|
961
|
-
console.log("[approvalContent] \u63A8\u8FDB\u5BA1\u6279\u8FDB\u5EA6,\u53C2\u6570\u4E3A \u5BA1\u6279\u5355: ".concat(recordId, " \u5F53\u524D\u6B65\u9AA4: ").concat(approvalNew.current_step, " \u5BA1\u6279\u7ED3\u679C\u4E3A: ").concat(currentStepApprovalStatus));
|
|
962
|
-
return [4, advanceApproval(ctx, recordId, currentStepApprovalStatus)];
|
|
963
|
-
case 4:
|
|
964
|
-
_b.sent();
|
|
965
|
-
return [2, {}];
|
|
966
|
-
}
|
|
967
|
-
});
|
|
968
|
-
});
|
|
969
|
-
};
|
|
970
|
-
exports.approvalContent = approvalContent;
|
|
971
|
-
var rejectContent = function (ctx, recordId, _a) {
|
|
972
|
-
var approveField = _a.approveField;
|
|
973
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
974
|
-
var user, approvalNew, currentStepApprovalStatus;
|
|
975
|
-
return tslib_1.__generator(this, function (_b) {
|
|
976
|
-
switch (_b.label) {
|
|
977
|
-
case 0:
|
|
978
|
-
user = ctx.meta.user;
|
|
979
|
-
return [4, updateApproveFieldStatus(ctx, recordId, approveField, false)];
|
|
980
|
-
case 1:
|
|
981
|
-
_b.sent();
|
|
982
|
-
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
983
|
-
case 2:
|
|
984
|
-
approvalNew = _b.sent();
|
|
985
|
-
currentStepApprovalStatus = consts_1.ApprovalStatus.rejected;
|
|
986
|
-
return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: consts_1.ApprovalStatus.rejected })];
|
|
987
|
-
case 3:
|
|
988
|
-
_b.sent();
|
|
989
|
-
if (approvalNew.current_step === consts_1.Step.departmental_review) {
|
|
990
|
-
if (!hasReviewed(approvalNew.ca_approval_status) || !hasReviewed(approvalNew.ns_approval_status) || !hasReviewed(approvalNew.legal_approval_status) || !hasReviewed(approvalNew.sra_approval_status)) {
|
|
991
|
-
console.log('[rejectContent]: 有其他部门未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
992
|
-
return [2, {}];
|
|
993
|
-
}
|
|
994
|
-
console.log('[rejectContent]: 部门复审完成');
|
|
995
|
-
}
|
|
996
|
-
else if (approvalNew.current_step === consts_1.Step.personnel_review) {
|
|
997
|
-
if (!hasReviewed(approvalNew.approval_status)) {
|
|
998
|
-
console.log('[rejectContent]: 固定人员未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
999
|
-
return [2, {}];
|
|
1000
|
-
}
|
|
1001
|
-
console.log('[rejectContent]: 固定人员复审完成');
|
|
1002
|
-
}
|
|
1003
|
-
if (approvalNew.child_files == 'yes') {
|
|
1004
|
-
if (!hasReviewed(approvalNew.kids_approval_status)) {
|
|
1005
|
-
console.log('[rejectContent]: kids审核人未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
1006
|
-
return [2, {}];
|
|
1007
|
-
}
|
|
1008
|
-
console.log('[rejectContent]: kids审核完成');
|
|
1009
|
-
}
|
|
1010
|
-
console.log("[rejectContent] \u63A8\u8FDB\u5BA1\u6279\u8FDB\u5EA6,\u53C2\u6570\u4E3A \u5BA1\u6279\u5355: ".concat(recordId, " \u5F53\u524D\u6B65\u9AA4: ").concat(approvalNew.current_step, " \u5BA1\u6279\u7ED3\u679C\u4E3A: ").concat(currentStepApprovalStatus));
|
|
1011
|
-
return [4, advanceApproval(ctx, recordId, currentStepApprovalStatus)];
|
|
1012
|
-
case 4:
|
|
1013
|
-
_b.sent();
|
|
1014
|
-
return [2, {}];
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
});
|
|
1018
|
-
};
|
|
1019
|
-
exports.rejectContent = rejectContent;
|
|
1020
|
-
var submitKidsContent = function (ctx, recordId, currentStepApprovalStatus) {
|
|
1021
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1022
|
-
var approveField;
|
|
1023
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1024
|
-
switch (_a.label) {
|
|
1025
|
-
case 0:
|
|
1026
|
-
if (currentStepApprovalStatus != consts_1.ApprovalStatus.approved && currentStepApprovalStatus != consts_1.ApprovalStatus.rejected) {
|
|
1027
|
-
throw new Error('无效的审核状态.');
|
|
1028
|
-
}
|
|
1029
|
-
approveField = "kids_approval_status";
|
|
1030
|
-
if (!(currentStepApprovalStatus === consts_1.ApprovalStatus.approved)) return [3, 2];
|
|
1031
|
-
return [4, (0, exports.approvalContent)(ctx, recordId, { approveField: approveField })];
|
|
1032
|
-
case 1:
|
|
1033
|
-
_a.sent();
|
|
1034
|
-
return [3, 4];
|
|
1035
|
-
case 2: return [4, (0, exports.rejectContent)(ctx, recordId, { approveField: approveField })];
|
|
1036
|
-
case 3:
|
|
1037
|
-
_a.sent();
|
|
1038
|
-
_a.label = 4;
|
|
1039
|
-
case 4: return [2];
|
|
1040
|
-
}
|
|
1041
|
-
});
|
|
1042
|
-
});
|
|
1043
|
-
};
|
|
1044
|
-
exports.submitKidsContent = submitKidsContent;
|
|
1045
|
-
var submitContent = function (ctx, recordId, currentStepApprovalStatus) {
|
|
1046
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1047
|
-
var approvalNew, approvalType, materials;
|
|
1048
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1049
|
-
switch (_a.label) {
|
|
1050
|
-
case 0: return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
1051
|
-
case 1:
|
|
1052
|
-
approvalNew = _a.sent();
|
|
1053
|
-
if (!(approvalNew.current_step === consts_1.Step.draft)) return [3, 4];
|
|
1054
|
-
return [4, getApproverStep(ctx, approvalNew)];
|
|
1055
|
-
case 2:
|
|
1056
|
-
approvalType = _a.sent();
|
|
1057
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1058
|
-
approval_type: approvalType
|
|
1059
|
-
})];
|
|
1060
|
-
case 3:
|
|
1061
|
-
_a.sent();
|
|
1062
|
-
_a.label = 4;
|
|
1063
|
-
case 4:
|
|
1064
|
-
console.log("[submitContent] \u6B65\u9AA4\u63D0\u4EA4\uFF0C\u53C2\u6570\u4E3A \u5BA1\u6279\u5355: ".concat(recordId, " \u5F53\u524D\u6B65\u9AA4: ").concat(approvalNew.current_step, " \u5BA1\u6279\u7ED3\u679C\u4E3A: ").concat(currentStepApprovalStatus));
|
|
1065
|
-
if (!(approvalNew.current_step === consts_1.Step.ai_review && currentStepApprovalStatus === consts_1.ApprovalStatus.approved
|
|
1066
|
-
&& approvalNew.materials_uploaded_to_onedrive_status != 'completed')) return [3, 9];
|
|
1067
|
-
return [4, (0, material_1.getPendingUploadsToOneDriveMaterials)(ctx, recordId)];
|
|
1068
|
-
case 5:
|
|
1069
|
-
materials = _a.sent();
|
|
1070
|
-
if (!(materials.length == 0)) return [3, 7];
|
|
1071
|
-
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1072
|
-
materials_uploaded_to_onedrive_status: 'no_materials_to_upload'
|
|
1073
|
-
})];
|
|
1074
|
-
case 6:
|
|
1075
|
-
_a.sent();
|
|
1076
|
-
return [3, 9];
|
|
1077
|
-
case 7: return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1078
|
-
materials_uploaded_to_onedrive_status: 'pending_upload'
|
|
1079
|
-
})];
|
|
1080
|
-
case 8:
|
|
1081
|
-
_a.sent();
|
|
1082
|
-
return [2];
|
|
1083
|
-
case 9: return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: currentStepApprovalStatus })];
|
|
1084
|
-
case 10:
|
|
1085
|
-
_a.sent();
|
|
1086
|
-
return [4, advanceApproval(ctx, recordId, currentStepApprovalStatus)];
|
|
1087
|
-
case 11:
|
|
1088
|
-
_a.sent();
|
|
1089
|
-
return [2];
|
|
1090
|
-
}
|
|
1091
|
-
});
|
|
1092
|
-
});
|
|
1093
|
-
};
|
|
1094
|
-
exports.submitContent = submitContent;
|
|
1095
|
-
var hasReviewed = function (approvalStatus) {
|
|
1096
|
-
if (approvalStatus === true || approvalStatus === false) {
|
|
1097
|
-
return true;
|
|
1098
|
-
}
|
|
1099
|
-
return false;
|
|
1100
|
-
};
|
|
1101
|
-
//# sourceMappingURL=approval_engine.js.map
|