@steedos-labs/content-compliance 0.0.77 → 0.0.78
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/lib/actions/addBulkMaterials.d.ts +15 -0
- package/lib/actions/addBulkMaterials.js +40 -0
- package/lib/actions/addBulkMaterials.js.map +1 -0
- package/lib/actions/confirmDeployment.d.ts +7 -0
- package/lib/actions/confirmDeployment.js +28 -0
- package/lib/actions/confirmDeployment.js.map +1 -0
- package/lib/actions/hasDuplicateMaterials.d.ts +9 -0
- package/lib/actions/hasDuplicateMaterials.js +30 -0
- package/lib/actions/hasDuplicateMaterials.js.map +1 -0
- package/lib/actions/index.d.ts +10 -0
- package/lib/actions/index.js +14 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/actions/postponeDeployment.d.ts +7 -0
- package/lib/actions/postponeDeployment.js +27 -0
- package/lib/actions/postponeDeployment.js.map +1 -0
- package/lib/actions/progress.d.ts +18 -0
- package/lib/actions/progress.js +71 -0
- package/lib/actions/progress.js.map +1 -0
- package/lib/actions/rule.d.ts +7 -0
- package/lib/actions/rule.js +27 -0
- package/lib/actions/rule.js.map +1 -0
- package/lib/actions/submit.d.ts +7 -0
- package/lib/actions/submit.js +28 -0
- package/lib/actions/submit.js.map +1 -0
- package/lib/actions/submitKids.d.ts +7 -0
- package/lib/actions/submitKids.js +27 -0
- package/lib/actions/submitKids.js.map +1 -0
- package/lib/actions/submitMaterial.d.ts +7 -0
- package/lib/actions/submitMaterial.js +27 -0
- package/lib/actions/submitMaterial.js.map +1 -0
- package/lib/actions/terminate.d.ts +7 -0
- package/lib/actions/terminate.js +27 -0
- package/lib/actions/terminate.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +393 -0
- package/lib/index.js.map +1 -0
- package/lib/methods/AI.d.ts +1 -0
- package/lib/methods/AI.js +39 -0
- package/lib/methods/AI.js.map +1 -0
- package/lib/methods/approval_engine.d.ts +18 -0
- package/lib/methods/approval_engine.js +1164 -0
- package/lib/methods/approval_engine.js.map +1 -0
- package/lib/methods/consts.d.ts +148 -0
- package/lib/methods/consts.js +40 -0
- package/lib/methods/consts.js.map +1 -0
- package/lib/methods/content_hub.d.ts +1 -0
- package/lib/methods/content_hub.js +194 -0
- package/lib/methods/content_hub.js.map +1 -0
- package/lib/methods/docx.d.ts +3 -0
- package/lib/methods/docx.js +12 -0
- package/lib/methods/docx.js.map +1 -0
- package/lib/methods/index.d.ts +2 -0
- package/lib/methods/index.js +6 -0
- package/lib/methods/index.js.map +1 -0
- package/lib/methods/material.d.ts +14 -0
- package/lib/methods/material.js +564 -0
- package/lib/methods/material.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1164 @@
|
|
|
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.material_owner_id],
|
|
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 advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
569
|
+
var actionLabel, user, record, nextStep, nextApprovers, nextApproversUserIds_1, nextApprovers_3, nextApprovers_3_1, nextApprover, e_7_1, error_3;
|
|
570
|
+
var e_7, _a;
|
|
571
|
+
return tslib_1.__generator(this, function (_b) {
|
|
572
|
+
switch (_b.label) {
|
|
573
|
+
case 0:
|
|
574
|
+
_b.trys.push([0, 41, , 42]);
|
|
575
|
+
actionLabel = '请查看';
|
|
576
|
+
user = ctx.meta.user;
|
|
577
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
578
|
+
case 1:
|
|
579
|
+
record = _b.sent();
|
|
580
|
+
console.log('[advanceApproval]', record.current_step, record.person_pending_approve, user.userId);
|
|
581
|
+
if (record.current_step != consts_1.Step.draft && !(0, lodash_1.includes)(record.person_pending_approve, user.userId)) {
|
|
582
|
+
return [2, {}];
|
|
583
|
+
}
|
|
584
|
+
return [4, canSubmit(record)];
|
|
585
|
+
case 2:
|
|
586
|
+
_b.sent();
|
|
587
|
+
return [4, getNextStep(ctx, record, currentStepApprovalStatus)];
|
|
588
|
+
case 3:
|
|
589
|
+
nextStep = _b.sent();
|
|
590
|
+
return [4, getNextApprovers(ctx, record, nextStep)];
|
|
591
|
+
case 4:
|
|
592
|
+
nextApprovers = _b.sent();
|
|
593
|
+
console.log("[advanceApproval] currentStepApprovalStatus:", currentStepApprovalStatus, " nextStep:", nextStep, " nextApprovers:", nextApprovers);
|
|
594
|
+
nextApproversUserIds_1 = [];
|
|
595
|
+
(0, lodash_1.map)(nextApprovers, function (item) {
|
|
596
|
+
nextApproversUserIds_1 = (0, lodash_1.concat)(nextApproversUserIds_1, item.userIds);
|
|
597
|
+
});
|
|
598
|
+
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
599
|
+
current_step: nextStep,
|
|
600
|
+
review_status: getReviewStatus(nextStep),
|
|
601
|
+
person_pending_approve: nextApproversUserIds_1,
|
|
602
|
+
$push: {
|
|
603
|
+
person_approved: {
|
|
604
|
+
$each: record.person_pending_approve
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
})];
|
|
608
|
+
case 5:
|
|
609
|
+
_b.sent();
|
|
610
|
+
return [4, changeApprovalProcess(ctx, record, {
|
|
611
|
+
nextStep: nextStep,
|
|
612
|
+
nextApprovers: nextApprovers,
|
|
613
|
+
description: ""
|
|
614
|
+
})];
|
|
615
|
+
case 6:
|
|
616
|
+
_b.sent();
|
|
617
|
+
if (!(nextStep === consts_1.Step.ai_review)) return [3, 8];
|
|
618
|
+
return [4, (0, AI_1.callAIReview)(ctx, recordId)];
|
|
619
|
+
case 7:
|
|
620
|
+
_b.sent();
|
|
621
|
+
_b.label = 8;
|
|
622
|
+
case 8:
|
|
623
|
+
_b.trys.push([8, 29, 30, 31]);
|
|
624
|
+
nextApprovers_3 = tslib_1.__values(nextApprovers), nextApprovers_3_1 = nextApprovers_3.next();
|
|
625
|
+
_b.label = 9;
|
|
626
|
+
case 9:
|
|
627
|
+
if (!!nextApprovers_3_1.done) return [3, 28];
|
|
628
|
+
nextApprover = nextApprovers_3_1.value;
|
|
629
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.CA)) return [3, 12];
|
|
630
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
631
|
+
ca_approval_status: ''
|
|
632
|
+
})];
|
|
633
|
+
case 10:
|
|
634
|
+
_b.sent();
|
|
635
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ca_approval_status', '=', false]], {
|
|
636
|
+
ca_approval_status: ''
|
|
637
|
+
})];
|
|
638
|
+
case 11:
|
|
639
|
+
_b.sent();
|
|
640
|
+
_b.label = 12;
|
|
641
|
+
case 12:
|
|
642
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.Legal)) return [3, 15];
|
|
643
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
644
|
+
legal_approval_status: ''
|
|
645
|
+
})];
|
|
646
|
+
case 13:
|
|
647
|
+
_b.sent();
|
|
648
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['legal_approval_status', '=', false]], {
|
|
649
|
+
legal_approval_status: ''
|
|
650
|
+
})];
|
|
651
|
+
case 14:
|
|
652
|
+
_b.sent();
|
|
653
|
+
_b.label = 15;
|
|
654
|
+
case 15:
|
|
655
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.NS)) return [3, 18];
|
|
656
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
657
|
+
ns_approval_status: ''
|
|
658
|
+
})];
|
|
659
|
+
case 16:
|
|
660
|
+
_b.sent();
|
|
661
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ns_approval_status', '=', false]], {
|
|
662
|
+
ns_approval_status: ''
|
|
663
|
+
})];
|
|
664
|
+
case 17:
|
|
665
|
+
_b.sent();
|
|
666
|
+
_b.label = 18;
|
|
667
|
+
case 18:
|
|
668
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.SRA)) return [3, 21];
|
|
669
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
670
|
+
sra_approval_status: ''
|
|
671
|
+
})];
|
|
672
|
+
case 19:
|
|
673
|
+
_b.sent();
|
|
674
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['sra_approval_status', '=', false]], {
|
|
675
|
+
sra_approval_status: ''
|
|
676
|
+
})];
|
|
677
|
+
case 20:
|
|
678
|
+
_b.sent();
|
|
679
|
+
_b.label = 21;
|
|
680
|
+
case 21:
|
|
681
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.guding)) return [3, 24];
|
|
682
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
683
|
+
approval_status: ''
|
|
684
|
+
})];
|
|
685
|
+
case 22:
|
|
686
|
+
_b.sent();
|
|
687
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['approval_status', '=', false]], {
|
|
688
|
+
approval_status: ''
|
|
689
|
+
})];
|
|
690
|
+
case 23:
|
|
691
|
+
_b.sent();
|
|
692
|
+
_b.label = 24;
|
|
693
|
+
case 24:
|
|
694
|
+
if (!(nextApprover.type === consts_1.ProcessApprovalType.Kids)) return [3, 27];
|
|
695
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
696
|
+
kids_approval_status: ''
|
|
697
|
+
})];
|
|
698
|
+
case 25:
|
|
699
|
+
_b.sent();
|
|
700
|
+
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['kids_approval_status', '=', false]], {
|
|
701
|
+
kids_approval_status: ''
|
|
702
|
+
})];
|
|
703
|
+
case 26:
|
|
704
|
+
_b.sent();
|
|
705
|
+
_b.label = 27;
|
|
706
|
+
case 27:
|
|
707
|
+
nextApprovers_3_1 = nextApprovers_3.next();
|
|
708
|
+
return [3, 9];
|
|
709
|
+
case 28: return [3, 31];
|
|
710
|
+
case 29:
|
|
711
|
+
e_7_1 = _b.sent();
|
|
712
|
+
e_7 = { error: e_7_1 };
|
|
713
|
+
return [3, 31];
|
|
714
|
+
case 30:
|
|
715
|
+
try {
|
|
716
|
+
if (nextApprovers_3_1 && !nextApprovers_3_1.done && (_a = nextApprovers_3.return)) _a.call(nextApprovers_3);
|
|
717
|
+
}
|
|
718
|
+
finally { if (e_7) throw e_7.error; }
|
|
719
|
+
return [7];
|
|
720
|
+
case 31:
|
|
721
|
+
if (!(nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) return [3, 33];
|
|
722
|
+
return [4, setPersonView(ctx, record)];
|
|
723
|
+
case 32:
|
|
724
|
+
_b.sent();
|
|
725
|
+
_b.label = 33;
|
|
726
|
+
case 33:
|
|
727
|
+
if (!(record.current_step === consts_1.Step.departmental_review || record.current_step === consts_1.Step.personnel_review)) return [3, 35];
|
|
728
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
729
|
+
materials_remove_share_link_from_onedrive_status: 'pending'
|
|
730
|
+
})];
|
|
731
|
+
case 34:
|
|
732
|
+
_b.sent();
|
|
733
|
+
_b.label = 35;
|
|
734
|
+
case 35:
|
|
735
|
+
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 37];
|
|
736
|
+
return [4, pendingDeployment(ctx, recordId)];
|
|
737
|
+
case 36:
|
|
738
|
+
_b.sent();
|
|
739
|
+
_b.label = 37;
|
|
740
|
+
case 37:
|
|
741
|
+
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 39];
|
|
742
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
743
|
+
materials_download_from_onedrive_status: 'pending'
|
|
744
|
+
})];
|
|
745
|
+
case 38:
|
|
746
|
+
_b.sent();
|
|
747
|
+
_b.label = 39;
|
|
748
|
+
case 39:
|
|
749
|
+
if (currentStepApprovalStatus === consts_1.ApprovalStatus.rejected) {
|
|
750
|
+
actionLabel = '内容审批被驳回';
|
|
751
|
+
}
|
|
752
|
+
if (currentStepApprovalStatus === consts_1.ApprovalStatus.approved
|
|
753
|
+
&& (nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) {
|
|
754
|
+
actionLabel = '请审批';
|
|
755
|
+
}
|
|
756
|
+
if (nextStep === consts_1.Step.awaiting_deployment) {
|
|
757
|
+
actionLabel = "\u5185\u5BB9\u5BA1\u6279\u5DF2\u901A\u8FC7\u5F85\u4E0A\u7EBF";
|
|
758
|
+
}
|
|
759
|
+
return [4, sendNotifications(ctx, record, nextApproversUserIds_1, actionLabel)];
|
|
760
|
+
case 40:
|
|
761
|
+
_b.sent();
|
|
762
|
+
return [2, {}];
|
|
763
|
+
case 41:
|
|
764
|
+
error_3 = _b.sent();
|
|
765
|
+
return [2, {
|
|
766
|
+
msg: error_3.message,
|
|
767
|
+
status: 500
|
|
768
|
+
}];
|
|
769
|
+
case 42: return [2];
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
}); };
|
|
773
|
+
var terminate = function (ctx, recordId, description) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
774
|
+
var user, record;
|
|
775
|
+
return tslib_1.__generator(this, function (_a) {
|
|
776
|
+
switch (_a.label) {
|
|
777
|
+
case 0:
|
|
778
|
+
user = ctx.meta.user;
|
|
779
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
780
|
+
case 1:
|
|
781
|
+
record = _a.sent();
|
|
782
|
+
if (!(record.owner === user.userId || user.is_space_admin)) return [3, 4];
|
|
783
|
+
return [4, ctx.getObject('pepsico_approval_process').insert({
|
|
784
|
+
pepsico_material_approval: record._id,
|
|
785
|
+
current_step: consts_1.Step.conclusion,
|
|
786
|
+
space: record.space,
|
|
787
|
+
created: new Date(),
|
|
788
|
+
created_by: user.userId,
|
|
789
|
+
modified: new Date(),
|
|
790
|
+
modified_by: user.userId,
|
|
791
|
+
approvalStatus: 'terminate',
|
|
792
|
+
name: description
|
|
793
|
+
})];
|
|
794
|
+
case 2:
|
|
795
|
+
_a.sent();
|
|
796
|
+
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
797
|
+
current_step: consts_1.Step.conclusion,
|
|
798
|
+
review_status: consts_1.ReviewStatus.terminated
|
|
799
|
+
})];
|
|
800
|
+
case 3:
|
|
801
|
+
_a.sent();
|
|
802
|
+
return [2, {}];
|
|
803
|
+
case 4: throw new Error('Sorry, you don’t have permission to terminate the review.');
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
}); };
|
|
807
|
+
exports.terminate = terminate;
|
|
808
|
+
var pendingDeployment = function (ctx, recordId) {
|
|
809
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
810
|
+
return tslib_1.__generator(this, function (_a) {
|
|
811
|
+
switch (_a.label) {
|
|
812
|
+
case 0: return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
813
|
+
launch: 'pending'
|
|
814
|
+
})];
|
|
815
|
+
case 1:
|
|
816
|
+
_a.sent();
|
|
817
|
+
return [2];
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
};
|
|
822
|
+
var confirmDeployment = function (ctx, recordId, data) {
|
|
823
|
+
if (data === void 0) { data = {
|
|
824
|
+
content_rule: null
|
|
825
|
+
}; }
|
|
826
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
827
|
+
var user, record;
|
|
828
|
+
return tslib_1.__generator(this, function (_a) {
|
|
829
|
+
switch (_a.label) {
|
|
830
|
+
case 0:
|
|
831
|
+
user = ctx.meta.user;
|
|
832
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
833
|
+
case 1:
|
|
834
|
+
record = _a.sent();
|
|
835
|
+
if (user.userId !== record.material_owner_id) {
|
|
836
|
+
throw new Error('只有材料拥有者才能执行此操作.');
|
|
837
|
+
}
|
|
838
|
+
return [4, updateUserStepStatus(ctx, record, { approvalStatus: consts_1.ApprovalStatus.submit })];
|
|
839
|
+
case 2:
|
|
840
|
+
_a.sent();
|
|
841
|
+
if (!(record.current_step === consts_1.Step.awaiting_deployment && (0, lodash_1.includes)(record.person_pending_approve, user.userId))) return [3, 6];
|
|
842
|
+
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
843
|
+
launch: 'launched',
|
|
844
|
+
content_rule: data.content_rule,
|
|
845
|
+
aunch_time: new Date()
|
|
846
|
+
})];
|
|
847
|
+
case 3:
|
|
848
|
+
_a.sent();
|
|
849
|
+
return [4, advanceApproval(ctx, recordId, consts_1.ApprovalStatus.submit)];
|
|
850
|
+
case 4:
|
|
851
|
+
_a.sent();
|
|
852
|
+
return [4, (0, content_hub_1.inventoryApprovalMaterial)(ctx, recordId)];
|
|
853
|
+
case 5:
|
|
854
|
+
_a.sent();
|
|
855
|
+
_a.label = 6;
|
|
856
|
+
case 6: return [2, {}];
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
};
|
|
861
|
+
exports.confirmDeployment = confirmDeployment;
|
|
862
|
+
var postponeDeployment = function (ctx, recordId, data) {
|
|
863
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
864
|
+
var user, record;
|
|
865
|
+
return tslib_1.__generator(this, function (_a) {
|
|
866
|
+
switch (_a.label) {
|
|
867
|
+
case 0:
|
|
868
|
+
user = ctx.meta.user;
|
|
869
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
870
|
+
case 1:
|
|
871
|
+
record = _a.sent();
|
|
872
|
+
if (user.userId !== record.material_owner_id) {
|
|
873
|
+
throw new Error('只有材料拥有者才能执行此操作.');
|
|
874
|
+
}
|
|
875
|
+
if (!(record.current_step === consts_1.Step.awaiting_deployment && (0, lodash_1.includes)(record.person_pending_approve, user.userId))) return [3, 3];
|
|
876
|
+
return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
877
|
+
launch: 'postpone',
|
|
878
|
+
postpone_launch_date: data.postpone_launch_date
|
|
879
|
+
})];
|
|
880
|
+
case 2:
|
|
881
|
+
_a.sent();
|
|
882
|
+
_a.label = 3;
|
|
883
|
+
case 3: return [2, {}];
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
};
|
|
888
|
+
exports.postponeDeployment = postponeDeployment;
|
|
889
|
+
var approvalContent = function (ctx, recordId, _a) {
|
|
890
|
+
var approveField = _a.approveField;
|
|
891
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
892
|
+
var approvalNew, currentStepApprovalStatus;
|
|
893
|
+
return tslib_1.__generator(this, function (_b) {
|
|
894
|
+
switch (_b.label) {
|
|
895
|
+
case 0: return [4, updateApproveFieldStatus(ctx, recordId, approveField, true)];
|
|
896
|
+
case 1:
|
|
897
|
+
_b.sent();
|
|
898
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
899
|
+
case 2:
|
|
900
|
+
approvalNew = _b.sent();
|
|
901
|
+
return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: consts_1.ApprovalStatus.approved })];
|
|
902
|
+
case 3:
|
|
903
|
+
_b.sent();
|
|
904
|
+
currentStepApprovalStatus = consts_1.ApprovalStatus.approved;
|
|
905
|
+
if (approvalNew.current_step === consts_1.Step.departmental_review) {
|
|
906
|
+
if (!hasReviewed(approvalNew.ca_approval_status) || !hasReviewed(approvalNew.ns_approval_status) || !hasReviewed(approvalNew.legal_approval_status) || !hasReviewed(approvalNew.sra_approval_status)) {
|
|
907
|
+
console.log('[approvalContent]: 有其他部门未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
908
|
+
return [2, {}];
|
|
909
|
+
}
|
|
910
|
+
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;
|
|
911
|
+
console.log('[approvalContent]: 部门复审完成, 结果为:', currentStepApprovalStatus);
|
|
912
|
+
}
|
|
913
|
+
else if (approvalNew.current_step === consts_1.Step.personnel_review) {
|
|
914
|
+
if (!hasReviewed(approvalNew.approval_status)) {
|
|
915
|
+
console.log('[approvalContent]: 固定人员未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
916
|
+
return [2, {}];
|
|
917
|
+
}
|
|
918
|
+
currentStepApprovalStatus = approvalNew.approval_status ? consts_1.ApprovalStatus.approved : consts_1.ApprovalStatus.rejected;
|
|
919
|
+
console.log('[approvalContent]: 固定人员复审完成, 结果为:', currentStepApprovalStatus);
|
|
920
|
+
}
|
|
921
|
+
if (approvalNew.child_files == 'yes') {
|
|
922
|
+
if (!hasReviewed(approvalNew.kids_approval_status)) {
|
|
923
|
+
console.log('[approvalContent]: kids审核人未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
924
|
+
return [2, {}];
|
|
925
|
+
}
|
|
926
|
+
if (approvalNew.kids_approval_status == false) {
|
|
927
|
+
currentStepApprovalStatus = consts_1.ApprovalStatus.rejected;
|
|
928
|
+
}
|
|
929
|
+
console.log('[approvalContent]: kids审核完成, 结果为:', currentStepApprovalStatus);
|
|
930
|
+
}
|
|
931
|
+
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));
|
|
932
|
+
return [4, advanceApproval(ctx, recordId, currentStepApprovalStatus)];
|
|
933
|
+
case 4:
|
|
934
|
+
_b.sent();
|
|
935
|
+
return [2, {}];
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
});
|
|
939
|
+
};
|
|
940
|
+
exports.approvalContent = approvalContent;
|
|
941
|
+
var rejectContent = function (ctx, recordId, _a) {
|
|
942
|
+
var approveField = _a.approveField;
|
|
943
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
944
|
+
var user, approvalNew, currentStepApprovalStatus;
|
|
945
|
+
return tslib_1.__generator(this, function (_b) {
|
|
946
|
+
switch (_b.label) {
|
|
947
|
+
case 0:
|
|
948
|
+
user = ctx.meta.user;
|
|
949
|
+
return [4, updateApproveFieldStatus(ctx, recordId, approveField, false)];
|
|
950
|
+
case 1:
|
|
951
|
+
_b.sent();
|
|
952
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
953
|
+
case 2:
|
|
954
|
+
approvalNew = _b.sent();
|
|
955
|
+
currentStepApprovalStatus = consts_1.ApprovalStatus.rejected;
|
|
956
|
+
return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: consts_1.ApprovalStatus.rejected })];
|
|
957
|
+
case 3:
|
|
958
|
+
_b.sent();
|
|
959
|
+
if (approvalNew.current_step === consts_1.Step.departmental_review) {
|
|
960
|
+
if (!hasReviewed(approvalNew.ca_approval_status) || !hasReviewed(approvalNew.ns_approval_status) || !hasReviewed(approvalNew.legal_approval_status) || !hasReviewed(approvalNew.sra_approval_status)) {
|
|
961
|
+
console.log('[rejectContent]: 有其他部门未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
962
|
+
return [2, {}];
|
|
963
|
+
}
|
|
964
|
+
console.log('[rejectContent]: 部门复审完成');
|
|
965
|
+
}
|
|
966
|
+
else if (approvalNew.current_step === consts_1.Step.personnel_review) {
|
|
967
|
+
if (!hasReviewed(approvalNew.approval_status)) {
|
|
968
|
+
console.log('[rejectContent]: 固定人员未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
969
|
+
return [2, {}];
|
|
970
|
+
}
|
|
971
|
+
console.log('[rejectContent]: 固定人员复审完成');
|
|
972
|
+
}
|
|
973
|
+
if (approvalNew.child_files == 'yes') {
|
|
974
|
+
if (!hasReviewed(approvalNew.kids_approval_status)) {
|
|
975
|
+
console.log('[rejectContent]: kids审核人未审批, 只结束当前用户审批任务,不推进审批进度.');
|
|
976
|
+
return [2, {}];
|
|
977
|
+
}
|
|
978
|
+
console.log('[rejectContent]: kids审核完成');
|
|
979
|
+
}
|
|
980
|
+
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));
|
|
981
|
+
return [4, advanceApproval(ctx, recordId, currentStepApprovalStatus)];
|
|
982
|
+
case 4:
|
|
983
|
+
_b.sent();
|
|
984
|
+
return [2, {}];
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
};
|
|
989
|
+
exports.rejectContent = rejectContent;
|
|
990
|
+
var submitKidsContent = function (ctx, recordId, currentStepApprovalStatus) {
|
|
991
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
992
|
+
var approveField;
|
|
993
|
+
return tslib_1.__generator(this, function (_a) {
|
|
994
|
+
switch (_a.label) {
|
|
995
|
+
case 0:
|
|
996
|
+
if (currentStepApprovalStatus != consts_1.ApprovalStatus.approved && currentStepApprovalStatus != consts_1.ApprovalStatus.rejected) {
|
|
997
|
+
throw new Error('无效的审核状态.');
|
|
998
|
+
}
|
|
999
|
+
approveField = "kids_approval_status";
|
|
1000
|
+
if (!(currentStepApprovalStatus === consts_1.ApprovalStatus.approved)) return [3, 2];
|
|
1001
|
+
return [4, (0, exports.approvalContent)(ctx, recordId, { approveField: approveField })];
|
|
1002
|
+
case 1:
|
|
1003
|
+
_a.sent();
|
|
1004
|
+
return [3, 4];
|
|
1005
|
+
case 2: return [4, (0, exports.rejectContent)(ctx, recordId, { approveField: approveField })];
|
|
1006
|
+
case 3:
|
|
1007
|
+
_a.sent();
|
|
1008
|
+
_a.label = 4;
|
|
1009
|
+
case 4: return [2];
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
});
|
|
1013
|
+
};
|
|
1014
|
+
exports.submitKidsContent = submitKidsContent;
|
|
1015
|
+
var submitContent = function (ctx, recordId, currentStepApprovalStatus) {
|
|
1016
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1017
|
+
var approvalNew, approvalType, allTrue, spaceUsers, owner, materials, materials_1, materials_1_1, material, e_8_1, pendingXmlToWordMaterials, pendingUploadMaterials;
|
|
1018
|
+
var e_8, _a;
|
|
1019
|
+
return tslib_1.__generator(this, function (_b) {
|
|
1020
|
+
switch (_b.label) {
|
|
1021
|
+
case 0: return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
1022
|
+
case 1:
|
|
1023
|
+
approvalNew = _b.sent();
|
|
1024
|
+
if (!(approvalNew.current_step === consts_1.Step.draft)) return [3, 8];
|
|
1025
|
+
return [4, getApproverStep(ctx, approvalNew)];
|
|
1026
|
+
case 2:
|
|
1027
|
+
approvalType = _b.sent();
|
|
1028
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1029
|
+
approval_type: approvalType
|
|
1030
|
+
})];
|
|
1031
|
+
case 3:
|
|
1032
|
+
_b.sent();
|
|
1033
|
+
return [4, (0, material_1.deleteBulkDocOneDriveShareLink)(ctx, recordId)];
|
|
1034
|
+
case 4:
|
|
1035
|
+
_b.sent();
|
|
1036
|
+
return [4, (0, material_1.downloadBulkFromOneDriveDoc)(ctx, recordId)];
|
|
1037
|
+
case 5:
|
|
1038
|
+
allTrue = _b.sent();
|
|
1039
|
+
if (allTrue != true) {
|
|
1040
|
+
return [2, {
|
|
1041
|
+
status: 500,
|
|
1042
|
+
msg: '更新素材失败, 请稍后重试',
|
|
1043
|
+
data: {}
|
|
1044
|
+
}];
|
|
1045
|
+
}
|
|
1046
|
+
if (!(approvalNew && approvalNew.material_owner)) return [3, 8];
|
|
1047
|
+
return [4, ctx.getObject('space_users').find({
|
|
1048
|
+
filters: [['email', '=', approvalNew.material_owner], ['space', '=', approvalNew.space]]
|
|
1049
|
+
})];
|
|
1050
|
+
case 6:
|
|
1051
|
+
spaceUsers = _b.sent();
|
|
1052
|
+
if (!(spaceUsers && spaceUsers.length > 0)) return [3, 8];
|
|
1053
|
+
owner = spaceUsers[0];
|
|
1054
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1055
|
+
material_owner_id: owner.user
|
|
1056
|
+
})];
|
|
1057
|
+
case 7:
|
|
1058
|
+
_b.sent();
|
|
1059
|
+
_b.label = 8;
|
|
1060
|
+
case 8:
|
|
1061
|
+
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));
|
|
1062
|
+
if (!(approvalNew.current_step === consts_1.Step.ai_review && currentStepApprovalStatus === consts_1.ApprovalStatus.approved)) return [3, 26];
|
|
1063
|
+
return [4, (0, material_1.getOneDriveMaterials)(ctx, recordId)];
|
|
1064
|
+
case 9:
|
|
1065
|
+
materials = _b.sent();
|
|
1066
|
+
if (!(approvalNew.materials_xml_to_word_status != 'completed')) return [3, 20];
|
|
1067
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1068
|
+
materials_download_from_onedrive_failed_count: 0,
|
|
1069
|
+
materials_download_from_onedrive_status: 'not_started',
|
|
1070
|
+
materials_remove_share_link_from_onedrive_failed_count: 0,
|
|
1071
|
+
materials_remove_share_link_from_onedrive_status: 'not_started',
|
|
1072
|
+
materials_uploaded_to_onedrive_failed_count: 0,
|
|
1073
|
+
materials_uploaded_to_onedrive_status: 'not_started'
|
|
1074
|
+
})];
|
|
1075
|
+
case 10:
|
|
1076
|
+
_b.sent();
|
|
1077
|
+
_b.label = 11;
|
|
1078
|
+
case 11:
|
|
1079
|
+
_b.trys.push([11, 16, 17, 18]);
|
|
1080
|
+
materials_1 = tslib_1.__values(materials), materials_1_1 = materials_1.next();
|
|
1081
|
+
_b.label = 12;
|
|
1082
|
+
case 12:
|
|
1083
|
+
if (!!materials_1_1.done) return [3, 15];
|
|
1084
|
+
material = materials_1_1.value;
|
|
1085
|
+
return [4, ctx.getObject('pepsico_material').directUpdate(material._id, {
|
|
1086
|
+
uploaded_to_onedrive: false,
|
|
1087
|
+
download_from_onedrive: false,
|
|
1088
|
+
remove_share_link_from_onedrive: false
|
|
1089
|
+
})];
|
|
1090
|
+
case 13:
|
|
1091
|
+
_b.sent();
|
|
1092
|
+
_b.label = 14;
|
|
1093
|
+
case 14:
|
|
1094
|
+
materials_1_1 = materials_1.next();
|
|
1095
|
+
return [3, 12];
|
|
1096
|
+
case 15: return [3, 18];
|
|
1097
|
+
case 16:
|
|
1098
|
+
e_8_1 = _b.sent();
|
|
1099
|
+
e_8 = { error: e_8_1 };
|
|
1100
|
+
return [3, 18];
|
|
1101
|
+
case 17:
|
|
1102
|
+
try {
|
|
1103
|
+
if (materials_1_1 && !materials_1_1.done && (_a = materials_1.return)) _a.call(materials_1);
|
|
1104
|
+
}
|
|
1105
|
+
finally { if (e_8) throw e_8.error; }
|
|
1106
|
+
return [7];
|
|
1107
|
+
case 18: return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
1108
|
+
case 19:
|
|
1109
|
+
approvalNew = _b.sent();
|
|
1110
|
+
_b.label = 20;
|
|
1111
|
+
case 20:
|
|
1112
|
+
if (!(approvalNew.materials_uploaded_to_onedrive_status != 'completed')) return [3, 26];
|
|
1113
|
+
console.log('materials:', materials.length);
|
|
1114
|
+
if (!(materials.length === 0)) return [3, 22];
|
|
1115
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1116
|
+
materials_uploaded_to_onedrive_status: 'no_materials',
|
|
1117
|
+
materials_xml_to_word_status: 'no_materials'
|
|
1118
|
+
})];
|
|
1119
|
+
case 21:
|
|
1120
|
+
_b.sent();
|
|
1121
|
+
return [3, 26];
|
|
1122
|
+
case 22:
|
|
1123
|
+
pendingXmlToWordMaterials = materials.filter(function (material) {
|
|
1124
|
+
return material.xml_converted_word !== true;
|
|
1125
|
+
});
|
|
1126
|
+
console.log('pendingXmlToWordMaterials:', pendingXmlToWordMaterials.length);
|
|
1127
|
+
if (!(pendingXmlToWordMaterials.length > 0)) return [3, 24];
|
|
1128
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1129
|
+
materials_xml_to_word_status: 'pending'
|
|
1130
|
+
})];
|
|
1131
|
+
case 23:
|
|
1132
|
+
_b.sent();
|
|
1133
|
+
return [2];
|
|
1134
|
+
case 24:
|
|
1135
|
+
pendingUploadMaterials = materials.filter(function (material) {
|
|
1136
|
+
return material.uploaded_to_onedrive !== true;
|
|
1137
|
+
});
|
|
1138
|
+
console.log('pendingUploadMaterials:', pendingUploadMaterials.length);
|
|
1139
|
+
if (!(pendingUploadMaterials.length > 0)) return [3, 26];
|
|
1140
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(approvalNew._id, {
|
|
1141
|
+
materials_uploaded_to_onedrive_status: 'pending'
|
|
1142
|
+
})];
|
|
1143
|
+
case 25:
|
|
1144
|
+
_b.sent();
|
|
1145
|
+
return [2];
|
|
1146
|
+
case 26: return [4, updateUserStepStatus(ctx, approvalNew, { approvalStatus: currentStepApprovalStatus })];
|
|
1147
|
+
case 27:
|
|
1148
|
+
_b.sent();
|
|
1149
|
+
return [4, advanceApproval(ctx, recordId, currentStepApprovalStatus)];
|
|
1150
|
+
case 28:
|
|
1151
|
+
_b.sent();
|
|
1152
|
+
return [2];
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
};
|
|
1157
|
+
exports.submitContent = submitContent;
|
|
1158
|
+
var hasReviewed = function (approvalStatus) {
|
|
1159
|
+
if (approvalStatus === true || approvalStatus === false) {
|
|
1160
|
+
return true;
|
|
1161
|
+
}
|
|
1162
|
+
return false;
|
|
1163
|
+
};
|
|
1164
|
+
//# sourceMappingURL=approval_engine.js.map
|