@7365admin1/layer-common 4.21.3 → 4.21.4-staging.340
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 +4 -4
- package/components/AnprCameraBadge.vue +220 -0
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidAccessLogDashboard.vue +29 -5
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +48 -1
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +833 -152
- package/components/Input/NRICNumber.vue +14 -2
- package/components/InvitationClientForm.vue +19 -1
- package/components/PlateNumberDisplay.vue +105 -1
- package/components/VehicleForm.vue +324 -3
- package/components/VehicleManagement.vue +346 -51
- package/components/VisitorManagement.vue +434 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +97 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/usePeople.ts +19 -0
- package/composables/useVehicle.ts +101 -1
- package/composables/useWebUsb.ts +14 -11
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +5 -2
- package/types/vehicle.d.ts +57 -2
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/vehicle-actions.ts +45 -17
|
@@ -20,11 +20,25 @@
|
|
|
20
20
|
show-header @row-click="handleRowClick"
|
|
21
21
|
@update:page="handleUpdatePage">
|
|
22
22
|
|
|
23
|
+
<!-- Residents / Season Passes / Block Listed, on the toolbar row the way
|
|
24
|
+
the other screens draw their tabs. Each tab shows every status. -->
|
|
25
|
+
<template #tabs>
|
|
26
|
+
<button v-for="tab in vehicleTabs" :key="tab.value" type="button" role="tab" class="app-tab"
|
|
27
|
+
:class="{ 'app-tab--active': activeTab === tab.value }" :aria-selected="activeTab === tab.value"
|
|
28
|
+
@click="activeTab = tab.value">
|
|
29
|
+
{{ tab.name }}
|
|
30
|
+
</button>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
23
33
|
<!-- Search joins the toolbar row rather than stacking a second one. -->
|
|
24
34
|
<template #prepend-additional>
|
|
25
35
|
<AppField v-model="searchInput" search compact placeholder="Search" klass="app-toolbar__search" />
|
|
26
36
|
</template>
|
|
27
37
|
|
|
38
|
+
<template #item.category="{ value }">
|
|
39
|
+
{{ formatValues("category", value) }}
|
|
40
|
+
</template>
|
|
41
|
+
|
|
28
42
|
<template #item.block="{ value }">
|
|
29
43
|
{{ value ? `Blk ${value}` : "" }}
|
|
30
44
|
</template>
|
|
@@ -34,7 +48,9 @@
|
|
|
34
48
|
</template>
|
|
35
49
|
|
|
36
50
|
<template #item.plates="{ value, item }">
|
|
37
|
-
<PlateNumberDisplay :plate-numbers="value" :default-value="item.plateNumber"
|
|
51
|
+
<PlateNumberDisplay :plate-numbers="value" :default-value="item.plateNumber" show-cameras
|
|
52
|
+
:active-counts="activeCameraCounts" @synced="handleSynced"
|
|
53
|
+
:show-expiry="activeTab === 'season-passes'" />
|
|
38
54
|
</template>
|
|
39
55
|
|
|
40
56
|
<!--
|
|
@@ -137,12 +153,49 @@
|
|
|
137
153
|
the colour word keeps the width and lets the edge fall back to
|
|
138
154
|
`--v-border-color`, which is the design's `--border` in each theme. -->
|
|
139
155
|
<v-card flat outlined class="pa-2" border="sm" :loading="loadingPlateNumberDetails">
|
|
140
|
-
<v-data-table :items="selectedVehicleObject[key]" :headers="
|
|
156
|
+
<v-data-table :items="selectedVehicleObject[key]" :headers="plateHeadersView" hide-default-footer>
|
|
157
|
+
<!-- A season pass's dates, large enough to read at a
|
|
158
|
+
glance: green while valid, red once expired. -->
|
|
159
|
+
<template #item.passDates="{ item: pass }">
|
|
160
|
+
<div class="pass-dates">
|
|
161
|
+
<div class="pass-dates__line">
|
|
162
|
+
<span class="pass-date">{{ formatPassDate((pass as any).start) }}</span>
|
|
163
|
+
</div>
|
|
164
|
+
<div class="pass-dates__line">
|
|
165
|
+
<span v-if="(pass as any).end" class="pass-date pass-date--end"
|
|
166
|
+
:class="isPassExpired((pass as any).end) ? 'pass-date--expired' : 'pass-date--valid'">
|
|
167
|
+
<v-icon :icon="isPassExpired((pass as any).end) ? 'mdi-alert-circle' : 'mdi-calendar-check'" size="18" />
|
|
168
|
+
{{ formatPassDate((pass as any).end) }}
|
|
169
|
+
<span class="pass-date__tag">{{ isPassExpired((pass as any).end) ? "Expired" : "Valid" }}</span>
|
|
170
|
+
</span>
|
|
171
|
+
<span v-else class="pass-date">-</span>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
</template>
|
|
175
|
+
<template #item.remarks="{ value }">
|
|
176
|
+
<span class="plate-remarks">{{ String(value ?? "").trim() || "N/A" }}</span>
|
|
177
|
+
</template>
|
|
141
178
|
<template #item.status="{ value }">
|
|
142
179
|
<v-chip :color="formatVehicleStatus(value).color" size="x-small" dark>
|
|
143
180
|
{{ formatVehicleStatus(value).label }}
|
|
144
181
|
</v-chip>
|
|
145
182
|
</template>
|
|
183
|
+
<template #item.plateNumber="{ value, item: plateNumberItem }">
|
|
184
|
+
<span class="d-inline-flex align-center ga-2">
|
|
185
|
+
{{ value }}
|
|
186
|
+
<AnprCameraBadge :cameras="(plateNumberItem as any).anprCameras ?? []" :plate-number="value"
|
|
187
|
+
:plate-id="(plateNumberItem as any)._id ?? ''" :status="(plateNumberItem as any).status ?? ''"
|
|
188
|
+
:type="(plateNumberItem as any).type ?? ''" :active-counts="activeCameraCounts"
|
|
189
|
+
@synced="handleSynced" />
|
|
190
|
+
</span>
|
|
191
|
+
</template>
|
|
192
|
+
<template #item.type="{ value }">
|
|
193
|
+
{{ formatValues("type", value) }}
|
|
194
|
+
</template>
|
|
195
|
+
<template #item.history="{ item: plateNumberItem }">
|
|
196
|
+
<v-btn icon="mdi-history" flat size="x-small" aria-label="History"
|
|
197
|
+
v-tooltip:top="'History'" @click="openHistory(plateNumberItem as TPlateNumber)" />
|
|
198
|
+
</template>
|
|
146
199
|
<template #item.action="{ item: plateNumberItem }">
|
|
147
200
|
<v-menu v-if="vehiclePlateActions(plateNumberItem, vehiclePermissions).length">
|
|
148
201
|
<template #activator="{ props: menuProps }">
|
|
@@ -158,8 +211,9 @@
|
|
|
158
211
|
</v-menu>
|
|
159
212
|
</template>
|
|
160
213
|
</v-data-table>
|
|
161
|
-
|
|
162
|
-
|
|
214
|
+
<!-- More plates are added to a resident only. -->
|
|
215
|
+
<v-btn v-if="activeTab === 'residents'" text="Add Vehicle Number" class="mt-6 text-capitalize"
|
|
216
|
+
prepend-icon="mdi-plus" @click="addNewPlateNumbers" color="primary" />
|
|
163
217
|
</v-card>
|
|
164
218
|
</v-col>
|
|
165
219
|
|
|
@@ -205,10 +259,49 @@
|
|
|
205
259
|
:prompt-title="`Are you sure want to restore this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
|
|
206
260
|
@proceed="submitRestore" @close="closeActionDialog('restoreVehicle')" />
|
|
207
261
|
</v-dialog>
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
262
|
+
<!-- Block / Unblock say what happens on the cameras, because that is the
|
|
263
|
+
part the operator cannot see from here. -->
|
|
264
|
+
<v-dialog v-model="dialog.blockVehicle" persistent width="540">
|
|
265
|
+
<DialogReusablePrompt :loading="blockingVehicle" :message="actionError"
|
|
266
|
+
:prompt-title="`Block vehicle ${selectedPlateNumberObject?.plateNumber}? It is added to every ANPR camera's blocklist and taken off the allowed list. Its status becomes Blocked and its category Block Listed.`"
|
|
267
|
+
@proceed="submitBlock" @close="closeActionDialog('blockVehicle')" />
|
|
268
|
+
</v-dialog>
|
|
269
|
+
<v-dialog v-model="dialog.unblockVehicle" persistent width="540">
|
|
270
|
+
<DialogReusablePrompt :loading="unblockingVehicle" :message="actionError"
|
|
271
|
+
:prompt-title="`Unblock vehicle ${selectedPlateNumberObject?.plateNumber}? It is taken off every ANPR camera's blocklist. It is NOT whitelisted - the record stays with status Unblocked.`"
|
|
272
|
+
@proceed="submitUnblock" @close="closeActionDialog('unblockVehicle')" />
|
|
273
|
+
</v-dialog>
|
|
274
|
+
|
|
275
|
+
<!-- The last 20 changes to one plate, newest first. -->
|
|
276
|
+
<v-dialog v-model="dialog.history" width="720">
|
|
277
|
+
<v-card>
|
|
278
|
+
<v-card-title class="d-flex align-center">
|
|
279
|
+
<span>History - {{ historyPlate?.plateNumber }}</span>
|
|
280
|
+
<v-spacer />
|
|
281
|
+
<v-btn icon="mdi-close" flat size="small" aria-label="Close" @click="dialog.history = false" />
|
|
282
|
+
</v-card-title>
|
|
283
|
+
<v-card-text>
|
|
284
|
+
<v-alert v-if="historyError" type="error" variant="tonal" density="compact" class="mb-3">
|
|
285
|
+
{{ historyError }}
|
|
286
|
+
</v-alert>
|
|
287
|
+
<v-data-table :items="historyItems" :headers="historyHeaders" :loading="loadingHistory"
|
|
288
|
+
density="compact" hide-default-footer :items-per-page="-1"
|
|
289
|
+
no-data-text="No changes recorded yet.">
|
|
290
|
+
<template #item.updatedAt="{ value }">
|
|
291
|
+
{{ value ? formatDate(value) : "" }}
|
|
292
|
+
</template>
|
|
293
|
+
<template #item.action="{ value }">
|
|
294
|
+
{{ historyActionLabel(value) }}
|
|
295
|
+
</template>
|
|
296
|
+
<template #item.updatedByName="{ item: entry }">
|
|
297
|
+
{{ entry.updatedByName || (entry.updatedBy ? "Unknown user" : "System") }}
|
|
298
|
+
</template>
|
|
299
|
+
<template #item.fields="{ value }">
|
|
300
|
+
{{ formatHistoryFields(value) }}
|
|
301
|
+
</template>
|
|
302
|
+
</v-data-table>
|
|
303
|
+
</v-card-text>
|
|
304
|
+
</v-card>
|
|
212
305
|
</v-dialog>
|
|
213
306
|
<Snackbar v-model="messageSnackbar" :text="message" :color="messageColor" />
|
|
214
307
|
</v-row>
|
|
@@ -260,13 +353,95 @@ const plateHeaders = [
|
|
|
260
353
|
{ title: "Plate Number", value: "plateNumber" },
|
|
261
354
|
{ title: "Type", value: "type" },
|
|
262
355
|
{ title: "Status", value: "status" },
|
|
263
|
-
{ title: "", value: "
|
|
356
|
+
{ title: "", value: "history", sortable: false },
|
|
357
|
+
{ title: "", value: "action", sortable: false },
|
|
264
358
|
]
|
|
265
359
|
|
|
360
|
+
/**
|
|
361
|
+
* The Season Passes tab also shows each pass's start and expiry; the Block
|
|
362
|
+
* Listed tab shows each vehicle's remarks (why it was blocked).
|
|
363
|
+
*/
|
|
364
|
+
const plateHeadersView = computed(() => {
|
|
365
|
+
if (activeTab.value === "season-passes")
|
|
366
|
+
return [
|
|
367
|
+
plateHeaders[0],
|
|
368
|
+
{ title: "Start / Expiry", value: "passDates", sortable: false },
|
|
369
|
+
...plateHeaders.slice(2),
|
|
370
|
+
]
|
|
371
|
+
if (activeTab.value === "block-listed")
|
|
372
|
+
return [
|
|
373
|
+
...plateHeaders.slice(0, 3),
|
|
374
|
+
{ title: "Remarks", value: "remarks", sortable: false },
|
|
375
|
+
...plateHeaders.slice(3),
|
|
376
|
+
]
|
|
377
|
+
return plateHeaders
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
/** Same as the form's date fields: 09/21/2036 07:35 PM. */
|
|
381
|
+
function formatPassDate(value: unknown): string {
|
|
382
|
+
if (!value) return "-"
|
|
383
|
+
const date = new Date(value as any)
|
|
384
|
+
if (Number.isNaN(date.getTime())) return "-"
|
|
385
|
+
const pad = (n: number) => String(n).padStart(2, "0")
|
|
386
|
+
const hours = date.getHours()
|
|
387
|
+
return (
|
|
388
|
+
`${pad(date.getMonth() + 1)}/${pad(date.getDate())}/${date.getFullYear()} ` +
|
|
389
|
+
`${pad(hours % 12 || 12)}:${pad(date.getMinutes())} ${hours < 12 ? "AM" : "PM"}`
|
|
390
|
+
)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function isPassExpired(value: unknown): boolean {
|
|
394
|
+
const date = new Date(value as any)
|
|
395
|
+
return !Number.isNaN(date.getTime()) && date.getTime() <= Date.now()
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const historyHeaders = [
|
|
399
|
+
{ title: "Date", value: "updatedAt" },
|
|
400
|
+
{ title: "Updated By", value: "updatedByName" },
|
|
401
|
+
{ title: "Action", value: "action" },
|
|
402
|
+
{ title: "Fields Updated", value: "fields", sortable: false },
|
|
403
|
+
]
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* The three tabs. The server decides what each holds (`view`):
|
|
407
|
+
* - Residents: whitelist vehicles, category resident
|
|
408
|
+
* - Season Passes: category season_pass (and older passes saved as resident
|
|
409
|
+
* with a season pass type)
|
|
410
|
+
* - Block Listed: every blocklist vehicle - visitor, contractor, or a
|
|
411
|
+
* resident / season pass that was blocked
|
|
412
|
+
*/
|
|
413
|
+
type TVehicleTab = "residents" | "season-passes" | "block-listed";
|
|
414
|
+
const vehicleTabs: { name: string; value: TVehicleTab }[] = [
|
|
415
|
+
{ name: "Residents", value: "residents" },
|
|
416
|
+
{ name: "Season Passes", value: "season-passes" },
|
|
417
|
+
{ name: "Block Listed", value: "block-listed" },
|
|
418
|
+
]
|
|
419
|
+
const activeTab = ref<TVehicleTab>("residents");
|
|
420
|
+
|
|
266
421
|
|
|
267
422
|
|
|
268
423
|
const { formatCamelCaseToWords, formatDate, debounce, maskNRIC } = useUtils();
|
|
269
|
-
const { getVehicles, deleteVehicle, formatVehicleStatus, approveVehicle,
|
|
424
|
+
const { getVehicles, deleteVehicle, formatVehicleStatus, approveVehicle, blockVehicle, unblockVehicle, getSpecificVehicleById, getActiveCameraCounts } = useVehicle();
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Active ANPR cameras per list at the site. A live plate on fewer cameras
|
|
428
|
+
* than this shows "Sync" beside its badge. Re-read on every list refresh, so a
|
|
429
|
+
* camera switched on elsewhere is picked up.
|
|
430
|
+
*/
|
|
431
|
+
const activeCameraCounts = ref<{ allowed: number; blocked: number } | null>(null);
|
|
432
|
+
|
|
433
|
+
async function loadActiveCameraCounts() {
|
|
434
|
+
try {
|
|
435
|
+
activeCameraCounts.value = await getActiveCameraCounts(props.site);
|
|
436
|
+
} catch {
|
|
437
|
+
activeCameraCounts.value = null;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
async function handleSynced(result: { ok: boolean; message: string }) {
|
|
442
|
+
showMessage(result.message, result.ok ? "success" : "error");
|
|
443
|
+
await getVehiclesRefresh();
|
|
444
|
+
}
|
|
270
445
|
|
|
271
446
|
const items = ref<Array<Record<string, any>>>([]);
|
|
272
447
|
const page = ref(1);
|
|
@@ -282,11 +457,16 @@ const loadingPlateNumberDetails = ref(false);
|
|
|
282
457
|
const deletingVehicle = ref(false);
|
|
283
458
|
const approvingVehicle = ref(false);
|
|
284
459
|
const restoringVehicle = ref(false);
|
|
285
|
-
const
|
|
460
|
+
const blockingVehicle = ref(false);
|
|
461
|
+
const unblockingVehicle = ref(false);
|
|
462
|
+
const loadingHistory = ref(false);
|
|
463
|
+
const historyError = ref("");
|
|
464
|
+
const historyPlate = ref<TPlateNumber | null>(null);
|
|
465
|
+
const historyItems = ref<TVehicleHistoryEntry[]>([]);
|
|
286
466
|
|
|
287
467
|
const selectedVehicleId = ref<string | null>(null)
|
|
288
468
|
const vehicleType = ref<TVehicleType | 'seasonpass' | null>(null);
|
|
289
|
-
|
|
469
|
+
|
|
290
470
|
|
|
291
471
|
const selectedPlateNumberObject = ref<TPlateNumber | null>(null);
|
|
292
472
|
const selectedPlateNumberId = ref<string | null>(null); // individual plate number
|
|
@@ -302,7 +482,7 @@ const deleteError = ref("");
|
|
|
302
482
|
// and whose refusals were being thrown at a snackbar that times out.
|
|
303
483
|
const actionError = ref("");
|
|
304
484
|
|
|
305
|
-
function closeActionDialog(key: "approveVehicle" | "restoreVehicle" | "
|
|
485
|
+
function closeActionDialog(key: "approveVehicle" | "restoreVehicle" | "blockVehicle" | "unblockVehicle") {
|
|
306
486
|
dialog[key] = false;
|
|
307
487
|
actionError.value = "";
|
|
308
488
|
}
|
|
@@ -321,15 +501,24 @@ const dialog = reactive({
|
|
|
321
501
|
showMoreActions: false,
|
|
322
502
|
approveVehicle: false,
|
|
323
503
|
restoreVehicle: false,
|
|
324
|
-
|
|
504
|
+
blockVehicle: false,
|
|
505
|
+
unblockVehicle: false,
|
|
506
|
+
history: false,
|
|
325
507
|
bulkVehicle: false
|
|
326
508
|
});
|
|
327
509
|
|
|
328
510
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
511
|
+
|
|
512
|
+
const VEHICLE_CATEGORY_LABELS: Record<string, string> = {
|
|
513
|
+
resident: "Resident",
|
|
514
|
+
season_pass: "Season Pass",
|
|
515
|
+
visitor: "Visitor",
|
|
516
|
+
contractor: "Contractor",
|
|
517
|
+
delivery: "Delivery",
|
|
518
|
+
"pick-up": "Pick-up",
|
|
519
|
+
"drop-off": "Drop-off",
|
|
520
|
+
"Block Listed": "Block Listed",
|
|
521
|
+
}
|
|
333
522
|
|
|
334
523
|
const formattedFields: Partial<Record<keyof TVehicle, string>> = {
|
|
335
524
|
name: "Name",
|
|
@@ -359,8 +548,9 @@ function formatValues(key: string, value: any) {
|
|
|
359
548
|
return formatDate(value)
|
|
360
549
|
case "end":
|
|
361
550
|
return formatDate(value)
|
|
362
|
-
case "type":
|
|
363
551
|
case "category":
|
|
552
|
+
return VEHICLE_CATEGORY_LABELS[String(value)] ?? String(value);
|
|
553
|
+
case "type":
|
|
364
554
|
return String(value).charAt(0).toUpperCase() + String(value).slice(1).toLowerCase();
|
|
365
555
|
}
|
|
366
556
|
|
|
@@ -376,7 +566,6 @@ const handleCloseAll = () => {
|
|
|
376
566
|
dialog.createVehicle = false;
|
|
377
567
|
dialog.updateVehicle = false;
|
|
378
568
|
dialog.showSelection = false;
|
|
379
|
-
dialog.updateVehicleType = false;
|
|
380
569
|
mode.value = "add";
|
|
381
570
|
vehicleType.value = null;
|
|
382
571
|
}
|
|
@@ -420,7 +609,7 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
|
|
|
420
609
|
getVehicles({
|
|
421
610
|
page: page.value,
|
|
422
611
|
search: searchInput.value,
|
|
423
|
-
|
|
612
|
+
view: activeTab.value,
|
|
424
613
|
site: props.site,
|
|
425
614
|
}),
|
|
426
615
|
{
|
|
@@ -430,6 +619,7 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
|
|
|
430
619
|
|
|
431
620
|
|
|
432
621
|
watch(getVehiclesReq, (newData: any) => {
|
|
622
|
+
loadActiveCameraCounts();
|
|
433
623
|
items.value = newData?.items || [];
|
|
434
624
|
pages.value = newData?.pages || 0;
|
|
435
625
|
pageRange.value = newData?.pageRange || "-- - -- of --";
|
|
@@ -494,10 +684,57 @@ function handleRestoreVehicle(item: TPlateNumber) {
|
|
|
494
684
|
dialog.restoreVehicle = true;
|
|
495
685
|
}
|
|
496
686
|
|
|
497
|
-
function
|
|
687
|
+
function handleBlockVehicle(item: TPlateNumber) {
|
|
688
|
+
selectedPlateNumberObject.value = item || null;
|
|
689
|
+
actionError.value = "";
|
|
690
|
+
dialog.blockVehicle = true;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
function handleUnblockVehicle(item: TPlateNumber) {
|
|
498
694
|
selectedPlateNumberObject.value = item || null;
|
|
499
695
|
actionError.value = "";
|
|
500
|
-
dialog.
|
|
696
|
+
dialog.unblockVehicle = true;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const HISTORY_ACTIONS: Record<string, string> = {
|
|
700
|
+
created: "Created",
|
|
701
|
+
updated: "Updated",
|
|
702
|
+
approved: "Approved",
|
|
703
|
+
restored: "Restored",
|
|
704
|
+
blocked: "Blocked",
|
|
705
|
+
unblocked: "Unblocked",
|
|
706
|
+
deleted: "Deleted",
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
function historyActionLabel(action: string) {
|
|
710
|
+
if (!action) return "";
|
|
711
|
+
return HISTORY_ACTIONS[action] ?? action.charAt(0).toUpperCase() + action.slice(1);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
function formatHistoryFields(fields: string[] | undefined) {
|
|
715
|
+
if (!Array.isArray(fields) || !fields.length) return "-";
|
|
716
|
+
return fields.map((f) => formatCamelCaseToWords(f)).join(", ");
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** Fetches the plate's own record: the list does not carry `history`. */
|
|
720
|
+
async function openHistory(item: TPlateNumber) {
|
|
721
|
+
historyPlate.value = item || null;
|
|
722
|
+
historyItems.value = [];
|
|
723
|
+
historyError.value = "";
|
|
724
|
+
dialog.history = true;
|
|
725
|
+
if (!item?._id) return;
|
|
726
|
+
|
|
727
|
+
try {
|
|
728
|
+
loadingHistory.value = true;
|
|
729
|
+
const res: any = await getSpecificVehicleById(item._id);
|
|
730
|
+
const entries: TVehicleHistoryEntry[] = Array.isArray(res?.history) ? res.history : [];
|
|
731
|
+
// Stored oldest first; read newest first.
|
|
732
|
+
historyItems.value = [...entries].reverse();
|
|
733
|
+
} catch (error: any) {
|
|
734
|
+
historyError.value = errorConverter(error);
|
|
735
|
+
} finally {
|
|
736
|
+
loadingHistory.value = false;
|
|
737
|
+
}
|
|
501
738
|
}
|
|
502
739
|
|
|
503
740
|
/**
|
|
@@ -522,8 +759,10 @@ function runVehicleAction(key: VehicleActionKey, plate: TPlateNumber) {
|
|
|
522
759
|
return handleApproveVehicle(plate);
|
|
523
760
|
case "restore":
|
|
524
761
|
return handleRestoreVehicle(plate);
|
|
525
|
-
case "
|
|
526
|
-
return
|
|
762
|
+
case "block":
|
|
763
|
+
return handleBlockVehicle(plate);
|
|
764
|
+
case "unblock":
|
|
765
|
+
return handleUnblockVehicle(plate);
|
|
527
766
|
case "delete":
|
|
528
767
|
return handleDeleteVehicleAction(plate);
|
|
529
768
|
}
|
|
@@ -648,49 +887,46 @@ async function submitRestore() {
|
|
|
648
887
|
}
|
|
649
888
|
|
|
650
889
|
|
|
651
|
-
async function
|
|
652
|
-
|
|
653
|
-
|
|
890
|
+
async function submitBlock() {
|
|
654
891
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
if (!type) {
|
|
660
|
-
showMessage("Invalid vehicle type.", "error");
|
|
892
|
+
if (!vehicleId) {
|
|
893
|
+
showMessage("Invalid vehicle selected for blocking.", "error");
|
|
661
894
|
return;
|
|
662
895
|
}
|
|
663
896
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
897
|
+
try {
|
|
898
|
+
blockingVehicle.value = true;
|
|
899
|
+
actionError.value = "";
|
|
900
|
+
const res = await blockVehicle({ site: props.site, id: vehicleId as string });
|
|
901
|
+
closeActionDialog("blockVehicle");
|
|
902
|
+
showMessage(res.message, "success");
|
|
903
|
+
await getVehiclesRefresh();
|
|
904
|
+
} catch (error: any) {
|
|
905
|
+
actionError.value = errorConverter(error);
|
|
906
|
+
} finally {
|
|
907
|
+
blockingVehicle.value = false;
|
|
675
908
|
}
|
|
909
|
+
}
|
|
676
910
|
|
|
677
911
|
|
|
912
|
+
async function submitUnblock() {
|
|
913
|
+
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
678
914
|
if (!vehicleId) {
|
|
679
|
-
showMessage("Invalid vehicle
|
|
915
|
+
showMessage("Invalid vehicle selected for unblocking.", "error");
|
|
680
916
|
return;
|
|
681
917
|
}
|
|
682
918
|
|
|
683
919
|
try {
|
|
684
|
-
|
|
920
|
+
unblockingVehicle.value = true;
|
|
685
921
|
actionError.value = "";
|
|
686
|
-
const res = await
|
|
687
|
-
closeActionDialog("
|
|
922
|
+
const res = await unblockVehicle({ site: props.site, id: vehicleId as string });
|
|
923
|
+
closeActionDialog("unblockVehicle");
|
|
688
924
|
showMessage(res.message, "success");
|
|
689
925
|
await getVehiclesRefresh();
|
|
690
926
|
} catch (error: any) {
|
|
691
927
|
actionError.value = errorConverter(error);
|
|
692
928
|
} finally {
|
|
693
|
-
|
|
929
|
+
unblockingVehicle.value = false;
|
|
694
930
|
}
|
|
695
931
|
}
|
|
696
932
|
|
|
@@ -720,10 +956,69 @@ async function submitApprove() {
|
|
|
720
956
|
}
|
|
721
957
|
|
|
722
958
|
const debouncedSearch = debounce(getVehiclesRefresh, 500);
|
|
723
|
-
watch(
|
|
959
|
+
watch(searchInput, () => {
|
|
724
960
|
page.value = 1;
|
|
725
961
|
debouncedSearch()
|
|
726
962
|
})
|
|
727
963
|
|
|
964
|
+
// A new tab starts from its first page and loads straight away.
|
|
965
|
+
watch(activeTab, () => {
|
|
966
|
+
page.value = 1;
|
|
967
|
+
getVehiclesRefresh();
|
|
968
|
+
})
|
|
969
|
+
|
|
728
970
|
|
|
729
971
|
</script>
|
|
972
|
+
|
|
973
|
+
<style scoped>
|
|
974
|
+
.plate-remarks {
|
|
975
|
+
display: inline-block;
|
|
976
|
+
max-width: 220px;
|
|
977
|
+
white-space: pre-line;
|
|
978
|
+
word-break: break-word;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
.pass-dates {
|
|
982
|
+
display: flex;
|
|
983
|
+
flex-direction: column;
|
|
984
|
+
gap: 6px;
|
|
985
|
+
padding: 8px 0;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
.pass-dates__line {
|
|
989
|
+
display: flex;
|
|
990
|
+
align-items: center;
|
|
991
|
+
gap: 10px;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
.pass-date {
|
|
995
|
+
font-size: 16px;
|
|
996
|
+
font-weight: 600;
|
|
997
|
+
white-space: nowrap;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
.pass-date--end {
|
|
1001
|
+
display: inline-flex;
|
|
1002
|
+
align-items: center;
|
|
1003
|
+
gap: 6px;
|
|
1004
|
+
padding: 4px 10px;
|
|
1005
|
+
border-radius: 999px;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
.pass-date--valid {
|
|
1009
|
+
color: rgb(var(--v-theme-success));
|
|
1010
|
+
background: rgba(var(--v-theme-success), 0.12);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
.pass-date--expired {
|
|
1014
|
+
color: rgb(var(--v-theme-error));
|
|
1015
|
+
background: rgba(var(--v-theme-error), 0.12);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
.pass-date__tag {
|
|
1019
|
+
font-size: 12px;
|
|
1020
|
+
font-weight: 700;
|
|
1021
|
+
text-transform: uppercase;
|
|
1022
|
+
letter-spacing: 0.04em;
|
|
1023
|
+
}
|
|
1024
|
+
</style>
|