@steedos-labs/content-compliance 0.7.2 → 0.7.4
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/index.d.ts +2 -0
- package/lib/actions/index.js +2 -0
- package/lib/actions/index.js.map +1 -1
- package/lib/actions/postponeReview.d.ts +7 -0
- package/lib/actions/postponeReview.js +30 -0
- package/lib/actions/postponeReview.js.map +1 -0
- package/lib/actions/urgentApproval.d.ts +14 -0
- package/lib/actions/urgentApproval.js +51 -0
- package/lib/actions/urgentApproval.js.map +1 -0
- package/lib/index.js +100 -52
- package/lib/index.js.map +1 -1
- package/lib/methods/approval_engine.d.ts +1 -0
- package/lib/methods/approval_engine.js +363 -100
- package/lib/methods/approval_engine.js.map +1 -1
- package/lib/methods/consts.d.ts +4 -0
- package/lib/methods/consts.js.map +1 -1
- package/lib/methods/index.d.ts +1 -0
- package/lib/methods/index.js +1 -0
- package/lib/methods/index.js.map +1 -1
- package/lib/methods/notification.d.ts +1 -0
- package/lib/methods/notification.js +109 -6
- package/lib/methods/notification.js.map +1 -1
- package/lib/methods/urgent.d.ts +19 -0
- package/lib/methods/urgent.js +253 -0
- package/lib/methods/urgent.js.map +1 -0
- package/main/default/applications/pepsico_content_review.app.yml +24 -102
- package/main/default/objects/pepsico_approval_process/fields/approved.field.yml +3 -0
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_postpone_review.button.yml +145 -0
- package/main/default/objects/pepsico_material_approval/buttons/pepsico_urgent_review.button.yml +156 -0
- package/main/default/objects/pepsico_material_approval/fields/is_urgent.field.yml +9 -0
- package/main/default/objects/pepsico_material_approval/fields/review_postponed_users.field.yml +15 -0
- package/main/default/objects/pepsico_material_approval/fields/urgent_at.field.yml +8 -0
- package/main/default/objects/pepsico_material_approval/fields/urgent_name_tag.field.yml +8 -0
- package/main/default/objects/pepsico_material_approval/fields/urgent_times.field.yml +9 -0
- package/main/default/objects/pepsico_material_approval/listviews/all.listview.yml +4 -0
- package/main/default/objects/pepsico_material_approval/listviews/collaboration.listview.yml +4 -0
- package/main/default/objects/pepsico_material_approval/listviews/handle.listview.yml +8 -0
- package/main/default/objects/pepsico_material_approval/listviews/handle_postpone.listview.yml +89 -0
- package/main/default/objects/pepsico_review_postpone/fields/department_type.field.yml +29 -0
- package/main/default/objects/pepsico_review_postpone/fields/is_marker.field.yml +7 -0
- package/main/default/objects/pepsico_review_postpone/fields/notification_sent.field.yml +6 -0
- package/main/default/objects/pepsico_review_postpone/fields/pepsico_material_approval.field.yml +10 -0
- package/main/default/objects/pepsico_review_postpone/fields/postpone_by.field.yml +7 -0
- package/main/default/objects/pepsico_review_postpone/fields/postpone_date.field.yml +6 -0
- package/main/default/objects/pepsico_review_postpone/fields/postpone_reason.field.yml +6 -0
- package/main/default/objects/pepsico_review_postpone/fields/postponed_user_ids.field.yml +6 -0
- package/main/default/objects/pepsico_review_postpone/fields/visible_after.field.yml +6 -0
- package/main/default/objects/pepsico_review_postpone/listviews/all.listview.yml +21 -0
- package/main/default/objects/pepsico_review_postpone/listviews/mine.listview.yml +16 -0
- package/main/default/objects/pepsico_review_postpone/pepsico_review_postpone.object.yml +16 -0
- package/main/default/objects/pepsico_review_postpone/permissions/admin.permission.yml +9 -0
- package/main/default/objects/pepsico_review_postpone/permissions/pepsico_submit.permission.yml +10 -0
- package/main/default/objects/pepsico_review_postpone/permissions/user.permission.yml +9 -0
- package/main/default/objects/pepsico_urgent_log/fields/approval.field.yml +7 -0
- package/main/default/objects/pepsico_urgent_log/fields/approval_name.field.yml +6 -0
- package/main/default/objects/pepsico_urgent_log/fields/half.field.yml +7 -0
- package/main/default/objects/pepsico_urgent_log/fields/operator.field.yml +7 -0
- package/main/default/objects/pepsico_urgent_log/fields/space.field.yml +6 -0
- package/main/default/objects/pepsico_urgent_log/fields/year.field.yml +6 -0
- package/main/default/objects/pepsico_urgent_log/pepsico_urgent_log.object.yml +16 -0
- package/main/default/objects/pepsico_urgent_quota/fields/h1_used.field.yml +7 -0
- package/main/default/objects/pepsico_urgent_quota/fields/h2_used.field.yml +7 -0
- package/main/default/objects/pepsico_urgent_quota/fields/space.field.yml +6 -0
- package/main/default/objects/pepsico_urgent_quota/fields/user.field.yml +7 -0
- package/main/default/objects/pepsico_urgent_quota/fields/year.field.yml +6 -0
- package/main/default/objects/pepsico_urgent_quota/pepsico_urgent_quota.object.yml +16 -0
- package/main/default/pages/pepsico_content_review_detail.page.amis.json +14 -6
- package/main/default/restrictionRules/pepsico_material_approval.restrictionRule.yml +1 -1
- package/main/default/tabs/object_pepsico_urgent_log.tab.yml +14 -0
- package/main/default/tabs/object_pepsico_urgent_quota.tab.yml +14 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasReviewed = exports.submitContent = exports.submitPreReviewContent = exports.submitKidsContent = exports.rejectContent = exports.approvalContent = exports.postponeDeployment = exports.confirmDeployment = exports.terminate = exports.advanceApproval = exports.hasNonPreReviewDepartments = exports.getPreReviewStatuses = exports.getDeptEffectiveStatus = exports.isDeptReviewComplete = exports.hasAnyPreReviewer = exports.getApproverStepRule = exports.getDefApproverStepRule = void 0;
|
|
4
|
+
exports.postponeReview = exports.hasReviewed = exports.submitContent = exports.submitPreReviewContent = exports.submitKidsContent = exports.rejectContent = exports.approvalContent = exports.postponeDeployment = exports.confirmDeployment = exports.terminate = exports.advanceApproval = exports.hasNonPreReviewDepartments = exports.getPreReviewStatuses = exports.getDeptEffectiveStatus = exports.isDeptReviewComplete = exports.hasAnyPreReviewer = exports.getApproverStepRule = exports.getDefApproverStepRule = void 0;
|
|
4
5
|
var tslib_1 = require("tslib");
|
|
5
6
|
var consts_1 = require("./consts");
|
|
6
7
|
var amis_formula_1 = require("amis-formula");
|
|
@@ -846,52 +847,52 @@ var hasNonPreReviewDepartments = function (materialApproval) {
|
|
|
846
847
|
};
|
|
847
848
|
exports.hasNonPreReviewDepartments = hasNonPreReviewDepartments;
|
|
848
849
|
var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
849
|
-
var actionLabel, user, record, nextStep, skipApprover, nextApprovers, _nextApprovers, nextApprovers_2, nextApprovers_2_1, reviewer, fieldName, status, e_6_1, nextApproversUserIds_1, nextApproversClientUserIds_1, setDoc, nextApprovers_3, nextApprovers_3_1, nextApprover, e_7_1, setDoc_1, initiator, materialOwner, error_1;
|
|
850
|
-
var e_6, _a, _b, _c, e_7, _d;
|
|
851
|
-
return tslib_1.__generator(this, function (
|
|
852
|
-
switch (
|
|
850
|
+
var actionLabel, user, record, nextStep, skipApprover, nextApprovers, _nextApprovers, nextApprovers_2, nextApprovers_2_1, reviewer, fieldName, status, e_6_1, nextApproversUserIds_1, nextApproversClientUserIds_1, setDoc, nextApprovers_3, nextApprovers_3_1, nextApprover, e_7_1, setDoc_1, postponedUserIds_1, now, visibleAfter, pastPostponeRecords, postponedDepts, _loop_1, nextApprovers_4, nextApprovers_4_1, reviewer, e_8_1, currentRecord, currentPostponed, newPostponed, notifyUserIds, initiator, materialOwner, error_1;
|
|
851
|
+
var e_6, _a, _b, _c, e_7, _d, e_8, _e;
|
|
852
|
+
return tslib_1.__generator(this, function (_f) {
|
|
853
|
+
switch (_f.label) {
|
|
853
854
|
case 0:
|
|
854
|
-
|
|
855
|
+
_f.trys.push([0, 95, , 96]);
|
|
855
856
|
actionLabel = '请查看';
|
|
856
857
|
user = ctx.meta.user;
|
|
857
858
|
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
858
859
|
case 1:
|
|
859
|
-
record =
|
|
860
|
+
record = _f.sent();
|
|
860
861
|
console.log('[advanceApproval]', record.current_step, record.person_pending_approve, user.userId);
|
|
861
862
|
return [4, canSubmit(record)];
|
|
862
863
|
case 2:
|
|
863
|
-
|
|
864
|
+
_f.sent();
|
|
864
865
|
return [4, getNextStep(ctx, record, currentStepApprovalStatus)];
|
|
865
866
|
case 3:
|
|
866
|
-
nextStep =
|
|
867
|
+
nextStep = _f.sent();
|
|
867
868
|
return [4, isSkipApprover(ctx, record)];
|
|
868
869
|
case 4:
|
|
869
|
-
skipApprover =
|
|
870
|
+
skipApprover = _f.sent();
|
|
870
871
|
if (!(nextStep === consts_1.Step.conclusion && skipApprover)) return [3, 8];
|
|
871
872
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(record._id, {
|
|
872
873
|
is_skip_approver: true
|
|
873
874
|
})];
|
|
874
875
|
case 5:
|
|
875
|
-
|
|
876
|
+
_f.sent();
|
|
876
877
|
return [4, ctx.getObject('pepsico_material').directUpdateMany(['pepsico_material_approval', '=', record._id], {
|
|
877
878
|
is_skip_approver: true
|
|
878
879
|
})];
|
|
879
880
|
case 6:
|
|
880
|
-
|
|
881
|
+
_f.sent();
|
|
881
882
|
return [4, setPersonView(ctx, record)];
|
|
882
883
|
case 7:
|
|
883
|
-
|
|
884
|
-
|
|
884
|
+
_f.sent();
|
|
885
|
+
_f.label = 8;
|
|
885
886
|
case 8: return [4, getNextApprovers(ctx, record, nextStep)];
|
|
886
887
|
case 9:
|
|
887
|
-
nextApprovers =
|
|
888
|
+
nextApprovers = _f.sent();
|
|
888
889
|
if (!(record.current_step === consts_1.Step.submitter_revisions && (nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review))) return [3, 23];
|
|
889
890
|
_nextApprovers = [];
|
|
890
|
-
|
|
891
|
+
_f.label = 10;
|
|
891
892
|
case 10:
|
|
892
|
-
|
|
893
|
+
_f.trys.push([10, 18, 19, 20]);
|
|
893
894
|
nextApprovers_2 = tslib_1.__values(nextApprovers), nextApprovers_2_1 = nextApprovers_2.next();
|
|
894
|
-
|
|
895
|
+
_f.label = 11;
|
|
895
896
|
case 11:
|
|
896
897
|
if (!!nextApprovers_2_1.done) return [3, 17];
|
|
897
898
|
reviewer = nextApprovers_2_1.value;
|
|
@@ -902,7 +903,7 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
902
903
|
}
|
|
903
904
|
return [4, (0, material_1.getUserReviewedAllMaterialsStatus)(ctx, record._id, fieldName)];
|
|
904
905
|
case 12:
|
|
905
|
-
status =
|
|
906
|
+
status = _f.sent();
|
|
906
907
|
console.log("getUserReviewedAllMaterialsStatus", record._id, fieldName, status);
|
|
907
908
|
if (!(status === consts_1.ApprovalStatus.approved)) return [3, 14];
|
|
908
909
|
console.log("[advanceApproval] \u81EA\u52A8\u66F4\u65B0\u5BA1\u6279\u5355\u4E0A\u7684\u72B6\u6001\u5B57\u6BB5", recordId, (_b = {},
|
|
@@ -912,7 +913,7 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
912
913
|
_c[fieldName] = true,
|
|
913
914
|
_c))];
|
|
914
915
|
case 13:
|
|
915
|
-
|
|
916
|
+
_f.sent();
|
|
916
917
|
return [3, 15];
|
|
917
918
|
case 14:
|
|
918
919
|
if (status === consts_1.ApprovalStatus.pass) {
|
|
@@ -921,16 +922,16 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
921
922
|
else {
|
|
922
923
|
_nextApprovers.push(reviewer);
|
|
923
924
|
}
|
|
924
|
-
|
|
925
|
+
_f.label = 15;
|
|
925
926
|
case 15:
|
|
926
927
|
;
|
|
927
|
-
|
|
928
|
+
_f.label = 16;
|
|
928
929
|
case 16:
|
|
929
930
|
nextApprovers_2_1 = nextApprovers_2.next();
|
|
930
931
|
return [3, 11];
|
|
931
932
|
case 17: return [3, 20];
|
|
932
933
|
case 18:
|
|
933
|
-
e_6_1 =
|
|
934
|
+
e_6_1 = _f.sent();
|
|
934
935
|
e_6 = { error: e_6_1 };
|
|
935
936
|
return [3, 20];
|
|
936
937
|
case 19:
|
|
@@ -947,8 +948,8 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
947
948
|
nextStep = consts_1.Step.awaiting_deployment;
|
|
948
949
|
return [4, getNextApprovers(ctx, record, nextStep)];
|
|
949
950
|
case 22:
|
|
950
|
-
nextApprovers =
|
|
951
|
-
|
|
951
|
+
nextApprovers = _f.sent();
|
|
952
|
+
_f.label = 23;
|
|
952
953
|
case 23:
|
|
953
954
|
console.log("[advanceApproval] currentStepApprovalStatus:", currentStepApprovalStatus, " nextStep:", nextStep, " nextApprovers:", nextApprovers);
|
|
954
955
|
nextApproversUserIds_1 = [];
|
|
@@ -976,8 +977,8 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
976
977
|
draft_submitted: setDoc.draft_submitted
|
|
977
978
|
})];
|
|
978
979
|
case 24:
|
|
979
|
-
|
|
980
|
-
|
|
980
|
+
_f.sent();
|
|
981
|
+
_f.label = 25;
|
|
981
982
|
case 25:
|
|
982
983
|
if (record.current_step === consts_1.Step.ai_review) {
|
|
983
984
|
setDoc.ai_reviewed_date = new Date();
|
|
@@ -991,8 +992,8 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
991
992
|
review_completed_date: setDoc.review_completed_date
|
|
992
993
|
})];
|
|
993
994
|
case 26:
|
|
994
|
-
|
|
995
|
-
|
|
995
|
+
_f.sent();
|
|
996
|
+
_f.label = 27;
|
|
996
997
|
case 27:
|
|
997
998
|
if (record.current_step === consts_1.Step.awaiting_deployment) {
|
|
998
999
|
setDoc.awaiting_deployment_date = new Date();
|
|
@@ -1005,8 +1006,8 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
1005
1006
|
review_completed_date: setDoc.review_completed_date
|
|
1006
1007
|
})];
|
|
1007
1008
|
case 28:
|
|
1008
|
-
|
|
1009
|
-
|
|
1009
|
+
_f.sent();
|
|
1010
|
+
_f.label = 29;
|
|
1010
1011
|
case 29:
|
|
1011
1012
|
if (record.current_step === consts_1.Step.submitter_revisions) {
|
|
1012
1013
|
setDoc.submitter_revision_date = new Date();
|
|
@@ -1017,25 +1018,25 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
1017
1018
|
}
|
|
1018
1019
|
return [4, ctx.getObject('pepsico_material_approval').update(recordId, setDoc)];
|
|
1019
1020
|
case 30:
|
|
1020
|
-
|
|
1021
|
+
_f.sent();
|
|
1021
1022
|
return [4, changeApprovalProcess(ctx, record, {
|
|
1022
1023
|
nextStep: nextStep,
|
|
1023
1024
|
nextApprovers: nextApprovers,
|
|
1024
1025
|
description: ""
|
|
1025
1026
|
})];
|
|
1026
1027
|
case 31:
|
|
1027
|
-
|
|
1028
|
+
_f.sent();
|
|
1028
1029
|
if (!(nextStep === consts_1.Step.ai_review)) return [3, 33];
|
|
1029
1030
|
console.time('callAIReview: ' + recordId);
|
|
1030
1031
|
return [4, (0, AI_1.callAIReview)(ctx, recordId)];
|
|
1031
1032
|
case 32:
|
|
1032
|
-
|
|
1033
|
+
_f.sent();
|
|
1033
1034
|
console.timeEnd('callAIReview: ' + recordId);
|
|
1034
|
-
|
|
1035
|
+
_f.label = 33;
|
|
1035
1036
|
case 33:
|
|
1036
|
-
|
|
1037
|
+
_f.trys.push([33, 69, 70, 71]);
|
|
1037
1038
|
nextApprovers_3 = tslib_1.__values(nextApprovers), nextApprovers_3_1 = nextApprovers_3.next();
|
|
1038
|
-
|
|
1039
|
+
_f.label = 34;
|
|
1039
1040
|
case 34:
|
|
1040
1041
|
if (!!nextApprovers_3_1.done) return [3, 68];
|
|
1041
1042
|
nextApprover = nextApprovers_3_1.value;
|
|
@@ -1044,149 +1045,149 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
1044
1045
|
ca_approval_status: ''
|
|
1045
1046
|
})];
|
|
1046
1047
|
case 35:
|
|
1047
|
-
|
|
1048
|
+
_f.sent();
|
|
1048
1049
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ca_approval_status', '=', false]], {
|
|
1049
1050
|
ca_approval_status: ''
|
|
1050
1051
|
})];
|
|
1051
1052
|
case 36:
|
|
1052
|
-
|
|
1053
|
-
|
|
1053
|
+
_f.sent();
|
|
1054
|
+
_f.label = 37;
|
|
1054
1055
|
case 37:
|
|
1055
1056
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.Legal)) return [3, 40];
|
|
1056
1057
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1057
1058
|
legal_approval_status: ''
|
|
1058
1059
|
})];
|
|
1059
1060
|
case 38:
|
|
1060
|
-
|
|
1061
|
+
_f.sent();
|
|
1061
1062
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['legal_approval_status', '=', false]], {
|
|
1062
1063
|
legal_approval_status: ''
|
|
1063
1064
|
})];
|
|
1064
1065
|
case 39:
|
|
1065
|
-
|
|
1066
|
-
|
|
1066
|
+
_f.sent();
|
|
1067
|
+
_f.label = 40;
|
|
1067
1068
|
case 40:
|
|
1068
1069
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.NS)) return [3, 43];
|
|
1069
1070
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1070
1071
|
ns_approval_status: ''
|
|
1071
1072
|
})];
|
|
1072
1073
|
case 41:
|
|
1073
|
-
|
|
1074
|
+
_f.sent();
|
|
1074
1075
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['ns_approval_status', '=', false]], {
|
|
1075
1076
|
ns_approval_status: ''
|
|
1076
1077
|
})];
|
|
1077
1078
|
case 42:
|
|
1078
|
-
|
|
1079
|
-
|
|
1079
|
+
_f.sent();
|
|
1080
|
+
_f.label = 43;
|
|
1080
1081
|
case 43:
|
|
1081
1082
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.SRA)) return [3, 46];
|
|
1082
1083
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1083
1084
|
sra_approval_status: ''
|
|
1084
1085
|
})];
|
|
1085
1086
|
case 44:
|
|
1086
|
-
|
|
1087
|
+
_f.sent();
|
|
1087
1088
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['sra_approval_status', '=', false]], {
|
|
1088
1089
|
sra_approval_status: ''
|
|
1089
1090
|
})];
|
|
1090
1091
|
case 45:
|
|
1091
|
-
|
|
1092
|
-
|
|
1092
|
+
_f.sent();
|
|
1093
|
+
_f.label = 46;
|
|
1093
1094
|
case 46:
|
|
1094
1095
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.guding)) return [3, 49];
|
|
1095
1096
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1096
1097
|
approval_status: ''
|
|
1097
1098
|
})];
|
|
1098
1099
|
case 47:
|
|
1099
|
-
|
|
1100
|
+
_f.sent();
|
|
1100
1101
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['approval_status', '=', false]], {
|
|
1101
1102
|
approval_status: ''
|
|
1102
1103
|
})];
|
|
1103
1104
|
case 48:
|
|
1104
|
-
|
|
1105
|
-
|
|
1105
|
+
_f.sent();
|
|
1106
|
+
_f.label = 49;
|
|
1106
1107
|
case 49:
|
|
1107
1108
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.Kids)) return [3, 52];
|
|
1108
1109
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1109
1110
|
kids_approval_status: ''
|
|
1110
1111
|
})];
|
|
1111
1112
|
case 50:
|
|
1112
|
-
|
|
1113
|
+
_f.sent();
|
|
1113
1114
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['kids_approval_status', '=', false]], {
|
|
1114
1115
|
kids_approval_status: ''
|
|
1115
1116
|
})];
|
|
1116
1117
|
case 51:
|
|
1117
|
-
|
|
1118
|
-
|
|
1118
|
+
_f.sent();
|
|
1119
|
+
_f.label = 52;
|
|
1119
1120
|
case 52:
|
|
1120
1121
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.PreNS)) return [3, 55];
|
|
1121
1122
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1122
1123
|
pre_ns_approval_status: ''
|
|
1123
1124
|
})];
|
|
1124
1125
|
case 53:
|
|
1125
|
-
|
|
1126
|
+
_f.sent();
|
|
1126
1127
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['pre_ns_approval_status', '=', false]], {
|
|
1127
1128
|
pre_ns_approval_status: ''
|
|
1128
1129
|
})];
|
|
1129
1130
|
case 54:
|
|
1130
|
-
|
|
1131
|
-
|
|
1131
|
+
_f.sent();
|
|
1132
|
+
_f.label = 55;
|
|
1132
1133
|
case 55:
|
|
1133
1134
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.PreLegal)) return [3, 58];
|
|
1134
1135
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1135
1136
|
pre_legal_approval_status: ''
|
|
1136
1137
|
})];
|
|
1137
1138
|
case 56:
|
|
1138
|
-
|
|
1139
|
+
_f.sent();
|
|
1139
1140
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['pre_legal_approval_status', '=', false]], {
|
|
1140
1141
|
pre_legal_approval_status: ''
|
|
1141
1142
|
})];
|
|
1142
1143
|
case 57:
|
|
1143
|
-
|
|
1144
|
-
|
|
1144
|
+
_f.sent();
|
|
1145
|
+
_f.label = 58;
|
|
1145
1146
|
case 58:
|
|
1146
1147
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.PreSRA)) return [3, 61];
|
|
1147
1148
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1148
1149
|
pre_sra_approval_status: ''
|
|
1149
1150
|
})];
|
|
1150
1151
|
case 59:
|
|
1151
|
-
|
|
1152
|
+
_f.sent();
|
|
1152
1153
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['pre_sra_approval_status', '=', false]], {
|
|
1153
1154
|
pre_sra_approval_status: ''
|
|
1154
1155
|
})];
|
|
1155
1156
|
case 60:
|
|
1156
|
-
|
|
1157
|
-
|
|
1157
|
+
_f.sent();
|
|
1158
|
+
_f.label = 61;
|
|
1158
1159
|
case 61:
|
|
1159
1160
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.PreCA)) return [3, 64];
|
|
1160
1161
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1161
1162
|
pre_ca_approval_status: ''
|
|
1162
1163
|
})];
|
|
1163
1164
|
case 62:
|
|
1164
|
-
|
|
1165
|
+
_f.sent();
|
|
1165
1166
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['pre_ca_approval_status', '=', false]], {
|
|
1166
1167
|
pre_ca_approval_status: ''
|
|
1167
1168
|
})];
|
|
1168
1169
|
case 63:
|
|
1169
|
-
|
|
1170
|
-
|
|
1170
|
+
_f.sent();
|
|
1171
|
+
_f.label = 64;
|
|
1171
1172
|
case 64:
|
|
1172
1173
|
if (!(nextApprover.type === consts_1.ProcessApprovalType.Preguding)) return [3, 67];
|
|
1173
1174
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1174
1175
|
pre_approval_status: ''
|
|
1175
1176
|
})];
|
|
1176
1177
|
case 65:
|
|
1177
|
-
|
|
1178
|
+
_f.sent();
|
|
1178
1179
|
return [4, ctx.getObject('pepsico_material').directUpdateMany([['pepsico_material_approval', '=', recordId], ['pre_approval_status', '=', false]], {
|
|
1179
1180
|
pre_approval_status: ''
|
|
1180
1181
|
})];
|
|
1181
1182
|
case 66:
|
|
1182
|
-
|
|
1183
|
-
|
|
1183
|
+
_f.sent();
|
|
1184
|
+
_f.label = 67;
|
|
1184
1185
|
case 67:
|
|
1185
1186
|
nextApprovers_3_1 = nextApprovers_3.next();
|
|
1186
1187
|
return [3, 34];
|
|
1187
1188
|
case 68: return [3, 71];
|
|
1188
1189
|
case 69:
|
|
1189
|
-
e_7_1 =
|
|
1190
|
+
e_7_1 = _f.sent();
|
|
1190
1191
|
e_7 = { error: e_7_1 };
|
|
1191
1192
|
return [3, 71];
|
|
1192
1193
|
case 70:
|
|
@@ -1199,22 +1200,22 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
1199
1200
|
if (!(nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) return [3, 73];
|
|
1200
1201
|
return [4, setPersonView(ctx, record)];
|
|
1201
1202
|
case 72:
|
|
1202
|
-
|
|
1203
|
-
|
|
1203
|
+
_f.sent();
|
|
1204
|
+
_f.label = 73;
|
|
1204
1205
|
case 73:
|
|
1205
1206
|
if (!(record.current_step === consts_1.Step.departmental_review || record.current_step === consts_1.Step.personnel_review)) return [3, 75];
|
|
1206
1207
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1207
1208
|
materials_remove_share_link_from_onedrive_status: 'pending'
|
|
1208
1209
|
})];
|
|
1209
1210
|
case 74:
|
|
1210
|
-
|
|
1211
|
-
|
|
1211
|
+
_f.sent();
|
|
1212
|
+
_f.label = 75;
|
|
1212
1213
|
case 75:
|
|
1213
1214
|
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 77];
|
|
1214
1215
|
return [4, pendingDeployment(ctx, recordId)];
|
|
1215
1216
|
case 76:
|
|
1216
|
-
|
|
1217
|
-
|
|
1217
|
+
_f.sent();
|
|
1218
|
+
_f.label = 77;
|
|
1218
1219
|
case 77:
|
|
1219
1220
|
if (!(nextStep === consts_1.Step.awaiting_deployment || (nextStep === consts_1.Step.conclusion && record.current_step === consts_1.Step.ai_review))) return [3, 79];
|
|
1220
1221
|
setDoc_1 = {
|
|
@@ -1222,8 +1223,8 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
1222
1223
|
};
|
|
1223
1224
|
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, setDoc_1)];
|
|
1224
1225
|
case 78:
|
|
1225
|
-
|
|
1226
|
-
|
|
1226
|
+
_f.sent();
|
|
1227
|
+
_f.label = 79;
|
|
1227
1228
|
case 79:
|
|
1228
1229
|
if (currentStepApprovalStatus === consts_1.ApprovalStatus.rejected) {
|
|
1229
1230
|
actionLabel = '内容审批被驳回';
|
|
@@ -1235,31 +1236,138 @@ var advanceApproval = function (ctx, recordId, currentStepApprovalStatus) { retu
|
|
|
1235
1236
|
if (nextStep === consts_1.Step.awaiting_deployment) {
|
|
1236
1237
|
actionLabel = "\u5185\u5BB9\u5BA1\u6279\u5DF2\u901A\u8FC7\u5F85\u4E0A\u7EBF";
|
|
1237
1238
|
}
|
|
1238
|
-
|
|
1239
|
+
postponedUserIds_1 = [];
|
|
1240
|
+
if (!(nextStep === consts_1.Step.departmental_review || nextStep === consts_1.Step.personnel_review)) return [3, 91];
|
|
1241
|
+
now = new Date();
|
|
1242
|
+
visibleAfter = new Date(now.getTime() + 3 * 24 * 60 * 60 * 1000);
|
|
1243
|
+
return [4, ctx.getObject('pepsico_review_postpone').directFind({
|
|
1244
|
+
filters: [
|
|
1245
|
+
['pepsico_material_approval', '=', recordId],
|
|
1246
|
+
['is_marker', '=', true]
|
|
1247
|
+
]
|
|
1248
|
+
})];
|
|
1239
1249
|
case 80:
|
|
1240
|
-
|
|
1241
|
-
if (!(
|
|
1250
|
+
pastPostponeRecords = _f.sent();
|
|
1251
|
+
if (!(pastPostponeRecords && pastPostponeRecords.length > 0)) return [3, 91];
|
|
1252
|
+
postponedDepts = new Set(pastPostponeRecords.map(function (r) { return r.department_type; }));
|
|
1253
|
+
_loop_1 = function (reviewer) {
|
|
1254
|
+
var deptUserIds, deptMarkers, deptMarkers_1, deptMarkers_1_1, marker, e_9_1;
|
|
1255
|
+
var e_9, _g;
|
|
1256
|
+
return tslib_1.__generator(this, function (_h) {
|
|
1257
|
+
switch (_h.label) {
|
|
1258
|
+
case 0:
|
|
1259
|
+
if (!postponedDepts.has(reviewer.type))
|
|
1260
|
+
return [2, "continue"];
|
|
1261
|
+
deptUserIds = reviewer.userIds || [];
|
|
1262
|
+
deptMarkers = pastPostponeRecords.filter(function (r) { return r.department_type === reviewer.type; });
|
|
1263
|
+
_h.label = 1;
|
|
1264
|
+
case 1:
|
|
1265
|
+
_h.trys.push([1, 6, 7, 8]);
|
|
1266
|
+
deptMarkers_1 = (e_9 = void 0, tslib_1.__values(deptMarkers)), deptMarkers_1_1 = deptMarkers_1.next();
|
|
1267
|
+
_h.label = 2;
|
|
1268
|
+
case 2:
|
|
1269
|
+
if (!!deptMarkers_1_1.done) return [3, 5];
|
|
1270
|
+
marker = deptMarkers_1_1.value;
|
|
1271
|
+
return [4, ctx.getObject('pepsico_review_postpone').directUpdate(marker._id, {
|
|
1272
|
+
is_marker: false,
|
|
1273
|
+
visible_after: visibleAfter,
|
|
1274
|
+
notification_sent: false,
|
|
1275
|
+
postponed_user_ids: deptUserIds.join(','),
|
|
1276
|
+
modified: now,
|
|
1277
|
+
modified_by: user.userId
|
|
1278
|
+
})];
|
|
1279
|
+
case 3:
|
|
1280
|
+
_h.sent();
|
|
1281
|
+
_h.label = 4;
|
|
1282
|
+
case 4:
|
|
1283
|
+
deptMarkers_1_1 = deptMarkers_1.next();
|
|
1284
|
+
return [3, 2];
|
|
1285
|
+
case 5: return [3, 8];
|
|
1286
|
+
case 6:
|
|
1287
|
+
e_9_1 = _h.sent();
|
|
1288
|
+
e_9 = { error: e_9_1 };
|
|
1289
|
+
return [3, 8];
|
|
1290
|
+
case 7:
|
|
1291
|
+
try {
|
|
1292
|
+
if (deptMarkers_1_1 && !deptMarkers_1_1.done && (_g = deptMarkers_1.return)) _g.call(deptMarkers_1);
|
|
1293
|
+
}
|
|
1294
|
+
finally { if (e_9) throw e_9.error; }
|
|
1295
|
+
return [7];
|
|
1296
|
+
case 8:
|
|
1297
|
+
postponedUserIds_1 = (0, lodash_1.compact)((0, lodash_1.uniq)((0, lodash_1.concat)(postponedUserIds_1, deptUserIds)));
|
|
1298
|
+
return [2];
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
};
|
|
1302
|
+
_f.label = 81;
|
|
1303
|
+
case 81:
|
|
1304
|
+
_f.trys.push([81, 86, 87, 88]);
|
|
1305
|
+
nextApprovers_4 = tslib_1.__values(nextApprovers), nextApprovers_4_1 = nextApprovers_4.next();
|
|
1306
|
+
_f.label = 82;
|
|
1307
|
+
case 82:
|
|
1308
|
+
if (!!nextApprovers_4_1.done) return [3, 85];
|
|
1309
|
+
reviewer = nextApprovers_4_1.value;
|
|
1310
|
+
return [5, _loop_1(reviewer)];
|
|
1311
|
+
case 83:
|
|
1312
|
+
_f.sent();
|
|
1313
|
+
_f.label = 84;
|
|
1314
|
+
case 84:
|
|
1315
|
+
nextApprovers_4_1 = nextApprovers_4.next();
|
|
1316
|
+
return [3, 82];
|
|
1317
|
+
case 85: return [3, 88];
|
|
1318
|
+
case 86:
|
|
1319
|
+
e_8_1 = _f.sent();
|
|
1320
|
+
e_8 = { error: e_8_1 };
|
|
1321
|
+
return [3, 88];
|
|
1322
|
+
case 87:
|
|
1323
|
+
try {
|
|
1324
|
+
if (nextApprovers_4_1 && !nextApprovers_4_1.done && (_e = nextApprovers_4.return)) _e.call(nextApprovers_4);
|
|
1325
|
+
}
|
|
1326
|
+
finally { if (e_8) throw e_8.error; }
|
|
1327
|
+
return [7];
|
|
1328
|
+
case 88:
|
|
1329
|
+
if (!(postponedUserIds_1.length > 0)) return [3, 91];
|
|
1330
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
1331
|
+
case 89:
|
|
1332
|
+
currentRecord = _f.sent();
|
|
1333
|
+
currentPostponed = currentRecord.review_postponed_users || [];
|
|
1334
|
+
newPostponed = (0, lodash_1.compact)((0, lodash_1.uniq)((0, lodash_1.concat)(currentPostponed, postponedUserIds_1)));
|
|
1335
|
+
return [4, ctx.getObject('pepsico_material_approval').directUpdate(recordId, {
|
|
1336
|
+
review_postponed_users: newPostponed
|
|
1337
|
+
})];
|
|
1338
|
+
case 90:
|
|
1339
|
+
_f.sent();
|
|
1340
|
+
console.log("[advanceApproval] \u81EA\u52A8\u5EF6\u540E\u5BA1\u6838\u4EBA: ".concat(postponedUserIds_1, ", visibleAfter: ").concat(visibleAfter));
|
|
1341
|
+
_f.label = 91;
|
|
1342
|
+
case 91:
|
|
1343
|
+
notifyUserIds = postponedUserIds_1.length > 0
|
|
1344
|
+
? nextApproversUserIds_1.filter(function (id) { return !postponedUserIds_1.includes(id); })
|
|
1345
|
+
: nextApproversUserIds_1;
|
|
1346
|
+
return [4, (0, notification_1.sendNotifications)(ctx, record, notifyUserIds, actionLabel)];
|
|
1347
|
+
case 92:
|
|
1348
|
+
_f.sent();
|
|
1349
|
+
if (!(nextStep === consts_1.Step.awaiting_deployment)) return [3, 94];
|
|
1242
1350
|
initiator = record.owner;
|
|
1243
1351
|
materialOwner = record.material_owner_id;
|
|
1244
|
-
if (!(initiator && materialOwner && initiator !== materialOwner)) return [3,
|
|
1352
|
+
if (!(initiator && materialOwner && initiator !== materialOwner)) return [3, 94];
|
|
1245
1353
|
console.log("[advanceApproval] \u901A\u77E5\u53D1\u8D77\u4EBA\u5BA1\u6838\u5B8C\u6210: initiator=".concat(initiator, ", material_owner=").concat(materialOwner));
|
|
1246
1354
|
return [4, (0, notification_1.sendNotifications)(ctx, record, [initiator], '审核完成')];
|
|
1247
|
-
case
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
case
|
|
1251
|
-
case
|
|
1252
|
-
error_1 =
|
|
1355
|
+
case 93:
|
|
1356
|
+
_f.sent();
|
|
1357
|
+
_f.label = 94;
|
|
1358
|
+
case 94: return [2, {}];
|
|
1359
|
+
case 95:
|
|
1360
|
+
error_1 = _f.sent();
|
|
1253
1361
|
console.error('[advanceApproval] Error:', error_1.message, error_1.stack);
|
|
1254
1362
|
throw error_1;
|
|
1255
|
-
case
|
|
1363
|
+
case 96: return [2];
|
|
1256
1364
|
}
|
|
1257
1365
|
});
|
|
1258
1366
|
}); };
|
|
1259
1367
|
exports.advanceApproval = advanceApproval;
|
|
1260
1368
|
var terminate = function (ctx, recordId, description) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
1261
|
-
var user, record, records, records_1, records_1_1, process_2,
|
|
1262
|
-
var
|
|
1369
|
+
var user, record, records, records_1, records_1_1, process_2, e_10_1;
|
|
1370
|
+
var e_10, _a;
|
|
1263
1371
|
return tslib_1.__generator(this, function (_b) {
|
|
1264
1372
|
switch (_b.label) {
|
|
1265
1373
|
case 0:
|
|
@@ -1308,14 +1416,14 @@ var terminate = function (ctx, recordId, description) { return tslib_1.__awaiter
|
|
|
1308
1416
|
return [3, 5];
|
|
1309
1417
|
case 8: return [3, 11];
|
|
1310
1418
|
case 9:
|
|
1311
|
-
|
|
1312
|
-
|
|
1419
|
+
e_10_1 = _b.sent();
|
|
1420
|
+
e_10 = { error: e_10_1 };
|
|
1313
1421
|
return [3, 11];
|
|
1314
1422
|
case 10:
|
|
1315
1423
|
try {
|
|
1316
1424
|
if (records_1_1 && !records_1_1.done && (_a = records_1.return)) _a.call(records_1);
|
|
1317
1425
|
}
|
|
1318
|
-
finally { if (
|
|
1426
|
+
finally { if (e_10) throw e_10.error; }
|
|
1319
1427
|
return [7];
|
|
1320
1428
|
case 11: return [4, ctx.getObject('pepsico_material_approval').update(recordId, {
|
|
1321
1429
|
current_step: consts_1.Step.conclusion,
|
|
@@ -1671,8 +1779,8 @@ var submitPreReviewContent = function (ctx, recordId, currentStepApprovalStatus)
|
|
|
1671
1779
|
exports.submitPreReviewContent = submitPreReviewContent;
|
|
1672
1780
|
var submitContent = function (ctx, recordId, currentStepApprovalStatus, skip) {
|
|
1673
1781
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1674
|
-
var approvalNew, user, allow, aProcess, aProcess_1, aProcess_1_1, item,
|
|
1675
|
-
var
|
|
1782
|
+
var approvalNew, user, allow, aProcess, aProcess_1, aProcess_1_1, item, e_11_1, approvalType, allTrue1, allTrue, spaceUsers, owner, materials, pendingXmlToWordMaterials, pendingUploadMaterials;
|
|
1783
|
+
var e_11, _a;
|
|
1676
1784
|
return tslib_1.__generator(this, function (_b) {
|
|
1677
1785
|
switch (_b.label) {
|
|
1678
1786
|
case 0: return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
@@ -1730,14 +1838,14 @@ var submitContent = function (ctx, recordId, currentStepApprovalStatus, skip) {
|
|
|
1730
1838
|
return [3, 4];
|
|
1731
1839
|
case 7: return [3, 10];
|
|
1732
1840
|
case 8:
|
|
1733
|
-
|
|
1734
|
-
|
|
1841
|
+
e_11_1 = _b.sent();
|
|
1842
|
+
e_11 = { error: e_11_1 };
|
|
1735
1843
|
return [3, 10];
|
|
1736
1844
|
case 9:
|
|
1737
1845
|
try {
|
|
1738
1846
|
if (aProcess_1_1 && !aProcess_1_1.done && (_a = aProcess_1.return)) _a.call(aProcess_1);
|
|
1739
1847
|
}
|
|
1740
|
-
finally { if (
|
|
1848
|
+
finally { if (e_11) throw e_11.error; }
|
|
1741
1849
|
return [7];
|
|
1742
1850
|
case 10:
|
|
1743
1851
|
if (allow != true && approvalNew.current_step != consts_1.Step.draft && !(0, lodash_1.includes)(approvalNew.person_pending_approve, user.userId)) {
|
|
@@ -1886,4 +1994,159 @@ var hasReviewed = function (approvalStatus) {
|
|
|
1886
1994
|
return false;
|
|
1887
1995
|
};
|
|
1888
1996
|
exports.hasReviewed = hasReviewed;
|
|
1997
|
+
var TYPE_TO_REVIEWER_FIELD = (_a = {},
|
|
1998
|
+
_a[consts_1.ProcessApprovalType.NS] = 'ns_reviewer',
|
|
1999
|
+
_a[consts_1.ProcessApprovalType.Legal] = 'legal_reviewer',
|
|
2000
|
+
_a[consts_1.ProcessApprovalType.SRA] = 'sra_reviewer',
|
|
2001
|
+
_a[consts_1.ProcessApprovalType.CA] = 'ca_reviewer',
|
|
2002
|
+
_a[consts_1.ProcessApprovalType.guding] = 'reviewer',
|
|
2003
|
+
_a[consts_1.ProcessApprovalType.Kids] = 'kids_reviewer',
|
|
2004
|
+
_a[consts_1.ProcessApprovalType.PreNS] = 'pre_ns_reviewer',
|
|
2005
|
+
_a[consts_1.ProcessApprovalType.PreLegal] = 'pre_legal_reviewer',
|
|
2006
|
+
_a[consts_1.ProcessApprovalType.PreSRA] = 'pre_sra_reviewer',
|
|
2007
|
+
_a[consts_1.ProcessApprovalType.PreCA] = 'pre_ca_reviewer',
|
|
2008
|
+
_a[consts_1.ProcessApprovalType.Preguding] = 'pre_reviewer',
|
|
2009
|
+
_a);
|
|
2010
|
+
var postponeReview = function (ctx, recordId, data) {
|
|
2011
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2012
|
+
var user, record, progessRecords, userProcessRecords, departmentType, reviewerField, deptUserIds, val, now, unactivatedMarkers, latestMarker, _a, _b, marker, e_12_1;
|
|
2013
|
+
var e_12, _c;
|
|
2014
|
+
return tslib_1.__generator(this, function (_d) {
|
|
2015
|
+
switch (_d.label) {
|
|
2016
|
+
case 0:
|
|
2017
|
+
user = ctx.meta.user;
|
|
2018
|
+
return [4, ctx.getObject('pepsico_material_approval').findOne(recordId)];
|
|
2019
|
+
case 1:
|
|
2020
|
+
record = _d.sent();
|
|
2021
|
+
if (record.current_step !== consts_1.Step.departmental_review && record.current_step !== consts_1.Step.personnel_review) {
|
|
2022
|
+
throw new Error('当前步骤不支持延后审核操作');
|
|
2023
|
+
}
|
|
2024
|
+
if (!(0, lodash_1.includes)(record.person_approved, user.userId)) {
|
|
2025
|
+
throw new Error('您不在当前已审批人列表中');
|
|
2026
|
+
}
|
|
2027
|
+
return [4, ctx.getObject('pepsico_approval_process').directFind({
|
|
2028
|
+
filters: [
|
|
2029
|
+
['pepsico_material_approval', '=', recordId],
|
|
2030
|
+
['owner', '=', user.userId],
|
|
2031
|
+
['approved', '=', 'progess'],
|
|
2032
|
+
['space', '=', record.space]
|
|
2033
|
+
]
|
|
2034
|
+
})];
|
|
2035
|
+
case 2:
|
|
2036
|
+
progessRecords = _d.sent();
|
|
2037
|
+
if (progessRecords.length > 0) {
|
|
2038
|
+
throw new Error('您还有待处理的审批任务,无法执行延后审核');
|
|
2039
|
+
}
|
|
2040
|
+
return [4, ctx.getObject('pepsico_approval_process').directFind({
|
|
2041
|
+
filters: [
|
|
2042
|
+
['pepsico_material_approval', '=', recordId],
|
|
2043
|
+
['owner', '=', user.userId],
|
|
2044
|
+
['space', '=', record.space]
|
|
2045
|
+
],
|
|
2046
|
+
sort: 'created desc',
|
|
2047
|
+
top: 1
|
|
2048
|
+
})];
|
|
2049
|
+
case 3:
|
|
2050
|
+
userProcessRecords = _d.sent();
|
|
2051
|
+
if (!userProcessRecords || userProcessRecords.length === 0) {
|
|
2052
|
+
throw new Error('未找到您的审核记录');
|
|
2053
|
+
}
|
|
2054
|
+
departmentType = userProcessRecords[0].type;
|
|
2055
|
+
if (!departmentType) {
|
|
2056
|
+
throw new Error('无法确定您所在的审核部门');
|
|
2057
|
+
}
|
|
2058
|
+
reviewerField = TYPE_TO_REVIEWER_FIELD[departmentType];
|
|
2059
|
+
deptUserIds = [];
|
|
2060
|
+
if (reviewerField && record[reviewerField]) {
|
|
2061
|
+
val = record[reviewerField];
|
|
2062
|
+
deptUserIds = Array.isArray(val) ? val : [val];
|
|
2063
|
+
}
|
|
2064
|
+
if (deptUserIds.length === 0) {
|
|
2065
|
+
deptUserIds = [user.userId];
|
|
2066
|
+
}
|
|
2067
|
+
now = new Date();
|
|
2068
|
+
return [4, ctx.getObject('pepsico_review_postpone').directFind({
|
|
2069
|
+
filters: [
|
|
2070
|
+
['pepsico_material_approval', '=', recordId],
|
|
2071
|
+
['postpone_by', '=', user.userId],
|
|
2072
|
+
['space', '=', record.space],
|
|
2073
|
+
['is_marker', '=', true]
|
|
2074
|
+
],
|
|
2075
|
+
sort: 'created desc'
|
|
2076
|
+
})];
|
|
2077
|
+
case 4:
|
|
2078
|
+
unactivatedMarkers = _d.sent();
|
|
2079
|
+
if (!(unactivatedMarkers && unactivatedMarkers.length > 0)) return [3, 14];
|
|
2080
|
+
latestMarker = unactivatedMarkers[0];
|
|
2081
|
+
return [4, ctx.getObject('pepsico_review_postpone').directUpdate(latestMarker._id, {
|
|
2082
|
+
department_type: departmentType,
|
|
2083
|
+
postpone_reason: data.postpone_reason || '',
|
|
2084
|
+
postpone_date: now,
|
|
2085
|
+
postponed_user_ids: deptUserIds.join(','),
|
|
2086
|
+
notification_sent: false,
|
|
2087
|
+
modified: now,
|
|
2088
|
+
modified_by: user.userId,
|
|
2089
|
+
name: "".concat(departmentType, " \u5EF6\u540E\u5BA1\u6838\u6807\u8BB0 ").concat(now.toISOString())
|
|
2090
|
+
})];
|
|
2091
|
+
case 5:
|
|
2092
|
+
_d.sent();
|
|
2093
|
+
_d.label = 6;
|
|
2094
|
+
case 6:
|
|
2095
|
+
_d.trys.push([6, 11, 12, 13]);
|
|
2096
|
+
_a = tslib_1.__values(unactivatedMarkers.slice(1)), _b = _a.next();
|
|
2097
|
+
_d.label = 7;
|
|
2098
|
+
case 7:
|
|
2099
|
+
if (!!_b.done) return [3, 10];
|
|
2100
|
+
marker = _b.value;
|
|
2101
|
+
return [4, ctx.getObject('pepsico_review_postpone').directUpdate(marker._id, {
|
|
2102
|
+
is_marker: false,
|
|
2103
|
+
notification_sent: true,
|
|
2104
|
+
modified: now,
|
|
2105
|
+
modified_by: user.userId
|
|
2106
|
+
})];
|
|
2107
|
+
case 8:
|
|
2108
|
+
_d.sent();
|
|
2109
|
+
_d.label = 9;
|
|
2110
|
+
case 9:
|
|
2111
|
+
_b = _a.next();
|
|
2112
|
+
return [3, 7];
|
|
2113
|
+
case 10: return [3, 13];
|
|
2114
|
+
case 11:
|
|
2115
|
+
e_12_1 = _d.sent();
|
|
2116
|
+
e_12 = { error: e_12_1 };
|
|
2117
|
+
return [3, 13];
|
|
2118
|
+
case 12:
|
|
2119
|
+
try {
|
|
2120
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
2121
|
+
}
|
|
2122
|
+
finally { if (e_12) throw e_12.error; }
|
|
2123
|
+
return [7];
|
|
2124
|
+
case 13: return [3, 16];
|
|
2125
|
+
case 14: return [4, ctx.getObject('pepsico_review_postpone').insert({
|
|
2126
|
+
pepsico_material_approval: recordId,
|
|
2127
|
+
department_type: departmentType,
|
|
2128
|
+
postpone_by: user.userId,
|
|
2129
|
+
postpone_reason: data.postpone_reason || '',
|
|
2130
|
+
postpone_date: now,
|
|
2131
|
+
is_marker: true,
|
|
2132
|
+
notification_sent: false,
|
|
2133
|
+
postponed_user_ids: deptUserIds.join(','),
|
|
2134
|
+
space: record.space,
|
|
2135
|
+
created: now,
|
|
2136
|
+
created_by: user.userId,
|
|
2137
|
+
modified: now,
|
|
2138
|
+
modified_by: user.userId,
|
|
2139
|
+
name: "".concat(departmentType, " \u5EF6\u540E\u5BA1\u6838\u6807\u8BB0 ").concat(now.toISOString())
|
|
2140
|
+
})];
|
|
2141
|
+
case 15:
|
|
2142
|
+
_d.sent();
|
|
2143
|
+
_d.label = 16;
|
|
2144
|
+
case 16:
|
|
2145
|
+
console.log("[postponeReview] recordId=".concat(recordId, ", departmentType=").concat(departmentType, ", deptUserIds=").concat(deptUserIds, ", markedForNextRound=true"));
|
|
2146
|
+
return [2, {}];
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
});
|
|
2150
|
+
};
|
|
2151
|
+
exports.postponeReview = postponeReview;
|
|
1889
2152
|
//# sourceMappingURL=approval_engine.js.map
|