@7365admin1/layer-common 1.10.0 → 1.10.1
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/CHANGELOG.md +6 -0
- package/components/AcceptDialog.vue +44 -0
- package/components/AccessCardAddForm.vue +101 -13
- package/components/AccessManagement.vue +130 -47
- package/components/AddSupplyForm.vue +165 -0
- package/components/AreaChecklistHistoryLogs.vue +235 -0
- package/components/AreaChecklistHistoryMain.vue +176 -0
- package/components/AreaFormDialog.vue +266 -0
- package/components/AreaMain.vue +841 -0
- package/components/AttendanceCheckInOutDialog.vue +416 -0
- package/components/AttendanceDetailsDialog.vue +184 -0
- package/components/AttendanceMain.vue +155 -0
- package/components/AttendanceMapSearchDialog.vue +393 -0
- package/components/AttendanceSettingsDialog.vue +398 -0
- package/components/BuildingManagement/buildings.vue +5 -5
- package/components/BuildingManagement/units.vue +5 -5
- package/components/ChecklistItemRow.vue +54 -0
- package/components/CheckoutItemMain.vue +705 -0
- package/components/CleaningScheduleMain.vue +271 -0
- package/components/DocumentManagement.vue +4 -0
- package/components/EntryPass/QrTemplatePreview.vue +104 -0
- package/components/EntryPassMain.vue +252 -200
- package/components/HygieneUpdateMoreAction.vue +238 -0
- package/components/ManageChecklistMain.vue +384 -0
- package/components/MemberMain.vue +48 -20
- package/components/MyAttendanceMain.vue +224 -0
- package/components/OnlineFormsConfiguration.vue +9 -2
- package/components/PhotoUpload.vue +410 -0
- package/components/ScheduleAreaMain.vue +313 -0
- package/components/ScheduleTaskAreaFormDialog.vue +144 -0
- package/components/ScheduleTaskAreaUpdateMoreAction.vue +109 -0
- package/components/ScheduleTaskForm.vue +471 -0
- package/components/ScheduleTaskMain.vue +345 -0
- package/components/ScheduleTastTicketMain.vue +182 -0
- package/components/StockCard.vue +191 -0
- package/components/SupplyManagementMain.vue +557 -0
- package/components/TableHygiene.vue +617 -0
- package/components/UnitMain.vue +451 -0
- package/components/VisitorManagement.vue +28 -15
- package/composables/useAccessManagement.ts +90 -0
- package/composables/useAreaPermission.ts +51 -0
- package/composables/useAreas.ts +99 -0
- package/composables/useAttendance.ts +89 -0
- package/composables/useAttendancePermission.ts +68 -0
- package/composables/useBuilding.ts +2 -2
- package/composables/useBuildingUnit.ts +2 -2
- package/composables/useCard.ts +2 -0
- package/composables/useCheckout.ts +61 -0
- package/composables/useCheckoutPermission.ts +80 -0
- package/composables/useCleaningPermission.ts +229 -0
- package/composables/useCleaningSchedulePermission.ts +58 -0
- package/composables/useCleaningSchedules.ts +233 -0
- package/composables/useCountry.ts +8 -0
- package/composables/useDashboardData.ts +2 -2
- package/composables/useFeedback.ts +1 -1
- package/composables/useLocation.ts +78 -0
- package/composables/useOnlineForm.ts +16 -9
- package/composables/usePeople.ts +87 -72
- package/composables/useQR.ts +29 -0
- package/composables/useScheduleTask.ts +89 -0
- package/composables/useScheduleTaskArea.ts +85 -0
- package/composables/useScheduleTaskPermission.ts +68 -0
- package/composables/useSiteEntryPassSettings.ts +4 -15
- package/composables/useStock.ts +45 -0
- package/composables/useSupply.ts +63 -0
- package/composables/useSupplyPermission.ts +92 -0
- package/composables/useUnitPermission.ts +51 -0
- package/composables/useUnits.ts +82 -0
- package/composables/useWebUsb.ts +389 -0
- package/composables/useWorkOrder.ts +1 -1
- package/nuxt.config.ts +3 -0
- package/package.json +4 -1
- package/types/area.d.ts +22 -0
- package/types/attendance.d.ts +38 -0
- package/types/checkout-item.d.ts +27 -0
- package/types/cleaner-schedule.d.ts +54 -0
- package/types/location.d.ts +42 -0
- package/types/schedule-task.d.ts +18 -0
- package/types/stock.d.ts +16 -0
- package/types/supply.d.ts +11 -0
- package/utils/acm-crypto.ts +30 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function useCleaningSchedulePermission() {
|
|
2
|
+
const { hasPermission } = usePermission();
|
|
3
|
+
const { permissions } = useCleaningPermission();
|
|
4
|
+
|
|
5
|
+
const { userAppRole } = useLocalSetup();
|
|
6
|
+
|
|
7
|
+
const canViewSchedules = computed(() => {
|
|
8
|
+
if (!userAppRole.value) return true;
|
|
9
|
+
if (userAppRole.value.permissions.includes("*")) return true;
|
|
10
|
+
return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "see-all-schedules");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const canViewScheduleDetails = computed(() => {
|
|
14
|
+
if (!userAppRole.value) return true;
|
|
15
|
+
if (userAppRole.value.permissions.includes("*")) return true;
|
|
16
|
+
return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "see-schedule-details");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const canDownloadSchedule = computed(() => {
|
|
20
|
+
if (!userAppRole.value) return true;
|
|
21
|
+
if (userAppRole.value.permissions.includes("*")) return true;
|
|
22
|
+
return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "download-schedule");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const canManageScheduleTasks = computed(() => {
|
|
26
|
+
if (!userAppRole.value) return true;
|
|
27
|
+
if (userAppRole.value.permissions.includes("*")) return true;
|
|
28
|
+
return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "manage-schedule-tasks");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const canGenerateChecklist = computed(() => {
|
|
32
|
+
if (!userAppRole.value) return true;
|
|
33
|
+
if (userAppRole.value.permissions.includes("*")) return true;
|
|
34
|
+
return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "generate-checklist");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const canViewHistory = computed(() => {
|
|
38
|
+
if (!userAppRole.value) return true;
|
|
39
|
+
if (userAppRole.value.permissions.includes("*")) return true;
|
|
40
|
+
return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "view-history");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const canAddRemarks = computed(() => {
|
|
44
|
+
if (!userAppRole.value) return true;
|
|
45
|
+
if (userAppRole.value.permissions.includes("*")) return true;
|
|
46
|
+
return hasPermission(userAppRole.value, permissions, "cleaning-schedule-mgmt", "add-remarks");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
canViewSchedules,
|
|
51
|
+
canViewScheduleDetails,
|
|
52
|
+
canDownloadSchedule,
|
|
53
|
+
canManageScheduleTasks,
|
|
54
|
+
canGenerateChecklist,
|
|
55
|
+
canViewHistory,
|
|
56
|
+
canAddRemarks,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
export default function useCleaningSchedules() {
|
|
2
|
+
const _cleanerChecklists = ref({
|
|
3
|
+
_id: "",
|
|
4
|
+
date: "",
|
|
5
|
+
status: [],
|
|
6
|
+
createdAt: "",
|
|
7
|
+
updatedAt: "",
|
|
8
|
+
attachments: [],
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
async function getCleaningSchedules({
|
|
12
|
+
site = "",
|
|
13
|
+
search = "",
|
|
14
|
+
page = 1,
|
|
15
|
+
limit = 10,
|
|
16
|
+
startDate = "",
|
|
17
|
+
endDate = "",
|
|
18
|
+
status = "",
|
|
19
|
+
} = {}) {
|
|
20
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
21
|
+
`/api/hygiene-parent-checklist/site/${site}`,
|
|
22
|
+
{
|
|
23
|
+
method: "GET",
|
|
24
|
+
query: {
|
|
25
|
+
search,
|
|
26
|
+
page,
|
|
27
|
+
limit,
|
|
28
|
+
startDate,
|
|
29
|
+
endDate,
|
|
30
|
+
status,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function getScheduleAreas({
|
|
37
|
+
scheduleAreaId = "",
|
|
38
|
+
page = 1,
|
|
39
|
+
limit = 10,
|
|
40
|
+
search = "",
|
|
41
|
+
status = "",
|
|
42
|
+
type = "",
|
|
43
|
+
} = {}) {
|
|
44
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
45
|
+
`/api/hygiene-area-checklist/schedule/${scheduleAreaId}`,
|
|
46
|
+
{
|
|
47
|
+
method: "GET",
|
|
48
|
+
query: {
|
|
49
|
+
search,
|
|
50
|
+
page,
|
|
51
|
+
limit,
|
|
52
|
+
status,
|
|
53
|
+
type,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function acceptAreaChecklist(id: string) {
|
|
60
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
61
|
+
`/api/hygiene-area-checklist/id/${id}/accept`,
|
|
62
|
+
{
|
|
63
|
+
method: "PATCH",
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function getUnitCleanerChecklist({
|
|
69
|
+
scheduleAreaId = "",
|
|
70
|
+
page = 1,
|
|
71
|
+
limit = 10,
|
|
72
|
+
search = "",
|
|
73
|
+
} = {}) {
|
|
74
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
75
|
+
`/api/hygiene-area-checklist/id/${scheduleAreaId}/units`,
|
|
76
|
+
{
|
|
77
|
+
method: "GET",
|
|
78
|
+
query: {
|
|
79
|
+
search,
|
|
80
|
+
page,
|
|
81
|
+
limit,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function updateUnitChecklist(
|
|
88
|
+
checklistId: string,
|
|
89
|
+
unitId: string,
|
|
90
|
+
set: number,
|
|
91
|
+
decision: "approve" | "reject",
|
|
92
|
+
remarks?: string,
|
|
93
|
+
attachment?: string[],
|
|
94
|
+
) {
|
|
95
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
96
|
+
`/api/hygiene-area-checklist/id/${checklistId}/set/${set}/units/${unitId}/${decision}`,
|
|
97
|
+
{
|
|
98
|
+
method: "PATCH",
|
|
99
|
+
body: { remarks, attachment },
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function updateAreaChecklistStatus(
|
|
105
|
+
id: string,
|
|
106
|
+
status: "complete" | "submit",
|
|
107
|
+
signature: string,
|
|
108
|
+
) {
|
|
109
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
110
|
+
`/api/hygiene-area-checklist/id/${id}/${status}`,
|
|
111
|
+
{
|
|
112
|
+
method: "PATCH",
|
|
113
|
+
body: { signature },
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function uploadAreaChecklistAttachment(id: string, attachments: string[]) {
|
|
119
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
120
|
+
`/api/hygiene-area-checklist/id/${id}/upload`,
|
|
121
|
+
{
|
|
122
|
+
method: "PATCH",
|
|
123
|
+
body: { attachments },
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function generateChecklist(site: string, parentChecklistId: string) {
|
|
129
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
130
|
+
`/api/hygiene-area-checklist/site/${site}/schedule/${parentChecklistId}`,
|
|
131
|
+
{
|
|
132
|
+
method: "POST",
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function getAreaChecklistHistory({
|
|
138
|
+
parentChecklistId = "",
|
|
139
|
+
page = 1,
|
|
140
|
+
limit = 10,
|
|
141
|
+
search = "",
|
|
142
|
+
status = "",
|
|
143
|
+
} = {}) {
|
|
144
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
145
|
+
`/api/hygiene-area-checklist/schedule/${parentChecklistId}/history`,
|
|
146
|
+
{
|
|
147
|
+
method: "GET",
|
|
148
|
+
query: { page, limit, search, status },
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function getAreaChecklistHistoryById(id: string) {
|
|
154
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
155
|
+
`/api/hygiene-area-checklist/id/${id}/history`,
|
|
156
|
+
{
|
|
157
|
+
method: "GET",
|
|
158
|
+
},
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function exportAreas(site: string) {
|
|
163
|
+
const res = await useNuxtApp().$api<Blob | MediaSource>(
|
|
164
|
+
`/api/hygiene-area/site/${site}/download`,
|
|
165
|
+
{
|
|
166
|
+
method: "GET",
|
|
167
|
+
},
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
if (!res) throw new Error("Error downloading areas");
|
|
171
|
+
|
|
172
|
+
const date = new Date();
|
|
173
|
+
const formattedDate = `${String(date.getMonth() + 1).padStart(
|
|
174
|
+
2,
|
|
175
|
+
"0",
|
|
176
|
+
)}-${String(date.getDate()).padStart(2, "0")}-${date.getFullYear()}`;
|
|
177
|
+
|
|
178
|
+
const downloadUrl = window.URL.createObjectURL(res);
|
|
179
|
+
const a = document.createElement("a");
|
|
180
|
+
a.href = downloadUrl;
|
|
181
|
+
a.download = `areas-${formattedDate}.xlsx`;
|
|
182
|
+
document.body.appendChild(a);
|
|
183
|
+
a.click();
|
|
184
|
+
document.body.removeChild(a);
|
|
185
|
+
window.URL.revokeObjectURL(downloadUrl);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async function downloadChecklistPdf(scheduleId: string) {
|
|
189
|
+
const res = await useNuxtApp().$api<Blob | MediaSource>(
|
|
190
|
+
`/api/hygiene-area-checklist/schedule/${scheduleId}/pdf`,
|
|
191
|
+
{
|
|
192
|
+
method: "GET",
|
|
193
|
+
responseType: "blob",
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
if (!res) throw new Error("Error downloading checklist PDF");
|
|
198
|
+
|
|
199
|
+
const date = new Date();
|
|
200
|
+
const formattedDate = `${String(date.getDate()).padStart(2, "0")}_${String(
|
|
201
|
+
date.getMonth() + 1,
|
|
202
|
+
).padStart(2, "0")}_${date.getFullYear()} ${String(
|
|
203
|
+
date.getHours(),
|
|
204
|
+
).padStart(2, "0")}_${String(date.getMinutes()).padStart(2, "0")}`;
|
|
205
|
+
|
|
206
|
+
const downloadUrl = window.URL.createObjectURL(res);
|
|
207
|
+
const a = document.createElement("a");
|
|
208
|
+
a.href = downloadUrl;
|
|
209
|
+
a.download = `CHECKLIST_DOWNLOADED_${formattedDate}.pdf`;
|
|
210
|
+
a.target = "_blank";
|
|
211
|
+
a.rel = "noopener noreferrer";
|
|
212
|
+
document.body.appendChild(a);
|
|
213
|
+
a.click();
|
|
214
|
+
document.body.removeChild(a);
|
|
215
|
+
setTimeout(() => window.URL.revokeObjectURL(downloadUrl), 1000);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
_cleanerChecklists,
|
|
220
|
+
getCleaningSchedules,
|
|
221
|
+
getScheduleAreas,
|
|
222
|
+
acceptAreaChecklist,
|
|
223
|
+
updateUnitChecklist,
|
|
224
|
+
getUnitCleanerChecklist,
|
|
225
|
+
updateAreaChecklistStatus,
|
|
226
|
+
uploadAreaChecklistAttachment,
|
|
227
|
+
generateChecklist,
|
|
228
|
+
getAreaChecklistHistory,
|
|
229
|
+
getAreaChecklistHistoryById,
|
|
230
|
+
exportAreas,
|
|
231
|
+
downloadChecklistPdf,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
@@ -145,7 +145,7 @@ const dashboardDataMap: Record<string, ModuleData> = {
|
|
|
145
145
|
color: '#7E57C2',
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
|
-
title: '
|
|
148
|
+
title: 'Checkout Items',
|
|
149
149
|
value: 19,
|
|
150
150
|
percentage: 5.1,
|
|
151
151
|
isPositive: true,
|
|
@@ -167,7 +167,7 @@ const dashboardDataMap: Record<string, ModuleData> = {
|
|
|
167
167
|
'Schedule Task Ticket',
|
|
168
168
|
'Attendance',
|
|
169
169
|
'Supply Management',
|
|
170
|
-
'
|
|
170
|
+
'Checkout Items',
|
|
171
171
|
'Cleaning Schedule - Checklist, Area, Unit',
|
|
172
172
|
],
|
|
173
173
|
},
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export default function useLocation() {
|
|
2
|
+
function getCountries() {
|
|
3
|
+
return useNuxtApp()
|
|
4
|
+
.$api<Record<string, any>>("/json/country.json", {
|
|
5
|
+
method: "GET",
|
|
6
|
+
})
|
|
7
|
+
.then((countries) =>
|
|
8
|
+
countries
|
|
9
|
+
.map((c: any) => c.name)
|
|
10
|
+
.sort((a: string, b: string) => a.localeCompare(b)),
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getAddressByPostalCode(postalCode: string, country?: string) {
|
|
15
|
+
const countryISOMap: Record<string, string> = {
|
|
16
|
+
Singapore: "sg",
|
|
17
|
+
Malaysia: "my",
|
|
18
|
+
"United States": "us",
|
|
19
|
+
"United Kingdom": "gb",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const isoCode = country
|
|
23
|
+
? countryISOMap[country] || country.toLowerCase()
|
|
24
|
+
: undefined;
|
|
25
|
+
|
|
26
|
+
return useNuxtApp()
|
|
27
|
+
.$api<Record<string, any>[]>(
|
|
28
|
+
"https://nominatim.openstreetmap.org/search",
|
|
29
|
+
{
|
|
30
|
+
method: "GET",
|
|
31
|
+
query: {
|
|
32
|
+
postalcode: postalCode,
|
|
33
|
+
country: isoCode,
|
|
34
|
+
format: "json",
|
|
35
|
+
limit: 1,
|
|
36
|
+
addressdetails: 1,
|
|
37
|
+
},
|
|
38
|
+
headers: {
|
|
39
|
+
"User-Agent": "iService365-Hygiene-App",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
.then((data) => (data?.length ? data[0] : null));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function searchLocationByAddress({
|
|
47
|
+
postalCode,
|
|
48
|
+
city,
|
|
49
|
+
address,
|
|
50
|
+
country,
|
|
51
|
+
}: TLocationSearchParams) {
|
|
52
|
+
const searchParts = [postalCode, city, address, country].filter(Boolean);
|
|
53
|
+
|
|
54
|
+
return useNuxtApp()
|
|
55
|
+
.$api<Record<string, any>[]>(
|
|
56
|
+
"https://nominatim.openstreetmap.org/search",
|
|
57
|
+
{
|
|
58
|
+
method: "GET",
|
|
59
|
+
query: {
|
|
60
|
+
q: searchParts.join(", "),
|
|
61
|
+
format: "json",
|
|
62
|
+
limit: 1,
|
|
63
|
+
addressdetails: 1,
|
|
64
|
+
},
|
|
65
|
+
headers: {
|
|
66
|
+
"User-Agent": "iService365-Hygiene-App",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
)
|
|
70
|
+
.then((data) => (data?.length ? data[0] : null));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
getCountries,
|
|
75
|
+
getAddressByPostalCode,
|
|
76
|
+
searchLocationByAddress,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -24,19 +24,26 @@ export default function useOnlineForm() {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
function getOnlineFormById(id: string) {
|
|
27
|
-
return useNuxtApp().$api<Record<string, any>>(
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
28
|
+
`/api/online-forms/id/${id}`,
|
|
29
|
+
{
|
|
30
|
+
method: "GET",
|
|
31
|
+
}
|
|
32
|
+
);
|
|
30
33
|
}
|
|
31
34
|
function updateOnlineFormById(id: string, value: any) {
|
|
32
|
-
return useNuxtApp().$api<Record<string, any>>(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
36
|
+
`/api/online-forms/id/${id}`,
|
|
37
|
+
{
|
|
38
|
+
method: "PUT",
|
|
39
|
+
body: value,
|
|
40
|
+
}
|
|
41
|
+
);
|
|
36
42
|
}
|
|
37
43
|
function deleteOnlineFormById(id: string) {
|
|
38
|
-
return useNuxtApp().$api(`/api/online-forms/
|
|
39
|
-
method: "
|
|
44
|
+
return useNuxtApp().$api(`/api/online-forms/deleted/online-form`, {
|
|
45
|
+
method: "PUT",
|
|
46
|
+
query: { id },
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
function getAllBySiteId(
|
package/composables/usePeople.ts
CHANGED
|
@@ -1,88 +1,103 @@
|
|
|
1
|
-
export default function(){
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
query: { page, limit, sort, search, org, site, dateTo, dateFrom, type }
|
|
19
|
-
});
|
|
1
|
+
export default function () {
|
|
2
|
+
async function getAll({
|
|
3
|
+
page = 1,
|
|
4
|
+
limit = 10,
|
|
5
|
+
sort = "asc",
|
|
6
|
+
search = "",
|
|
7
|
+
org = "",
|
|
8
|
+
site = "",
|
|
9
|
+
dateTo = "",
|
|
10
|
+
dateFrom = "",
|
|
11
|
+
type = "",
|
|
12
|
+
displayNoCheckOut = false,
|
|
13
|
+
} = {}) {
|
|
14
|
+
return await useNuxtApp().$api<Record<string, any>>("/api/people", {
|
|
15
|
+
method: "GET",
|
|
16
|
+
query: { page, limit, sort, search, org, site, dateTo, dateFrom, type },
|
|
17
|
+
});
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
async function findPersonByNRIC(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
async function findPersonByNRIC(
|
|
21
|
+
nric: string
|
|
22
|
+
): Promise<null | Partial<TPeople>> {
|
|
23
|
+
return await $fetch<Record<string, any>>(`/api/people/nric/${nric}`, {
|
|
24
|
+
method: "GET",
|
|
25
|
+
});
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async function findPersonByContact(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
async function findPersonByContact(
|
|
29
|
+
contact: string
|
|
30
|
+
): Promise<null | Partial<TPeople>> {
|
|
31
|
+
return await $fetch<Record<string, any>>(`/api/people/contact/${contact}`, {
|
|
32
|
+
method: "GET",
|
|
33
|
+
});
|
|
32
34
|
}
|
|
33
|
-
async function findUsersByPlateNumber(
|
|
34
|
-
|
|
35
|
+
async function findUsersByPlateNumber(
|
|
36
|
+
plateNumber: string
|
|
37
|
+
): Promise<null | Partial<TPeople>> {
|
|
38
|
+
return await $fetch<Record<string, any>>(
|
|
39
|
+
`/api/people/plateNumber/${plateNumber}`,
|
|
40
|
+
{
|
|
35
41
|
method: "GET",
|
|
36
|
-
query: { limit: 20 }
|
|
37
|
-
}
|
|
42
|
+
query: { limit: 20 },
|
|
43
|
+
}
|
|
44
|
+
);
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
async function searchCompanyList(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
async function searchCompanyList(
|
|
48
|
+
company: string
|
|
49
|
+
): Promise<null | Partial<TPeople>> {
|
|
50
|
+
return await $fetch<Record<string, any>>("/api/people/company", {
|
|
51
|
+
method: "GET",
|
|
52
|
+
query: { search: company },
|
|
53
|
+
});
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
async function create(payload: Partial<TPeoplePayload>) {
|
|
57
|
+
return await useNuxtApp().$api<Record<string, any>>("/api/people", {
|
|
58
|
+
method: "POST",
|
|
59
|
+
body: payload,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
53
62
|
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
async function updateById(_id: string, payload: Partial<TPeoplePayload>) {
|
|
64
|
+
return await useNuxtApp().$api<Record<string, any>>(
|
|
65
|
+
`/api/people/id/${_id}`,
|
|
66
|
+
{
|
|
56
67
|
method: "PUT",
|
|
57
68
|
body: payload,
|
|
58
|
-
}
|
|
59
|
-
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
async function deleteById(_id: string) {
|
|
74
|
+
return await useNuxtApp().$api<Record<string, any>>(`/api/people/${_id}`, {
|
|
75
|
+
method: "PUT",
|
|
76
|
+
});
|
|
77
|
+
}
|
|
66
78
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
async function getPeopleByUnit(
|
|
80
|
+
_id: string,
|
|
81
|
+
{ status = "active", type = "resident" } = {}
|
|
82
|
+
) {
|
|
83
|
+
return await useNuxtApp().$api<Record<string, any>>(
|
|
84
|
+
`/api/people/unit/${_id}`,
|
|
85
|
+
{
|
|
86
|
+
method: "GET",
|
|
87
|
+
query: { status, type },
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
76
91
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
92
|
+
return {
|
|
93
|
+
create,
|
|
94
|
+
getAll,
|
|
95
|
+
updateById,
|
|
96
|
+
deleteById,
|
|
97
|
+
findPersonByNRIC,
|
|
98
|
+
findPersonByContact,
|
|
99
|
+
getPeopleByUnit,
|
|
100
|
+
searchCompanyList,
|
|
101
|
+
findUsersByPlateNumber,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default function useQR() {
|
|
2
|
+
async function downloadQR(url: string, filename: string = "qrcode") {
|
|
3
|
+
const res = await useNuxtApp().$api<Blob | MediaSource>(
|
|
4
|
+
`/api/hygiene-qr/generate`,
|
|
5
|
+
{
|
|
6
|
+
method: "GET",
|
|
7
|
+
query: {
|
|
8
|
+
url,
|
|
9
|
+
filename,
|
|
10
|
+
},
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
if (!res) throw new Error("Error downloading QR code");
|
|
15
|
+
|
|
16
|
+
const downloadUrl = window.URL.createObjectURL(res);
|
|
17
|
+
const a = document.createElement("a");
|
|
18
|
+
a.href = downloadUrl;
|
|
19
|
+
a.download = `${filename}.png`;
|
|
20
|
+
document.body.appendChild(a);
|
|
21
|
+
a.click();
|
|
22
|
+
document.body.removeChild(a);
|
|
23
|
+
window.URL.revokeObjectURL(downloadUrl);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
downloadQR,
|
|
28
|
+
};
|
|
29
|
+
}
|