@7365admin1/layer-common 4.97.1-staging.733 → 4.97.1-staging.735
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/InventoryCheckoutReturnDialog.vue +144 -0
- package/components/InventoryCheckoutsTab.vue +260 -0
- 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 +36 -4
- 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/SiteSettingsWorkOrder.vue +14 -1
- package/components/WorkOrder/IssuedItems.vue +153 -0
- package/composables/useInventory.ts +21 -2
- package/composables/useWorkOrder.ts +12 -0
- package/package.json +1 -1
- package/types/inventory.d.ts +52 -0
- package/utils/inventory-checkout.ts +64 -0
|
@@ -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>
|
|
@@ -48,6 +48,16 @@
|
|
|
48
48
|
:disabled="isLoading || !canManageSiteSettings || !showMaterialsInResidentApp"
|
|
49
49
|
label="Also show the cost" />
|
|
50
50
|
|
|
51
|
+
<!-- DV-1787: items issued for a work order with a return date block completing it. -->
|
|
52
|
+
<v-divider class="my-4" />
|
|
53
|
+
<div class="text-subtitle-1 mb-1">Issued items</div>
|
|
54
|
+
<p class="text-body-2 text-medium-emphasis mb-2">
|
|
55
|
+
Items issued from the store for a work order with a return date (for example tools) must be returned before the work order, or the feedback it is attached to, can be completed.
|
|
56
|
+
</p>
|
|
57
|
+
<v-switch v-model="requireItemReturnToComplete" color="primary" hide-details
|
|
58
|
+
:disabled="isLoading || !canManageSiteSettings"
|
|
59
|
+
label="Items must be returned before completing" />
|
|
60
|
+
|
|
51
61
|
<!-- Still a `v-btn`: `AppButton` has no loading state, and the
|
|
52
62
|
spinner on save is feedback, not decoration. -->
|
|
53
63
|
<v-btn v-if="canManageSiteSettings" class="screen-btn-primary text-none mt-4"
|
|
@@ -107,6 +117,7 @@ const noOfDigits = ref(1)
|
|
|
107
117
|
/** Service365 (resident) app switches; missing on a saved setting = off. */
|
|
108
118
|
const showMaterialsInResidentApp = ref(false)
|
|
109
119
|
const showMaterialCostInResidentApp = ref(false)
|
|
120
|
+
const requireItemReturnToComplete = ref(false)
|
|
110
121
|
const isLoading = ref(false)
|
|
111
122
|
|
|
112
123
|
const toast = reactive({
|
|
@@ -182,6 +193,7 @@ watchEffect(() => {
|
|
|
182
193
|
noOfDigits.value = workOrderSetting.value.noOfDigits
|
|
183
194
|
showMaterialsInResidentApp.value = !!workOrderSetting.value.showMaterialsInResidentApp
|
|
184
195
|
showMaterialCostInResidentApp.value = !!workOrderSetting.value.showMaterialCostInResidentApp
|
|
196
|
+
requireItemReturnToComplete.value = !!workOrderSetting.value.requireItemReturnToComplete
|
|
185
197
|
}
|
|
186
198
|
})
|
|
187
199
|
|
|
@@ -209,7 +221,8 @@ async function save() {
|
|
|
209
221
|
noOfDigits: noOfDigits.value,
|
|
210
222
|
showMaterialsInResidentApp: showMaterialsInResidentApp.value,
|
|
211
223
|
// Cost only shows with the materials.
|
|
212
|
-
showMaterialCostInResidentApp: showMaterialsInResidentApp.value && showMaterialCostInResidentApp.value
|
|
224
|
+
showMaterialCostInResidentApp: showMaterialsInResidentApp.value && showMaterialCostInResidentApp.value,
|
|
225
|
+
requireItemReturnToComplete: requireItemReturnToComplete.value
|
|
213
226
|
})
|
|
214
227
|
show("Saved successfully", "success")
|
|
215
228
|
} catch {
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
DV-1787: items issued from the store for this work order (or the feedback's attached work orders):
|
|
4
|
+
who has them, when they were issued, the return date, and when they came back. Hidden when none.
|
|
5
|
+
-->
|
|
6
|
+
<div v-if="items.length" class="issued-items">
|
|
7
|
+
<div class="text-subtitle-2 mb-2">Issued items</div>
|
|
8
|
+
<!-- The holder sees this right above Submit: hand the tools back so management can complete it. -->
|
|
9
|
+
<v-alert v-if="mineOut.length" type="info" variant="tonal" density="compact" class="mb-2" icon="mdi-keyboard-return">
|
|
10
|
+
{{ mineOut.length === 1 ? "1 item is with you." : `${mineOut.length} items are with you.` }} Ask to return when you hand {{ mineOut.length === 1 ? "it" : "them" }} back.
|
|
11
|
+
</v-alert>
|
|
12
|
+
<v-alert v-if="blocking" type="warning" variant="tonal" density="compact" class="mb-2" icon="mdi-lock-outline">
|
|
13
|
+
{{ blockingCount === 1 ? "1 item not returned yet." : `${blockingCount} items not returned yet.` }} Return {{ blockingCount === 1 ? "it" : "them" }} before completing.
|
|
14
|
+
</v-alert>
|
|
15
|
+
<!-- Stacked rows, not a table: the Information panel and the work order dialog are narrow. -->
|
|
16
|
+
<div class="issued-items__list">
|
|
17
|
+
<div v-for="c in items" :key="c._id" class="issued-items__row">
|
|
18
|
+
<div class="issued-items__top">
|
|
19
|
+
<span class="issued-items__name">
|
|
20
|
+
{{ c.itemName }}
|
|
21
|
+
<span v-if="showNumber && c.workOrderNumber" class="text-caption text-medium-emphasis">· {{ c.workOrderNumber }}</span>
|
|
22
|
+
</span>
|
|
23
|
+
<span class="d-flex flex-wrap ga-1">
|
|
24
|
+
<!-- hover: what the status means -->
|
|
25
|
+
<v-tooltip :text="checkoutChip(c).info" location="top" max-width="280">
|
|
26
|
+
<template #activator="{ props: tip }">
|
|
27
|
+
<v-chip v-bind="tip" size="small" variant="tonal" :color="checkoutChip(c).color" :prepend-icon="checkoutChip(c).icon">{{ checkoutChip(c).text }}</v-chip>
|
|
28
|
+
</template>
|
|
29
|
+
</v-tooltip>
|
|
30
|
+
<v-tooltip v-if="c.status === 'out' && c.returnRequest" :text="RETURN_ASKED_INFO" location="top" max-width="280">
|
|
31
|
+
<template #activator="{ props: tip }">
|
|
32
|
+
<v-chip v-bind="tip" size="small" variant="tonal" color="primary" prepend-icon="mdi-keyboard-return">Return asked</v-chip>
|
|
33
|
+
</template>
|
|
34
|
+
</v-tooltip>
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="issued-items__meta">{{ qtyUnit(c.status === "out" ? c.outQty : c.qty, c.unit) }} · with {{ c.holderName }}</div>
|
|
38
|
+
<div v-if="c.serials?.length" class="issued-items__meta text-medium-emphasis">S/N {{ c.serials.map((x) => x.serial).join(", ") }}</div>
|
|
39
|
+
<div class="issued-items__dates">
|
|
40
|
+
<span><span class="issued-items__label">Issued</span> {{ standardFormatDateTime(c.createdAt) }}</span>
|
|
41
|
+
<span><span class="issued-items__label">Return by</span> {{ c.returnDate ? returnDayText(c.returnDate) : "—" }}</span>
|
|
42
|
+
<span v-if="c.status !== 'out' && c.closedAt"><span class="issued-items__label">{{ c.status === "returned" ? "Returned" : "Closed" }}</span> {{ standardFormatDateTime(c.closedAt) }}</span>
|
|
43
|
+
</div>
|
|
44
|
+
<!-- DV-1787: the holder asks to return their own item from here (e.g. before Submit for review). -->
|
|
45
|
+
<v-btn
|
|
46
|
+
v-if="isMine(c) && !c.returnRequest"
|
|
47
|
+
size="small"
|
|
48
|
+
variant="tonal"
|
|
49
|
+
color="primary"
|
|
50
|
+
class="text-none mt-1"
|
|
51
|
+
prepend-icon="mdi-keyboard-return"
|
|
52
|
+
@click="openAsk(c)"
|
|
53
|
+
>
|
|
54
|
+
Ask to return
|
|
55
|
+
</v-btn>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
<InventoryCheckoutReturnDialog v-model="ask.show" :row="ask.row" mode="ask" @done="load" />
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import useInventory from "../../composables/useInventory";
|
|
64
|
+
import useUtils from "../../composables/useUtils";
|
|
65
|
+
import { qtyUnit } from "../../utils/inventory-ack";
|
|
66
|
+
import { checkoutChip, returnDayKey, RETURN_ASKED_INFO } from "../../utils/inventory-checkout";
|
|
67
|
+
|
|
68
|
+
const props = defineProps({
|
|
69
|
+
/** One of the two: the work order, or the feedback whose attached work orders are shown. */
|
|
70
|
+
workOrderId: { type: String, default: "" },
|
|
71
|
+
feedbackId: { type: String, default: "" },
|
|
72
|
+
/**
|
|
73
|
+
* Only on a page with a Complete button (management): warn that the items block completing.
|
|
74
|
+
* Service provider apps only Submit for review, so they leave it off.
|
|
75
|
+
*/
|
|
76
|
+
showCompletionBlock: { type: Boolean, default: false },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const { standardFormatDate, standardFormatDateTime } = useUtils();
|
|
80
|
+
const items = ref<TInventoryCheckout[]>([]);
|
|
81
|
+
const requireReturn = ref(false);
|
|
82
|
+
// A feedback can have more than one work order (re-opened): say which one each item was for.
|
|
83
|
+
const showNumber = computed(() => Boolean(props.feedbackId) && new Set(items.value.map((c) => c.workOrder)).size > 1);
|
|
84
|
+
const blockingCount = computed(() => items.value.filter((c) => c.status === "out" && c.returnDate).length);
|
|
85
|
+
const blocking = computed(() => props.showCompletionBlock && requireReturn.value && blockingCount.value > 0);
|
|
86
|
+
/** For the page's Complete button: true while items with a return date are out and the setting is on. */
|
|
87
|
+
const emit = defineEmits<{ blocking: [boolean] }>();
|
|
88
|
+
watch(() => requireReturn.value && blockingCount.value > 0, (v) => emit("blocking", v), { immediate: true });
|
|
89
|
+
|
|
90
|
+
const returnDayText = (d: string) => standardFormatDate(returnDayKey(d));
|
|
91
|
+
|
|
92
|
+
// The signed-in person's own items still out: they can ask to return them here.
|
|
93
|
+
const { currentUser } = useLocalAuth();
|
|
94
|
+
const me = computed(() => String(currentUser.value?._id ?? ""));
|
|
95
|
+
const isMine = (c: TInventoryCheckout) => c.status === "out" && !!me.value && String(c.holder) === me.value;
|
|
96
|
+
const mineOut = computed(() => items.value.filter((c) => isMine(c) && !c.returnRequest));
|
|
97
|
+
const ask = reactive({ show: false, row: null as TInventoryCheckout | null });
|
|
98
|
+
const openAsk = (row: TInventoryCheckout) => Object.assign(ask, { show: true, row });
|
|
99
|
+
|
|
100
|
+
async function load() {
|
|
101
|
+
if (!props.workOrderId && !props.feedbackId) return;
|
|
102
|
+
try {
|
|
103
|
+
const res = await useInventory().getWorkOrderCheckouts(props.workOrderId ? { workOrder: props.workOrderId } : { feedback: props.feedbackId });
|
|
104
|
+
items.value = res.items ?? [];
|
|
105
|
+
requireReturn.value = Boolean(res.requireReturn);
|
|
106
|
+
} catch {
|
|
107
|
+
items.value = [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
watch(() => [props.workOrderId, props.feedbackId], load);
|
|
111
|
+
onMounted(load);
|
|
112
|
+
defineExpose({ load });
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<style scoped>
|
|
116
|
+
.issued-items {
|
|
117
|
+
margin-top: 16px;
|
|
118
|
+
}
|
|
119
|
+
.issued-items__row {
|
|
120
|
+
padding: 8px 0;
|
|
121
|
+
border-bottom: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
|
|
122
|
+
}
|
|
123
|
+
.issued-items__row:last-child {
|
|
124
|
+
border-bottom: 0;
|
|
125
|
+
}
|
|
126
|
+
.issued-items__top {
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-wrap: wrap;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: space-between;
|
|
131
|
+
gap: 4px 8px;
|
|
132
|
+
}
|
|
133
|
+
.issued-items__name {
|
|
134
|
+
font-weight: 500;
|
|
135
|
+
min-width: 0;
|
|
136
|
+
overflow-wrap: anywhere;
|
|
137
|
+
}
|
|
138
|
+
.issued-items__meta {
|
|
139
|
+
font-size: 0.8125rem;
|
|
140
|
+
margin-top: 2px;
|
|
141
|
+
}
|
|
142
|
+
.issued-items__dates {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-wrap: wrap;
|
|
145
|
+
gap: 2px 16px;
|
|
146
|
+
font-size: 0.75rem;
|
|
147
|
+
margin-top: 2px;
|
|
148
|
+
color: rgba(var(--v-theme-on-surface), var(--v-medium-emphasis-opacity));
|
|
149
|
+
}
|
|
150
|
+
.issued-items__label {
|
|
151
|
+
color: rgba(var(--v-theme-on-surface), var(--v-disabled-opacity));
|
|
152
|
+
}
|
|
153
|
+
</style>
|
|
@@ -61,6 +61,25 @@ export default function useInventory() {
|
|
|
61
61
|
count: (store: string, body: { item: string; countedQty: number; reason: string }) =>
|
|
62
62
|
api(`/stores/${store}/counts`, { method: "POST", body }),
|
|
63
63
|
issue: (store: string, body: Record<string, any>) => api(`/stores/${store}/issue`, { method: "POST", body }),
|
|
64
|
+
/** DV-1787: a store keeper takes back one checked-out item (or accepts the holder's request for it). */
|
|
65
|
+
returnCheckout: (checkout: string, note = "", serials?: string[]) =>
|
|
66
|
+
api(`/checkouts/${checkout}/return`, { method: "POST", body: { note, ...(serials?.length ? { serials } : {}) } }),
|
|
67
|
+
/** DV-1787: an item's serial numbers with their history, and adding serials to units on the shelf. */
|
|
68
|
+
getSerials: (item: string, status: "in_store" | "out" | "written_off" | "used" | "all" | "mine" = "all") =>
|
|
69
|
+
api<{ items: TInventorySerial[]; inStore: number; onHand: number }>(`/items/${item}/serials`, { query: status === "mine" ? { mine: true } : { status } }),
|
|
70
|
+
addSerials: (item: string, serials: string[]) => api(`/items/${item}/serials`, { method: "POST", body: { serials } }),
|
|
71
|
+
/** DV-1787: a store keeper sets, changes or clears (null) a checkout's return date. */
|
|
72
|
+
changeReturnDate: (checkout: string, returnDate: string | null, reason = "") =>
|
|
73
|
+
api(`/checkouts/${checkout}/return-date`, { method: "POST", body: { returnDate, reason } }),
|
|
74
|
+
/** DV-1787: the holder asks to return one checked-out item. */
|
|
75
|
+
requestCheckoutReturn: (checkout: string, note = "", serials?: string[]) =>
|
|
76
|
+
api(`/checkouts/${checkout}/return-request`, { method: "POST", body: { note, ...(serials?.length ? { serials } : {}) } }),
|
|
77
|
+
/** DV-1787: the items issued for a work order (or a feedback's work orders), and whether they block completing it. */
|
|
78
|
+
getWorkOrderCheckouts: (query: { workOrder?: string; feedback?: string }) =>
|
|
79
|
+
api<{ items: TInventoryCheckout[]; requireReturn: boolean }>(`/work-order-checkouts`, { query }),
|
|
80
|
+
/** DV-1787: what is checked out (issued for a work order / to come back by a date), with overdue flags. */
|
|
81
|
+
getCheckouts: (store: string, query: { status?: "out" | "closed" | "all"; mine?: boolean; overdue?: boolean; page?: number; limit?: number; search?: string } = {}) =>
|
|
82
|
+
api<{ items: TInventoryCheckout[]; total: number; page: number; pages: number; counts: { out: number; overdue: number } }>(`/stores/${store}/checkouts`, { query }),
|
|
64
83
|
receiveReturn: (store: string, body: Record<string, any>) => api(`/stores/${store}/returns`, { method: "POST", body }),
|
|
65
84
|
recordUsage: (store: string, body: Record<string, any>) => api(`/stores/${store}/usage`, { method: "POST", body }),
|
|
66
85
|
/** Usage drafts: before photo now, after photo and submit after the job (stock is deducted on submit). */
|
|
@@ -91,10 +110,10 @@ export default function useInventory() {
|
|
|
91
110
|
acknowledgeRequest: (id: string) => api<TInventoryRequest>(`/requests/${id}/acknowledge`, { method: "POST", body: {} }),
|
|
92
111
|
notReceived: (id: string, reason: string) => api<TInventoryRequest>(`/requests/${id}/not-received`, { method: "POST", body: { reason } }),
|
|
93
112
|
/** Used up / spoilt / damaged / lost / other: from the person's own stock, or from the store shelf (store keeper). */
|
|
94
|
-
writeOff: (store: string, body: { from: "holding" | "store"; site?: string; item: string; qty: number; reason: string; remarks?: string; photos?: string[] }) =>
|
|
113
|
+
writeOff: (store: string, body: { from: "holding" | "store"; site?: string; item: string; qty: number; reason: string; remarks?: string; photos?: string[]; serials?: string[] }) =>
|
|
95
114
|
api<TInventoryTransaction>(`/stores/${store}/write-offs`, { method: "POST", body }),
|
|
96
115
|
/** The holder asks to give stock back; a store keeper accepts it (acceptHandover) when it arrives. */
|
|
97
|
-
requestReturn: (store: string, body: { site: string; item: string; qty: number; note?: string }) =>
|
|
116
|
+
requestReturn: (store: string, body: { site: string; item: string; qty: number; note?: string; serials?: string[] }) =>
|
|
98
117
|
api<TInventoryHandover>(`/stores/${store}/returns/request`, { method: "POST", body }),
|
|
99
118
|
takeOverDraft: (id: string) => api<TInventoryUsageDraft>(`/usage-drafts/${id}/take-over`, { method: "POST", body: {} }),
|
|
100
119
|
acknowledgeLowStock: (itemId: string, poNumber = "") =>
|
|
@@ -91,7 +91,16 @@ export default function useWorkOrder() {
|
|
|
91
91
|
endDate = "",
|
|
92
92
|
date,
|
|
93
93
|
search = "",
|
|
94
|
+
assignee,
|
|
95
|
+
subject,
|
|
96
|
+
feedbackCreator,
|
|
94
97
|
}: {
|
|
98
|
+
/** DV-1787: also return feedbackCreator (who created the attached feedback) and search it. */
|
|
99
|
+
feedbackCreator?: boolean;
|
|
100
|
+
/** DV-1787: only work orders assigned to this user id. */
|
|
101
|
+
assignee?: string;
|
|
102
|
+
/** DV-1787: only work orders whose subject contains this text. */
|
|
103
|
+
subject?: string;
|
|
95
104
|
page?: number;
|
|
96
105
|
limit?: number;
|
|
97
106
|
search?: string;
|
|
@@ -119,6 +128,9 @@ export default function useWorkOrder() {
|
|
|
119
128
|
site,
|
|
120
129
|
provider,
|
|
121
130
|
providerService,
|
|
131
|
+
...(assignee ? { assignee } : {}),
|
|
132
|
+
...(subject ? { subject } : {}),
|
|
133
|
+
...(feedbackCreator ? { feedbackCreator: true } : {}),
|
|
122
134
|
},
|
|
123
135
|
});
|
|
124
136
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.735",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
package/types/inventory.d.ts
CHANGED
|
@@ -58,6 +58,9 @@ declare type TInventoryItem = {
|
|
|
58
58
|
available?: number;
|
|
59
59
|
/** Issued but not yet confirmed (Received) by the person. */
|
|
60
60
|
awaitingReceipt?: number;
|
|
61
|
+
/** DV-1787: serial numbers - in all, and of units on the shelf (> 0: choose serials when issuing). */
|
|
62
|
+
serialsTotal?: number;
|
|
63
|
+
serialsInStore?: number;
|
|
61
64
|
/** Only while the item is low. */
|
|
62
65
|
lowStockAlert?: {
|
|
63
66
|
since?: string;
|
|
@@ -147,6 +150,8 @@ declare type TInventoryTransaction = {
|
|
|
147
150
|
workOrder?: string;
|
|
148
151
|
workOrderNumber?: string;
|
|
149
152
|
workOrderExists?: boolean;
|
|
153
|
+
/** Issue (DV-1787): when the person is expected to give it back ("YYYY-MM-DD" at midnight UTC). */
|
|
154
|
+
returnDate?: string | null;
|
|
150
155
|
/** The feedback the work order is tied to (2026-11): its link goes there. */
|
|
151
156
|
workOrderFeedback?: string | null;
|
|
152
157
|
supplier?: string;
|
|
@@ -174,6 +179,8 @@ declare type TInventoryTransaction = {
|
|
|
174
179
|
photosAfterAt?: string | null;
|
|
175
180
|
submittedAt?: string;
|
|
176
181
|
writeOffReason?: string;
|
|
182
|
+
/** DV-1787: the serial numbers this movement covers (issue, return, write-off, use). */
|
|
183
|
+
serials?: string[];
|
|
177
184
|
/** "Also attended" on a usage record. */
|
|
178
185
|
attendedWith?: string;
|
|
179
186
|
/** A draft taken over from a colleague. */
|
|
@@ -246,3 +253,48 @@ declare type TInventoryPoLine = {
|
|
|
246
253
|
receivedBy: string;
|
|
247
254
|
}[];
|
|
248
255
|
};
|
|
256
|
+
|
|
257
|
+
/** DV-1787: the work order picked in Issue Stock - its id, number as shown ("#CLN0012"), subject and status. */
|
|
258
|
+
declare type TPickedWorkOrder = { _id: string; number: string; subject: string; status: string };
|
|
259
|
+
|
|
260
|
+
/** DV-1787: stock issued for a work order and/or to come back by a date, tracked until it does. */
|
|
261
|
+
declare type TInventoryCheckout = {
|
|
262
|
+
_id: string;
|
|
263
|
+
store: string;
|
|
264
|
+
site?: string;
|
|
265
|
+
item: string;
|
|
266
|
+
itemName: string;
|
|
267
|
+
unit: string;
|
|
268
|
+
holder: string;
|
|
269
|
+
holderName: string;
|
|
270
|
+
qty: number;
|
|
271
|
+
outQty: number;
|
|
272
|
+
workOrder?: string;
|
|
273
|
+
workOrderNumber?: string;
|
|
274
|
+
returnDate: string | null;
|
|
275
|
+
status: "out" | "returned" | "written_off" | "used" | "handed_over" | "closed";
|
|
276
|
+
createdByName: string;
|
|
277
|
+
createdAt: string;
|
|
278
|
+
closedAt?: string;
|
|
279
|
+
overdue: boolean;
|
|
280
|
+
daysOverdue: number;
|
|
281
|
+
/** A return the holder asked for, waiting for a store keeper (its id), or null. */
|
|
282
|
+
returnRequest?: string | null;
|
|
283
|
+
/** Serial numbers still out on it. */
|
|
284
|
+
serials?: { _id: string; serial: string }[];
|
|
285
|
+
/** Return date set, changed or cleared after the issue (newest last). */
|
|
286
|
+
dateChanges?: { from: string | null; to: string | null; at: string; byName: string; reason?: string }[];
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/** DV-1787: one unit with its own serial number, and its history. */
|
|
290
|
+
declare type TInventorySerial = {
|
|
291
|
+
_id: string;
|
|
292
|
+
item: string;
|
|
293
|
+
itemName: string;
|
|
294
|
+
serial: string;
|
|
295
|
+
status: "in_store" | "out" | "written_off" | "used";
|
|
296
|
+
holderName?: string;
|
|
297
|
+
workOrderNumber?: string;
|
|
298
|
+
history: { type: string; at: string; byName: string; holderName?: string; workOrderNumber?: string; reason?: string; fromName?: string; note?: string }[];
|
|
299
|
+
createdAt: string;
|
|
300
|
+
};
|