@7365admin1/module-hygiene 4.29.1-staging.16 → 4.29.1-staging.17
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/.changeset/schedule-task-set-fields.md +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +45 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/schedule-followups.test.mjs +24 -0
package/dist/index.mjs
CHANGED
|
@@ -3186,7 +3186,9 @@ var areaChecklistSchema = Joi9.object({
|
|
|
3186
3186
|
}).required()
|
|
3187
3187
|
).min(1).required(),
|
|
3188
3188
|
isScheduleTask: Joi9.boolean().optional().default(false),
|
|
3189
|
-
scheduleTaskId: Joi9.string().hex().optional().allow(null)
|
|
3189
|
+
scheduleTaskId: Joi9.string().hex().optional().allow(null),
|
|
3190
|
+
scheduleTaskTitle: Joi9.string().optional().allow("", null),
|
|
3191
|
+
scheduleTaskTime: Joi9.string().optional().allow("", null)
|
|
3190
3192
|
}).required()
|
|
3191
3193
|
).optional().default([])
|
|
3192
3194
|
});
|
|
@@ -3216,6 +3218,8 @@ function MAreaChecklist(value) {
|
|
|
3216
3218
|
set: checklistItem.set,
|
|
3217
3219
|
isScheduleTask: checklistItem.isScheduleTask ?? false,
|
|
3218
3220
|
scheduleTaskId: checklistItem.scheduleTaskId ?? void 0,
|
|
3221
|
+
scheduleTaskTitle: checklistItem.scheduleTaskTitle ?? void 0,
|
|
3222
|
+
scheduleTaskTime: checklistItem.scheduleTaskTime ?? void 0,
|
|
3219
3223
|
units: checklistItem.units.map((unit) => ({
|
|
3220
3224
|
unit: new ObjectId8(unit.unit),
|
|
3221
3225
|
name: unit.name,
|
|
@@ -3710,6 +3714,9 @@ function useAreaChecklistRepo() {
|
|
|
3710
3714
|
isScheduleTask: {
|
|
3711
3715
|
$ifNull: ["$checklist.isScheduleTask", false]
|
|
3712
3716
|
},
|
|
3717
|
+
scheduleTaskId: { $ifNull: ["$checklist.scheduleTaskId", null] },
|
|
3718
|
+
scheduleTaskTitle: { $ifNull: ["$checklist.scheduleTaskTitle", null] },
|
|
3719
|
+
scheduleTaskTime: { $ifNull: ["$checklist.scheduleTaskTime", null] },
|
|
3713
3720
|
unit: "$checklist.units.unit",
|
|
3714
3721
|
name: "$checklist.units.name",
|
|
3715
3722
|
approve: "$checklist.units.approve",
|
|
@@ -3746,6 +3753,9 @@ function useAreaChecklistRepo() {
|
|
|
3746
3753
|
$group: {
|
|
3747
3754
|
_id: "$set",
|
|
3748
3755
|
isScheduleTask: { $first: "$isScheduleTask" },
|
|
3756
|
+
scheduleTaskId: { $first: "$scheduleTaskId" },
|
|
3757
|
+
scheduleTaskTitle: { $first: "$scheduleTaskTitle" },
|
|
3758
|
+
scheduleTaskTime: { $first: "$scheduleTaskTime" },
|
|
3749
3759
|
units: {
|
|
3750
3760
|
$push: {
|
|
3751
3761
|
unit: "$unit",
|
|
@@ -3766,6 +3776,9 @@ function useAreaChecklistRepo() {
|
|
|
3766
3776
|
_id: 0,
|
|
3767
3777
|
set: "$_id",
|
|
3768
3778
|
isScheduleTask: 1,
|
|
3779
|
+
scheduleTaskId: 1,
|
|
3780
|
+
scheduleTaskTitle: 1,
|
|
3781
|
+
scheduleTaskTime: 1,
|
|
3769
3782
|
units: 1
|
|
3770
3783
|
}
|
|
3771
3784
|
},
|
|
@@ -3897,6 +3910,8 @@ function useAreaChecklistRepo() {
|
|
|
3897
3910
|
isScheduleTask: {
|
|
3898
3911
|
$ifNull: ["$checklist.isScheduleTask", false]
|
|
3899
3912
|
},
|
|
3913
|
+
scheduleTaskTitle: { $ifNull: ["$checklist.scheduleTaskTitle", null] },
|
|
3914
|
+
scheduleTaskTime: { $ifNull: ["$checklist.scheduleTaskTime", null] },
|
|
3900
3915
|
scheduleTaskId: {
|
|
3901
3916
|
$ifNull: ["$checklist.scheduleTaskId", null]
|
|
3902
3917
|
},
|
|
@@ -3937,6 +3952,8 @@ function useAreaChecklistRepo() {
|
|
|
3937
3952
|
$group: {
|
|
3938
3953
|
_id: "$set",
|
|
3939
3954
|
isScheduleTask: { $first: "$isScheduleTask" },
|
|
3955
|
+
scheduleTaskTitle: { $first: "$scheduleTaskTitle" },
|
|
3956
|
+
scheduleTaskTime: { $first: "$scheduleTaskTime" },
|
|
3940
3957
|
scheduleTaskId: { $first: "$scheduleTaskId" },
|
|
3941
3958
|
remarks: { $first: "$remarks" },
|
|
3942
3959
|
attachment: { $first: "$attachment" },
|
|
@@ -3961,6 +3978,8 @@ function useAreaChecklistRepo() {
|
|
|
3961
3978
|
_id: 0,
|
|
3962
3979
|
set: "$_id",
|
|
3963
3980
|
isScheduleTask: 1,
|
|
3981
|
+
scheduleTaskTitle: 1,
|
|
3982
|
+
scheduleTaskTime: 1,
|
|
3964
3983
|
scheduleTaskId: 1,
|
|
3965
3984
|
remarks: "$remarks",
|
|
3966
3985
|
attachment: "$attachment",
|
|
@@ -4945,6 +4964,8 @@ import { AppServiceType as AppServiceType10 } from "@7365admin1/core";
|
|
|
4945
4964
|
import { launch } from "puppeteer";
|
|
4946
4965
|
import { InternalServerError as InternalServerError6, useAtlas as useAtlas8 } from "@7365admin1/node-server-utils";
|
|
4947
4966
|
import { ObjectId as ObjectId11 } from "mongodb";
|
|
4967
|
+
|
|
4968
|
+
// src/utils/checklist-pdf-html.util.ts
|
|
4948
4969
|
function escapeHtml(text) {
|
|
4949
4970
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4950
4971
|
}
|
|
@@ -4957,7 +4978,7 @@ function buildChecklistHtml(areaChecklists) {
|
|
|
4957
4978
|
const unitRows = (setItem.units || []).map(
|
|
4958
4979
|
(unit) => `
|
|
4959
4980
|
<tr>
|
|
4960
|
-
<td class="unit-name">${escapeHtml(unit.name || "")}</td>
|
|
4981
|
+
<td class="unit-name">${escapeHtml(unit.name || "")}${unit.approve || unit.reject ? "" : ' <span class="missed-label">Missed</span>'}</td>
|
|
4961
4982
|
<td class="icon-cell">${unit.reject ? '<span class="reject-icon">✗</span>' : ""}</td>
|
|
4962
4983
|
<td class="icon-cell">${unit.approve ? '<span class="approve-icon">✓</span>' : ""}</td>
|
|
4963
4984
|
</tr>`
|
|
@@ -5094,6 +5115,12 @@ function buildChecklistHtml(areaChecklists) {
|
|
|
5094
5115
|
font-size: 16px;
|
|
5095
5116
|
font-weight: bold;
|
|
5096
5117
|
}
|
|
5118
|
+
.missed-label {
|
|
5119
|
+
color: #b3261e;
|
|
5120
|
+
font-size: 11px;
|
|
5121
|
+
font-weight: bold;
|
|
5122
|
+
margin-left: 6px;
|
|
5123
|
+
}
|
|
5097
5124
|
.reject-icon {
|
|
5098
5125
|
color: #e74c3c;
|
|
5099
5126
|
font-size: 16px;
|
|
@@ -5109,6 +5136,8 @@ function buildChecklistHtml(areaChecklists) {
|
|
|
5109
5136
|
</body>
|
|
5110
5137
|
</html>`;
|
|
5111
5138
|
}
|
|
5139
|
+
|
|
5140
|
+
// src/services/hygiene-checklist-pdf.service.ts
|
|
5112
5141
|
function useChecklistPdfService() {
|
|
5113
5142
|
async function generateChecklistPdf(scheduleId) {
|
|
5114
5143
|
const db = useAtlas8.getDb();
|
|
@@ -7399,6 +7428,18 @@ function useScheduleTaskRepository() {
|
|
|
7399
7428
|
};
|
|
7400
7429
|
}
|
|
7401
7430
|
|
|
7431
|
+
// src/utils/schedule-task-set.util.ts
|
|
7432
|
+
function buildScheduleTaskSets(task, units, startSet, count) {
|
|
7433
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
7434
|
+
set: startSet + i,
|
|
7435
|
+
units,
|
|
7436
|
+
isScheduleTask: true,
|
|
7437
|
+
scheduleTaskId: task._id,
|
|
7438
|
+
scheduleTaskTitle: task.title,
|
|
7439
|
+
scheduleTaskTime: task.time
|
|
7440
|
+
}));
|
|
7441
|
+
}
|
|
7442
|
+
|
|
7402
7443
|
// src/services/hygiene-schedule-task.service.ts
|
|
7403
7444
|
import { ObjectId as ObjectId20 } from "mongodb";
|
|
7404
7445
|
import { logger as logger32 } from "@7365admin1/node-server-utils";
|
|
@@ -7544,15 +7585,7 @@ function useScheduleTaskService() {
|
|
|
7544
7585
|
)
|
|
7545
7586
|
) : 0;
|
|
7546
7587
|
const startSetNumber = maxSetInChecklist + 1;
|
|
7547
|
-
const newSets =
|
|
7548
|
-
{ length: areaSetConfig },
|
|
7549
|
-
(_, index) => ({
|
|
7550
|
-
set: startSetNumber + index,
|
|
7551
|
-
units,
|
|
7552
|
-
isScheduleTask: true,
|
|
7553
|
-
scheduleTaskId: scheduleTask._id
|
|
7554
|
-
})
|
|
7555
|
-
);
|
|
7588
|
+
const newSets = buildScheduleTaskSets(scheduleTask, units, startSetNumber, areaSetConfig);
|
|
7556
7589
|
const modified = await pushScheduleTaskSets(
|
|
7557
7590
|
parentChecklistId.toString(),
|
|
7558
7591
|
serviceType,
|
|
@@ -7572,16 +7605,7 @@ function useScheduleTaskService() {
|
|
|
7572
7605
|
}
|
|
7573
7606
|
} else {
|
|
7574
7607
|
const areaSetConfig = Number(areaDetails.set) || 1;
|
|
7575
|
-
const
|
|
7576
|
-
const schedTaskSets = Array.from(
|
|
7577
|
-
{ length: areaSetConfig },
|
|
7578
|
-
(_, index) => ({
|
|
7579
|
-
set: index + 1,
|
|
7580
|
-
units,
|
|
7581
|
-
isScheduleTask: true,
|
|
7582
|
-
scheduleTaskId: schedTaskId
|
|
7583
|
-
})
|
|
7584
|
-
);
|
|
7608
|
+
const schedTaskSets = buildScheduleTaskSets(scheduleTask, units, 1, areaSetConfig);
|
|
7585
7609
|
const checklistData = {
|
|
7586
7610
|
schedule: parentChecklistId.toString(),
|
|
7587
7611
|
serviceType,
|