@7365admin1/layer-common 4.97.1-staging.732 → 4.97.1-staging.734
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/DashboardMain.vue +6 -4
- package/components/InventoryCheckoutReturnDialog.vue +144 -0
- package/components/InventoryCheckoutsTab.vue +257 -0
- package/components/InventoryItemDetail.vue +2 -0
- package/components/InventoryItemDialog.vue +37 -0
- package/components/InventoryLinesDialog.vue +158 -20
- package/components/InventoryMain.vue +21 -0
- package/components/InventoryMyStockTab.vue +16 -1
- package/components/InventorySerialPick.vue +85 -0
- package/components/InventorySerialScanner.vue +188 -0
- package/components/InventorySerialsDialog.vue +193 -0
- package/components/InventoryStockTab.vue +17 -0
- package/components/InventoryUsageDialog.vue +18 -0
- package/components/InventoryWorkOrderPicker.vue +222 -0
- package/components/InventoryWriteOffDialog.vue +14 -0
- package/components/Layout/Header.vue +3 -1
- package/components/Layout/NavigationDrawer.vue +3 -1
- package/components/ListCsvExport.vue +3 -1
- package/components/NavigationItem.vue +5 -3
- package/components/SiteSettingsWorkOrder.vue +14 -1
- package/components/WorkOrder/IssuedItems.vue +153 -0
- package/composables/useInventory.ts +20 -1
- package/composables/useReportPdf.ts +1 -1
- package/composables/useUiLanguage.ts +1 -1
- package/composables/useWorkOrder.ts +12 -0
- package/package.json +1 -1
- package/plugins/ui-language.ts +1 -1
- package/types/inventory.d.ts +52 -0
- package/utils/inventory-checkout.ts +64 -0
|
@@ -59,6 +59,8 @@
|
|
|
59
59
|
density="comfortable"
|
|
60
60
|
:rules="[requiredRule]"
|
|
61
61
|
no-filter
|
|
62
|
+
clearable
|
|
63
|
+
persistent-clear
|
|
62
64
|
hint="Everyone at this property who can take stock: your staff and the service providers' people."
|
|
63
65
|
persistent-hint
|
|
64
66
|
@update:search="searchPeople"
|
|
@@ -122,6 +124,8 @@
|
|
|
122
124
|
placeholder="Type to search"
|
|
123
125
|
density="comfortable"
|
|
124
126
|
:rules="[requiredRule]"
|
|
127
|
+
clearable
|
|
128
|
+
persistent-clear
|
|
125
129
|
class="flex-grow-1"
|
|
126
130
|
style="min-width: 220px"
|
|
127
131
|
@update:search="(q: string) => typedSearch(line, q)"
|
|
@@ -148,10 +152,33 @@
|
|
|
148
152
|
min="1"
|
|
149
153
|
label="Qty"
|
|
150
154
|
density="comfortable"
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
clearable
|
|
156
|
+
persistent-clear
|
|
157
|
+
style="max-width: 140px"
|
|
158
|
+
:rules="[qtyRule(line), serialQtyRule(line)]"
|
|
153
159
|
:suffix="unitWord(line.qty, line.newItem ? line.newItem.unit : unitOf(line.item))"
|
|
154
160
|
/>
|
|
161
|
+
<!-- DV-1787: an item with serial numbers - choose which units are issued; Qty follows -->
|
|
162
|
+
<v-autocomplete
|
|
163
|
+
v-if="hasSerials(line)"
|
|
164
|
+
v-model="line.serials"
|
|
165
|
+
:items="serialOptions[line.item!] ?? []"
|
|
166
|
+
item-title="serial"
|
|
167
|
+
item-value="_id"
|
|
168
|
+
label="Serial numbers (optional)"
|
|
169
|
+
placeholder="Pick the units you are issuing by serial"
|
|
170
|
+
multiple
|
|
171
|
+
chips
|
|
172
|
+
closable-chips
|
|
173
|
+
clearable
|
|
174
|
+
persistent-clear
|
|
175
|
+
density="comfortable"
|
|
176
|
+
class="w-100"
|
|
177
|
+
:hint="serialHint(line)"
|
|
178
|
+
persistent-hint
|
|
179
|
+
:no-data-text="'No serial numbers on the shelf'"
|
|
180
|
+
@update:model-value="(v: string[] | null) => (line.qty = Math.max(Number(line.qty) || 0, v?.length ?? 0) || null)"
|
|
181
|
+
/>
|
|
155
182
|
<v-text-field
|
|
156
183
|
v-if="mode === 'receive' && receivingType !== 'CASH'"
|
|
157
184
|
v-model.number="line.ordered"
|
|
@@ -244,12 +271,45 @@
|
|
|
244
271
|
label="For which property"
|
|
245
272
|
density="comfortable"
|
|
246
273
|
/>
|
|
247
|
-
|
|
248
|
-
<
|
|
274
|
+
<!-- DV-1787: Issue Stock picks a real work order of the site, kept apart from the free-text reference. -->
|
|
275
|
+
<template v-if="mode === 'issue'">
|
|
276
|
+
<InputLabel title="Work order (optional)" class="mb-1" />
|
|
277
|
+
<v-text-field
|
|
278
|
+
:model-value="workOrder ? [workOrder.number, workOrder.subject].filter(Boolean).join(' · ') : ''"
|
|
279
|
+
density="comfortable"
|
|
280
|
+
readonly
|
|
281
|
+
placeholder="Select the work order this stock is for"
|
|
282
|
+
append-inner-icon="mdi-clipboard-text-search-outline"
|
|
283
|
+
:clearable="Boolean(workOrder)"
|
|
284
|
+
persistent-clear
|
|
285
|
+
@click="workOrderPicker = true"
|
|
286
|
+
@click:append-inner="workOrderPicker = true"
|
|
287
|
+
@click:clear="workOrder = null"
|
|
288
|
+
/>
|
|
289
|
+
<InputLabel title="Reference no. (optional)" class="mb-1" />
|
|
290
|
+
<v-text-field v-model="reference" density="comfortable" placeholder="e.g. EE202507-0002" clearable persistent-clear />
|
|
291
|
+
<InputLabel title="Return date (optional)" class="mb-1" />
|
|
292
|
+
<!-- the apps standard date field: DD/MM/YYYY, the value stays YYYY-MM-DD -->
|
|
293
|
+
<InputDatePicker
|
|
294
|
+
v-model="returnDate"
|
|
295
|
+
:min="today"
|
|
296
|
+
:rules="[returnDateRule]"
|
|
297
|
+
placeholder="DD/MM/YYYY"
|
|
298
|
+
density="comfortable"
|
|
299
|
+
clearable
|
|
300
|
+
persistent-clear
|
|
301
|
+
hint="When they should give it back. Leave empty if it is not coming back."
|
|
302
|
+
persistent-hint
|
|
303
|
+
/>
|
|
304
|
+
</template>
|
|
305
|
+
<template v-else>
|
|
306
|
+
<InputLabel title="Work order / reference no. (optional)" class="mb-1" />
|
|
307
|
+
<v-text-field v-model="reference" density="comfortable" placeholder="e.g. EE202507-0002" />
|
|
308
|
+
</template>
|
|
249
309
|
</template>
|
|
250
310
|
|
|
251
311
|
<InputLabel title="Remarks (optional)" class="mb-1 mt-2" />
|
|
252
|
-
<v-textarea v-model="remarks" rows="2" auto-grow density="comfortable" />
|
|
312
|
+
<v-textarea v-model="remarks" rows="2" auto-grow density="comfortable" clearable persistent-clear />
|
|
253
313
|
</v-form>
|
|
254
314
|
</v-card-text>
|
|
255
315
|
|
|
@@ -258,6 +318,14 @@
|
|
|
258
318
|
<v-btn class="screen-btn-primary" variant="flat" :loading="saving" @click="submit">{{ copy.button }}</v-btn>
|
|
259
319
|
</div>
|
|
260
320
|
</v-card>
|
|
321
|
+
<InventoryWorkOrderPicker
|
|
322
|
+
v-if="mode === 'issue'"
|
|
323
|
+
v-model="workOrderPicker"
|
|
324
|
+
:site-id="site || siteId"
|
|
325
|
+
:technicians="people"
|
|
326
|
+
:default-assignee="holder"
|
|
327
|
+
@picked="(w: TPickedWorkOrder) => (workOrder = w)"
|
|
328
|
+
/>
|
|
261
329
|
</v-dialog>
|
|
262
330
|
</template>
|
|
263
331
|
|
|
@@ -271,7 +339,7 @@ import { notListedText } from "../utils/inventory-request-text";
|
|
|
271
339
|
|
|
272
340
|
type TMode = "receive" | "issue" | "request" | "return" | "transfer";
|
|
273
341
|
type TNewItem = { name: string; unit: string; category: string; note: string };
|
|
274
|
-
type TRow = { item: string; qty: number | null; unitCost?: number | null; ordered?: number | null; typed?: string; newItem?: TNewItem | null };
|
|
342
|
+
type TRow = { serials?: string[]; item: string | null; qty: number | null; unitCost?: number | null; ordered?: number | null; typed?: string; newItem?: TNewItem | null };
|
|
275
343
|
|
|
276
344
|
const show = defineModel<boolean>({ default: false });
|
|
277
345
|
const props = defineProps({
|
|
@@ -347,7 +415,7 @@ const copy = computed(() => {
|
|
|
347
415
|
|
|
348
416
|
const form = ref();
|
|
349
417
|
const saving = ref(false);
|
|
350
|
-
const blank = (): TRow => ({ item:
|
|
418
|
+
const blank = (): TRow => ({ item: null, qty: null, unitCost: null, ordered: null, typed: "", newItem: null });
|
|
351
419
|
/** Receive: only store managers may add items to the list (the API says 403 otherwise). Request: anyone may ask. */
|
|
352
420
|
const canAddNew = computed(() => (props.mode === "receive" ? props.store.access.canManage : props.mode === "request"));
|
|
353
421
|
function typedSearch(line: TRow, q: string) {
|
|
@@ -356,7 +424,7 @@ function typedSearch(line: TRow, q: string) {
|
|
|
356
424
|
}
|
|
357
425
|
function addNew(line: TRow) {
|
|
358
426
|
line.newItem = { name: line.typed || "", unit: "pcs", category: "", note: "" };
|
|
359
|
-
line.item =
|
|
427
|
+
line.item = null;
|
|
360
428
|
}
|
|
361
429
|
const rows = ref<TRow[]>([blank()]);
|
|
362
430
|
const chosenCount = computed(() => rows.value.filter((r) => r.item || r.newItem?.name?.trim()).length);
|
|
@@ -366,8 +434,62 @@ const remarks = ref("");
|
|
|
366
434
|
const photos = ref<string[]>([]);
|
|
367
435
|
const today = new Date().toLocaleDateString("en-CA");
|
|
368
436
|
const date = ref(today);
|
|
369
|
-
|
|
437
|
+
// null (not ""): an empty field, so its clear button shows only once someone is picked.
|
|
438
|
+
const holder = ref<string | null>(null);
|
|
370
439
|
const site = ref(props.siteId);
|
|
440
|
+
// DV-1787: Issue Stock - the work order it is for, and when it should come back (both optional).
|
|
441
|
+
const workOrder = ref<TPickedWorkOrder | null>(null);
|
|
442
|
+
const workOrderPicker = ref(false);
|
|
443
|
+
const returnDate = ref<string | null>("");
|
|
444
|
+
const returnDateRule = (v: string | null) => !v || v >= today || "The return date cannot be in the past";
|
|
445
|
+
// Another property: its work orders differ, so a picked one no longer applies.
|
|
446
|
+
watch(site, () => (workOrder.value = null));
|
|
447
|
+
// DV-1787: serial numbers of the chosen items (issue only), loaded when an item with serials is picked.
|
|
448
|
+
const serialOptions = reactive<Record<string, { _id: string; serial: string }[]>>({});
|
|
449
|
+
const hasSerials = (line: TRow) =>
|
|
450
|
+
props.mode === "issue" && !!line.item && (itemChoices.value.find((c) => c._id === line.item)?.serialsInStore ?? 0) > 0;
|
|
451
|
+
/** Units of the item on the shelf without a serial number (mixed stock: serials are optional). */
|
|
452
|
+
const withoutSerial = (line: TRow) => {
|
|
453
|
+
const c = itemChoices.value.find((x) => x._id === line.item);
|
|
454
|
+
return c ? Math.max(0, Number(c.onHand ?? 0) - Number(c.serialsInStore ?? 0)) : 0;
|
|
455
|
+
};
|
|
456
|
+
const serialHint = (line: TRow) => {
|
|
457
|
+
const n = withoutSerial(line);
|
|
458
|
+
const picked = line.serials?.length ?? 0;
|
|
459
|
+
const rest = Math.max(0, Number(line.qty || 0) - picked);
|
|
460
|
+
return `${picked} by serial${rest ? `, ${rest} without a serial` : ""}. ${n} on the shelf without a serial.`;
|
|
461
|
+
};
|
|
462
|
+
/** Qty = units by serial + units without one; no more without one than the shelf has. */
|
|
463
|
+
function serialQtyRule(line: TRow) {
|
|
464
|
+
return (v: number | null) => {
|
|
465
|
+
if (!hasSerials(line)) return true;
|
|
466
|
+
const picked = line.serials?.length ?? 0;
|
|
467
|
+
const q = Number(v || 0);
|
|
468
|
+
if (q < picked) return `At least ${picked} (the serials chosen)`;
|
|
469
|
+
const n = withoutSerial(line);
|
|
470
|
+
if (q - picked > n) return n ? `Only ${n} without a serial: pick serials for the rest` : "Pick a serial number for each unit";
|
|
471
|
+
return true;
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
watch(
|
|
475
|
+
() => rows.value.map((r) => r.item),
|
|
476
|
+
async () => {
|
|
477
|
+
for (const r of rows.value) {
|
|
478
|
+
if (!hasSerials(r)) {
|
|
479
|
+
if (r.serials?.length) r.serials = [];
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
if (serialOptions[r.item!]) continue;
|
|
483
|
+
try {
|
|
484
|
+
serialOptions[r.item!] = (await api.getSerials(r.item!, "in_store")).items.map((s) => ({ _id: s._id, serial: s.serial }));
|
|
485
|
+
} catch {
|
|
486
|
+
serialOptions[r.item!] = [];
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
);
|
|
491
|
+
// Another person (or none): the work order was picked for the previous one, so it goes too.
|
|
492
|
+
watch(holder, () => (workOrder.value = null));
|
|
371
493
|
// Receiving (client 2026-10-02): PO / DO / cash, each with its own paperwork.
|
|
372
494
|
const receivingType = ref<TReceivingType>("PO");
|
|
373
495
|
const doNumber = ref("");
|
|
@@ -397,7 +519,7 @@ async function loadTargets() {
|
|
|
397
519
|
const receivingHelp = computed(() => RECEIVING_TYPES.find((t) => t.value === receivingType.value)?.help ?? "");
|
|
398
520
|
const hasOrdered = (r: TRow) => r.ordered !== null && r.ordered !== undefined && r.ordered !== ("" as any);
|
|
399
521
|
const receivingCheck = () =>
|
|
400
|
-
receivingProblem({ type: receivingType.value, poNumber: reference.value, doNumber: doNumber.value, doDate: doDate.value, anyOrdered: receivingType.value !== "CASH" && rows.value.some(hasOrdered) });
|
|
522
|
+
receivingProblem({ type: receivingType.value, poNumber: reference.value || "", doNumber: doNumber.value, doDate: doDate.value, anyOrdered: receivingType.value !== "CASH" && rows.value.some(hasOrdered) });
|
|
401
523
|
/** Shown once they have tried to save, so the form does not open with a warning. */
|
|
402
524
|
const receivingError = computed(() => (props.mode === "receive" && tried.value ? receivingCheck() : ""));
|
|
403
525
|
const orderedRule = (v: number | null | string) => v === null || v === "" || (Number.isInteger(Number(v)) && Number(v) >= 1) || "Whole number";
|
|
@@ -410,8 +532,8 @@ const choices = computed<any[]>(() =>
|
|
|
410
532
|
);
|
|
411
533
|
const siteChoices = computed(() => (props.sites.length ? props.sites : props.store.sites.map((_id) => ({ _id, name: _id === props.siteId ? "This property" : "Other property" }))));
|
|
412
534
|
|
|
413
|
-
const unitOf = (id: string) => choices.value.find((c) => c._id === id)?.unit ?? "";
|
|
414
|
-
const availableOf = (id: string) => {
|
|
535
|
+
const unitOf = (id: string | null) => choices.value.find((c) => c._id === id)?.unit ?? "";
|
|
536
|
+
const availableOf = (id: string | null) => {
|
|
415
537
|
const c = choices.value.find((x) => x._id === id);
|
|
416
538
|
return c && (props.mode === "request" || props.mode === "issue" || props.mode === "transfer") ? availableQty(c) : c?.onHand;
|
|
417
539
|
};
|
|
@@ -499,7 +621,7 @@ async function submit() {
|
|
|
499
621
|
supplier: supplier.value,
|
|
500
622
|
...receivingFields({
|
|
501
623
|
type: receivingType.value,
|
|
502
|
-
poNumber: reference.value,
|
|
624
|
+
poNumber: reference.value || "",
|
|
503
625
|
doNumber: doNumber.value,
|
|
504
626
|
// The server refuses a future time: today's DO date is "now", an earlier one noon that day.
|
|
505
627
|
doDateIso: doDate.value ? (pickedDate(doDate.value) ?? new Date().toISOString()) : undefined,
|
|
@@ -507,7 +629,7 @@ async function submit() {
|
|
|
507
629
|
}),
|
|
508
630
|
date: pickedDate(date.value),
|
|
509
631
|
photos: photos.value,
|
|
510
|
-
remarks: remarks.value,
|
|
632
|
+
remarks: remarks.value || "",
|
|
511
633
|
});
|
|
512
634
|
} else if (props.mode === "request") {
|
|
513
635
|
const newItems = fresh.map((r) => ({
|
|
@@ -521,15 +643,27 @@ async function submit() {
|
|
|
521
643
|
lines,
|
|
522
644
|
...(newItems.length ? { newItems } : {}),
|
|
523
645
|
...(deliverChoice.value && deliverTo.value === "store" ? { deliverTo: { store: ownStore.value!._id } } : {}),
|
|
524
|
-
reference: reference.value,
|
|
525
|
-
remarks: remarks.value,
|
|
646
|
+
reference: reference.value || "",
|
|
647
|
+
remarks: remarks.value || "",
|
|
526
648
|
});
|
|
527
649
|
} else if (props.mode === "transfer") {
|
|
528
|
-
await api.transferToStore(props.store._id, { to: transferTo.value, site: props.siteId, lines, reference: reference.value, remarks: remarks.value });
|
|
650
|
+
await api.transferToStore(props.store._id, { to: transferTo.value, site: props.siteId, lines, reference: reference.value || "", remarks: remarks.value || "" });
|
|
529
651
|
} else if (props.mode === "issue") {
|
|
530
|
-
await api.issue(props.store._id, {
|
|
652
|
+
await api.issue(props.store._id, {
|
|
653
|
+
holder: holder.value,
|
|
654
|
+
site: site.value || props.siteId,
|
|
655
|
+
// DV-1787: the chosen serial numbers go with their item.
|
|
656
|
+
lines: lines.map((l) => {
|
|
657
|
+
const row = rows.value.find((r) => r.item === l.item && r.serials?.length);
|
|
658
|
+
return row ? { ...l, serials: row.serials } : l;
|
|
659
|
+
}),
|
|
660
|
+
reference: reference.value || "",
|
|
661
|
+
remarks: remarks.value || "",
|
|
662
|
+
...(workOrder.value ? { workOrder: workOrder.value._id } : {}),
|
|
663
|
+
...(returnDate.value ? { returnDate: returnDate.value } : {}),
|
|
664
|
+
});
|
|
531
665
|
} else {
|
|
532
|
-
await api.receiveReturn(props.store._id, { holder: props.holderId, lines, remarks: remarks.value });
|
|
666
|
+
await api.receiveReturn(props.store._id, { holder: props.holderId, lines, remarks: remarks.value || "" });
|
|
533
667
|
}
|
|
534
668
|
notify(copy.value.success);
|
|
535
669
|
show.value = false;
|
|
@@ -545,13 +679,17 @@ watch(show, (open) => {
|
|
|
545
679
|
if (!open) return;
|
|
546
680
|
form.value?.resetValidation();
|
|
547
681
|
rows.value = [blank()];
|
|
682
|
+
// serial numbers change with every issue / return: load them fresh
|
|
683
|
+
for (const k of Object.keys(serialOptions)) delete serialOptions[k];
|
|
548
684
|
supplier.value = "";
|
|
549
685
|
reference.value = "";
|
|
550
686
|
remarks.value = "";
|
|
551
687
|
photos.value = [];
|
|
552
688
|
date.value = today;
|
|
553
|
-
holder.value =
|
|
689
|
+
holder.value = null;
|
|
554
690
|
site.value = props.siteId;
|
|
691
|
+
workOrder.value = null;
|
|
692
|
+
returnDate.value = "";
|
|
555
693
|
receivingType.value = "PO";
|
|
556
694
|
doNumber.value = "";
|
|
557
695
|
doDate.value = "";
|
|
@@ -169,6 +169,10 @@
|
|
|
169
169
|
<v-window-item v-if="ctl.tabs.mine" value="mine">
|
|
170
170
|
<InventoryMyStockTab :store="store" :site-id="siteId" :sites="storeSites" @changed="refreshCounts" />
|
|
171
171
|
</v-window-item>
|
|
172
|
+
<!-- DV-1787: what is checked out (issued for a work order / to come back by a date), overdue first. -->
|
|
173
|
+
<v-window-item v-if="seesCheckouts" value="checkouts">
|
|
174
|
+
<InventoryCheckoutsTab :store="store" @counts="(c: { out: number; overdue: number }) => (overdueCount = c.overdue)" @changed="refreshCounts" />
|
|
175
|
+
</v-window-item>
|
|
172
176
|
<v-window-item v-if="ctl.tabs.requests" value="requests">
|
|
173
177
|
<InventoryRequestsTab :store="store" :site-id="siteId" :focus-request="focusRequest" @changed="refreshCounts" />
|
|
174
178
|
</v-window-item>
|
|
@@ -303,6 +307,21 @@ const worker = useWorkerTerm({ providers: true });
|
|
|
303
307
|
|
|
304
308
|
const ctl = computed(() => inventoryControls(store.value?.access));
|
|
305
309
|
|
|
310
|
+
// DV-1787: the store's keepers, approvers, managers and report readers see everyone's checkouts.
|
|
311
|
+
const seesCheckouts = computed(() => {
|
|
312
|
+
const a = store.value?.access;
|
|
313
|
+
return Boolean(a && (a.canHandle || a.canApprove || a.canManage || a.canReports));
|
|
314
|
+
});
|
|
315
|
+
const overdueCount = ref(0);
|
|
316
|
+
async function refreshOverdue() {
|
|
317
|
+
if (!store.value || !seesCheckouts.value) return (overdueCount.value = 0);
|
|
318
|
+
try {
|
|
319
|
+
overdueCount.value = (await useInventory().getCheckouts(store.value._id, { limit: 1 })).counts.overdue;
|
|
320
|
+
} catch {
|
|
321
|
+
overdueCount.value = 0;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
306
325
|
const tabs = computed(() => {
|
|
307
326
|
const a = store.value?.access;
|
|
308
327
|
if (!a) return [];
|
|
@@ -310,6 +329,7 @@ const tabs = computed(() => {
|
|
|
310
329
|
{ value: "stock", label: "Stock" },
|
|
311
330
|
// Hide, never grey: each tab only for the job that uses it (API-core decides `access`).
|
|
312
331
|
...(ctl.value.tabs.mine ? [{ value: "mine", label: "My Stock" }] : []),
|
|
332
|
+
...(seesCheckouts.value ? [{ value: "checkouts", label: "Checked out", badge: overdueCount.value }] : []),
|
|
313
333
|
...(ctl.value.tabs.requests ? [{ value: "requests", label: a.canApprove ? "Requests" : "My Requests", badge: a.canApprove ? pendingCount.value : 0 }] : []),
|
|
314
334
|
...(ctl.value.tabs.people ? [{ value: "technicians", label: worker.many, badge: returnsWaiting.value }] : []),
|
|
315
335
|
...(ctl.value.tabs.reports ? [{ value: "reports", label: a.canReports ? "Reports" : "Usage check" }] : []),
|
|
@@ -399,6 +419,7 @@ async function refreshReturns() {
|
|
|
399
419
|
async function refreshCounts() {
|
|
400
420
|
refreshToConfirm();
|
|
401
421
|
refreshReturns();
|
|
422
|
+
refreshOverdue();
|
|
402
423
|
if (!store.value?.access.canApprove) return (pendingCount.value = 0);
|
|
403
424
|
try {
|
|
404
425
|
pendingCount.value = (await getRequests(store.value._id, { status: "pending", limit: 1 }))?.pendingCount ?? 0;
|
|
@@ -103,6 +103,12 @@
|
|
|
103
103
|
</v-col>
|
|
104
104
|
</v-row>
|
|
105
105
|
|
|
106
|
+
<!-- DV-1787: what was issued to me for a work order / to give back by a date, flagged when overdue. -->
|
|
107
|
+
<div v-show="checkedOut > 0" class="mt-6">
|
|
108
|
+
<div class="text-subtitle-2 mb-2">Checked out to me</div>
|
|
109
|
+
<InventoryCheckoutsTab ref="checkoutsList" :store="store" mine @counts="(c: { out: number; overdue: number }) => (checkedOut = c.out)" @changed="changed" />
|
|
110
|
+
</div>
|
|
111
|
+
|
|
106
112
|
<div class="d-flex align-center mt-6 mb-2">
|
|
107
113
|
<div class="text-subtitle-2">My recent activity</div>
|
|
108
114
|
<v-spacer />
|
|
@@ -126,7 +132,7 @@
|
|
|
126
132
|
<td>{{ activityText(t) }}</td>
|
|
127
133
|
<td class="text-right">{{ t.qty }}</td>
|
|
128
134
|
<td class="text-caption">
|
|
129
|
-
{{ [t.location?.type === "tenant_unit" ? `${t.location.unitName} ${t.location.tenantName || ""}` : t.location?.area, t.type === "handover" ? t.remarks : t.reference].filter(Boolean).join(" · ") }}
|
|
135
|
+
{{ [t.location?.type === "tenant_unit" ? `${t.location.unitName} ${t.location.tenantName || ""}` : t.location?.area, t.type === "handover" ? t.remarks : t.reference, t.type === "issue" && t.workOrderNumber ? `WO ${t.workOrderNumber}` : "", t.type === "issue" && t.returnDate ? `Return by ${returnDayText(t.returnDate)}` : ""].filter(Boolean).join(" · ") }}
|
|
130
136
|
</td>
|
|
131
137
|
<td class="text-right">{{ t.holderBalance }}</td>
|
|
132
138
|
</tr>
|
|
@@ -369,6 +375,14 @@ const toConfirm = computed(() => handovers.value.filter((h) => h.status === "pen
|
|
|
369
375
|
const waiting = computed(() => handovers.value.filter((h) => h.status === "pending" && String(h.from) === me.value));
|
|
370
376
|
const acting = ref("");
|
|
371
377
|
|
|
378
|
+
// DV-1787: checked out to me (shown only when something is), and the return date as its calendar day.
|
|
379
|
+
const checkedOut = ref(0);
|
|
380
|
+
const checkoutsList = ref<{ load: () => void } | null>(null);
|
|
381
|
+
const returnDayText = (d: string) => {
|
|
382
|
+
const [y, m, day] = d.slice(0, 10).split("-").map(Number);
|
|
383
|
+
return standardFormatDate(new Date(y, m - 1, day));
|
|
384
|
+
};
|
|
385
|
+
|
|
372
386
|
function activityText(t: TInventoryTransaction) {
|
|
373
387
|
if (t.type === "issue") return "Taken from store";
|
|
374
388
|
if (t.type === "return") return "Given back to store";
|
|
@@ -475,6 +489,7 @@ function use(h: TInventoryHolding) {
|
|
|
475
489
|
|
|
476
490
|
function changed() {
|
|
477
491
|
load();
|
|
492
|
+
checkoutsList.value?.load();
|
|
478
493
|
loadHandovers();
|
|
479
494
|
loadDrafts();
|
|
480
495
|
loadColleagueDrafts();
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
DV-1787: which serial numbers go (write-off, usage) for an item with serials. Optional: the rest
|
|
4
|
+
of the quantity goes as units without a serial. Shows nothing when there are no serials to choose.
|
|
5
|
+
-->
|
|
6
|
+
<v-autocomplete
|
|
7
|
+
v-if="choices.length"
|
|
8
|
+
v-model="picked"
|
|
9
|
+
:items="choices"
|
|
10
|
+
item-title="serial"
|
|
11
|
+
item-value="_id"
|
|
12
|
+
:label="label"
|
|
13
|
+
placeholder="Pick the units by serial"
|
|
14
|
+
density="comfortable"
|
|
15
|
+
multiple
|
|
16
|
+
chips
|
|
17
|
+
closable-chips
|
|
18
|
+
clearable
|
|
19
|
+
persistent-clear
|
|
20
|
+
:hint="hint"
|
|
21
|
+
persistent-hint
|
|
22
|
+
:rules="[rule]"
|
|
23
|
+
class="mb-2"
|
|
24
|
+
/>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import useInventory from "../composables/useInventory";
|
|
29
|
+
|
|
30
|
+
const picked = defineModel<string[]>({ default: () => [] });
|
|
31
|
+
const props = defineProps({
|
|
32
|
+
item: { type: String, default: "" },
|
|
33
|
+
/** `store`: serials on the shelf. `mine`: serials out with the signed-in person. */
|
|
34
|
+
source: { type: String as PropType<"store" | "mine">, default: "mine" },
|
|
35
|
+
qty: { type: Number, default: 0 },
|
|
36
|
+
/** Units of the item in this stock (the shelf, or the person's hand). */
|
|
37
|
+
units: { type: Number, default: 0 },
|
|
38
|
+
label: { type: String, default: "Serial numbers (optional)" },
|
|
39
|
+
/** Whether the dialog is open (reloads the choices each time). */
|
|
40
|
+
open: { type: Boolean, default: true },
|
|
41
|
+
/** Serials chosen before (a draft) that are still the person's. */
|
|
42
|
+
initial: { type: Array as PropType<string[]>, default: () => [] },
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const api = useInventory();
|
|
46
|
+
const choices = ref<{ _id: string; serial: string }[]>([]);
|
|
47
|
+
|
|
48
|
+
const without = computed(() => Math.max(0, props.units - choices.value.length));
|
|
49
|
+
const hint = computed(() => {
|
|
50
|
+
const n = picked.value?.length ?? 0;
|
|
51
|
+
const rest = Math.max(0, Number(props.qty || 0) - n);
|
|
52
|
+
return `${n} by serial${rest ? `, ${rest} without a serial` : ""}. Choose the exact units so each serial's history is right.`;
|
|
53
|
+
});
|
|
54
|
+
/** No more serials than the quantity; on the shelf, no more units without a serial than it has. */
|
|
55
|
+
function rule() {
|
|
56
|
+
const n = picked.value?.length ?? 0;
|
|
57
|
+
const q = Number(props.qty || 0);
|
|
58
|
+
if (n > q) return `You chose ${n} serial numbers for ${q}`;
|
|
59
|
+
if (props.source === "store" && q - n > without.value) {
|
|
60
|
+
return without.value ? `Only ${without.value} without a serial: pick serials for the rest` : "Pick a serial number for each unit";
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function load() {
|
|
66
|
+
choices.value = [];
|
|
67
|
+
if (!props.item) return;
|
|
68
|
+
try {
|
|
69
|
+
const res = await api.getSerials(props.item, props.source === "store" ? "in_store" : "mine");
|
|
70
|
+
choices.value = res.items.map((s) => ({ _id: s._id, serial: s.serial }));
|
|
71
|
+
const ok = new Set(choices.value.map((c) => c._id));
|
|
72
|
+
picked.value = props.initial.filter((id) => ok.has(String(id))).map(String);
|
|
73
|
+
} catch {
|
|
74
|
+
choices.value = [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
watch(
|
|
79
|
+
() => [props.open, props.item],
|
|
80
|
+
([open]) => {
|
|
81
|
+
if (open) load();
|
|
82
|
+
},
|
|
83
|
+
{ immediate: true },
|
|
84
|
+
);
|
|
85
|
+
</script>
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
DV-1787: scan serial numbers with the device camera, one after another, until every unit has
|
|
4
|
+
one (or Done). Reads 1D barcodes (Code 128, Code 39, EAN, UPC, ...) and 2D codes (QR, Data
|
|
5
|
+
Matrix, PDF417, Aztec). The same code twice, or one already entered, is skipped.
|
|
6
|
+
-->
|
|
7
|
+
<v-dialog v-model="show" max-width="560" persistent @after-enter="start">
|
|
8
|
+
<v-card class="screen-modal">
|
|
9
|
+
<v-card-title class="d-flex align-center">
|
|
10
|
+
Scan serial numbers
|
|
11
|
+
<v-spacer />
|
|
12
|
+
<v-btn icon="mdi-close" variant="text" class="screen-modal__close" aria-label="Close" @click="finish" />
|
|
13
|
+
</v-card-title>
|
|
14
|
+
<v-card-text class="screen-modal__body">
|
|
15
|
+
<p class="text-body-2 text-medium-emphasis mb-2">
|
|
16
|
+
Point the camera at each unit's barcode or QR code, one at a time. Each scan fills the next unit.
|
|
17
|
+
</p>
|
|
18
|
+
<div class="d-flex align-center mb-2">
|
|
19
|
+
<span class="text-subtitle-2">{{ scanned.length }} of {{ max }} scanned</span>
|
|
20
|
+
<v-spacer />
|
|
21
|
+
<v-btn v-if="cameras > 1" size="small" variant="text" class="text-none" prepend-icon="mdi-camera-switch" @click="switchCamera">Switch camera</v-btn>
|
|
22
|
+
</div>
|
|
23
|
+
<v-progress-linear :model-value="max ? (scanned.length / max) * 100 : 0" color="primary" rounded class="mb-3" />
|
|
24
|
+
<div :id="readerId" class="serial-scan__reader" />
|
|
25
|
+
<v-alert v-if="error" type="warning" variant="tonal" density="compact" class="mt-2">{{ error }}</v-alert>
|
|
26
|
+
<div v-if="last" class="serial-scan__last mt-2" :class="`serial-scan__last--${last.kind}`">
|
|
27
|
+
<v-icon :icon="last.kind === 'ok' ? 'mdi-check-circle' : 'mdi-information'" size="18" class="mr-1" />{{ last.text }}
|
|
28
|
+
</div>
|
|
29
|
+
<div v-if="scanned.length" class="d-flex flex-wrap ga-1 mt-3">
|
|
30
|
+
<v-chip v-for="(s, i) in scanned" :key="s" size="small" closable @click:close="scanned.splice(i, 1)">{{ s }}</v-chip>
|
|
31
|
+
</div>
|
|
32
|
+
</v-card-text>
|
|
33
|
+
<div class="screen-modal__footer">
|
|
34
|
+
<v-btn class="screen-btn-ghost" variant="outlined" @click="cancel">Cancel</v-btn>
|
|
35
|
+
<v-btn class="screen-btn-primary" variant="flat" :disabled="!scanned.length" @click="finish">
|
|
36
|
+
Done{{ scanned.length ? ` (${scanned.length})` : "" }}
|
|
37
|
+
</v-btn>
|
|
38
|
+
</div>
|
|
39
|
+
</v-card>
|
|
40
|
+
</v-dialog>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
const show = defineModel<boolean>({ default: false });
|
|
45
|
+
const props = defineProps({
|
|
46
|
+
/** How many serials are still needed (the scan stops by itself at this many). */
|
|
47
|
+
max: { type: Number, default: 1 },
|
|
48
|
+
/** Serials already entered or saved: scanning one of them is skipped. */
|
|
49
|
+
existing: { type: Array as PropType<string[]>, default: () => [] },
|
|
50
|
+
});
|
|
51
|
+
const emit = defineEmits<{ scanned: [serials: string[]] }>();
|
|
52
|
+
|
|
53
|
+
const { $Html5Qrcode }: any = useNuxtApp();
|
|
54
|
+
const readerId = `serial-scan-${Math.random().toString(36).slice(2, 8)}`;
|
|
55
|
+
const scanned = ref<string[]>([]);
|
|
56
|
+
const error = ref("");
|
|
57
|
+
const last = ref<{ kind: "ok" | "skip"; text: string } | null>(null);
|
|
58
|
+
const cameras = ref(0);
|
|
59
|
+
const facing = ref<"environment" | "user">("environment");
|
|
60
|
+
let reader: any = null;
|
|
61
|
+
let lastCode = "";
|
|
62
|
+
let lastAt = 0;
|
|
63
|
+
|
|
64
|
+
const key = (s: string) => s.trim().replace(/\s+/g, " ").toUpperCase();
|
|
65
|
+
|
|
66
|
+
function beep() {
|
|
67
|
+
try {
|
|
68
|
+
const ctx = new (window.AudioContext || (window as any).webkitAudioContext)();
|
|
69
|
+
const o = ctx.createOscillator();
|
|
70
|
+
o.frequency.value = 880;
|
|
71
|
+
o.connect(ctx.destination);
|
|
72
|
+
o.start();
|
|
73
|
+
setTimeout(() => (o.stop(), ctx.close()), 120);
|
|
74
|
+
} catch {
|
|
75
|
+
/* no sound - fine */
|
|
76
|
+
}
|
|
77
|
+
navigator.vibrate?.(80);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function onCode(text: string) {
|
|
81
|
+
const code = String(text ?? "").trim();
|
|
82
|
+
if (!code) return;
|
|
83
|
+
const now = Date.now();
|
|
84
|
+
// The same code stays in front of the camera for a while: read it once.
|
|
85
|
+
if (code === lastCode && now - lastAt < 2500) return;
|
|
86
|
+
lastCode = code;
|
|
87
|
+
lastAt = now;
|
|
88
|
+
const k = key(code);
|
|
89
|
+
if (scanned.value.some((s) => key(s) === k) || props.existing.some((s) => key(String(s)) === k)) {
|
|
90
|
+
last.value = { kind: "skip", text: `${code} is already in the list` };
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (code.length > 100) {
|
|
94
|
+
last.value = { kind: "skip", text: "That code is too long for a serial number" };
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
scanned.value.push(code);
|
|
98
|
+
last.value = { kind: "ok", text: `${code} added` };
|
|
99
|
+
beep();
|
|
100
|
+
if (scanned.value.length >= props.max) finish();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function start() {
|
|
104
|
+
error.value = "";
|
|
105
|
+
if (reader) return;
|
|
106
|
+
try {
|
|
107
|
+
const list = await $Html5Qrcode.getCameras();
|
|
108
|
+
cameras.value = list?.length ?? 0;
|
|
109
|
+
} catch {
|
|
110
|
+
cameras.value = 0;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
reader = new $Html5Qrcode(readerId, { verbose: false, experimentalFeatures: { useBarCodeDetectorIfSupported: true } });
|
|
114
|
+
await reader.start(
|
|
115
|
+
{ facingMode: facing.value },
|
|
116
|
+
{
|
|
117
|
+
fps: 10,
|
|
118
|
+
// Wide box: long 1D barcodes fit; square codes fit too.
|
|
119
|
+
qrbox: (w: number, h: number) => ({ width: Math.floor(Math.min(w * 0.85, 420)), height: Math.floor(Math.min(h * 0.6, 240)) }),
|
|
120
|
+
},
|
|
121
|
+
onCode,
|
|
122
|
+
() => {},
|
|
123
|
+
);
|
|
124
|
+
} catch (e: any) {
|
|
125
|
+
reader = null;
|
|
126
|
+
error.value = `Could not open the camera. Allow camera access in the browser and try again. (${e?.message ?? e})`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function stop() {
|
|
131
|
+
const r = reader;
|
|
132
|
+
reader = null;
|
|
133
|
+
if (!r) return;
|
|
134
|
+
try {
|
|
135
|
+
if (r.isScanning) await r.stop();
|
|
136
|
+
r.clear();
|
|
137
|
+
} catch {
|
|
138
|
+
/* already stopped */
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function switchCamera() {
|
|
143
|
+
await stop();
|
|
144
|
+
facing.value = facing.value === "environment" ? "user" : "environment";
|
|
145
|
+
start();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function finish() {
|
|
149
|
+
await stop();
|
|
150
|
+
if (scanned.value.length) emit("scanned", [...scanned.value]);
|
|
151
|
+
show.value = false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function cancel() {
|
|
155
|
+
await stop();
|
|
156
|
+
show.value = false;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
watch(show, (open) => {
|
|
160
|
+
if (open) {
|
|
161
|
+
scanned.value = [];
|
|
162
|
+
last.value = null;
|
|
163
|
+
lastCode = "";
|
|
164
|
+
} else stop();
|
|
165
|
+
});
|
|
166
|
+
onBeforeUnmount(stop);
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<style scoped>
|
|
170
|
+
.serial-scan__reader {
|
|
171
|
+
width: 100%;
|
|
172
|
+
min-height: 240px;
|
|
173
|
+
border-radius: 8px;
|
|
174
|
+
overflow: hidden;
|
|
175
|
+
background: #000;
|
|
176
|
+
}
|
|
177
|
+
.serial-scan__last {
|
|
178
|
+
display: flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
font-size: 0.875rem;
|
|
181
|
+
}
|
|
182
|
+
.serial-scan__last--ok {
|
|
183
|
+
color: rgb(var(--v-theme-success));
|
|
184
|
+
}
|
|
185
|
+
.serial-scan__last--skip {
|
|
186
|
+
color: rgb(var(--v-theme-warning));
|
|
187
|
+
}
|
|
188
|
+
</style>
|