@7365admin1/layer-common 4.21.4-staging.339 → 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/components/AnprCameraBadge.vue +79 -1
- package/components/Input/NRICNumber.vue +14 -2
- package/components/PlateNumberDisplay.vue +14 -0
- package/components/VehicleForm.vue +78 -1
- package/components/VehicleManagement.vue +56 -12
- package/components/VisitorManagement.vue +79 -2
- package/composables/useVehicle.ts +18 -0
- package/package.json +1 -1
|
@@ -9,6 +9,23 @@
|
|
|
9
9
|
<template>
|
|
10
10
|
<!-- Only drawn when the plate is on at least one camera (inactive ones
|
|
11
11
|
included - a camera that went inactive still holds the plate). -->
|
|
12
|
+
<!-- "Sync": the plate is on fewer cameras than the site has active for its
|
|
13
|
+
list (e.g. it was saved while they were inactive). Puts it on every
|
|
14
|
+
active camera of its list that lacks it. -->
|
|
15
|
+
<button
|
|
16
|
+
v-if="showSync"
|
|
17
|
+
type="button"
|
|
18
|
+
class="anpr-badge anpr-badge--sync"
|
|
19
|
+
:disabled="syncing"
|
|
20
|
+
:aria-label="`Sync ${plateNumber} to all active ANPR cameras`"
|
|
21
|
+
v-tooltip:top="`On ${count} of ${expected} active camera${expected === 1 ? '' : 's'} - sync to all`"
|
|
22
|
+
@click.stop="sync"
|
|
23
|
+
>
|
|
24
|
+
<v-progress-circular v-if="syncing" indeterminate size="11" width="2" />
|
|
25
|
+
<v-icon v-else icon="mdi-sync" size="13" />
|
|
26
|
+
Sync
|
|
27
|
+
</button>
|
|
28
|
+
|
|
12
29
|
<v-menu v-if="count > 0" location="bottom start" :close-on-content-click="false">
|
|
13
30
|
<template #activator="{ props: menuProps }">
|
|
14
31
|
<button
|
|
@@ -45,14 +62,64 @@
|
|
|
45
62
|
</template>
|
|
46
63
|
|
|
47
64
|
<script setup lang="ts">
|
|
65
|
+
import useVehicle from "../composables/useVehicle";
|
|
66
|
+
import { errorConverter } from "../utils/data";
|
|
67
|
+
|
|
48
68
|
const props = defineProps({
|
|
49
69
|
cameras: {
|
|
50
70
|
type: Array as PropType<TVehicleAnprCamera[]>,
|
|
51
71
|
default: () => [],
|
|
52
72
|
},
|
|
53
73
|
plateNumber: { type: String, default: "" },
|
|
74
|
+
/** For Sync: the plate's own record, its status and list. */
|
|
75
|
+
plateId: { type: String, default: "" },
|
|
76
|
+
status: { type: String, default: "" },
|
|
77
|
+
type: { type: String, default: "" },
|
|
78
|
+
/** Active cameras per list at the site; null hides Sync. */
|
|
79
|
+
activeCounts: {
|
|
80
|
+
type: Object as PropType<{ allowed: number; blocked: number } | null>,
|
|
81
|
+
default: null,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const emit = defineEmits<{
|
|
86
|
+
(event: "synced", result: { ok: boolean; message: string }): void;
|
|
87
|
+
}>();
|
|
88
|
+
|
|
89
|
+
const { syncVehicle } = useVehicle();
|
|
90
|
+
const syncing = ref(false);
|
|
91
|
+
|
|
92
|
+
const LIVE = ["active", "temporary", "blocked"];
|
|
93
|
+
|
|
94
|
+
/** Active cameras for this plate's list. */
|
|
95
|
+
const expected = computed(() => {
|
|
96
|
+
if (!props.activeCounts) return 0;
|
|
97
|
+
return props.type === "blocklist"
|
|
98
|
+
? props.activeCounts.blocked
|
|
99
|
+
: props.activeCounts.allowed;
|
|
54
100
|
});
|
|
55
101
|
|
|
102
|
+
const showSync = computed(
|
|
103
|
+
() =>
|
|
104
|
+
!!props.plateId &&
|
|
105
|
+
LIVE.includes(props.status) &&
|
|
106
|
+
expected.value > 0 &&
|
|
107
|
+
count.value < expected.value
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
async function sync() {
|
|
111
|
+
if (syncing.value) return;
|
|
112
|
+
syncing.value = true;
|
|
113
|
+
try {
|
|
114
|
+
const res: any = await syncVehicle(props.plateId);
|
|
115
|
+
emit("synced", { ok: !res?.failed, message: res?.message || "Synced." });
|
|
116
|
+
} catch (error: any) {
|
|
117
|
+
emit("synced", { ok: false, message: errorConverter(error) });
|
|
118
|
+
} finally {
|
|
119
|
+
syncing.value = false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
56
123
|
const DIRECTION_LABELS: Record<string, string> = {
|
|
57
124
|
entry: "Entry",
|
|
58
125
|
exit: "Exit",
|
|
@@ -79,7 +146,7 @@ const uniqueCameras = computed(() => {
|
|
|
79
146
|
});
|
|
80
147
|
});
|
|
81
148
|
|
|
82
|
-
const count = computed(() => uniqueCameras.value.length);
|
|
149
|
+
const count = computed<number>(() => uniqueCameras.value.length);
|
|
83
150
|
const isBlocked = computed(() => props.cameras?.some((c) => c.list === "blocked"));
|
|
84
151
|
</script>
|
|
85
152
|
|
|
@@ -98,6 +165,17 @@ const isBlocked = computed(() => props.cameras?.some((c) => c.list === "blocked"
|
|
|
98
165
|
cursor: pointer;
|
|
99
166
|
}
|
|
100
167
|
|
|
168
|
+
.anpr-badge--sync {
|
|
169
|
+
margin-left: 4px;
|
|
170
|
+
color: var(--primary, rgb(var(--v-theme-primary)));
|
|
171
|
+
border-color: currentColor;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.anpr-badge--sync:disabled {
|
|
175
|
+
opacity: 0.6;
|
|
176
|
+
cursor: progress;
|
|
177
|
+
}
|
|
178
|
+
|
|
101
179
|
.anpr-badge--blocked {
|
|
102
180
|
color: var(--err);
|
|
103
181
|
}
|
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
:counter="maxlength"
|
|
9
9
|
@input="onInput"
|
|
10
10
|
:loading="loading"
|
|
11
|
+
:type="masked && !shown ? 'password' : 'text'"
|
|
12
|
+
:append-inner-icon="masked ? (shown ? 'mdi-eye-off' : 'mdi-eye') : undefined"
|
|
13
|
+
autocomplete="off"
|
|
11
14
|
outlined
|
|
12
15
|
clearable
|
|
16
|
+
@click:append-inner="shown = !shown"
|
|
13
17
|
/>
|
|
14
18
|
</template>
|
|
15
19
|
|
|
@@ -31,9 +35,16 @@ const props = defineProps({
|
|
|
31
35
|
loading: {
|
|
32
36
|
type: Boolean,
|
|
33
37
|
default: false
|
|
38
|
+
},
|
|
39
|
+
/** Shown as *** with an eye to reveal it, like a password. */
|
|
40
|
+
masked: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
34
43
|
}
|
|
35
44
|
})
|
|
36
45
|
|
|
46
|
+
const shown = ref(false)
|
|
47
|
+
|
|
37
48
|
const emit = defineEmits(['update:modelValue'])
|
|
38
49
|
|
|
39
50
|
const model = defineModel({required: true})
|
|
@@ -41,8 +52,9 @@ const model = defineModel({required: true})
|
|
|
41
52
|
function onInput(event) {
|
|
42
53
|
const value = typeof event === 'string' ? event : event?.target?.value || ''
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
// Same rule as the Whitelist (Bulk) sheet (`bulkIdNumber`): capitals,
|
|
56
|
+
// digits and symbols such as - or /, but no spaces, commas or dots.
|
|
57
|
+
const formatted = value.replace(/[\s,.]/g, '').toUpperCase()
|
|
46
58
|
|
|
47
59
|
model.value = formatted || ""
|
|
48
60
|
}
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
v-if="showCameras"
|
|
10
10
|
:cameras="plate.anprCameras ?? []"
|
|
11
11
|
:plate-number="plate.plateNumber"
|
|
12
|
+
:plate-id="plate._id ?? ''"
|
|
13
|
+
:status="plate.status ?? ''"
|
|
14
|
+
:type="plate.type ?? ''"
|
|
15
|
+
:active-counts="activeCounts"
|
|
16
|
+
@synced="(result) => emit('synced', result)"
|
|
12
17
|
/>
|
|
13
18
|
</span>
|
|
14
19
|
<!-- A season pass's expiry under its number: green while valid, red
|
|
@@ -59,6 +64,11 @@ const props = defineProps({
|
|
|
59
64
|
type: Boolean,
|
|
60
65
|
default: false
|
|
61
66
|
},
|
|
67
|
+
/** Active ANPR cameras per list at the site - lets the badge offer Sync. */
|
|
68
|
+
activeCounts: {
|
|
69
|
+
type: Object as PropType<{ allowed: number; blocked: number } | null>,
|
|
70
|
+
default: null
|
|
71
|
+
},
|
|
62
72
|
/** The ANPR camera badge beside each vehicle number. */
|
|
63
73
|
showCameras: {
|
|
64
74
|
type: Boolean,
|
|
@@ -88,6 +98,10 @@ function expiryOf(plate: any): { label: string; expired: boolean } | null {
|
|
|
88
98
|
}
|
|
89
99
|
}
|
|
90
100
|
|
|
101
|
+
const emit = defineEmits<{
|
|
102
|
+
(event: "synced", result: { ok: boolean; message: string }): void
|
|
103
|
+
}>()
|
|
104
|
+
|
|
91
105
|
const shownPlates = computed<any[]>(() => {
|
|
92
106
|
const plates = (props.plateNumbers ?? []).filter((v: any) => v?.plateNumber)
|
|
93
107
|
return props.showAll ? plates : plates.slice(0, 2)
|
|
@@ -69,6 +69,27 @@
|
|
|
69
69
|
the Season Pass dialog report. An empty field has nothing unresolved
|
|
70
70
|
to redraw, so it has nothing to gain from the remount.
|
|
71
71
|
-->
|
|
72
|
+
<!-- A Block Listed vehicle's block / level / unit: taken from the
|
|
73
|
+
visitor transaction it was blocked from, and shown read-only -
|
|
74
|
+
here and when the vehicle is edited later. -->
|
|
75
|
+
<template v-if="readonlyLocation">
|
|
76
|
+
<v-col cols="12">
|
|
77
|
+
<InputLabel class="text-capitalize" title="Block" />
|
|
78
|
+
<v-text-field :model-value="readonlyLocation.block || 'N/A'" density="comfortable" readonly
|
|
79
|
+
class="class-readonly" />
|
|
80
|
+
</v-col>
|
|
81
|
+
<v-col cols="12">
|
|
82
|
+
<InputLabel class="text-capitalize" title="Level" />
|
|
83
|
+
<v-text-field :model-value="readonlyLocation.level || 'N/A'" density="comfortable" readonly
|
|
84
|
+
class="class-readonly" />
|
|
85
|
+
</v-col>
|
|
86
|
+
<v-col cols="12">
|
|
87
|
+
<InputLabel class="text-capitalize" title="Unit" />
|
|
88
|
+
<v-text-field :model-value="readonlyLocation.unit || 'N/A'" density="comfortable" readonly
|
|
89
|
+
class="class-readonly" />
|
|
90
|
+
</v-col>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
72
93
|
<v-col v-if="shouldShowField('block')" cols="12">
|
|
73
94
|
<InputLabel class="text-capitalize" title="Block" required />
|
|
74
95
|
<v-autocomplete
|
|
@@ -131,6 +152,7 @@
|
|
|
131
152
|
<InputNRICNumber
|
|
132
153
|
v-model="vehicle.nric"
|
|
133
154
|
density="comfortable"
|
|
155
|
+
masked
|
|
134
156
|
:disabled="
|
|
135
157
|
disablePrefilledInputs &&
|
|
136
158
|
type !== 'blocklist' &&
|
|
@@ -253,7 +275,8 @@
|
|
|
253
275
|
</v-col>
|
|
254
276
|
</v-row>
|
|
255
277
|
|
|
256
|
-
|
|
278
|
+
<!-- One vehicle number per Block Listed vehicle. -->
|
|
279
|
+
<AppButton v-if="type !== 'blocklist'" variant="ghost" icon="mdi-plus" @click="addPlate">
|
|
257
280
|
Add Plate
|
|
258
281
|
</AppButton>
|
|
259
282
|
</template>
|
|
@@ -539,6 +562,18 @@ const prop = defineProps({
|
|
|
539
562
|
type: String,
|
|
540
563
|
default: "",
|
|
541
564
|
},
|
|
565
|
+
/**
|
|
566
|
+
* Blocking from a visitor transaction: the visit's block / level / unit,
|
|
567
|
+
* saved on the Block Listed vehicle and shown read-only.
|
|
568
|
+
*/
|
|
569
|
+
presetLocation: {
|
|
570
|
+
type: Object as PropType<{
|
|
571
|
+
block?: { id: string; name: string };
|
|
572
|
+
level?: { id: string; name: string };
|
|
573
|
+
unit?: { id: string; name: string };
|
|
574
|
+
} | null>,
|
|
575
|
+
default: null,
|
|
576
|
+
},
|
|
542
577
|
});
|
|
543
578
|
|
|
544
579
|
const { requiredRule, debounce } = useUtils();
|
|
@@ -587,6 +622,40 @@ const vehicle = reactive<
|
|
|
587
622
|
plateNumber: "",
|
|
588
623
|
});
|
|
589
624
|
|
|
625
|
+
/**
|
|
626
|
+
* The read-only Block / Level / Unit of a Block Listed vehicle: from the
|
|
627
|
+
* visitor transaction when blocking from Visitor Mgmt, or the location the
|
|
628
|
+
* vehicle already has when it is edited. Null when there is none to show.
|
|
629
|
+
*/
|
|
630
|
+
const readonlyLocation = computed(() => {
|
|
631
|
+
if (prop.type !== "blocklist") return null;
|
|
632
|
+
|
|
633
|
+
if (prop.mode === "add") {
|
|
634
|
+
const loc = prop.presetLocation;
|
|
635
|
+
if (!loc) return null;
|
|
636
|
+
const out = {
|
|
637
|
+
block: loc.block?.name ?? "",
|
|
638
|
+
level: loc.level?.name ?? "",
|
|
639
|
+
unit: loc.unit?.name ?? "",
|
|
640
|
+
};
|
|
641
|
+
return out.block || out.level || out.unit ? out : null;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
const data: any = prop.vehicleData ?? {};
|
|
645
|
+
const nameOf = (value: any) => {
|
|
646
|
+
if (!value) return "";
|
|
647
|
+
if (typeof value === "object") return String(value.name ?? "");
|
|
648
|
+
return String(prop.nameHints?.[String(value)] ?? "");
|
|
649
|
+
};
|
|
650
|
+
const hasAny = data.block || data.level || data.unit;
|
|
651
|
+
if (!hasAny) return null;
|
|
652
|
+
return {
|
|
653
|
+
block: nameOf(data.block),
|
|
654
|
+
level: nameOf(data.level),
|
|
655
|
+
unit: nameOf(data.unit) || String(data.unitName ?? ""),
|
|
656
|
+
};
|
|
657
|
+
});
|
|
658
|
+
|
|
590
659
|
const newPlateNumbers = ref<string[]>([prop.prefillPlate ? prop.prefillPlate : ""]);
|
|
591
660
|
|
|
592
661
|
type TBlocklistCategory = "visitor" | "contractor" | "delivery" | "pick-up" | "drop-off";
|
|
@@ -1208,6 +1277,14 @@ async function submit() {
|
|
|
1208
1277
|
payload = {
|
|
1209
1278
|
...payload,
|
|
1210
1279
|
remarks,
|
|
1280
|
+
// The visit's location, when blocked from a visitor transaction.
|
|
1281
|
+
...(prop.mode === "add" && prop.presetLocation
|
|
1282
|
+
? {
|
|
1283
|
+
...(prop.presetLocation.block?.id && { block: prop.presetLocation.block.id }),
|
|
1284
|
+
...(prop.presetLocation.level?.id && { level: prop.presetLocation.level.id }),
|
|
1285
|
+
...(prop.presetLocation.unit?.id && { unit: prop.presetLocation.unit.id }),
|
|
1286
|
+
}
|
|
1287
|
+
: {}),
|
|
1211
1288
|
};
|
|
1212
1289
|
}
|
|
1213
1290
|
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
|
|
50
50
|
<template #item.plates="{ value, item }">
|
|
51
51
|
<PlateNumberDisplay :plate-numbers="value" :default-value="item.plateNumber" show-cameras
|
|
52
|
+
:active-counts="activeCameraCounts" @synced="handleSynced"
|
|
52
53
|
:show-expiry="activeTab === 'season-passes'" />
|
|
53
54
|
</template>
|
|
54
55
|
|
|
@@ -171,6 +172,9 @@
|
|
|
171
172
|
</div>
|
|
172
173
|
</div>
|
|
173
174
|
</template>
|
|
175
|
+
<template #item.remarks="{ value }">
|
|
176
|
+
<span class="plate-remarks">{{ String(value ?? "").trim() || "N/A" }}</span>
|
|
177
|
+
</template>
|
|
174
178
|
<template #item.status="{ value }">
|
|
175
179
|
<v-chip :color="formatVehicleStatus(value).color" size="x-small" dark>
|
|
176
180
|
{{ formatVehicleStatus(value).label }}
|
|
@@ -179,7 +183,10 @@
|
|
|
179
183
|
<template #item.plateNumber="{ value, item: plateNumberItem }">
|
|
180
184
|
<span class="d-inline-flex align-center ga-2">
|
|
181
185
|
{{ value }}
|
|
182
|
-
<AnprCameraBadge :cameras="(plateNumberItem as any).anprCameras ?? []" :plate-number="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" />
|
|
183
190
|
</span>
|
|
184
191
|
</template>
|
|
185
192
|
<template #item.type="{ value }">
|
|
@@ -350,16 +357,25 @@ const plateHeaders = [
|
|
|
350
357
|
{ title: "", value: "action", sortable: false },
|
|
351
358
|
]
|
|
352
359
|
|
|
353
|
-
/**
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
]
|
|
361
|
-
|
|
362
|
-
)
|
|
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
|
+
})
|
|
363
379
|
|
|
364
380
|
/** Same as the form's date fields: 09/21/2036 07:35 PM. */
|
|
365
381
|
function formatPassDate(value: unknown): string {
|
|
@@ -405,7 +421,27 @@ const activeTab = ref<TVehicleTab>("residents");
|
|
|
405
421
|
|
|
406
422
|
|
|
407
423
|
const { formatCamelCaseToWords, formatDate, debounce, maskNRIC } = useUtils();
|
|
408
|
-
const { getVehicles, deleteVehicle, formatVehicleStatus, approveVehicle, blockVehicle, unblockVehicle, getSpecificVehicleById } = useVehicle();
|
|
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
|
+
}
|
|
409
445
|
|
|
410
446
|
const items = ref<Array<Record<string, any>>>([]);
|
|
411
447
|
const page = ref(1);
|
|
@@ -583,6 +619,7 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
|
|
|
583
619
|
|
|
584
620
|
|
|
585
621
|
watch(getVehiclesReq, (newData: any) => {
|
|
622
|
+
loadActiveCameraCounts();
|
|
586
623
|
items.value = newData?.items || [];
|
|
587
624
|
pages.value = newData?.pages || 0;
|
|
588
625
|
pageRange.value = newData?.pageRange || "-- - -- of --";
|
|
@@ -934,6 +971,13 @@ watch(activeTab, () => {
|
|
|
934
971
|
</script>
|
|
935
972
|
|
|
936
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
|
+
|
|
937
981
|
.pass-dates {
|
|
938
982
|
display: flex;
|
|
939
983
|
flex-direction: column;
|
|
@@ -913,7 +913,25 @@
|
|
|
913
913
|
<div class="visitor-preview__label">{{ label }}</div>
|
|
914
914
|
<div class="visitor-preview__value d-flex align-center justify-space-between ga-2">
|
|
915
915
|
<span>{{ selectedVisitorObject[key] }}</span>
|
|
916
|
-
|
|
916
|
+
<!-- Already in Block Listed: greyed "Blocked" that only says so
|
|
917
|
+
when pressed, rather than opening the form again. -->
|
|
918
|
+
<AppButton
|
|
919
|
+
v-if="selectedPlateBlocked"
|
|
920
|
+
variant="ghost"
|
|
921
|
+
icon="mdi-cancel"
|
|
922
|
+
class="visitor-preview__blocked"
|
|
923
|
+
:aria-disabled="true"
|
|
924
|
+
@click="showMessage(`${selectedVisitorRow.plateNumber} is already in Block Listed.`, 'info')"
|
|
925
|
+
>
|
|
926
|
+
Blocked
|
|
927
|
+
</AppButton>
|
|
928
|
+
<AppButton
|
|
929
|
+
v-else
|
|
930
|
+
variant="err"
|
|
931
|
+
icon="mdi-cancel"
|
|
932
|
+
:disabled="checkingBlockedPlate"
|
|
933
|
+
@click="openBlockVehicle"
|
|
934
|
+
>
|
|
917
935
|
Block
|
|
918
936
|
</AppButton>
|
|
919
937
|
</div>
|
|
@@ -950,6 +968,7 @@
|
|
|
950
968
|
:vehicle-data="blockVehicleData"
|
|
951
969
|
:preset-category="blockVehicleCategory"
|
|
952
970
|
:prefill-plate="blockVehiclePlate"
|
|
971
|
+
:preset-location="blockVehicleLocation"
|
|
953
972
|
@done="handleBlockVehicleDone"
|
|
954
973
|
@back="dialog.blockVehicle = false"
|
|
955
974
|
@close="dialog.blockVehicle = false"
|
|
@@ -1785,22 +1804,74 @@ const canBlockSelectedVehicle = computed(() => {
|
|
|
1785
1804
|
const blockVehiclePlate = ref("");
|
|
1786
1805
|
const blockVehicleCategory = ref("");
|
|
1787
1806
|
const blockVehicleData = ref<Record<string, any>>({});
|
|
1807
|
+
const blockVehicleLocation = ref<Record<string, any> | null>(null);
|
|
1808
|
+
|
|
1809
|
+
/** An id and a name from a visitor field that may be an object or an id. */
|
|
1810
|
+
function locationPart(value: any, fallbackName = "") {
|
|
1811
|
+
if (!value && !fallbackName) return undefined;
|
|
1812
|
+
const id = typeof value === "object" && value ? String(value._id ?? "") : String(value ?? "");
|
|
1813
|
+
const name = (typeof value === "object" && value ? String(value.name ?? "") : "") || fallbackName;
|
|
1814
|
+
return id || name ? { id, name } : undefined;
|
|
1815
|
+
}
|
|
1788
1816
|
|
|
1789
1817
|
function openBlockVehicle() {
|
|
1790
1818
|
const row = selectedVisitorRow.value;
|
|
1791
1819
|
blockVehiclePlate.value = String(row?.plateNumber ?? "").trim().toUpperCase();
|
|
1792
1820
|
blockVehicleCategory.value = blockCategoryForVisitorType(row?.type);
|
|
1821
|
+
// The visit's block / level / unit, saved on the vehicle and shown read-only.
|
|
1822
|
+
blockVehicleLocation.value = {
|
|
1823
|
+
block: locationPart(row?.block),
|
|
1824
|
+
level: locationPart(row?.level),
|
|
1825
|
+
unit: locationPart(row?.unit, String(row?.unitName ?? "")),
|
|
1826
|
+
};
|
|
1827
|
+
// Remarks are left empty: the reason for blocking is not the visit's remarks.
|
|
1793
1828
|
blockVehicleData.value = {
|
|
1794
1829
|
name: row?.name ?? "",
|
|
1795
1830
|
nric: row?.nric ?? "",
|
|
1796
1831
|
phoneNumber: row?.contact ?? "",
|
|
1797
|
-
remarks:
|
|
1832
|
+
remarks: "",
|
|
1798
1833
|
};
|
|
1799
1834
|
dialog.blockVehicle = true;
|
|
1800
1835
|
}
|
|
1801
1836
|
|
|
1837
|
+
/**
|
|
1838
|
+
* Whether the previewed plate is already in Block Listed (status "blocked"),
|
|
1839
|
+
* asked of the server each time the Preview opens and after a block.
|
|
1840
|
+
*/
|
|
1841
|
+
const { checkExistingPlates } = useVehicle();
|
|
1842
|
+
const selectedPlateBlocked = ref(false);
|
|
1843
|
+
const checkingBlockedPlate = ref(false);
|
|
1844
|
+
|
|
1845
|
+
async function refreshSelectedPlateBlocked() {
|
|
1846
|
+
selectedPlateBlocked.value = false;
|
|
1847
|
+
const plate = String(selectedVisitorRow.value?.plateNumber ?? "").trim();
|
|
1848
|
+
if (!plate || !canBlockSelectedVehicle.value) return;
|
|
1849
|
+
checkingBlockedPlate.value = true;
|
|
1850
|
+
try {
|
|
1851
|
+
const res = await checkExistingPlates({ site: siteId, plateNumbers: [plate] });
|
|
1852
|
+
// Only if the Preview still shows the same plate when the answer arrives.
|
|
1853
|
+
if (String(selectedVisitorRow.value?.plateNumber ?? "").trim() !== plate) return;
|
|
1854
|
+
selectedPlateBlocked.value = (res?.items ?? []).some(
|
|
1855
|
+
(item) => item.status === "blocked"
|
|
1856
|
+
);
|
|
1857
|
+
} catch {
|
|
1858
|
+
// Unknown: leave Block available; the form says if the plate exists.
|
|
1859
|
+
} finally {
|
|
1860
|
+
checkingBlockedPlate.value = false;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
watch(
|
|
1865
|
+
() => [dialog.viewVisitor, selectedVisitorId.value],
|
|
1866
|
+
([open]) => {
|
|
1867
|
+
if (open) refreshSelectedPlateBlocked();
|
|
1868
|
+
}
|
|
1869
|
+
);
|
|
1870
|
+
|
|
1802
1871
|
function handleBlockVehicleDone() {
|
|
1803
1872
|
dialog.blockVehicle = false;
|
|
1873
|
+
// The form closes and the Preview's button turns to "Blocked".
|
|
1874
|
+
refreshSelectedPlateBlocked();
|
|
1804
1875
|
showMessage(`Vehicle ${blockVehiclePlate.value} is now in Block Listed.`, "success");
|
|
1805
1876
|
}
|
|
1806
1877
|
|
|
@@ -3252,4 +3323,10 @@ watchEffect(async () => {
|
|
|
3252
3323
|
border: 1px solid #dce3e8;
|
|
3253
3324
|
background: #fff;
|
|
3254
3325
|
}
|
|
3326
|
+
|
|
3327
|
+
/* Looks disabled, but still answers a click with "already in Block Listed". */
|
|
3328
|
+
.visitor-preview__blocked {
|
|
3329
|
+
opacity: 0.55;
|
|
3330
|
+
cursor: not-allowed;
|
|
3331
|
+
}
|
|
3255
3332
|
</style>
|
|
@@ -187,6 +187,22 @@ export default function useVehicle() {
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
/** Active ANPR cameras per list at a site: { allowed, blocked }. */
|
|
191
|
+
async function getActiveCameraCounts(site: string) {
|
|
192
|
+
return await useNuxtApp().$api<{ allowed: number; blocked: number }>(
|
|
193
|
+
`/api/vehicles/anpr-cameras/site/${site}`,
|
|
194
|
+
{ method: "GET" }
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Put a vehicle's plate on every active camera of its list that lacks it. */
|
|
199
|
+
async function syncVehicle(id: string) {
|
|
200
|
+
return await useNuxtApp().$api<{ message: string; synced: number; failed: number }>(
|
|
201
|
+
`/api/vehicles/sync/id/${id}`,
|
|
202
|
+
{ method: "PUT" }
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
190
206
|
async function getVehicleByNRIC(search: string) {
|
|
191
207
|
return await useNuxtApp().$api<Record<string, any>>(
|
|
192
208
|
`/api/vehicles/nric`,
|
|
@@ -271,6 +287,8 @@ function getSpecificVehicleById(id: string){
|
|
|
271
287
|
unblockVehicle,
|
|
272
288
|
checkExistingPlates,
|
|
273
289
|
moveVehicle,
|
|
290
|
+
getActiveCameraCounts,
|
|
291
|
+
syncVehicle,
|
|
274
292
|
searchMultipleVehiclesByUnitId,
|
|
275
293
|
getSpecificVehicleById
|
|
276
294
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.21.4-staging.
|
|
5
|
+
"version": "4.21.4-staging.340",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|