@7365admin1/layer-common 4.97.1-staging.697 → 4.97.1-staging.699
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/VehicleForm.vue +76 -2
- package/components/VehicleManagement.vue +18 -12
- package/components/VehicleQrStickerDialog.vue +23 -5
- package/composables/useVehicle.ts +23 -2
- package/package.json +1 -1
- package/utils/vehicle-qr-blank.ts +60 -0
- package/utils/vehicle-qr-design.ts +12 -2
- package/utils/vehicle-qr-sticker.ts +28 -9
|
@@ -280,6 +280,24 @@
|
|
|
280
280
|
Add Plate
|
|
281
281
|
</AppButton>
|
|
282
282
|
</template>
|
|
283
|
+
|
|
284
|
+
<!--
|
|
285
|
+
A blank (pre-printed) QR sticker to link as the vehicle is
|
|
286
|
+
added: the next sticker number is picked already. Optional -
|
|
287
|
+
"No sticker" adds the vehicle alone. With several plates the
|
|
288
|
+
sticker goes on the first plate, as Link QR sticker does per plate.
|
|
289
|
+
-->
|
|
290
|
+
<div v-if="prop.qrLink && qrPickItems.length > 1" class="w-100 mt-3">
|
|
291
|
+
<InputLabel title="QR sticker" />
|
|
292
|
+
<v-autocomplete
|
|
293
|
+
v-model="qrPick"
|
|
294
|
+
:items="qrPickItems"
|
|
295
|
+
density="comfortable"
|
|
296
|
+
:hint="newPlateNumbers.filter(Boolean).length > 1 ? 'Linked to the first plate number above.' : 'Type a sticker number to find it.'"
|
|
297
|
+
persistent-hint
|
|
298
|
+
data-test="vehicle-form-qr-sticker"
|
|
299
|
+
/>
|
|
300
|
+
</div>
|
|
283
301
|
</template>
|
|
284
302
|
|
|
285
303
|
<template v-else-if="prop.mode === 'edit'">
|
|
@@ -493,6 +511,7 @@
|
|
|
493
511
|
|
|
494
512
|
<script setup lang="ts">
|
|
495
513
|
import { errorConverter } from "../utils/data";
|
|
514
|
+
import { blankPickLabel, type BlankPick } from "../utils/vehicle-qr-blank";
|
|
496
515
|
import { isPermissionRefusalError } from "../utils/permission-refusal";
|
|
497
516
|
const prop = defineProps({
|
|
498
517
|
type: {
|
|
@@ -543,6 +562,11 @@ const prop = defineProps({
|
|
|
543
562
|
* Blocking from a visitor transaction: the visit's block / level / unit,
|
|
544
563
|
* saved on the Block Listed vehicle and shown read-only.
|
|
545
564
|
*/
|
|
565
|
+
/** Offer a blank QR sticker to link on add (site has Vehicle QR on and the person may link). */
|
|
566
|
+
qrLink: {
|
|
567
|
+
type: Boolean,
|
|
568
|
+
default: false,
|
|
569
|
+
},
|
|
546
570
|
presetLocation: {
|
|
547
571
|
type: Object as PropType<{
|
|
548
572
|
block?: { id: string; name: string };
|
|
@@ -561,7 +585,51 @@ const {
|
|
|
561
585
|
formatVehicleStatus,
|
|
562
586
|
checkExistingPlates,
|
|
563
587
|
moveVehicle,
|
|
588
|
+
getBlankStickersBySerial,
|
|
589
|
+
linkVehicleQr,
|
|
564
590
|
} = useVehicle();
|
|
591
|
+
|
|
592
|
+
/*
|
|
593
|
+
* Link a blank QR sticker while adding (owner 2026-11-16). The host passes
|
|
594
|
+
* `qrLink` only when the site has Vehicle QR on and this person may link.
|
|
595
|
+
*/
|
|
596
|
+
const qrPicks = ref<BlankPick[]>([]);
|
|
597
|
+
const qrPick = ref("");
|
|
598
|
+
const qrPickItems = computed(() => [
|
|
599
|
+
...qrPicks.value.map((p) => ({ title: blankPickLabel(p), value: p.code })),
|
|
600
|
+
{ title: "No sticker", value: "" },
|
|
601
|
+
]);
|
|
602
|
+
onMounted(async () => {
|
|
603
|
+
if (!prop.qrLink || prop.mode !== "add") return;
|
|
604
|
+
try {
|
|
605
|
+
const res = await getBlankStickersBySerial(prop.site, { limit: 50 });
|
|
606
|
+
qrPicks.value = res.items;
|
|
607
|
+
qrPick.value = res.next?.code ?? "";
|
|
608
|
+
} catch {
|
|
609
|
+
qrPicks.value = []; // ponytail: no list, no picker - the vehicle still adds
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
/** After the add: link the picked sticker to the first new plate. A failure keeps the vehicle and says so. */
|
|
614
|
+
async function linkPickedSticker(plates: string[]): Promise<{ text: string; ok: boolean }> {
|
|
615
|
+
const code = qrPick.value;
|
|
616
|
+
const plate = plates[0];
|
|
617
|
+
if (!code || !plate) return { text: "", ok: true };
|
|
618
|
+
const label = blankPickLabel(qrPicks.value.find((p) => p.code === code) ?? { token: code, code });
|
|
619
|
+
try {
|
|
620
|
+
const found = await checkExistingPlates({ site: prop.site, plateNumbers: [plate] });
|
|
621
|
+
const key = (v: unknown) => String(v ?? "").replace(/[^A-Za-z0-9]/g, "").toUpperCase();
|
|
622
|
+
const id = found?.items?.find((i) => key(i.plateNumber) === key(plate))?._id;
|
|
623
|
+
if (!id) throw new Error("The new vehicle could not be found.");
|
|
624
|
+
await linkVehicleQr(code, String(id));
|
|
625
|
+
return { text: `QR sticker ${label.split(" - ")[0]} linked to ${plate}.`, ok: true };
|
|
626
|
+
} catch (error: any) {
|
|
627
|
+
return {
|
|
628
|
+
text: `Vehicle saved, but the QR sticker was not linked (${errorConverter(error)}). Link it from Link QR sticker on the vehicle.`,
|
|
629
|
+
ok: false,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
}
|
|
565
633
|
const { getSiteById, getSiteLevels, getSiteUnits } = useSiteSettings();
|
|
566
634
|
const { findPersonByNRICMultipleResult, getPeopleByUnit } = usePeople();
|
|
567
635
|
const { getBlocksSelection, getLevelsSelection, getUnitSelection } =
|
|
@@ -1154,13 +1222,17 @@ async function confirmExistingUpdate() {
|
|
|
1154
1222
|
}
|
|
1155
1223
|
|
|
1156
1224
|
const remaining = newPlatesAfterExisting.value;
|
|
1225
|
+
let linkOk = true;
|
|
1157
1226
|
if (remaining.length) {
|
|
1158
1227
|
const res: any = await addVehicle({ ...payload, plateNumber: remaining });
|
|
1159
1228
|
messages.push(res?.data || res?.message || "Vehicle added successfully.");
|
|
1229
|
+
const linked = await linkPickedSticker(remaining);
|
|
1230
|
+
if (linked.text) messages.push(linked.text);
|
|
1231
|
+
linkOk = linked.ok;
|
|
1160
1232
|
}
|
|
1161
1233
|
|
|
1162
1234
|
showExistingDialog.value = false;
|
|
1163
|
-
showMessage(messages.join(" ") || "Vehicle updated.", "success");
|
|
1235
|
+
showMessage(messages.join(" ") || "Vehicle updated.", linkOk ? "success" : "warning");
|
|
1164
1236
|
emit("done");
|
|
1165
1237
|
} catch (error: any) {
|
|
1166
1238
|
// Shown under the form. A record moved before the failure stays moved.
|
|
@@ -1310,7 +1382,9 @@ async function submit() {
|
|
|
1310
1382
|
}
|
|
1311
1383
|
|
|
1312
1384
|
const res: any = await addVehicle(payload);
|
|
1313
|
-
|
|
1385
|
+
const added = res?.data || res?.message || "Vehicle added successfully.";
|
|
1386
|
+
const linked = await linkPickedSticker(plates);
|
|
1387
|
+
showMessage([added, linked.text].filter(Boolean).join(" "), linked.ok ? "success" : "warning");
|
|
1314
1388
|
} else if (prop.mode === "edit") {
|
|
1315
1389
|
const plateNumberId = prop.plateNumberId as string;
|
|
1316
1390
|
const res: any = await updateVehicle(plateNumberId, payload);
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
<v-dialog v-model="dialog.createVehicle" v-if="vehicleType" width="450" persistent>
|
|
162
162
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedVehicleObject"
|
|
163
163
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
164
|
+
:qr-link="qrActionsOn({ type: vehicleType })"
|
|
164
165
|
:org="org" :site="props.site" @close:all="handleCloseAll" @refused="handleFormRefused" />
|
|
165
166
|
</v-dialog>
|
|
166
167
|
|
|
@@ -429,10 +430,10 @@
|
|
|
429
430
|
<v-card data-test="vehicle-qr-link-dialog">
|
|
430
431
|
<v-card-title>Link QR sticker</v-card-title>
|
|
431
432
|
<v-card-text>
|
|
432
|
-
Pick an available sticker
|
|
433
|
-
{{ qrPlate?.plateNumber }} when scanned.
|
|
434
|
-
<v-combobox v-model="qrLinkCode" v-model:search="qrSearch" :items="qrCodes" no-filter clearable label="Sticker
|
|
435
|
-
placeholder="Pick or type ABCD-EFGH-JKMN-PQRS-TVWX-YZ01" density="compact" variant="outlined" class="mt-3"
|
|
433
|
+
Pick an available sticker (next number first) or type its sticker number, scan the sticker, or type the code
|
|
434
|
+
printed on it. It will show {{ qrPlate?.plateNumber }} when scanned.
|
|
435
|
+
<v-combobox v-model="qrLinkCode" v-model:search="qrSearch" :items="qrCodes" no-filter clearable label="Sticker"
|
|
436
|
+
placeholder="Pick, or type TLR002 / ABCD-EFGH-JKMN-PQRS-TVWX-YZ01" density="compact" variant="outlined" class="mt-3"
|
|
436
437
|
:disabled="qrBusy" :hint="qrLinkHint" persistent-hint hide-no-data data-test="vehicle-qr-link-code"
|
|
437
438
|
@keyup.enter="confirmLink(false)" />
|
|
438
439
|
<p v-if="qrSummary" class="text-caption mt-2" data-test="vehicle-qr-link-summary">{{ blankSummaryText(qrSummary) }}</p>
|
|
@@ -489,7 +490,7 @@ import {
|
|
|
489
490
|
// `error.message` put ofetch's own developer string in the delete dialog:
|
|
490
491
|
// `[PUT] "/api/vehicles/6a9691f25648d7633171c9e3": 502`.
|
|
491
492
|
import { errorConverter } from '../utils/data';
|
|
492
|
-
import { BLANK_LIST_NOTE, UNDO_REISSUE_NOTE, blankSummaryText, qrStickerNumbers, qrStickerSummary, stickerCodeHint, type BlankSummary } from '../utils/vehicle-qr-blank';
|
|
493
|
+
import { BLANK_LIST_NOTE, UNDO_REISSUE_NOTE, blankPickLabel, blankSummaryText, pickedStickerCode, qrStickerNumbers, qrStickerSummary, stickerCodeHint, type BlankPick, type BlankSummary } from '../utils/vehicle-qr-blank';
|
|
493
494
|
import { isPermissionRefusalError } from '../utils/permission-refusal';
|
|
494
495
|
|
|
495
496
|
|
|
@@ -606,7 +607,7 @@ const canAddBlocklist = computed(() => props.canManageBlocklist === true);
|
|
|
606
607
|
|
|
607
608
|
|
|
608
609
|
const { formatCamelCaseToWords, formatDate, debounce, maskNRIC } = useUtils();
|
|
609
|
-
const { getVehicles, deleteVehicle, formatVehicleStatus, approveVehicle, blockVehicle, unblockVehicle, getSpecificVehicleById, getActiveCameraCounts, getVehicleQrSettings, regenerateVehicleQr, undoReissueVehicleQr, linkVehicleQr, unlinkVehicleQr,
|
|
610
|
+
const { getVehicles, deleteVehicle, formatVehicleStatus, approveVehicle, blockVehicle, unblockVehicle, getSpecificVehicleById, getActiveCameraCounts, getVehicleQrSettings, regenerateVehicleQr, undoReissueVehicleQr, linkVehicleQr, unlinkVehicleQr, getBlankStickersBySerial } = useVehicle();
|
|
610
611
|
|
|
611
612
|
// Vehicle QR stickers: the site's switch (Settings) decides whether the print
|
|
612
613
|
// and re-issue actions exist; only people who may update vehicles get them.
|
|
@@ -672,26 +673,31 @@ const qrError = ref("");
|
|
|
672
673
|
const qrLinkHint = computed(() => (qrCodeToLink.value ? stickerCodeHint(qrCodeToLink.value) : ""));
|
|
673
674
|
// the combobox keeps a typed-but-not-committed code in its search text
|
|
674
675
|
const qrSearch = ref("");
|
|
675
|
-
|
|
676
|
+
// the pick-list's stickers ("TLR002 - ABCD-..."), by sticker number with the next one first
|
|
677
|
+
const qrPicks = ref<BlankPick[]>([]);
|
|
678
|
+
const qrCodes = computed(() => qrPicks.value.map(blankPickLabel));
|
|
676
679
|
const qrSummary = ref<BlankSummary | null>(null);
|
|
677
|
-
|
|
680
|
+
// a picked line or a typed sticker number becomes that sticker's code; a typed code is sent as is
|
|
681
|
+
const qrCodeToLink = computed(() => pickedStickerCode(qrLinkCode.value || qrSearch.value, qrPicks.value));
|
|
678
682
|
|
|
679
683
|
// Saved blank codes still free to link + the site's printed / linked / available count.
|
|
680
684
|
async function loadQrAvailable(search = "") {
|
|
681
685
|
// The Link dialog lists the blanks for whoever may link this plate.
|
|
682
686
|
if (!qrStickersOn.value && !(dialog.qrLink && qrActionsOn(qrPlate.value))) return;
|
|
683
687
|
try {
|
|
684
|
-
const res = await
|
|
685
|
-
qrSummary.value = res
|
|
686
|
-
|
|
688
|
+
const res = await getBlankStickersBySerial(props.site, { search, limit: 50 });
|
|
689
|
+
qrSummary.value = res.summary;
|
|
690
|
+
qrPicks.value = res.items;
|
|
687
691
|
} catch {
|
|
688
692
|
qrSummary.value = null;
|
|
689
|
-
|
|
693
|
+
qrPicks.value = [];
|
|
690
694
|
}
|
|
691
695
|
}
|
|
692
696
|
let qrSearchTimer: ReturnType<typeof setTimeout> | undefined;
|
|
693
697
|
watch(qrSearch, (v) => {
|
|
694
698
|
clearTimeout(qrSearchTimer);
|
|
699
|
+
// picking a line puts its label in the search text - that is not a search
|
|
700
|
+
if (qrCodes.value.includes(String(v ?? ""))) return;
|
|
695
701
|
if (dialog.qrLink) qrSearchTimer = setTimeout(() => loadQrAvailable(String(v ?? "")), 250);
|
|
696
702
|
});
|
|
697
703
|
watch(qrStickersOn, (on) => on && loadQrAvailable());
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
@update:model-value="(v: any) => (ticked = setIds(ticked, [it.vehicleId], !!v))" /></td>
|
|
99
99
|
<template v-if="isBlank">
|
|
100
100
|
<td class="font-weight-bold">{{ blankRowLabel(it) }}</td>
|
|
101
|
-
<td class="text-medium-emphasis">{{
|
|
101
|
+
<td class="text-medium-emphasis">{{ blankStripNote(it, design) }}</td>
|
|
102
102
|
</template>
|
|
103
103
|
<template v-else>
|
|
104
104
|
<td>{{ installerLine(it).place || "-" }}</td>
|
|
@@ -117,10 +117,19 @@
|
|
|
117
117
|
</v-table>
|
|
118
118
|
<v-alert v-if="isBlank && design.shape !== 'square' && design.text === 'none'" type="warning" variant="tonal"
|
|
119
119
|
density="compact" class="my-2" data-test="vehicle-qr-blank-notext">
|
|
120
|
-
With "No text" the sticker's code
|
|
121
|
-
|
|
120
|
+
With "No text" nothing is printed under the shape - neither the sticker's code nor its number - so these stickers
|
|
121
|
+
can only be linked by scanning them with iMA365 / iSecure365. Pick another Text option to print it.
|
|
122
122
|
</v-alert>
|
|
123
|
-
<
|
|
123
|
+
<v-alert v-if="isBlank && design.blankCode === 'hide' && blankWithoutNumber" type="info" variant="tonal"
|
|
124
|
+
density="compact" class="my-2" data-test="vehicle-qr-blank-code-kept">
|
|
125
|
+
{{ blankWithoutNumber }} sticker(s) have no sticker number, so their long code is still printed on them.
|
|
126
|
+
</v-alert>
|
|
127
|
+
<p v-if="isBlank && design.blankCode === 'hide'" class="text-caption text-medium-emphasis my-2">
|
|
128
|
+
Each sticker has a cut-off strip under the dashed line saying it is not linked yet - cut it off before pasting
|
|
129
|
+
the sticker on the car. To link one, pick its sticker number in Vehicles > Link QR sticker, or scan it with
|
|
130
|
+
iMA365 / iSecure365.
|
|
131
|
+
</p>
|
|
132
|
+
<p v-else-if="isBlank" class="text-caption text-medium-emphasis my-2">
|
|
124
133
|
Each sticker has a cut-off strip under the dashed line saying it is not linked yet - cut it off before pasting
|
|
125
134
|
the sticker on the car. The code on the sticker is what you type in Vehicles > Link QR sticker.
|
|
126
135
|
</p>
|
|
@@ -178,6 +187,10 @@
|
|
|
178
187
|
<v-select v-model="design.serial" :items="SERIAL_OPTIONS" label="Serial number" density="compact"
|
|
179
188
|
hide-details data-test="vehicle-qr-serial" />
|
|
180
189
|
</v-col>
|
|
190
|
+
<v-col v-if="isBlank" cols="12" sm="6" md="4">
|
|
191
|
+
<v-select v-model="design.blankCode" :items="BLANK_CODE_OPTIONS" label="Sticker code (long code)"
|
|
192
|
+
density="compact" hide-details data-test="vehicle-qr-blank-code" />
|
|
193
|
+
</v-col>
|
|
181
194
|
<v-col v-if="!isBlank" cols="12" sm="6" md="4">
|
|
182
195
|
<v-select v-model="design.plate" :items="PLATE_OPTIONS" label="Plate number on the sticker" density="compact"
|
|
183
196
|
hide-details data-test="vehicle-qr-plate" />
|
|
@@ -260,7 +273,7 @@
|
|
|
260
273
|
<script lang="ts" setup>
|
|
261
274
|
import QRCode from "qrcode";
|
|
262
275
|
import useVehicle from "../composables/useVehicle";
|
|
263
|
-
import { BLANK_DEFAULT_COUNT, BLANK_LIST_NOTE, BLANK_MAX_COUNT,
|
|
276
|
+
import { BLANK_DEFAULT_COUNT, BLANK_LIST_NOTE, BLANK_MAX_COUNT, SAVED_REPRINT_MAX, blankRowLabel, savedBlankItems, STICKER_NEW_NOTE, STICKER_SAME_NOTE, blankCount, blankStickerItems, blankSummaryText, reprintItems, type BlankSummary } from "../utils/vehicle-qr-blank";
|
|
264
277
|
import { errorConverter } from "../utils/data";
|
|
265
278
|
import { saveFile, stickerBundleName, stickerFileNames, svgToImage, zipFiles, type ImageFormat } from "../utils/vehicle-qr-export";
|
|
266
279
|
import {
|
|
@@ -277,11 +290,14 @@ import {
|
|
|
277
290
|
stickerSizeLines,
|
|
278
291
|
stickerCardSvgs,
|
|
279
292
|
stickerFileLabel,
|
|
293
|
+
stickerSerial,
|
|
280
294
|
stickerWarning,
|
|
295
|
+
blankStripNote,
|
|
281
296
|
type StickerItem,
|
|
282
297
|
type StickerPlateRow,
|
|
283
298
|
} from "../utils/vehicle-qr-sticker";
|
|
284
299
|
import {
|
|
300
|
+
BLANK_CODE_OPTIONS,
|
|
285
301
|
DEFAULT_STICKER_DESIGN,
|
|
286
302
|
DOT_OPTIONS,
|
|
287
303
|
EYE_OPTIONS,
|
|
@@ -337,6 +353,8 @@ const step = ref<"select" | "review">("select");
|
|
|
337
353
|
const plates = ref<StickerPlateRow[]>([]);
|
|
338
354
|
const selected = ref<string[]>([]);
|
|
339
355
|
const items = ref<StickerItem[]>([]);
|
|
356
|
+
// "Sticker code: Hide" keeps the code on a blank that has no number (never neither).
|
|
357
|
+
const blankWithoutNumber = computed(() => items.value.filter((i) => i.blank && !stickerSerial(i)).length);
|
|
340
358
|
const ticked = ref<string[]>([]);
|
|
341
359
|
const missing = ref<string[]>([]);
|
|
342
360
|
const dropped = ref(0);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { orderedBlankPicks, type BlankPick } from "../utils/vehicle-qr-blank";
|
|
2
|
+
|
|
1
3
|
export default function useVehicle() {
|
|
2
4
|
async function getVehicles({
|
|
3
5
|
search = "",
|
|
@@ -330,17 +332,35 @@ function getSpecificVehicleById(id: string){
|
|
|
330
332
|
|
|
331
333
|
// Blank codes saved when printed and still free to link, plus {printed, linked, available}.
|
|
332
334
|
// `search` matches the code or the sticker number; `qr` lets a saved sticker be printed again.
|
|
333
|
-
function getAvailableBlankVehicleQr(site: string, query: { search?: string; page?: number; limit?: number } = {}) {
|
|
335
|
+
function getAvailableBlankVehicleQr(site: string, query: { search?: string; page?: number; limit?: number; sort?: "serial" } = {}) {
|
|
334
336
|
return useNuxtApp().$api<{
|
|
335
337
|
site?: { _id: string; name: string };
|
|
336
338
|
summary: { printed: number; linked: number; available: number };
|
|
337
339
|
total: number;
|
|
338
340
|
page: number;
|
|
339
341
|
limit: number;
|
|
340
|
-
items:
|
|
342
|
+
items: BlankPick[];
|
|
343
|
+
/** With `sort=serial`: the first available sticker (lowest number). */
|
|
344
|
+
next?: BlankPick | null;
|
|
341
345
|
}>(`/api/vehicles/qr/blank-stickers/site/${site}`, { query });
|
|
342
346
|
}
|
|
343
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Blank stickers for a pick-list: by sticker number, the NEXT one first.
|
|
350
|
+
* Asks for `sort=serial`; a server without it yet refuses the unknown field
|
|
351
|
+
* (400), so the list is asked again without it and sorted here.
|
|
352
|
+
*/
|
|
353
|
+
async function getBlankStickersBySerial(site: string, query: { search?: string; limit?: number } = {}) {
|
|
354
|
+
let res: Awaited<ReturnType<typeof getAvailableBlankVehicleQr>>;
|
|
355
|
+
try {
|
|
356
|
+
res = await getAvailableBlankVehicleQr(site, { ...query, sort: "serial" });
|
|
357
|
+
} catch (e: any) {
|
|
358
|
+
if ((e?.statusCode ?? e?.status ?? e?.response?.status) !== 400) throw e;
|
|
359
|
+
res = await getAvailableBlankVehicleQr(site, query);
|
|
360
|
+
}
|
|
361
|
+
return { summary: res?.summary ?? null, ...orderedBlankPicks(res) };
|
|
362
|
+
}
|
|
363
|
+
|
|
344
364
|
// `token` is sent as typed - the server ignores case, spaces and dashes.
|
|
345
365
|
function linkVehicleQr(token: string, vehicleId: string, replace?: boolean) {
|
|
346
366
|
return useNuxtApp().$api<Record<string, any>>("/api/vehicles/qr/link", {
|
|
@@ -381,6 +401,7 @@ function getSpecificVehicleById(id: string){
|
|
|
381
401
|
undoReissueVehicleQr,
|
|
382
402
|
getBlankVehicleQrStickers,
|
|
383
403
|
getAvailableBlankVehicleQr,
|
|
404
|
+
getBlankStickersBySerial,
|
|
384
405
|
linkVehicleQr,
|
|
385
406
|
unlinkVehicleQr,
|
|
386
407
|
};
|
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.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.699",
|
|
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.",
|
|
@@ -148,3 +148,63 @@ export function blankSummaryText(s: Partial<BlankSummary> | null | undefined): s
|
|
|
148
148
|
|
|
149
149
|
/** Shown beside the pick-list: stickers printed before the list existed were never saved. */
|
|
150
150
|
export const BLANK_LIST_NOTE = "Stickers printed before 9 Oct 2026 are not in this list - scan them or type their code.";
|
|
151
|
+
|
|
152
|
+
/** The strip under a blank sticker printed WITHOUT its long code: link it by its number, never "type the code". */
|
|
153
|
+
export const BLANK_STRIP_NOTE_NUMBER = "Not linked yet - link it by its sticker number in Vehicles > Link QR sticker, or scan it with iMA365 / iSecure365";
|
|
154
|
+
|
|
155
|
+
/** One saved blank sticker in a pick-list (GET /api/vehicles/qr/blank-stickers/site/:site). */
|
|
156
|
+
export type BlankPick = { token: string; code: string; qr?: string; serialNo?: number | null; serialLabel?: string | null };
|
|
157
|
+
|
|
158
|
+
const serialOf = (i: Pick<BlankPick, "serialNo">) => {
|
|
159
|
+
const n = Number(i?.serialNo);
|
|
160
|
+
return Number.isInteger(n) && n > 0 ? n : 0;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/** The number a pick-list shows: "TLR002", "No. 2", or "" when the sticker has none. */
|
|
164
|
+
export function blankPickSerial(i: Pick<BlankPick, "serialNo" | "serialLabel">): string {
|
|
165
|
+
const n = serialOf(i);
|
|
166
|
+
return n ? String(i.serialLabel ?? "").trim() || `No. ${n}` : "";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** "TLR002 - ABCD-EFGH-..." - or just the code for a sticker with no number. */
|
|
170
|
+
export function blankPickLabel(i: BlankPick): string {
|
|
171
|
+
const sn = blankPickSerial(i);
|
|
172
|
+
return sn ? `${sn} - ${i.code}` : i.code;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Ascending by sticker number; stickers with no number last, in the order they came. */
|
|
176
|
+
export function sortBlankBySerial<T extends Pick<BlankPick, "serialNo">>(items: T[]): T[] {
|
|
177
|
+
return items
|
|
178
|
+
.map((item, at) => ({ item, at, n: serialOf(item) }))
|
|
179
|
+
.sort((a, b) => (a.n && b.n ? a.n - b.n : a.n ? -1 : b.n ? 1 : 0) || a.at - b.at)
|
|
180
|
+
.map((x) => x.item);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The pick-list in sticker-number order with the NEXT sticker on top. A server
|
|
185
|
+
* that took `sort=serial` sends its order and `next`; an older one sends
|
|
186
|
+
* neither, so the list is sorted here and the lowest number is next.
|
|
187
|
+
*/
|
|
188
|
+
export function orderedBlankPicks<T extends BlankPick>(res: { items?: T[] | null; next?: T | null } | null | undefined): { items: T[]; next: T | null } {
|
|
189
|
+
const raw = Array.isArray(res?.items) ? res!.items! : [];
|
|
190
|
+
const items = res?.next ? [...raw] : sortBlankBySerial(raw);
|
|
191
|
+
const next = res?.next ?? items[0] ?? null;
|
|
192
|
+
if (!next) return { items, next: null };
|
|
193
|
+
return { items: [next, ...items.filter((i) => i.token !== next.token)], next };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* What a pick-list's text means as a code to link: a picked "TLR002 - ABCD-..."
|
|
198
|
+
* line, a sticker number typed on its own ("tlr002"), or a typed / scanned code
|
|
199
|
+
* (sent as is - the server reads it).
|
|
200
|
+
*/
|
|
201
|
+
export function pickedStickerCode(text: unknown, items: BlankPick[] = []): string {
|
|
202
|
+
const t = String(text ?? "").trim();
|
|
203
|
+
if (!t) return "";
|
|
204
|
+
const byLabel = items.find((i) => blankPickLabel(i) === t);
|
|
205
|
+
if (byLabel) return byLabel.code;
|
|
206
|
+
const bySerial = items.find((i) => blankPickSerial(i) && blankPickSerial(i).toUpperCase() === t.toUpperCase());
|
|
207
|
+
if (bySerial) return bySerial.code;
|
|
208
|
+
const at = t.lastIndexOf(" - ");
|
|
209
|
+
return at >= 0 ? t.slice(at + 3).trim() : t;
|
|
210
|
+
}
|
|
@@ -48,8 +48,10 @@ export type LabelChoice = "app" | "verify" | "scanme" | "site" | "none";
|
|
|
48
48
|
export type TextChoice = "below" | "none";
|
|
49
49
|
/** Where the sticker's running number ("No. 12") is printed: not at all, on the sticker, on the cut-off strip, or both. */
|
|
50
50
|
export type SerialChoice = "off" | "sticker" | "strip" | "both";
|
|
51
|
-
/** The vehicle's plate number on the print-out: shown, or left off (a blank sticker's code is
|
|
51
|
+
/** The vehicle's plate number on the print-out: shown, or left off (a blank sticker's code is set by `blankCode`). */
|
|
52
52
|
export type PlateChoice = "show" | "hide";
|
|
53
|
+
/** Blank stickers: print the long 24-character code, or leave it off and print the sticker number in its place (one with no number keeps its code). */
|
|
54
|
+
export type BlankCodeChoice = "print" | "hide";
|
|
53
55
|
|
|
54
56
|
export type StickerTheme = { id: string; title: string; ink: string; eye: string; paper: string };
|
|
55
57
|
|
|
@@ -68,6 +70,7 @@ export type StickerDesign = {
|
|
|
68
70
|
cutLines?: boolean;
|
|
69
71
|
serial?: SerialChoice;
|
|
70
72
|
plate?: PlateChoice;
|
|
73
|
+
blankCode?: BlankCodeChoice;
|
|
71
74
|
};
|
|
72
75
|
|
|
73
76
|
export const DOT_OPTIONS: { value: DotShape; title: string }[] = [
|
|
@@ -154,6 +157,11 @@ export const PLATE_OPTIONS: { value: PlateChoice; title: string }[] = [
|
|
|
154
157
|
{ value: "hide", title: "Hide - QR and serial number only" },
|
|
155
158
|
];
|
|
156
159
|
|
|
160
|
+
export const BLANK_CODE_OPTIONS: { value: BlankCodeChoice; title: string }[] = [
|
|
161
|
+
{ value: "print", title: "Print (default)" },
|
|
162
|
+
{ value: "hide", title: "Hide - QR code and sticker number only" },
|
|
163
|
+
];
|
|
164
|
+
|
|
157
165
|
export const LABEL_OPTIONS: { value: LabelChoice; title: string }[] = [
|
|
158
166
|
{ value: "app", title: "Scan with iSecure365 / iMA365" },
|
|
159
167
|
{ value: "verify", title: "Scan to verify vehicle" },
|
|
@@ -185,6 +193,7 @@ export const DEFAULT_STICKER_DESIGN: StickerDesign = {
|
|
|
185
193
|
cutLines: true,
|
|
186
194
|
serial: "sticker",
|
|
187
195
|
plate: "show",
|
|
196
|
+
blankCode: "print",
|
|
188
197
|
};
|
|
189
198
|
|
|
190
199
|
/** A saved or typed-in design with anything unknown replaced by the default. */
|
|
@@ -209,6 +218,7 @@ export function normalizeDesign(raw: unknown): StickerDesign {
|
|
|
209
218
|
cutLines: typeof r.cutLines === "boolean" ? r.cutLines : true,
|
|
210
219
|
serial: pick(r.serial, SERIAL_OPTIONS, d.serial),
|
|
211
220
|
plate: pick(r.plate, PLATE_OPTIONS, d.plate!),
|
|
221
|
+
blankCode: pick(r.blankCode, BLANK_CODE_OPTIONS, d.blankCode!),
|
|
212
222
|
};
|
|
213
223
|
}
|
|
214
224
|
|
|
@@ -226,7 +236,7 @@ export function rememberedDesign(saved: unknown, savedSerial: unknown): StickerD
|
|
|
226
236
|
* The design as printed. With the plate hidden on vehicle stickers, a shaped
|
|
227
237
|
* code whose tab under the shape would be left empty (no serial or words on
|
|
228
238
|
* it) is printed with no tab, so no bare paper tab hangs under the shape.
|
|
229
|
-
* Blank stickers always print their code in the tab, so they keep it.
|
|
239
|
+
* Blank stickers always print their code or sticker number in the tab, so they keep it.
|
|
230
240
|
*/
|
|
231
241
|
export function printedDesign(design: unknown, blank = false, siteName = ""): StickerDesign {
|
|
232
242
|
const d = normalizeDesign(design);
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
stickerTheme,
|
|
19
19
|
type StickerDesign,
|
|
20
20
|
} from "./vehicle-qr-design.ts";
|
|
21
|
-
import { BLANK_STRIP_NOTE, isBlankCode, plateLines } from "./vehicle-qr-blank.ts";
|
|
21
|
+
import { BLANK_STRIP_NOTE, BLANK_STRIP_NOTE_NUMBER, isBlankCode, plateLines } from "./vehicle-qr-blank.ts";
|
|
22
22
|
|
|
23
23
|
/** The server's most vehicles per request (POST /api/vehicles/qr/stickers). */
|
|
24
24
|
export const STICKER_MAX_PER_REQUEST = 500;
|
|
@@ -208,12 +208,27 @@ export function stickerSerial(item: Pick<StickerItem, "serialNo" | "serialLabel"
|
|
|
208
208
|
return text(item?.serialLabel) || `No. ${n}`;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
/**
|
|
212
|
-
|
|
211
|
+
/**
|
|
212
|
+
* A blank sticker printed with its sticker number in place of the long code
|
|
213
|
+
* (design "Sticker code: Hide"). Only when it HAS a number - a sticker never
|
|
214
|
+
* goes out with neither the code nor a number on it.
|
|
215
|
+
*/
|
|
216
|
+
export function blankCodeHidden(item: Pick<StickerItem, "blank" | "serialNo" | "serialLabel">, design: Pick<StickerDesign, "blankCode">): boolean {
|
|
217
|
+
return !!item.blank && design.blankCode === "hide" && !!stickerSerial(item);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** The strip under a blank sticker: link by number when the code is not on it. */
|
|
221
|
+
export function blankStripNote(item: Pick<StickerItem, "blank" | "serialNo" | "serialLabel">, design: Pick<StickerDesign, "blankCode">): string {
|
|
222
|
+
return blankCodeHidden(item, design) ? BLANK_STRIP_NOTE_NUMBER : BLANK_STRIP_NOTE;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** What a saved picture is named after: the plate - or, with the plate (or a blank's code) hidden, the sticker's number (the file name must not give the plate away either). */
|
|
226
|
+
export function stickerFileLabel(item: StickerItem, design: Pick<StickerDesign, "plate" | "blankCode">): string {
|
|
227
|
+
if (blankCodeHidden(item, design)) return stickerSerial(item);
|
|
213
228
|
return shownPlateLines(item, design.plate === "hide").length ? text(item.plateNumber) : stickerSerial(item) || "sticker";
|
|
214
229
|
}
|
|
215
230
|
|
|
216
|
-
/** The plate lines printed on a sticker: none when the plate is hidden -
|
|
231
|
+
/** The plate lines printed on a sticker: none when the plate is hidden - a blank sticker's code is printed unless `blankCodeHidden` (see `headLines`). */
|
|
217
232
|
function shownPlateLines(item: StickerItem, hidePlate: boolean): string[] {
|
|
218
233
|
const plate = text(item.plateNumber);
|
|
219
234
|
return hidePlate && !item.blank && !isBlankCode(plate) ? [] : plateLines(plate);
|
|
@@ -222,9 +237,12 @@ function shownPlateLines(item: StickerItem, hidePlate: boolean): string[] {
|
|
|
222
237
|
/**
|
|
223
238
|
* The big line(s) on the sticker and the small serial under them. With the
|
|
224
239
|
* plate hidden, the serial (when it is on the sticker) moves up into the
|
|
225
|
-
* plate's place, so the sticker keeps its usual look with no hole in it.
|
|
240
|
+
* plate's place, so the sticker keeps its usual look with no hole in it. A
|
|
241
|
+
* blank sticker with its code hidden prints its number there whatever the
|
|
242
|
+
* serial choice - the number is how it is linked.
|
|
226
243
|
*/
|
|
227
244
|
function headLines(item: StickerItem, c: CardContext): { lines: string[]; serialText: string } {
|
|
245
|
+
if (blankCodeHidden(item, c)) return { lines: [stickerSerial(item)], serialText: "" };
|
|
228
246
|
const lines = shownPlateLines(item, c.hidePlate);
|
|
229
247
|
const serialText = c.serial ? stickerSerial(item) : "";
|
|
230
248
|
return lines.length || !serialText ? { lines, serialText } : { lines: [serialText], serialText: "" };
|
|
@@ -408,7 +426,7 @@ export function tagPlateSizeMm(longest: string, tag: { w: number; h: number }, l
|
|
|
408
426
|
* `items` (each sticker's frame + QR, already drawn for the chosen design).
|
|
409
427
|
* Every value is HTML-escaped - an owner or site name is typed by a person.
|
|
410
428
|
*/
|
|
411
|
-
type CardContext = { cardW: number; ink: string; label: string; layout: SheetLayout; k: number; shaped: boolean; bare: boolean; wordsTop: number; tag: { x: number; y: number; w: number; h: number } | null; serial: boolean; hidePlate: boolean };
|
|
429
|
+
type CardContext = { blankCode?: StickerDesign["blankCode"]; cardW: number; ink: string; label: string; layout: SheetLayout; k: number; shaped: boolean; bare: boolean; wordsTop: number; tag: { x: number; y: number; w: number; h: number } | null; serial: boolean; hidePlate: boolean };
|
|
412
430
|
|
|
413
431
|
function cardContext(design: StickerDesign, siteName: string | undefined, n: number): CardContext {
|
|
414
432
|
const g = stickerGeometry(design, n);
|
|
@@ -427,6 +445,7 @@ function cardContext(design: StickerDesign, siteName: string | undefined, n: num
|
|
|
427
445
|
tag: g.band ? { x: mm(g.band.x * k), y: mm(g.band.y * k), w: mm(g.band.w * k), h: mm(g.band.h * k) } : null,
|
|
428
446
|
serial: serialOnSticker(design),
|
|
429
447
|
hidePlate: design.plate === "hide",
|
|
448
|
+
blankCode: design.blankCode,
|
|
430
449
|
};
|
|
431
450
|
}
|
|
432
451
|
|
|
@@ -448,7 +467,7 @@ function cardHtml(item: StickerItem, face: string, c: CardContext): string {
|
|
|
448
467
|
tagWords +
|
|
449
468
|
`</div>`
|
|
450
469
|
: `<div class="words" style="top:${c.wordsTop}mm${!lines.length && !label ? ";justify-content:center" : ""}">` +
|
|
451
|
-
(lines.length ? `<div class="plate"${lines.length > 1 ? ` style="font-size:${plateSizeMm(longest, c.cardW - 6, 4.6)}mm"` : ""}>${plate}</div>` : "") +
|
|
470
|
+
(lines.length ? `<div class="plate"${lines.length > 1 || blankCodeHidden(item, c) ? ` style="font-size:${plateSizeMm(longest, c.cardW - 6, 4.6)}mm"` : ""}>${plate}</div>` : "") +
|
|
452
471
|
serial +
|
|
453
472
|
label +
|
|
454
473
|
`<div class="brand"><span class="mark" style="background:${c.ink}">7</span>Powered by Seven365</div>` +
|
|
@@ -474,7 +493,7 @@ export function buildStickerDocument(
|
|
|
474
493
|
const stripSerial = (item: StickerItem) => design.serial === "strip" || design.serial === "both" || (c.serial && noRoom(item));
|
|
475
494
|
const cells = items.map((item, i) => {
|
|
476
495
|
const { place, owner } = installerLine(item);
|
|
477
|
-
const [noteHead, noteRest] =
|
|
496
|
+
const [noteHead, noteRest] = blankStripNote(item, design).split(" - ");
|
|
478
497
|
const sn = stripSerial(item) ? `<span class="sn">${escapeHtml(stickerSerial(item))}</span>` : "";
|
|
479
498
|
const strip = item.blank
|
|
480
499
|
? `<div class="cut${c.bare ? " free" : ""} blank"><div>${sn}<b>${escapeHtml(noteHead)}</b></div><div>${escapeHtml(noteRest)}</div></div>`
|
|
@@ -512,7 +531,7 @@ function cardWordsSvg(item: StickerItem, c: CardContext): string {
|
|
|
512
531
|
const box = c.tag ?? { x: 3, y: c.wordsTop, w: c.cardW - 6, h: c.layout.cardH - 2 - c.wordsTop };
|
|
513
532
|
const plateSize = c.tag
|
|
514
533
|
? tagPlateSizeMm(longest, c.tag, lines.length, !!serialText && lines.length > 1, c.k)
|
|
515
|
-
: lines.length > 1 ? plateSizeMm(longest, c.cardW - 6, 4.6) : 13 * PT;
|
|
534
|
+
: lines.length > 1 || blankCodeHidden(item, c) ? plateSizeMm(longest, c.cardW - 6, 4.6) : 13 * PT;
|
|
516
535
|
const small = 5.8 * PT;
|
|
517
536
|
type Row = { h: number; draw: (top: number) => string };
|
|
518
537
|
const rows: Row[] = [];
|