@7365admin1/layer-common 4.189.2 → 4.190.1
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 +32 -4
- package/components/AttendanceDetailsDialog.vue +13 -6
- package/components/AttendanceMain.vue +1 -1
- package/components/CleaningScheduleMain.vue +24 -0
- package/components/InventoryCheckoutDetail.vue +288 -0
- package/components/InventoryCheckoutReturnDialog.vue +189 -0
- package/components/InventoryCheckoutsTab.vue +349 -0
- package/components/InventoryHistoryDialog.vue +22 -1
- package/components/InventoryItemDetail.vue +12 -2
- package/components/InventoryItemDialog.vue +37 -0
- package/components/InventoryLinesDialog.vue +166 -20
- package/components/InventoryMain.vue +24 -0
- package/components/InventoryMyStockTab.vue +69 -5
- package/components/InventorySerialPick.vue +85 -0
- package/components/InventorySerialScanner.vue +188 -0
- package/components/InventorySerialsDialog.vue +202 -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/MyAttendanceMain.vue +1 -1
- package/components/SiteSettingsWorkOrder.vue +14 -1
- package/components/WorkOrder/IssuedItems.vue +156 -0
- package/composables/useInventory.ts +22 -2
- package/composables/useWorkOrder.ts +12 -0
- package/package.json +1 -1
- package/types/inventory.d.ts +66 -0
- package/utils/inventory-checkout.ts +114 -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) => serialsPicked(line, v)"
|
|
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({
|
|
@@ -346,8 +414,16 @@ const copy = computed(() => {
|
|
|
346
414
|
});
|
|
347
415
|
|
|
348
416
|
const form = ref();
|
|
417
|
+
/** DV-1787: serials picked - Qty covers them, and its message is checked again (not left stale). */
|
|
418
|
+
function serialsPicked(line: TRow, v: string[] | null) {
|
|
419
|
+
line.qty = Math.max(Number(line.qty) || 0, v?.length ?? 0) || null;
|
|
420
|
+
nextTick(() => {
|
|
421
|
+
const qtyField = (form.value?.items ?? []).find((i: any) => i.errorMessages?.length && /serial/i.test(String(i.errorMessages)));
|
|
422
|
+
qtyField?.validate?.();
|
|
423
|
+
});
|
|
424
|
+
}
|
|
349
425
|
const saving = ref(false);
|
|
350
|
-
const blank = (): TRow => ({ item:
|
|
426
|
+
const blank = (): TRow => ({ item: null, qty: null, unitCost: null, ordered: null, typed: "", newItem: null });
|
|
351
427
|
/** Receive: only store managers may add items to the list (the API says 403 otherwise). Request: anyone may ask. */
|
|
352
428
|
const canAddNew = computed(() => (props.mode === "receive" ? props.store.access.canManage : props.mode === "request"));
|
|
353
429
|
function typedSearch(line: TRow, q: string) {
|
|
@@ -356,7 +432,7 @@ function typedSearch(line: TRow, q: string) {
|
|
|
356
432
|
}
|
|
357
433
|
function addNew(line: TRow) {
|
|
358
434
|
line.newItem = { name: line.typed || "", unit: "pcs", category: "", note: "" };
|
|
359
|
-
line.item =
|
|
435
|
+
line.item = null;
|
|
360
436
|
}
|
|
361
437
|
const rows = ref<TRow[]>([blank()]);
|
|
362
438
|
const chosenCount = computed(() => rows.value.filter((r) => r.item || r.newItem?.name?.trim()).length);
|
|
@@ -366,8 +442,62 @@ const remarks = ref("");
|
|
|
366
442
|
const photos = ref<string[]>([]);
|
|
367
443
|
const today = new Date().toLocaleDateString("en-CA");
|
|
368
444
|
const date = ref(today);
|
|
369
|
-
|
|
445
|
+
// null (not ""): an empty field, so its clear button shows only once someone is picked.
|
|
446
|
+
const holder = ref<string | null>(null);
|
|
370
447
|
const site = ref(props.siteId);
|
|
448
|
+
// DV-1787: Issue Stock - the work order it is for, and when it should come back (both optional).
|
|
449
|
+
const workOrder = ref<TPickedWorkOrder | null>(null);
|
|
450
|
+
const workOrderPicker = ref(false);
|
|
451
|
+
const returnDate = ref<string | null>("");
|
|
452
|
+
const returnDateRule = (v: string | null) => !v || v >= today || "The return date cannot be in the past";
|
|
453
|
+
// Another property: its work orders differ, so a picked one no longer applies.
|
|
454
|
+
watch(site, () => (workOrder.value = null));
|
|
455
|
+
// DV-1787: serial numbers of the chosen items (issue only), loaded when an item with serials is picked.
|
|
456
|
+
const serialOptions = reactive<Record<string, { _id: string; serial: string }[]>>({});
|
|
457
|
+
const hasSerials = (line: TRow) =>
|
|
458
|
+
props.mode === "issue" && !!line.item && (itemChoices.value.find((c) => c._id === line.item)?.serialsInStore ?? 0) > 0;
|
|
459
|
+
/** Units of the item on the shelf without a serial number (mixed stock: serials are optional). */
|
|
460
|
+
const withoutSerial = (line: TRow) => {
|
|
461
|
+
const c = itemChoices.value.find((x) => x._id === line.item);
|
|
462
|
+
return c ? Math.max(0, Number(c.onHand ?? 0) - Number(c.serialsInStore ?? 0)) : 0;
|
|
463
|
+
};
|
|
464
|
+
const serialHint = (line: TRow) => {
|
|
465
|
+
const n = withoutSerial(line);
|
|
466
|
+
const picked = line.serials?.length ?? 0;
|
|
467
|
+
const rest = Math.max(0, Number(line.qty || 0) - picked);
|
|
468
|
+
return `${picked} by serial${rest ? `, ${rest} without a serial` : ""}. ${n} on the shelf without a serial.`;
|
|
469
|
+
};
|
|
470
|
+
/** Qty = units by serial + units without one; no more without one than the shelf has. */
|
|
471
|
+
function serialQtyRule(line: TRow) {
|
|
472
|
+
return (v: number | null) => {
|
|
473
|
+
if (!hasSerials(line)) return true;
|
|
474
|
+
const picked = line.serials?.length ?? 0;
|
|
475
|
+
const q = Number(v || 0);
|
|
476
|
+
if (q < picked) return `At least ${picked} (the serials chosen)`;
|
|
477
|
+
const n = withoutSerial(line);
|
|
478
|
+
if (q - picked > n) return n ? `Only ${n} without a serial: pick serials for the rest` : "Pick a serial number for each unit";
|
|
479
|
+
return true;
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
watch(
|
|
483
|
+
() => rows.value.map((r) => r.item),
|
|
484
|
+
async () => {
|
|
485
|
+
for (const r of rows.value) {
|
|
486
|
+
if (!hasSerials(r)) {
|
|
487
|
+
if (r.serials?.length) r.serials = [];
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (serialOptions[r.item!]) continue;
|
|
491
|
+
try {
|
|
492
|
+
serialOptions[r.item!] = (await api.getSerials(r.item!, "in_store")).items.map((s) => ({ _id: s._id, serial: s.serial }));
|
|
493
|
+
} catch {
|
|
494
|
+
serialOptions[r.item!] = [];
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
);
|
|
499
|
+
// Another person (or none): the work order was picked for the previous one, so it goes too.
|
|
500
|
+
watch(holder, () => (workOrder.value = null));
|
|
371
501
|
// Receiving (client 2026-10-02): PO / DO / cash, each with its own paperwork.
|
|
372
502
|
const receivingType = ref<TReceivingType>("PO");
|
|
373
503
|
const doNumber = ref("");
|
|
@@ -397,7 +527,7 @@ async function loadTargets() {
|
|
|
397
527
|
const receivingHelp = computed(() => RECEIVING_TYPES.find((t) => t.value === receivingType.value)?.help ?? "");
|
|
398
528
|
const hasOrdered = (r: TRow) => r.ordered !== null && r.ordered !== undefined && r.ordered !== ("" as any);
|
|
399
529
|
const receivingCheck = () =>
|
|
400
|
-
receivingProblem({ type: receivingType.value, poNumber: reference.value, doNumber: doNumber.value, doDate: doDate.value, anyOrdered: receivingType.value !== "CASH" && rows.value.some(hasOrdered) });
|
|
530
|
+
receivingProblem({ type: receivingType.value, poNumber: reference.value || "", doNumber: doNumber.value, doDate: doDate.value, anyOrdered: receivingType.value !== "CASH" && rows.value.some(hasOrdered) });
|
|
401
531
|
/** Shown once they have tried to save, so the form does not open with a warning. */
|
|
402
532
|
const receivingError = computed(() => (props.mode === "receive" && tried.value ? receivingCheck() : ""));
|
|
403
533
|
const orderedRule = (v: number | null | string) => v === null || v === "" || (Number.isInteger(Number(v)) && Number(v) >= 1) || "Whole number";
|
|
@@ -410,8 +540,8 @@ const choices = computed<any[]>(() =>
|
|
|
410
540
|
);
|
|
411
541
|
const siteChoices = computed(() => (props.sites.length ? props.sites : props.store.sites.map((_id) => ({ _id, name: _id === props.siteId ? "This property" : "Other property" }))));
|
|
412
542
|
|
|
413
|
-
const unitOf = (id: string) => choices.value.find((c) => c._id === id)?.unit ?? "";
|
|
414
|
-
const availableOf = (id: string) => {
|
|
543
|
+
const unitOf = (id: string | null) => choices.value.find((c) => c._id === id)?.unit ?? "";
|
|
544
|
+
const availableOf = (id: string | null) => {
|
|
415
545
|
const c = choices.value.find((x) => x._id === id);
|
|
416
546
|
return c && (props.mode === "request" || props.mode === "issue" || props.mode === "transfer") ? availableQty(c) : c?.onHand;
|
|
417
547
|
};
|
|
@@ -499,7 +629,7 @@ async function submit() {
|
|
|
499
629
|
supplier: supplier.value,
|
|
500
630
|
...receivingFields({
|
|
501
631
|
type: receivingType.value,
|
|
502
|
-
poNumber: reference.value,
|
|
632
|
+
poNumber: reference.value || "",
|
|
503
633
|
doNumber: doNumber.value,
|
|
504
634
|
// The server refuses a future time: today's DO date is "now", an earlier one noon that day.
|
|
505
635
|
doDateIso: doDate.value ? (pickedDate(doDate.value) ?? new Date().toISOString()) : undefined,
|
|
@@ -507,7 +637,7 @@ async function submit() {
|
|
|
507
637
|
}),
|
|
508
638
|
date: pickedDate(date.value),
|
|
509
639
|
photos: photos.value,
|
|
510
|
-
remarks: remarks.value,
|
|
640
|
+
remarks: remarks.value || "",
|
|
511
641
|
});
|
|
512
642
|
} else if (props.mode === "request") {
|
|
513
643
|
const newItems = fresh.map((r) => ({
|
|
@@ -521,15 +651,27 @@ async function submit() {
|
|
|
521
651
|
lines,
|
|
522
652
|
...(newItems.length ? { newItems } : {}),
|
|
523
653
|
...(deliverChoice.value && deliverTo.value === "store" ? { deliverTo: { store: ownStore.value!._id } } : {}),
|
|
524
|
-
reference: reference.value,
|
|
525
|
-
remarks: remarks.value,
|
|
654
|
+
reference: reference.value || "",
|
|
655
|
+
remarks: remarks.value || "",
|
|
526
656
|
});
|
|
527
657
|
} 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 });
|
|
658
|
+
await api.transferToStore(props.store._id, { to: transferTo.value, site: props.siteId, lines, reference: reference.value || "", remarks: remarks.value || "" });
|
|
529
659
|
} else if (props.mode === "issue") {
|
|
530
|
-
await api.issue(props.store._id, {
|
|
660
|
+
await api.issue(props.store._id, {
|
|
661
|
+
holder: holder.value,
|
|
662
|
+
site: site.value || props.siteId,
|
|
663
|
+
// DV-1787: the chosen serial numbers go with their item.
|
|
664
|
+
lines: lines.map((l) => {
|
|
665
|
+
const row = rows.value.find((r) => r.item === l.item && r.serials?.length);
|
|
666
|
+
return row ? { ...l, serials: row.serials } : l;
|
|
667
|
+
}),
|
|
668
|
+
reference: reference.value || "",
|
|
669
|
+
remarks: remarks.value || "",
|
|
670
|
+
...(workOrder.value ? { workOrder: workOrder.value._id } : {}),
|
|
671
|
+
...(returnDate.value ? { returnDate: returnDate.value } : {}),
|
|
672
|
+
});
|
|
531
673
|
} else {
|
|
532
|
-
await api.receiveReturn(props.store._id, { holder: props.holderId, lines, remarks: remarks.value });
|
|
674
|
+
await api.receiveReturn(props.store._id, { holder: props.holderId, lines, remarks: remarks.value || "" });
|
|
533
675
|
}
|
|
534
676
|
notify(copy.value.success);
|
|
535
677
|
show.value = false;
|
|
@@ -545,13 +687,17 @@ watch(show, (open) => {
|
|
|
545
687
|
if (!open) return;
|
|
546
688
|
form.value?.resetValidation();
|
|
547
689
|
rows.value = [blank()];
|
|
690
|
+
// serial numbers change with every issue / return: load them fresh
|
|
691
|
+
for (const k of Object.keys(serialOptions)) delete serialOptions[k];
|
|
548
692
|
supplier.value = "";
|
|
549
693
|
reference.value = "";
|
|
550
694
|
remarks.value = "";
|
|
551
695
|
photos.value = [];
|
|
552
696
|
date.value = today;
|
|
553
|
-
holder.value =
|
|
697
|
+
holder.value = null;
|
|
554
698
|
site.value = props.siteId;
|
|
699
|
+
workOrder.value = null;
|
|
700
|
+
returnDate.value = "";
|
|
555
701
|
receivingType.value = "PO";
|
|
556
702
|
doNumber.value = "";
|
|
557
703
|
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" :refresh="refreshTick" @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" }] : []),
|
|
@@ -396,9 +416,13 @@ async function refreshReturns() {
|
|
|
396
416
|
}
|
|
397
417
|
}
|
|
398
418
|
|
|
419
|
+
/** DV-1787: tells the Checked out list to reload after stock changed on another tab. */
|
|
420
|
+
const refreshTick = ref(0);
|
|
399
421
|
async function refreshCounts() {
|
|
422
|
+
refreshTick.value++;
|
|
400
423
|
refreshToConfirm();
|
|
401
424
|
refreshReturns();
|
|
425
|
+
refreshOverdue();
|
|
402
426
|
if (!store.value?.access.canApprove) return (pendingCount.value = 0);
|
|
403
427
|
try {
|
|
404
428
|
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 />
|
|
@@ -125,8 +131,14 @@
|
|
|
125
131
|
<td>{{ t.itemName }}</td>
|
|
126
132
|
<td>{{ activityText(t) }}</td>
|
|
127
133
|
<td class="text-right">{{ t.qty }}</td>
|
|
128
|
-
<td class="text-
|
|
129
|
-
|
|
134
|
+
<td class="text-body-2">
|
|
135
|
+
<!-- DV-1787: the work order as a link (issue, return, use for a work order), then the rest -->
|
|
136
|
+
<template v-if="t.workOrder && t.workOrderNumber">
|
|
137
|
+
<NuxtLink v-if="workOrderRoute(t)" :to="workOrderRoute(t)!" class="history-wo-link">WO {{ t.workOrderNumber }}</NuxtLink>
|
|
138
|
+
<span v-else>WO {{ t.workOrderNumber }}</span>
|
|
139
|
+
<span v-if="activityWhere(t)"> · </span>
|
|
140
|
+
</template>
|
|
141
|
+
{{ activityWhere(t) }}
|
|
130
142
|
</td>
|
|
131
143
|
<td class="text-right">{{ t.holderBalance }}</td>
|
|
132
144
|
</tr>
|
|
@@ -205,6 +217,17 @@
|
|
|
205
217
|
style="max-width: 200px"
|
|
206
218
|
:rules="[retQtyRule]"
|
|
207
219
|
/>
|
|
220
|
+
<!-- DV-1787: which serial numbers come back; the rest are units without a serial -->
|
|
221
|
+
<InventorySerialPick
|
|
222
|
+
v-model="ret.serials"
|
|
223
|
+
:item="String(ret.holding.item)"
|
|
224
|
+
source="mine"
|
|
225
|
+
:qty="Number(ret.qty || 0)"
|
|
226
|
+
:units="freeOf(ret.holding)"
|
|
227
|
+
:open="ret.show"
|
|
228
|
+
label="Which serial numbers? (optional)"
|
|
229
|
+
@update:model-value="(v: string[] | null) => (ret.qty = Math.max(Number(ret.qty) || 0, v?.length ?? 0) || null)"
|
|
230
|
+
/>
|
|
208
231
|
<InputLabel title="Note (optional)" class="mb-1" />
|
|
209
232
|
<v-text-field v-model="ret.note" density="comfortable" maxlength="500" placeholder="e.g. job cancelled, not needed" />
|
|
210
233
|
</v-form>
|
|
@@ -236,6 +259,7 @@ import useFile from "../composables/useFile";
|
|
|
236
259
|
import useUtils from "../composables/useUtils";
|
|
237
260
|
import useLocalAuth from "../composables/useLocalAuth";
|
|
238
261
|
import { inventoryControls } from "../utils/inventory-presets";
|
|
262
|
+
import { workOrderLinkTarget } from "../utils/work-order-link";
|
|
239
263
|
import { colleagueDraftText, draftCardText } from "../utils/inventory-usage";
|
|
240
264
|
import { ackText, holdText, inventoryStepsLive, qtyUnit, unitWord } from "../utils/inventory-ack";
|
|
241
265
|
|
|
@@ -255,6 +279,19 @@ const { currentUser } = useLocalAuth();
|
|
|
255
279
|
|
|
256
280
|
const holdings = ref<TInventoryHolding[]>([]);
|
|
257
281
|
const activity = ref<TInventoryTransaction[]>([]);
|
|
282
|
+
// DV-1787: My recent activity - the work order is a link; never show a raw id as the reference.
|
|
283
|
+
const route = useRoute();
|
|
284
|
+
const router = useRouter();
|
|
285
|
+
const workOrderRoute = (t: TInventoryTransaction) => workOrderLinkTarget(t, route, router);
|
|
286
|
+
const isId = (v?: string) => /^[a-f0-9]{24}$/i.test(v ?? "");
|
|
287
|
+
const activityWhere = (t: TInventoryTransaction) =>
|
|
288
|
+
[
|
|
289
|
+
t.location?.type === "tenant_unit" ? `${t.location.unitName} ${t.location.tenantName || ""}` : t.location?.area,
|
|
290
|
+
t.type === "handover" ? t.remarks : t.workOrder || isId(t.reference) ? "" : t.reference,
|
|
291
|
+
t.type === "issue" && t.returnDate ? `Return by ${returnDayText(t.returnDate)}` : "",
|
|
292
|
+
]
|
|
293
|
+
.filter(Boolean)
|
|
294
|
+
.join(" · ");
|
|
258
295
|
const loading = ref(false);
|
|
259
296
|
const showRequest = ref(false);
|
|
260
297
|
const usage = reactive({ show: false, holding: null as TInventoryHolding | null, draft: null as TInventoryUsageDraft | null });
|
|
@@ -281,14 +318,14 @@ async function loadToReceive() {
|
|
|
281
318
|
}
|
|
282
319
|
|
|
283
320
|
const retForm = ref();
|
|
284
|
-
const ret = reactive({ show: false, holding: null as TInventoryHolding | null, qty: 1 as number | null, note: "", saving: false });
|
|
321
|
+
const ret = reactive({ show: false, holding: null as TInventoryHolding | null, qty: 1 as number | null, note: "", serials: [] as string[], saving: false });
|
|
285
322
|
const retQtyRule = (v: any) => {
|
|
286
323
|
if (!Number.isInteger(Number(v)) || Number(v) < 1) return "Enter a whole number";
|
|
287
324
|
const max = ret.holding ? freeOf(ret.holding) : 0;
|
|
288
325
|
return Number(v) <= max || `You can return up to ${max}`;
|
|
289
326
|
};
|
|
290
327
|
function openReturn(h: TInventoryHolding) {
|
|
291
|
-
Object.assign(ret, { show: true, holding: h, qty: freeOf(h), note: "", saving: false });
|
|
328
|
+
Object.assign(ret, { show: true, holding: h, qty: freeOf(h), note: "", serials: [], saving: false });
|
|
292
329
|
}
|
|
293
330
|
async function submitReturn() {
|
|
294
331
|
const { valid } = await retForm.value.validate();
|
|
@@ -296,7 +333,13 @@ async function submitReturn() {
|
|
|
296
333
|
ret.saving = true;
|
|
297
334
|
try {
|
|
298
335
|
const site = props.store.sites.includes(props.siteId) ? props.siteId : props.store.sites[0];
|
|
299
|
-
await api.requestReturn(props.store._id, {
|
|
336
|
+
await api.requestReturn(props.store._id, {
|
|
337
|
+
site,
|
|
338
|
+
item: String(ret.holding.item),
|
|
339
|
+
qty: Number(ret.qty),
|
|
340
|
+
note: ret.note,
|
|
341
|
+
...(ret.serials.length ? { serials: ret.serials } : {}),
|
|
342
|
+
});
|
|
300
343
|
notify("Return requested. Bring the items to the store keeper; they leave your stock once the keeper accepts them.");
|
|
301
344
|
ret.show = false;
|
|
302
345
|
changed();
|
|
@@ -369,6 +412,14 @@ const toConfirm = computed(() => handovers.value.filter((h) => h.status === "pen
|
|
|
369
412
|
const waiting = computed(() => handovers.value.filter((h) => h.status === "pending" && String(h.from) === me.value));
|
|
370
413
|
const acting = ref("");
|
|
371
414
|
|
|
415
|
+
// DV-1787: checked out to me (shown only when something is), and the return date as its calendar day.
|
|
416
|
+
const checkedOut = ref(0);
|
|
417
|
+
const checkoutsList = ref<{ load: () => void } | null>(null);
|
|
418
|
+
const returnDayText = (d: string) => {
|
|
419
|
+
const [y, m, day] = d.slice(0, 10).split("-").map(Number);
|
|
420
|
+
return standardFormatDate(new Date(y, m - 1, day));
|
|
421
|
+
};
|
|
422
|
+
|
|
372
423
|
function activityText(t: TInventoryTransaction) {
|
|
373
424
|
if (t.type === "issue") return "Taken from store";
|
|
374
425
|
if (t.type === "return") return "Given back to store";
|
|
@@ -475,6 +526,7 @@ function use(h: TInventoryHolding) {
|
|
|
475
526
|
|
|
476
527
|
function changed() {
|
|
477
528
|
load();
|
|
529
|
+
checkoutsList.value?.load();
|
|
478
530
|
loadHandovers();
|
|
479
531
|
loadDrafts();
|
|
480
532
|
loadColleagueDrafts();
|
|
@@ -486,3 +538,15 @@ watch(() => props.store._id, () => (load(), loadHandovers(), loadDrafts(), loadC
|
|
|
486
538
|
watch(stepsLive, () => (loadToReceive(), loadColleagueDrafts()));
|
|
487
539
|
onMounted(() => (load(), loadHandovers(), loadDrafts(), loadColleagueDrafts(), loadToReceive()));
|
|
488
540
|
</script>
|
|
541
|
+
|
|
542
|
+
<style scoped>
|
|
543
|
+
/* DV-1787: work order link (as in item History) */
|
|
544
|
+
.history-wo-link {
|
|
545
|
+
color: var(--accent);
|
|
546
|
+
font-weight: 600;
|
|
547
|
+
text-decoration: none;
|
|
548
|
+
}
|
|
549
|
+
.history-wo-link:hover {
|
|
550
|
+
text-decoration: underline;
|
|
551
|
+
}
|
|
552
|
+
</style>
|
|
@@ -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>
|