@7365admin1/layer-common 4.21.1 → 4.21.4-staging.339
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 +45 -4
- package/components/AnprCameraBadge.vue +142 -0
- package/components/CameraWall.vue +3 -1
- 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 +193 -43
- 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/InvitationClientForm.vue +19 -1
- package/components/PlateNumberDisplay.vue +91 -1
- package/components/VehicleForm.vue +246 -2
- package/components/VehicleManagement.vue +302 -51
- package/components/VisitorManagement.vue +357 -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 +83 -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/camera-wall.ts +15 -3
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/materialSymbols.ts +3 -0
- package/utils/vehicle-actions.ts +45 -17
|
@@ -388,9 +388,27 @@ watch(
|
|
|
388
388
|
const roles = ref<any[]>([])
|
|
389
389
|
const { getRoles } = useRole()
|
|
390
390
|
|
|
391
|
+
/*
|
|
392
|
+
* `type` is the ROLE type, not the service the client subscribes to, and the
|
|
393
|
+
* only caller (`ClientMain.vue` "Invite Client") passes no `app` prop -- so
|
|
394
|
+
* this sent `type: ""` and the endpoint applied no type filter at all. The
|
|
395
|
+
* dropdown therefore listed every org-less role of every type, which includes
|
|
396
|
+
* the platform's OWN staff roles (`type: "admin"` -- the two rows the console's
|
|
397
|
+
* `/super-admin/role-permissions` screen edits). Offering a Seven365 console
|
|
398
|
+
* staff role on a CLIENT invitation is the defect.
|
|
399
|
+
*
|
|
400
|
+
* A client admin's role is `type: "organization"`, which is what the client
|
|
401
|
+
* roles screen (`org/[organization]/roles-permissions.vue`) already lists. This
|
|
402
|
+
* narrows to exactly that. It is a narrowing of this one picker only: no role
|
|
403
|
+
* changes, no permission changes, and the org-less `organization` roles that
|
|
404
|
+
* were already being picked are all still offered.
|
|
405
|
+
*
|
|
406
|
+
* Keying off the selected service instead would empty the dropdown -- no
|
|
407
|
+
* org-less role carries a service type -- so `props.app` is not the filter.
|
|
408
|
+
*/
|
|
391
409
|
const { data: roleData, refresh: refreshRoles } = await useLazyAsyncData(
|
|
392
410
|
"roles",
|
|
393
|
-
() => getRoles({ org: org.value?._id, type:
|
|
411
|
+
() => getRoles({ org: org.value?._id, type: "organization", limit: 50 }),
|
|
394
412
|
{ watch: [() => props.app] }
|
|
395
413
|
)
|
|
396
414
|
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="d-flex align-center ga-2 flex-wrap">
|
|
3
|
-
|
|
3
|
+
<!-- Each vehicle number with its ANPR camera badge beside it. -->
|
|
4
|
+
<template v-if="shownPlates.length">
|
|
5
|
+
<span v-for="plate in shownPlates" :key="plate._id ?? plate.plateNumber" class="plate-display__plate">
|
|
6
|
+
<span class="d-inline-flex align-center ga-1">
|
|
7
|
+
{{ plate.plateNumber }}
|
|
8
|
+
<AnprCameraBadge
|
|
9
|
+
v-if="showCameras"
|
|
10
|
+
:cameras="plate.anprCameras ?? []"
|
|
11
|
+
:plate-number="plate.plateNumber"
|
|
12
|
+
/>
|
|
13
|
+
</span>
|
|
14
|
+
<!-- A season pass's expiry under its number: green while valid, red
|
|
15
|
+
once it has passed - the camera no longer opens for it. -->
|
|
16
|
+
<span
|
|
17
|
+
v-if="showExpiry && expiryOf(plate)"
|
|
18
|
+
class="plate-display__expiry"
|
|
19
|
+
:class="expiryOf(plate)!.expired ? 'plate-display__expiry--expired' : 'plate-display__expiry--valid'"
|
|
20
|
+
>
|
|
21
|
+
<v-icon :icon="expiryOf(plate)!.expired ? 'mdi-alert-circle' : 'mdi-calendar-check'" size="13" />
|
|
22
|
+
{{ expiryOf(plate)!.expired ? "Expired" : "Expires" }} {{ expiryOf(plate)!.label }}
|
|
23
|
+
</span>
|
|
24
|
+
</span>
|
|
25
|
+
</template>
|
|
26
|
+
<span v-else-if="formatted">
|
|
4
27
|
{{ formatted }}
|
|
5
28
|
</span>
|
|
6
29
|
|
|
@@ -30,9 +53,46 @@ const props = defineProps({
|
|
|
30
53
|
showAll: {
|
|
31
54
|
type: Boolean,
|
|
32
55
|
default: false
|
|
56
|
+
},
|
|
57
|
+
/** A season pass's expiry date under each vehicle number. */
|
|
58
|
+
showExpiry: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: false
|
|
61
|
+
},
|
|
62
|
+
/** The ANPR camera badge beside each vehicle number. */
|
|
63
|
+
showCameras: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: false
|
|
33
66
|
}
|
|
34
67
|
})
|
|
35
68
|
|
|
69
|
+
/** Same as the Expiry Date field in the form: 09/21/2036 07:35 PM. */
|
|
70
|
+
function formatExpiry(date: Date): string {
|
|
71
|
+
const pad = (n: number) => String(n).padStart(2, "0")
|
|
72
|
+
const hours = date.getHours()
|
|
73
|
+
const hour12 = hours % 12 || 12
|
|
74
|
+
return (
|
|
75
|
+
`${pad(date.getMonth() + 1)}/${pad(date.getDate())}/${date.getFullYear()} ` +
|
|
76
|
+
`${pad(hour12)}:${pad(date.getMinutes())} ${hours < 12 ? "AM" : "PM"}`
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The plate's expiry, as a date and whether it has passed. */
|
|
81
|
+
function expiryOf(plate: any): { label: string; expired: boolean } | null {
|
|
82
|
+
if (!plate?.end) return null
|
|
83
|
+
const end = new Date(plate.end)
|
|
84
|
+
if (Number.isNaN(end.getTime())) return null
|
|
85
|
+
return {
|
|
86
|
+
label: formatExpiry(end),
|
|
87
|
+
expired: end.getTime() <= Date.now(),
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const shownPlates = computed<any[]>(() => {
|
|
92
|
+
const plates = (props.plateNumbers ?? []).filter((v: any) => v?.plateNumber)
|
|
93
|
+
return props.showAll ? plates : plates.slice(0, 2)
|
|
94
|
+
})
|
|
95
|
+
|
|
36
96
|
const formatted = computed(() => {
|
|
37
97
|
if (!props.plateNumbers?.length) return props.defaultValue || ""
|
|
38
98
|
|
|
@@ -54,3 +114,33 @@ const extraCount = computed(() => {
|
|
|
54
114
|
: 0
|
|
55
115
|
})
|
|
56
116
|
</script>
|
|
117
|
+
|
|
118
|
+
<style scoped>
|
|
119
|
+
.plate-display__plate {
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
flex-direction: column;
|
|
122
|
+
gap: 2px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.plate-display__expiry {
|
|
126
|
+
display: inline-flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: 3px;
|
|
129
|
+
width: fit-content;
|
|
130
|
+
padding: 0 6px;
|
|
131
|
+
border-radius: 999px;
|
|
132
|
+
font-size: 11px;
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
line-height: 18px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.plate-display__expiry--valid {
|
|
138
|
+
color: rgb(var(--v-theme-success));
|
|
139
|
+
background: rgba(var(--v-theme-success), 0.12);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.plate-display__expiry--expired {
|
|
143
|
+
color: rgb(var(--v-theme-error));
|
|
144
|
+
background: rgba(var(--v-theme-error), 0.12);
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -139,6 +139,23 @@
|
|
|
139
139
|
/>
|
|
140
140
|
</v-col>
|
|
141
141
|
|
|
142
|
+
<!-- Category is chosen only when ADDING a Block Listed vehicle in
|
|
143
|
+
Vehicle Mgmt. Blocked from a visitor transaction it is that
|
|
144
|
+
transaction's type and is shown read-only; editing a vehicle
|
|
145
|
+
never changes it. -->
|
|
146
|
+
<v-col v-if="showCategoryField" cols="12">
|
|
147
|
+
<InputLabel class="text-capitalize" title="Category" required />
|
|
148
|
+
<v-select
|
|
149
|
+
v-model="vehicle.category"
|
|
150
|
+
:items="blocklistCategoryOptions"
|
|
151
|
+
item-title="title"
|
|
152
|
+
item-value="value"
|
|
153
|
+
density="comfortable"
|
|
154
|
+
:readonly="!!prop.presetCategory"
|
|
155
|
+
:rules="[requiredRule]"
|
|
156
|
+
/>
|
|
157
|
+
</v-col>
|
|
158
|
+
|
|
142
159
|
<v-col v-if="shouldShowField('name')" cols="12">
|
|
143
160
|
<v-row>
|
|
144
161
|
<v-col cols="12">
|
|
@@ -361,6 +378,50 @@
|
|
|
361
378
|
</AppButton>
|
|
362
379
|
</div>
|
|
363
380
|
|
|
381
|
+
<!--
|
|
382
|
+
A plate the site already holds - in any tab, with any status. Rather
|
|
383
|
+
than refusing, say where it is and let the person update that record:
|
|
384
|
+
Update saves what they entered on it and moves it to this form's tab.
|
|
385
|
+
-->
|
|
386
|
+
<v-dialog v-model="showExistingDialog" max-width="520" persistent>
|
|
387
|
+
<v-card class="screen-modal">
|
|
388
|
+
<div class="vehicle-form__head">
|
|
389
|
+
<v-card-title>Vehicle already exists</v-card-title>
|
|
390
|
+
<AppButton variant="icon" icon="mdi-close" aria-label="Close" @click="cancelExistingUpdate" />
|
|
391
|
+
</div>
|
|
392
|
+
<div class="screen-modal__body vehicle-existing__body">
|
|
393
|
+
<p v-for="item in existingPlates" :key="item._id" class="vehicle-existing__line">
|
|
394
|
+
<strong>{{ item.plateNumber }}</strong> is already in
|
|
395
|
+
<strong>{{ tabLabel(item.view) }}</strong>
|
|
396
|
+
(status: <strong>{{ formatVehicleStatus(item.status).label }}</strong>).
|
|
397
|
+
</p>
|
|
398
|
+
<p class="vehicle-existing__line">
|
|
399
|
+
<template v-if="existingPlates.every((item) => item.view === targetView)">
|
|
400
|
+
Update will save the details you entered on
|
|
401
|
+
{{ existingPlates.length > 1 ? "them" : "it" }} and keep
|
|
402
|
+
{{ existingPlates.length > 1 ? "them" : "it" }} in
|
|
403
|
+
<strong>{{ tabLabel(targetView) }}</strong>.
|
|
404
|
+
</template>
|
|
405
|
+
<template v-else>
|
|
406
|
+
Update will save the details you entered on
|
|
407
|
+
{{ existingPlates.length > 1 ? "them" : "it" }} and move
|
|
408
|
+
{{ existingPlates.length > 1 ? "them" : "it" }} to
|
|
409
|
+
<strong>{{ tabLabel(targetView) }}</strong>.
|
|
410
|
+
</template>
|
|
411
|
+
<template v-if="newPlatesAfterExisting.length">
|
|
412
|
+
{{ newPlatesAfterExisting.join(", ") }}
|
|
413
|
+
{{ newPlatesAfterExisting.length > 1 ? "are" : "is" }} new and will be added.
|
|
414
|
+
</template>
|
|
415
|
+
Do you want to proceed?
|
|
416
|
+
</p>
|
|
417
|
+
</div>
|
|
418
|
+
<div class="vehicle-form__footer">
|
|
419
|
+
<AppButton variant="ghost" :disabled="processing" @click="cancelExistingUpdate">Cancel</AppButton>
|
|
420
|
+
<AppButton :disabled="processing" @click="confirmExistingUpdate">Update</AppButton>
|
|
421
|
+
</div>
|
|
422
|
+
</v-card>
|
|
423
|
+
</v-dialog>
|
|
424
|
+
|
|
364
425
|
<v-dialog v-model="showMatchingPeopleDialog" max-width="700" persistent>
|
|
365
426
|
<v-card class="screen-modal vehicle-match" :loading="checkingUnit">
|
|
366
427
|
<div class="vehicle-form__head">
|
|
@@ -465,6 +526,19 @@ const prop = defineProps({
|
|
|
465
526
|
type: String,
|
|
466
527
|
default: "",
|
|
467
528
|
},
|
|
529
|
+
/**
|
|
530
|
+
* Blocking from a visitor transaction: the Block Listed category taken from
|
|
531
|
+
* its type (guest -> visitor, contractor / delivery / pick-up / drop-off as
|
|
532
|
+
* they are), and the plate to block.
|
|
533
|
+
*/
|
|
534
|
+
presetCategory: {
|
|
535
|
+
type: String,
|
|
536
|
+
default: "",
|
|
537
|
+
},
|
|
538
|
+
prefillPlate: {
|
|
539
|
+
type: String,
|
|
540
|
+
default: "",
|
|
541
|
+
},
|
|
468
542
|
});
|
|
469
543
|
|
|
470
544
|
const { requiredRule, debounce } = useUtils();
|
|
@@ -473,6 +547,8 @@ const {
|
|
|
473
547
|
getCustomSeasonPassTypes,
|
|
474
548
|
updateVehicle,
|
|
475
549
|
formatVehicleStatus,
|
|
550
|
+
checkExistingPlates,
|
|
551
|
+
moveVehicle,
|
|
476
552
|
} = useVehicle();
|
|
477
553
|
const { getSiteById, getSiteLevels, getSiteUnits } = useSiteSettings();
|
|
478
554
|
const { findPersonByNRICMultipleResult, getPeopleByUnit } = usePeople();
|
|
@@ -511,7 +587,56 @@ const vehicle = reactive<
|
|
|
511
587
|
plateNumber: "",
|
|
512
588
|
});
|
|
513
589
|
|
|
514
|
-
const newPlateNumbers = ref<string[]>([""]);
|
|
590
|
+
const newPlateNumbers = ref<string[]>([prop.prefillPlate ? prop.prefillPlate : ""]);
|
|
591
|
+
|
|
592
|
+
type TBlocklistCategory = "visitor" | "contractor" | "delivery" | "pick-up" | "drop-off";
|
|
593
|
+
|
|
594
|
+
const BLOCKLIST_CATEGORY_LABELS: Record<TBlocklistCategory, string> = {
|
|
595
|
+
visitor: "Visitor",
|
|
596
|
+
contractor: "Contractor",
|
|
597
|
+
delivery: "Delivery",
|
|
598
|
+
"pick-up": "Pick-up",
|
|
599
|
+
"drop-off": "Drop-off",
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
function isBlocklistCategory(value: unknown): value is TBlocklistCategory {
|
|
603
|
+
return typeof value === "string" && value in BLOCKLIST_CATEGORY_LABELS;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Vehicle Mgmt offers Visitor and Contractor. A vehicle blocked from a visitor
|
|
608
|
+
* transaction brings its own type (Delivery, say), which is offered too so the
|
|
609
|
+
* field can show it.
|
|
610
|
+
*/
|
|
611
|
+
const blocklistCategoryOptions = computed(() => {
|
|
612
|
+
const values: TBlocklistCategory[] = ["visitor", "contractor"];
|
|
613
|
+
const extra = [prop.presetCategory, vehicle.category].filter(
|
|
614
|
+
(c): c is TBlocklistCategory => isBlocklistCategory(c) && !values.includes(c)
|
|
615
|
+
);
|
|
616
|
+
return [...values, ...new Set(extra)].map((value) => ({
|
|
617
|
+
title: BLOCKLIST_CATEGORY_LABELS[value],
|
|
618
|
+
value,
|
|
619
|
+
}));
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* The Category field is for ADDING a Block Listed vehicle only - editable in
|
|
624
|
+
* Vehicle Mgmt, read-only when it comes from a visitor transaction. Editing a
|
|
625
|
+
* vehicle does not show or change its category.
|
|
626
|
+
*/
|
|
627
|
+
const showCategoryField = computed(
|
|
628
|
+
() => prop.type === "blocklist" && prop.mode === "add"
|
|
629
|
+
);
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* What the server files the vehicle under: resident for a whitelist vehicle,
|
|
633
|
+
* season_pass for a season pass, visitor / contractor for a Block Listed one.
|
|
634
|
+
*/
|
|
635
|
+
function categoryForForm(formType: string, picked: unknown): TVehicle["category"] {
|
|
636
|
+
if (formType === "seasonpass") return "season_pass";
|
|
637
|
+
if (formType === "blocklist") return isBlocklistCategory(picked) ? picked : "visitor";
|
|
638
|
+
return "resident";
|
|
639
|
+
}
|
|
515
640
|
const disablePrefilledInputs = ref(true);
|
|
516
641
|
|
|
517
642
|
const blocksArray = ref<TDefaultOptionObj[]>([]);
|
|
@@ -686,6 +811,15 @@ if (prop.vehicleData) {
|
|
|
686
811
|
Object.assign(vehicle, existingVehicleData);
|
|
687
812
|
}
|
|
688
813
|
|
|
814
|
+
// Adding from a row copies that row's category (a resident's, say), and an
|
|
815
|
+
// older blocklist record may carry "Block Listed": a Block Listed vehicle
|
|
816
|
+
// starts as a visitor until the person picks.
|
|
817
|
+
if (showCategoryField.value && isBlocklistCategory(prop.presetCategory)) {
|
|
818
|
+
vehicle.category = prop.presetCategory;
|
|
819
|
+
} else if (showCategoryField.value && !isBlocklistCategory(vehicle.category)) {
|
|
820
|
+
vehicle.category = "visitor";
|
|
821
|
+
}
|
|
822
|
+
|
|
689
823
|
const {
|
|
690
824
|
data: blocksListData,
|
|
691
825
|
refresh: refreshBlockListData,
|
|
@@ -886,6 +1020,90 @@ function showMessage(msg: string, color: string) {
|
|
|
886
1020
|
messageSnackbar.value = true;
|
|
887
1021
|
}
|
|
888
1022
|
|
|
1023
|
+
/* ---- a plate the site already holds ------------------------------------ */
|
|
1024
|
+
|
|
1025
|
+
type TExistingPlate = Awaited<ReturnType<typeof checkExistingPlates>>["items"][number];
|
|
1026
|
+
|
|
1027
|
+
const showExistingDialog = ref(false);
|
|
1028
|
+
const existingPlates = ref<TExistingPlate[]>([]);
|
|
1029
|
+
const pendingPayload = ref<Partial<TVehiclePayload> | null>(null);
|
|
1030
|
+
|
|
1031
|
+
const TAB_LABELS: Record<string, string> = {
|
|
1032
|
+
residents: "Residents",
|
|
1033
|
+
"season-passes": "Season Passes",
|
|
1034
|
+
"block-listed": "Block Listed",
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
function tabLabel(view: string) {
|
|
1038
|
+
return TAB_LABELS[view] ?? view;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/** The tab this form adds to. */
|
|
1042
|
+
const targetView = computed(() =>
|
|
1043
|
+
prop.type === "blocklist"
|
|
1044
|
+
? "block-listed"
|
|
1045
|
+
: prop.type === "seasonpass"
|
|
1046
|
+
? "season-passes"
|
|
1047
|
+
: "residents"
|
|
1048
|
+
);
|
|
1049
|
+
|
|
1050
|
+
const plateKey = (plate: unknown) => String(plate ?? "").replace(/\s+/g, "").toUpperCase();
|
|
1051
|
+
|
|
1052
|
+
function formPlates(payload: Partial<TVehiclePayload> | null): string[] {
|
|
1053
|
+
const plates = payload?.plateNumber;
|
|
1054
|
+
return (Array.isArray(plates) ? plates : [plates])
|
|
1055
|
+
.map((p) => String(p ?? "").trim())
|
|
1056
|
+
.filter(Boolean);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/** The plates in the form that the site does NOT hold yet. */
|
|
1060
|
+
const newPlatesAfterExisting = computed(() => {
|
|
1061
|
+
const taken = new Set(
|
|
1062
|
+
existingPlates.value.flatMap((item) => [plateKey(item.plateNumber), plateKey(item.input)])
|
|
1063
|
+
);
|
|
1064
|
+
return formPlates(pendingPayload.value).filter((p) => !taken.has(plateKey(p)));
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
function cancelExistingUpdate() {
|
|
1068
|
+
showExistingDialog.value = false;
|
|
1069
|
+
existingPlates.value = [];
|
|
1070
|
+
pendingPayload.value = null;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
async function confirmExistingUpdate() {
|
|
1074
|
+
const payload = pendingPayload.value;
|
|
1075
|
+
if (!payload) return;
|
|
1076
|
+
|
|
1077
|
+
errorMessage.value = "";
|
|
1078
|
+
processing.value = true;
|
|
1079
|
+
const messages: string[] = [];
|
|
1080
|
+
try {
|
|
1081
|
+
// Everything the form was filled in with, for the existing record - the
|
|
1082
|
+
// plate is the record's own, so it is not sent.
|
|
1083
|
+
const { plateNumber: _plates, ...details } = payload as any;
|
|
1084
|
+
for (const item of existingPlates.value) {
|
|
1085
|
+
const res = await moveVehicle(item._id, { ...details, site: prop.site });
|
|
1086
|
+
if (res?.message) messages.push(res.message);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
const remaining = newPlatesAfterExisting.value;
|
|
1090
|
+
if (remaining.length) {
|
|
1091
|
+
const res: any = await addVehicle({ ...payload, plateNumber: remaining });
|
|
1092
|
+
messages.push(res?.data || res?.message || "Vehicle added successfully.");
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
showExistingDialog.value = false;
|
|
1096
|
+
showMessage(messages.join(" ") || "Vehicle updated.", "success");
|
|
1097
|
+
emit("done");
|
|
1098
|
+
} catch (error: any) {
|
|
1099
|
+
// Shown under the form. A record moved before the failure stays moved.
|
|
1100
|
+
showExistingDialog.value = false;
|
|
1101
|
+
errorMessage.value = errorConverter(error);
|
|
1102
|
+
} finally {
|
|
1103
|
+
processing.value = false;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
889
1107
|
async function submit() {
|
|
890
1108
|
errorMessage.value = "";
|
|
891
1109
|
|
|
@@ -946,7 +1164,7 @@ async function submit() {
|
|
|
946
1164
|
if (prop.mode === "add") {
|
|
947
1165
|
payload = {
|
|
948
1166
|
...payload,
|
|
949
|
-
category,
|
|
1167
|
+
category: categoryForForm(prop.type || String(type), category),
|
|
950
1168
|
site,
|
|
951
1169
|
org,
|
|
952
1170
|
plateNumber: newPlateNumbers.value,
|
|
@@ -998,6 +1216,22 @@ async function submit() {
|
|
|
998
1216
|
// camera is switched off saves the vehicle but registers nothing, and this
|
|
999
1217
|
// used to announce "Vehicle added successfully." over the top of that.
|
|
1000
1218
|
if (prop.mode === "add") {
|
|
1219
|
+
// A plate the site already holds is not refused outright: say which
|
|
1220
|
+
// tab and status it is under and offer to update it instead.
|
|
1221
|
+
const plates = formPlates(payload);
|
|
1222
|
+
if (plates.length) {
|
|
1223
|
+
const found = await checkExistingPlates({
|
|
1224
|
+
site: String(payload.site || prop.site),
|
|
1225
|
+
plateNumbers: plates,
|
|
1226
|
+
});
|
|
1227
|
+
if (found?.items?.length) {
|
|
1228
|
+
existingPlates.value = found.items;
|
|
1229
|
+
pendingPayload.value = payload;
|
|
1230
|
+
showExistingDialog.value = true;
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1001
1235
|
const res: any = await addVehicle(payload);
|
|
1002
1236
|
showMessage(res?.data || res?.message || "Vehicle added successfully.", "success");
|
|
1003
1237
|
} else if (prop.mode === "edit") {
|
|
@@ -1286,4 +1520,14 @@ onMounted(() => {
|
|
|
1286
1520
|
gap: 8px;
|
|
1287
1521
|
padding: 16px 20px 20px;
|
|
1288
1522
|
}
|
|
1523
|
+
|
|
1524
|
+
.vehicle-existing__body {
|
|
1525
|
+
padding: 4px 20px 0;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
.vehicle-existing__line {
|
|
1529
|
+
margin: 0 0 10px;
|
|
1530
|
+
font-size: var(--fs-cell);
|
|
1531
|
+
color: var(--text);
|
|
1532
|
+
}
|
|
1289
1533
|
</style>
|