@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.
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <!--
3
+ DV-1787: serial numbers of an item. Units on the shelf can each be given a serial; from then on
4
+ every unit is tracked one by one, with its own history (added, issued to whom and for which work
5
+ order, returned, written off, handed over).
6
+ -->
7
+ <v-dialog v-model="show" max-width="720" scrollable>
8
+ <v-card v-if="item" class="screen-modal">
9
+ <v-card-title class="d-flex align-center">
10
+ Serial numbers · {{ item.name }}
11
+ <v-spacer />
12
+ <v-btn icon="mdi-close" variant="text" class="screen-modal__close" aria-label="Close" @click="show = false" />
13
+ </v-card-title>
14
+ <v-card-text class="screen-modal__body">
15
+ <p class="text-body-2 text-medium-emphasis mb-3">
16
+ {{ inStore }} of {{ onHand }} {{ unitWord(onHand, item.unit) }} on the shelf {{ inStore === 1 ? "has" : "have" }} a serial number.
17
+ {{ rows.length - inStore > 0 ? `${rows.length - inStore} more with people or closed.` : "" }}
18
+ </p>
19
+
20
+ <!-- one field per unit on the shelf that has no serial number yet -->
21
+ <template v-if="canAdd && free > 0">
22
+ <div class="d-flex align-center mb-2">
23
+ <div class="text-subtitle-2">Add serial numbers</div>
24
+ <v-spacer />
25
+ <span class="text-caption text-medium-emphasis mr-2">{{ free }} {{ unitWord(free, item.unit) }} without one</span>
26
+ <!-- DV-1787: scan barcodes / QR codes with the camera, one after another -->
27
+ <v-btn size="small" variant="tonal" color="primary" class="text-none" prepend-icon="mdi-barcode-scan" :disabled="!emptySlots" @click="scanning = true">
28
+ Scan
29
+ </v-btn>
30
+ </div>
31
+ <v-row dense>
32
+ <v-col v-for="(v, i) in entries" :key="i" cols="12" sm="6">
33
+ <v-text-field v-model="entries[i]" :label="`Unit ${i + 1}`" density="comfortable" maxlength="100" clearable persistent-clear hide-details />
34
+ </v-col>
35
+ </v-row>
36
+ <div class="d-flex justify-end mt-2 mb-4">
37
+ <v-btn class="screen-btn-primary text-none" variant="flat" :loading="saving" :disabled="!filled.length" @click="save">
38
+ Save {{ filled.length || "" }} serial {{ filled.length === 1 ? "number" : "numbers" }}
39
+ </v-btn>
40
+ </div>
41
+ </template>
42
+
43
+ <div class="d-flex align-center mb-2 ga-2 flex-wrap">
44
+ <div class="text-subtitle-2">Serial numbers and history</div>
45
+ <v-spacer />
46
+ <v-text-field v-model="search" density="compact" prepend-inner-icon="mdi-magnify" placeholder="Search serial" hide-details clearable style="max-width: 220px" />
47
+ </div>
48
+ <div v-if="!shown.length" class="text-body-2 text-medium-emphasis py-4 text-center">{{ loading ? "Loading…" : "No serial numbers yet." }}</div>
49
+ <v-expansion-panels v-else variant="accordion" density="compact">
50
+ <v-expansion-panel v-for="s in shown" :key="s._id">
51
+ <v-expansion-panel-title>
52
+ <div class="d-flex flex-wrap align-center ga-2 w-100">
53
+ <span class="font-weight-medium">{{ s.serial }}</span>
54
+ <v-tooltip :text="STATUS[s.status].info" location="top" max-width="260">
55
+ <template #activator="{ props: tip }">
56
+ <v-chip v-bind="tip" size="x-small" variant="tonal" :color="STATUS[s.status].color">{{ STATUS[s.status].text }}</v-chip>
57
+ </template>
58
+ </v-tooltip>
59
+ <span v-if="s.status === 'out'" class="text-caption text-medium-emphasis">
60
+ with {{ s.holderName }}<template v-if="s.workOrderNumber"> · {{ s.workOrderNumber }}</template>
61
+ </span>
62
+ </div>
63
+ </v-expansion-panel-title>
64
+ <v-expansion-panel-text>
65
+ <div v-for="(e, i) in [...s.history].reverse()" :key="i" class="serial-event">
66
+ <span class="text-no-wrap text-medium-emphasis">{{ standardFormatDateTime(e.at) }}</span>
67
+ <span>{{ eventText(e) }}</span>
68
+ </div>
69
+ </v-expansion-panel-text>
70
+ </v-expansion-panel>
71
+ </v-expansion-panels>
72
+ </v-card-text>
73
+ <div class="screen-modal__footer">
74
+ <v-btn class="screen-btn-ghost" variant="outlined" @click="show = false">Close</v-btn>
75
+ </div>
76
+ </v-card>
77
+ </v-dialog>
78
+ <InventorySerialScanner v-model="scanning" :max="emptySlots" :existing="[...rows.map((r) => r.serial), ...filled]" @scanned="fillScanned" />
79
+ </template>
80
+
81
+ <script setup lang="ts">
82
+ import useInventory from "../composables/useInventory";
83
+ import useUtils from "../composables/useUtils";
84
+ import { unitWord, writeOffLabel } from "../utils/inventory-ack";
85
+
86
+ const show = defineModel<boolean>({ default: false });
87
+ const props = defineProps({
88
+ store: { type: Object as PropType<TInventoryStore>, required: true },
89
+ item: { type: Object as PropType<TInventoryItem | null>, default: null },
90
+ });
91
+ const emit = defineEmits<{ changed: [] }>();
92
+
93
+ const api = useInventory();
94
+ const { standardFormatDateTime } = useUtils();
95
+ const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
96
+
97
+ const rows = ref<TInventorySerial[]>([]);
98
+ const inStore = ref(0);
99
+ const onHand = ref(0);
100
+ const loading = ref(false);
101
+ const saving = ref(false);
102
+ const search = ref("");
103
+ const entries = ref<string[]>([]);
104
+
105
+ /** Keepers and managers add serial numbers (the API checks too). */
106
+ const canAdd = computed(() => Boolean(props.store.access?.canHandle || props.store.access?.canManage));
107
+ const free = computed(() => Math.max(0, onHand.value - inStore.value));
108
+ const filled = computed(() => entries.value.map((v) => String(v ?? "").trim()).filter(Boolean));
109
+ /** DV-1787: camera scan - fills the empty unit fields in order. */
110
+ const scanning = ref(false);
111
+ const emptySlots = computed(() => entries.value.filter((v) => !String(v ?? "").trim()).length);
112
+ function fillScanned(list: string[]) {
113
+ const queue = [...list];
114
+ entries.value = entries.value.map((v) => (String(v ?? "").trim() || !queue.length ? v : (queue.shift() as string)));
115
+ notify(`${list.length} serial ${list.length === 1 ? "number" : "numbers"} scanned. Check them, then Save.`);
116
+ }
117
+ const shown = computed(() => {
118
+ const q = String(search.value ?? "").trim().toLowerCase();
119
+ return q ? rows.value.filter((r) => r.serial.toLowerCase().includes(q)) : rows.value;
120
+ });
121
+
122
+ const STATUS: Record<string, { text: string; color: string; info: string }> = {
123
+ in_store: { text: "In store", color: "success", info: "On the shelf, ready to issue." },
124
+ out: { text: "Out", color: "info", info: "Issued to the person shown, for the work order shown, until it is returned." },
125
+ written_off: { text: "Written off", color: "grey", info: "Lost, damaged or used up: no longer in stock." },
126
+ used: { text: "Used", color: "grey", info: "Used up on a job: no longer in stock." },
127
+ };
128
+ const EVENT: Record<string, string> = {
129
+ added: "Serial number added",
130
+ issued: "Issued",
131
+ returned: "Returned to the store",
132
+ written_off: "Written off",
133
+ used: "Used",
134
+ handed_over: "Handed over",
135
+ closed: "Back in the store",
136
+ };
137
+ function eventText(e: TInventorySerial["history"][number]) {
138
+ const parts = [EVENT[e.type] ?? e.type];
139
+ // Write-off: why - "Written off as damaged" (Used up, Spoilt, Damaged, Lost, Other).
140
+ if (e.reason) parts[0] += ` as ${writeOffLabel(e.reason).toLowerCase()}`;
141
+ if (e.holderName) parts.push(e.type === "handed_over" ? `to ${e.holderName}` : `to ${e.holderName}`);
142
+ if (e.workOrderNumber) parts.push(`for ${e.workOrderNumber}`);
143
+ if (e.byName) parts.push(`· by ${e.byName}`);
144
+ if (e.note) parts.push(`· ${e.note}`);
145
+ return parts.join(" ");
146
+ }
147
+
148
+ async function load() {
149
+ if (!props.item) return;
150
+ loading.value = true;
151
+ try {
152
+ const res = await api.getSerials(props.item._id, "all");
153
+ rows.value = res.items;
154
+ inStore.value = res.inStore;
155
+ onHand.value = res.onHand;
156
+ entries.value = Array.from({ length: Math.min(100, Math.max(0, res.onHand - res.inStore)) }, () => "");
157
+ } catch (error: any) {
158
+ notify(error?.data?.message || "Could not load the serial numbers.", "error");
159
+ } finally {
160
+ loading.value = false;
161
+ }
162
+ }
163
+
164
+ async function save() {
165
+ if (!props.item || !filled.value.length) return;
166
+ saving.value = true;
167
+ try {
168
+ await api.addSerials(props.item._id, filled.value);
169
+ notify(`${filled.value.length} serial ${filled.value.length === 1 ? "number" : "numbers"} added.`);
170
+ await load();
171
+ emit("changed");
172
+ } catch (error: any) {
173
+ notify(error?.data?.message || "Could not add the serial numbers.", "error");
174
+ } finally {
175
+ saving.value = false;
176
+ }
177
+ }
178
+
179
+ watch(show, (open) => {
180
+ if (!open) return;
181
+ search.value = "";
182
+ load();
183
+ });
184
+ </script>
185
+
186
+ <style scoped>
187
+ .serial-event {
188
+ display: flex;
189
+ gap: 12px;
190
+ font-size: 0.8125rem;
191
+ padding: 2px 0;
192
+ }
193
+ </style>
@@ -106,6 +106,16 @@
106
106
  <v-chip v-if="item.status === 'inactive'" size="x-small" variant="tonal" class="ml-2">Not in use</v-chip>
107
107
  <div v-if="item.reserved" class="text-caption text-medium-emphasis">+ {{ item.reserved }} set aside for requests (still on the shelf)</div>
108
108
  <div v-if="item.awaitingReceipt" class="text-caption text-medium-emphasis">{{ item.awaitingReceipt }} handed out, waiting for Received</div>
109
+ <!-- DV-1787: give each unit its own serial number, and see each one's history -->
110
+ <a
111
+ v-if="item.serialsTotal || canSerial"
112
+ href="#"
113
+ class="text-caption text-primary d-flex align-center ga-1"
114
+ @click.prevent.stop="openSerials(item)"
115
+ >
116
+ <v-icon icon="mdi-barcode" size="14" />
117
+ {{ item.serialsTotal ? `Serial numbers (${item.serialsInStore} in store)` : "Serial numbers" }}
118
+ </a>
109
119
  <!-- Acknowledge / PO details are for the people who handle the store; a technician sees only the Low chip. -->
110
120
  <div v-if="item.lowStockAlert && canAckLow" class="text-caption text-error" @click.stop>
111
121
  {{ lowStockAlertText(item.lowStockAlert, standardFormatDate) }}
@@ -127,6 +137,7 @@
127
137
 
128
138
  <InventoryLinesDialog v-model="lines.show" :mode="lines.mode" :store="store" :site-id="siteId" :sites="sites" @done="done" />
129
139
  <InventoryItemDialog v-model="itemDialog.show" :store="store" :item="itemDialog.item" @done="done" />
140
+ <InventorySerialsDialog v-model="serialsDialog.show" :store="store" :item="serialsDialog.item" @changed="done" />
130
141
  <InventoryImportDialog v-model="showImport" :store="store" @done="done" />
131
142
  <InventoryImportDialog v-model="showReceiveImport" :store="store" kind="receipts" @done="done" />
132
143
  <InventoryPoDialog v-model="showPo" :store="store" />
@@ -298,6 +309,12 @@ function open(mode: "receive" | "issue" | "request" | "transfer") {
298
309
  }
299
310
 
300
311
  const itemDialog = reactive({ show: false, item: null as TInventoryItem | null });
312
+ // DV-1787: serial numbers of an item (store keepers / managers add them; everyone sees their history).
313
+ const serialsDialog = reactive({ show: false, item: null as TInventoryItem | null });
314
+ const canSerial = computed(() => Boolean(props.store.access?.canHandle || props.store.access?.canManage));
315
+ function openSerials(item: TInventoryItem) {
316
+ Object.assign(serialsDialog, { show: true, item });
317
+ }
301
318
  function editItem(item: TInventoryItem | null) {
302
319
  detail.show = false;
303
320
  Object.assign(itemDialog, { show: true, item });
@@ -27,6 +27,18 @@
27
27
  style="max-width: 200px"
28
28
  :rules="[(v: any) => (Number.isInteger(Number(v)) && Number(v) >= 1 && Number(v) <= maxQty) || `1 to ${maxQty}`]"
29
29
  />
30
+ <!-- DV-1787: which serial numbers are used up (an item with serials) -->
31
+ <InventorySerialPick
32
+ v-model="serials"
33
+ :item="holding.item"
34
+ source="mine"
35
+ :qty="Number(qty || 0)"
36
+ :units="holding.qty"
37
+ :open="show"
38
+ :initial="draftPicks"
39
+ label="Which serial numbers? (optional)"
40
+ @update:model-value="(v: string[] | null) => (qty = Math.max(Number(qty) || 0, v?.length ?? 0) || null)"
41
+ />
30
42
 
31
43
  <InputLabel title="Where?" required class="mb-1" />
32
44
  <v-btn-toggle v-model="where" mandatory divided variant="outlined" density="comfortable" class="mb-3">
@@ -173,6 +185,9 @@ const stepsLive = computed(() => inventoryStepsLive(props.store));
173
185
  const date = ref(today);
174
186
  const photosBefore = ref<string[]>([]);
175
187
  const photosAfter = ref<string[]>([]);
188
+ const serials = ref<string[]>([]);
189
+ /** A draft's earlier choice of serial numbers. */
190
+ const draftPicks = computed(() => ((props.draft as any)?.serialPicks ?? []).map(String) as string[]);
176
191
  const photoError = ref("");
177
192
  const USAGE_PHOTOS_REQUIRED = "Add a before photo and an after photo to record usage.";
178
193
 
@@ -214,6 +229,8 @@ function body() {
214
229
  photosAfter: photosAfter.value,
215
230
  remarks: remarks.value,
216
231
  reportedBy: reportedBy.value,
232
+ // DV-1787: serials only when chosen, or to clear a draft's earlier choice.
233
+ ...(serials.value.length || draftPicks.value.length ? { serials: serials.value } : {}),
217
234
  // Only to an API that knows it (an older one refuses an unknown field).
218
235
  ...(stepsLive.value && attendedWith.value.trim() ? { attendedWith: attendedWith.value.trim() } : {}),
219
236
  };
@@ -293,6 +310,7 @@ watch(show, (open) => {
293
310
  photoError.value = "";
294
311
  photosBefore.value = [];
295
312
  photosAfter.value = [];
313
+ serials.value = [];
296
314
  qty.value = 1;
297
315
  unit.value = "";
298
316
  area.value = "";
@@ -0,0 +1,222 @@
1
+ <template>
2
+ <!-- DV-1787: pick the site's work order that stock is issued for (Issue Stock). -->
3
+ <v-dialog v-model="show" max-width="980" scrollable>
4
+ <v-card class="screen-modal">
5
+ <v-card-title class="d-flex align-center">
6
+ Select work order
7
+ <v-spacer />
8
+ <v-btn icon="mdi-close" variant="text" class="screen-modal__close" aria-label="Close" @click="show = false" />
9
+ </v-card-title>
10
+
11
+ <v-card-text class="screen-modal__body">
12
+ <v-row dense class="mb-2">
13
+ <v-col cols="12" sm="6" md="3">
14
+ <v-text-field
15
+ v-model="search"
16
+ density="comfortable"
17
+ prepend-inner-icon="mdi-magnify"
18
+ placeholder="Search number or text"
19
+ clearable
20
+ hide-details
21
+ />
22
+ </v-col>
23
+ <v-col cols="12" sm="6" md="3">
24
+ <v-autocomplete
25
+ v-model="assignee"
26
+ :items="technicians"
27
+ :item-title="(p: any) => p.name"
28
+ item-value="_id"
29
+ label="Assigned technician"
30
+ density="comfortable"
31
+ clearable
32
+ hide-details
33
+ />
34
+ </v-col>
35
+ <v-col cols="12" sm="6" md="3">
36
+ <v-combobox
37
+ v-model="subject"
38
+ :items="subjects"
39
+ label="Subject"
40
+ density="comfortable"
41
+ clearable
42
+ hide-details
43
+ />
44
+ </v-col>
45
+ <v-col cols="12" sm="6" md="3">
46
+ <v-select v-model="status" :items="STATUSES" label="Status" density="comfortable" hide-details />
47
+ </v-col>
48
+ </v-row>
49
+
50
+ <v-data-table-server
51
+ :headers="headers"
52
+ :items="rows"
53
+ :items-length="total"
54
+ :loading="loading"
55
+ :page="page"
56
+ :items-per-page="limit"
57
+ :items-per-page-options="[10, 25, 50]"
58
+ density="comfortable"
59
+ hover
60
+ no-data-text="No work orders match."
61
+ @update:page="(p: number) => ((page = p), load())"
62
+ @update:items-per-page="(n: number) => ((limit = n), (page = 1), load())"
63
+ @click:row="(_e: Event, { item }: { item: any }) => pick(item)"
64
+ >
65
+ <template #item.number="{ item }">
66
+ <span class="font-weight-bold" :class="{ 'text-error': item.isHighPriority }">{{ numberOf(item) || "—" }}</span>
67
+ <!-- as the work order list: a work order attached to a feedback -->
68
+ <span v-if="linkedFeedback(item)" class="wo-link-pill ml-1" title="Linked to feedback">
69
+ <v-icon icon="mdi-link-variant" size="14" />
70
+ Linked to feedback
71
+ </span>
72
+ </template>
73
+ <!-- attached to a feedback: the person who reported it (the feedback's creator) -->
74
+ <template #item.createdBy="{ item }">{{ creatorOf(item) || "—" }}</template>
75
+ <template #item.assignee="{ item }">{{ item.assigneeInfo?.name || "Unassigned" }}</template>
76
+ <template #item.subject="{ item }">{{ item.subject || "—" }}</template>
77
+ <template #item.status="{ item }">
78
+ <v-chip size="small" :color="statusColor(item.status)" variant="tonal">{{ item.status }}</v-chip>
79
+ <v-tooltip v-if="isCompleted(item)" text="Completed: stock cannot be issued for it" location="top">
80
+ <template #activator="{ props: tip }">
81
+ <v-icon v-bind="tip" size="small" class="ml-1">mdi-lock-outline</v-icon>
82
+ </template>
83
+ </v-tooltip>
84
+ </template>
85
+ </v-data-table-server>
86
+ </v-card-text>
87
+
88
+ <div class="screen-modal__footer">
89
+ <v-btn class="screen-btn-ghost" variant="outlined" @click="show = false">Cancel</v-btn>
90
+ </div>
91
+ </v-card>
92
+ </v-dialog>
93
+ </template>
94
+
95
+ <script setup lang="ts">
96
+ import useWorkOrder from "../composables/useWorkOrder";
97
+ import useUtils from "../composables/useUtils";
98
+ import { withSubjectPrefix } from "../composables/useWorkOrderSubject";
99
+
100
+ const show = defineModel<boolean>({ default: false });
101
+ const props = defineProps({
102
+ siteId: { type: String, required: true },
103
+ /** The people the technician filter offers (the Issue Stock "Give to" list). */
104
+ technicians: { type: Array as PropType<{ _id: string; name: string }[]>, default: () => [] },
105
+ /** Only work orders of this service (e.g. "cleaning"); empty = every work order at the site. */
106
+ service: { type: String, default: "" },
107
+ /** The person stock is being given to: the technician filter starts on them (it can be cleared). */
108
+ defaultAssignee: { type: String, default: "" },
109
+ });
110
+ const emit = defineEmits<{ picked: [TPickedWorkOrder] }>();
111
+
112
+ const { getWorkOrders } = useWorkOrder();
113
+ const { debounce } = useUtils();
114
+ const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
115
+
116
+ const STATUSES = ["All", "To-Do", "In-Progress", "For Review", "Completed"];
117
+ const headers = [
118
+ { title: "Number", key: "number", sortable: false },
119
+ { title: "Created by", key: "createdBy", sortable: false },
120
+ { title: "Assigned technician", key: "assignee", sortable: false },
121
+ { title: "Subject", key: "subject", sortable: false },
122
+ { title: "Status", key: "status", sortable: false },
123
+ ];
124
+
125
+ const search = ref("");
126
+ const assignee = ref<string | null>(null);
127
+ const subject = ref<string | null>(null);
128
+ const status = ref("All");
129
+ const page = ref(1);
130
+ const limit = ref(10);
131
+ const rows = ref<Record<string, any>[]>([]);
132
+ const total = ref(0);
133
+ const loading = ref(false);
134
+ /** Subjects seen in the results, offered in the Subject filter (it also takes any text). */
135
+ const subjects = ref<string[]>([]);
136
+
137
+ /** "#CLN0012" / "#CLN0012.1", with the added subject's prefix: the same rule as the work order list. */
138
+ function numberOf(w: Record<string, any>) {
139
+ if (w.number === undefined || w.number === null || w.number === "") return "";
140
+ const digits = Number.parseFloat(String(w.workOrderSettings?.noOfDigits));
141
+ const padded = String(w.number).padStart(Number.isNaN(digits) || digits <= 0 ? 0 : digits, "0");
142
+ return withSubjectPrefix(`#${w.workOrderSettings?.prefix ?? ""}${padded}${w.version ? `.${w.version}` : ""}`, w);
143
+ }
144
+ const isCompleted = (w: Record<string, any>) => /^completed$/i.test(String(w.status ?? ""));
145
+ /** Attached to a feedback (the id, or the joined record). */
146
+ const linkedFeedback = (w: Record<string, any>) => {
147
+ const fb = w.feedback;
148
+ return Boolean(fb && typeof fb === "object" ? fb._id : fb);
149
+ };
150
+ /** Created by: the feedback's creator when attached to one, else the work order's. */
151
+ const creatorOf = (w: Record<string, any>) => (linkedFeedback(w) && w.feedbackCreator?.name) || w.createdBy?.name || "";
152
+ function statusColor(s: string) {
153
+ if (/^completed$/i.test(s)) return "success";
154
+ if (/^for review$/i.test(s)) return "info";
155
+ if (/^in-progress$/i.test(s)) return "warning";
156
+ return "grey";
157
+ }
158
+
159
+ async function load() {
160
+ loading.value = true;
161
+ try {
162
+ const res: any = await getWorkOrders({
163
+ site: props.siteId,
164
+ page: page.value,
165
+ limit: limit.value,
166
+ search: search.value || "",
167
+ status: status.value === "All" ? "" : status.value,
168
+ ...(props.service ? { providerService: props.service } : {}),
169
+ ...(assignee.value ? { assignee: assignee.value } : {}),
170
+ ...(subject.value ? { subject: subject.value } : {}),
171
+ feedbackCreator: true,
172
+ });
173
+ rows.value = res?.items ?? [];
174
+ const match = /of\s+(\d+)/.exec(String(res?.pageRange ?? ""));
175
+ total.value = match ? Number(match[1]) : rows.value.length;
176
+ const seen = new Set(subjects.value);
177
+ for (const r of rows.value) if (r.subject) seen.add(String(r.subject));
178
+ subjects.value = [...seen].sort((a, b) => a.localeCompare(b));
179
+ } catch (error: any) {
180
+ rows.value = [];
181
+ total.value = 0;
182
+ notify(error?.data?.message || "Could not load the work orders.", "error");
183
+ } finally {
184
+ loading.value = false;
185
+ }
186
+ }
187
+ const reload = debounce(() => {
188
+ page.value = 1;
189
+ load();
190
+ }, 300);
191
+ watch([search, assignee, subject, status], () => reload());
192
+
193
+ function pick(w: Record<string, any>) {
194
+ if (isCompleted(w)) return notify("That work order is completed. Pick an open one.", "error");
195
+ emit("picked", { _id: String(w._id), number: numberOf(w), subject: String(w.subject ?? ""), status: String(w.status ?? "") });
196
+ show.value = false;
197
+ }
198
+
199
+ watch(show, (open) => {
200
+ if (!open) return;
201
+ page.value = 1;
202
+ // Given to someone: show their work orders first (the watch on assignee reloads; else load now).
203
+ const start = props.defaultAssignee || null;
204
+ if (assignee.value !== start) assignee.value = start;
205
+ else load();
206
+ });
207
+ </script>
208
+
209
+ <style scoped>
210
+ /* the work order list's "Linked to feedback" pill */
211
+ .wo-link-pill {
212
+ display: inline-flex;
213
+ align-items: center;
214
+ gap: 2px;
215
+ padding: 0 6px;
216
+ border-radius: 999px;
217
+ font-size: 0.7rem;
218
+ white-space: nowrap;
219
+ color: rgb(var(--v-theme-primary));
220
+ background: rgba(var(--v-theme-primary), 0.1);
221
+ }
222
+ </style>
@@ -27,6 +27,17 @@
27
27
  style="max-width: 200px"
28
28
  :rules="[(v: any) => (Number.isInteger(Number(v)) && Number(v) >= 1) || 'Enter a whole number', (v: any) => Number(v) <= max || `You can write off up to ${max}`]"
29
29
  />
30
+ <!-- DV-1787: which serial numbers are written off (an item with serials) -->
31
+ <InventorySerialPick
32
+ v-model="serials"
33
+ :item="item"
34
+ :source="from === 'store' ? 'store' : 'mine'"
35
+ :qty="Number(qty || 0)"
36
+ :units="max"
37
+ :open="show"
38
+ label="Which serial numbers? (optional)"
39
+ @update:model-value="(v: string[] | null) => (qty = Math.max(Number(qty) || 0, v?.length ?? 0) || null)"
40
+ />
30
41
  <InputLabel title="Why?" required class="mb-1" />
31
42
  <v-chip-group v-model="reason" :mandatory="from !== 'store'" selected-class="text-primary" class="mb-2">
32
43
  <v-chip v-for="r in WRITE_OFF_REASONS" :key="r.value" :value="r.value" variant="outlined" filter>{{ r.title }}</v-chip>
@@ -71,6 +82,7 @@ const qty = ref<number | null>(1);
71
82
  const reason = ref<string>(writeOffDefaultReason(props.from));
72
83
  const remarks = ref("");
73
84
  const photos = ref<string[]>([]);
85
+ const serials = ref<string[]>([]);
74
86
  const saving = ref(false);
75
87
  const tried = ref(false);
76
88
  const problem = computed(() => (tried.value ? writeOffProblem({ reason: reason.value ?? "", remarks: remarks.value }) : ""));
@@ -89,6 +101,7 @@ async function save() {
89
101
  reason: reason.value,
90
102
  remarks: remarks.value.trim(),
91
103
  photos: photos.value,
104
+ ...(serials.value.length ? { serials: serials.value } : {}),
92
105
  });
93
106
  notify(`${qtyUnit(qty.value, props.unit)} of ${props.itemName} written off as ${writeOffLabel(reason.value).toLowerCase()}.${props.from === "holding" ? " The store keeper has been told." : ""}`);
94
107
  show.value = false;
@@ -107,6 +120,7 @@ watch(show, (open) => {
107
120
  reason.value = writeOffDefaultReason(props.from);
108
121
  remarks.value = "";
109
122
  photos.value = [];
123
+ serials.value = [];
110
124
  tried.value = false;
111
125
  });
112
126
  </script>
@@ -24,7 +24,7 @@
24
24
  <div ref="crumbEl" class="app-topbar-shell__crumb">
25
25
  <span v-if="siteName" class="app-topbar-shell__site">{{ siteName }}</span>
26
26
  <span v-if="siteName && moduleName" class="app-topbar-shell__sep">/</span>
27
- <span class="app-topbar-shell__module">{{ $tr(moduleName) }}</span>
27
+ <span class="app-topbar-shell__module">{{ uiTr(moduleName) }}</span>
28
28
  </div>
29
29
 
30
30
  <template #append>
@@ -128,6 +128,8 @@
128
128
  </template>
129
129
 
130
130
  <script setup lang="ts">
131
+ // Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
132
+ import { uiTr } from "../../composables/useUiLanguage";
131
133
  import { moduleNameFromRoute } from "../../utils/breadcrumb";
132
134
 
133
135
  const props = defineProps({
@@ -91,7 +91,7 @@
91
91
  v-for="({ item, section }, index) in sectionedItems"
92
92
  :key="`${item.title}-${index}`"
93
93
  >
94
- <div v-if="section" class="brand-drawer__section">{{ $tr(section) }}</div>
94
+ <div v-if="section" class="brand-drawer__section">{{ uiTr(section) }}</div>
95
95
 
96
96
  <v-tooltip location="right" :disabled="!item.disabled">
97
97
  <template #activator="{ props: tooltipProps }">
@@ -121,6 +121,8 @@
121
121
  </template>
122
122
 
123
123
  <script setup lang="ts">
124
+ // Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
125
+ import { uiTr } from "../../composables/useUiLanguage";
124
126
  import { useDisplay } from "vuetify";
125
127
 
126
128
  import { withSections } from "../../utils/nav-sections";
@@ -12,12 +12,14 @@
12
12
  data-test="list-csv-export"
13
13
  @click="download"
14
14
  >
15
- {{ label }}
15
+ {{ uiTr(label) }}
16
16
  </v-btn>
17
17
  <Snackbar v-model="toast.show" :text="toast.message" :color="toast.color" />
18
18
  </template>
19
19
 
20
20
  <script setup lang="ts">
21
+ // Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
22
+ import { uiTr } from "../composables/useUiLanguage";
21
23
  import { collectAllPages, EXPORT_MAX_ROWS, listCsv, type TExportColumn } from "../utils/list-export";
22
24
 
23
25
  const props = defineProps({
@@ -14,7 +14,7 @@
14
14
  class="nav-item"
15
15
  @click.stop="onParentClick"
16
16
  >
17
- {{ $tr(title) }}
17
+ {{ uiTr(title) }}
18
18
  </v-list-item>
19
19
  </template>
20
20
 
@@ -35,7 +35,7 @@
35
35
  color="primary"
36
36
  class="nav-item"
37
37
  >
38
- {{ $tr(title) }}
38
+ {{ uiTr(title) }}
39
39
  </v-list-item>
40
40
 
41
41
  <v-list-item
@@ -45,11 +45,13 @@
45
45
  color="primary"
46
46
  class="nav-item"
47
47
  >
48
- {{ $tr(title) }}
48
+ {{ uiTr(title) }}
49
49
  </v-list-item>
50
50
  </template>
51
51
 
52
52
  <script setup lang="ts">
53
+ // Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
54
+ import { uiTr } from "../composables/useUiLanguage";
53
55
  const props = defineProps({
54
56
  title: {
55
57
  type: String,