@7365admin1/layer-common 3.1.1 → 3.1.2-staging.30
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/.github/workflows/publish-staging.yml +11 -0
- package/components/AddEqupmentForm.vue +52 -1
- package/components/AddPassKeyToVisitor.vue +115 -53
- package/components/DashboardMain.vue +231 -87
- package/components/EquipmentManagementMain.vue +56 -0
- package/components/InvitationMain.vue +4 -3
- package/components/ManageChecklistMain.vue +44 -38
- package/components/Nfc/NFCPatrolReportMain.vue +128 -38
- package/components/Nfc/PatrolReport/DailyReportTab.vue +10 -6
- package/components/Nfc/PatrolReport/MonthlyReportTab.vue +19 -9
- package/components/Nfc/PatrolReport/MonthlyReportTable.vue +69 -0
- package/components/Nfc/PatrolReport/PatrolReportTab.vue +5 -3
- package/components/Nfc/PatrolReport/ReportFilters.vue +50 -18
- package/components/PhotoUpload.vue +19 -4
- package/components/ServiceProviderMain.vue +46 -29
- package/components/VisitorForm.vue +5 -5
- package/components/VisitorManagement.vue +109 -30
- package/composables/useCleaningSchedulePermission.ts +16 -51
- package/composables/useEquipment.ts +2 -0
- package/composables/useLocalAuth.ts +1 -1
- package/composables/useNFCPatrolDailyReport.ts +1 -4
- package/composables/useNFCPatrolMonthlyReport.ts +62 -30
- package/package.json +1 -1
- package/types/customer.d.ts +2 -1
- package/types/equipment.d.ts +5 -1
- package/types/nfc-patrol-report.ts +15 -1
|
@@ -2,6 +2,8 @@ import type {
|
|
|
2
2
|
NFCPatrolReportFilters,
|
|
3
3
|
NFCPatrolSummaryReport,
|
|
4
4
|
NFCPatrolReportSummaryRow,
|
|
5
|
+
NFCPatrolMonthlyReportRow,
|
|
6
|
+
NFCPatrolMonthlyReport,
|
|
5
7
|
} from "../types/nfc-patrol-report";
|
|
6
8
|
import useNFCPatrolLog from "./useNFCPatrolLog";
|
|
7
9
|
import useSite from "./useSite";
|
|
@@ -12,6 +14,55 @@ interface NFCPatrolLogListResponse {
|
|
|
12
14
|
pageRange?: string;
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
const MONTHS = [
|
|
18
|
+
"January",
|
|
19
|
+
"February",
|
|
20
|
+
"March",
|
|
21
|
+
"April",
|
|
22
|
+
"May",
|
|
23
|
+
"June",
|
|
24
|
+
"July",
|
|
25
|
+
"August",
|
|
26
|
+
"September",
|
|
27
|
+
"October",
|
|
28
|
+
"November",
|
|
29
|
+
"December",
|
|
30
|
+
];
|
|
31
|
+
function mapLogsToMonthlyRows(
|
|
32
|
+
logs: Record<string, any>[],
|
|
33
|
+
): NFCPatrolMonthlyReportRow[] {
|
|
34
|
+
const rows = MONTHS.map((month) => ({
|
|
35
|
+
month,
|
|
36
|
+
checked: 0,
|
|
37
|
+
checkedPercentage: 0,
|
|
38
|
+
missed: 0,
|
|
39
|
+
missedPercentage: 0,
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
logs.forEach((log) => {
|
|
43
|
+
const monthIndex = new Date(log.date).getMonth();
|
|
44
|
+
|
|
45
|
+
for (const checkpoint of log.checkPoints ?? []) {
|
|
46
|
+
if (checkpoint.status === "Completed") {
|
|
47
|
+
rows[monthIndex].checked++;
|
|
48
|
+
} else if (checkpoint.status === "Skipped") {
|
|
49
|
+
rows[monthIndex].missed++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
rows.forEach((row) => {
|
|
55
|
+
const total = row.checked + row.missed;
|
|
56
|
+
|
|
57
|
+
if (total > 0) {
|
|
58
|
+
row.checkedPercentage = Math.round((row.checked / total) * 100);
|
|
59
|
+
row.missedPercentage = Math.round((row.missed / total) * 100);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return rows;
|
|
64
|
+
}
|
|
65
|
+
|
|
15
66
|
function buildAddress(address?: Record<string, string>) {
|
|
16
67
|
if (!address) return undefined;
|
|
17
68
|
|
|
@@ -27,23 +78,7 @@ function buildAddress(address?: Record<string, string>) {
|
|
|
27
78
|
return parts.length ? parts.join(", ") : undefined;
|
|
28
79
|
}
|
|
29
80
|
|
|
30
|
-
function mapLogToSummaryRow(
|
|
31
|
-
log: Record<string, any>,
|
|
32
|
-
index: number,
|
|
33
|
-
): NFCPatrolReportSummaryRow {
|
|
34
|
-
const checkpoints: Record<string, any>[] = log.checkPoints ?? [];
|
|
35
|
-
const checked = checkpoints.filter((cp) => cp.status === "Completed").length;
|
|
36
|
-
const missed = checkpoints.filter((cp) => cp.status === "Skipped").length;
|
|
37
81
|
|
|
38
|
-
return {
|
|
39
|
-
id: log._id,
|
|
40
|
-
routeName: `${index + 1}. ${log.route?.name ?? "-"}`,
|
|
41
|
-
securityCheckSchedule: log.route?.startTime ?? "-",
|
|
42
|
-
checked,
|
|
43
|
-
missed,
|
|
44
|
-
status: missed === 0 ? "Completed" : "Incomplete",
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
82
|
|
|
48
83
|
export function useNFCPatrolMonthlyReport(
|
|
49
84
|
filters: NFCPatrolReportFilters,
|
|
@@ -52,12 +87,12 @@ export function useNFCPatrolMonthlyReport(
|
|
|
52
87
|
const { getAll: getPatrolLogs } = useNFCPatrolLog();
|
|
53
88
|
const { getSiteById } = useSite();
|
|
54
89
|
|
|
55
|
-
const report = ref<
|
|
90
|
+
const report = ref<NFCPatrolMonthlyReport | null>(null);
|
|
56
91
|
const loading = ref(false);
|
|
57
92
|
const notFound = ref(false);
|
|
58
93
|
|
|
59
94
|
async function fetchReport() {
|
|
60
|
-
if (!site || !filters.
|
|
95
|
+
if (!site || !filters.route) {
|
|
61
96
|
report.value = null;
|
|
62
97
|
notFound.value = false;
|
|
63
98
|
return;
|
|
@@ -65,19 +100,16 @@ export function useNFCPatrolMonthlyReport(
|
|
|
65
100
|
|
|
66
101
|
loading.value = true;
|
|
67
102
|
notFound.value = false;
|
|
68
|
-
|
|
103
|
+
const currentYear = new Date().getFullYear().toString();
|
|
69
104
|
try {
|
|
70
105
|
const [logsRes, siteInfo] = await Promise.all([
|
|
71
|
-
getPatrolLogs
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
? filters.timeRange.split(" - ")[0]
|
|
79
|
-
: undefined,
|
|
80
|
-
type: "month",
|
|
106
|
+
getPatrolLogs({
|
|
107
|
+
page: 1,
|
|
108
|
+
limit: 100,
|
|
109
|
+
site,
|
|
110
|
+
routeId: filters.route,
|
|
111
|
+
date: currentYear,
|
|
112
|
+
type: "month",
|
|
81
113
|
}),
|
|
82
114
|
getSiteById(site),
|
|
83
115
|
]);
|
|
@@ -93,7 +125,7 @@ export function useNFCPatrolMonthlyReport(
|
|
|
93
125
|
address: buildAddress(siteInfo.address),
|
|
94
126
|
},
|
|
95
127
|
title: `Patrol Route Summary: ${routeName}`,
|
|
96
|
-
rows: logs
|
|
128
|
+
rows: mapLogsToMonthlyRows(logs),
|
|
97
129
|
};
|
|
98
130
|
} else {
|
|
99
131
|
report.value = null;
|
package/package.json
CHANGED
package/types/customer.d.ts
CHANGED
package/types/equipment.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ declare type TEquipment = {
|
|
|
6
6
|
unitOfMeasurement: string;
|
|
7
7
|
createdAt: string;
|
|
8
8
|
updatedAt: string;
|
|
9
|
+
attachment?: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
declare type TEquipmentCreate = Pick<
|
|
12
|
+
declare type TEquipmentCreate = Pick<
|
|
13
|
+
TEquipment,
|
|
14
|
+
"name" | "unitOfMeasurement" | "attachment"
|
|
15
|
+
>;
|
|
@@ -26,7 +26,7 @@ export interface NFCPatrolReportFilterOptions {
|
|
|
26
26
|
|
|
27
27
|
export interface NFCPatrolReportLocation {
|
|
28
28
|
name?: string;
|
|
29
|
-
address?: string;
|
|
29
|
+
address?: string;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface NFCPatrolRouteSummary {
|
|
@@ -77,3 +77,17 @@ export interface NFCPatrolSummaryReport {
|
|
|
77
77
|
title: string;
|
|
78
78
|
rows: NFCPatrolReportSummaryRow[];
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
export interface NFCPatrolMonthlyReportRow {
|
|
82
|
+
month: string;
|
|
83
|
+
checked: number;
|
|
84
|
+
checkedPercentage: number;
|
|
85
|
+
missed: number;
|
|
86
|
+
missedPercentage: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface NFCPatrolMonthlyReport {
|
|
90
|
+
location: NFCPatrolReportLocation;
|
|
91
|
+
title: string;
|
|
92
|
+
rows: NFCPatrolMonthlyReportRow[];
|
|
93
|
+
}
|