@7365admin1/layer-common 4.189.1 → 4.190.0
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 +30 -4
- 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/Layout/Header.vue +45 -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/account-return.ts +58 -0
- package/utils/inventory-checkout.ts +114 -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>
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
v-if="APP_NAME.toLowerCase() !== 'account'"
|
|
75
75
|
type="button"
|
|
76
76
|
class="app-profile-menu__row"
|
|
77
|
-
@click="
|
|
77
|
+
@click="openAccount()"
|
|
78
78
|
>
|
|
79
79
|
<v-icon icon="mdi-account-cog-outline" size="18" />
|
|
80
80
|
Manage Account
|
|
@@ -131,6 +131,11 @@
|
|
|
131
131
|
// Explicit, not the `$tr` global: renders the same in unit tests that mount this file.
|
|
132
132
|
import { uiTr } from "../../composables/useUiLanguage";
|
|
133
133
|
import { moduleNameFromRoute } from "../../utils/breadcrumb";
|
|
134
|
+
import {
|
|
135
|
+
ACCOUNT_RETURN_KEY,
|
|
136
|
+
ACCOUNT_RETURN_STATE,
|
|
137
|
+
safeAccountReturn,
|
|
138
|
+
} from "../../utils/account-return";
|
|
134
139
|
|
|
135
140
|
const props = defineProps({
|
|
136
141
|
hideNavIcon: {
|
|
@@ -246,6 +251,45 @@ const profile = computed(() => {
|
|
|
246
251
|
return `/api/public/${currentUser.value?.profile}`;
|
|
247
252
|
});
|
|
248
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Manage Account carries the page the user is on, so the Account application
|
|
256
|
+
* can offer a way back to it (DV-1874). It opens Personal Info directly:
|
|
257
|
+
* `/home` is a server redirect there that would drop the query.
|
|
258
|
+
*/
|
|
259
|
+
function openAccount() {
|
|
260
|
+
redirect(
|
|
261
|
+
APP_ACCOUNT,
|
|
262
|
+
`personal-info?return=${encodeURIComponent(window.location.href)}`
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* In the Account application, the Back target: taken from `?return=` when it
|
|
268
|
+
* arrives (and only if it is one of our own apps), then kept for the tab's
|
|
269
|
+
* session so it survives moving between the Personal Info screens, which drop
|
|
270
|
+
* the query. Read in `onMounted` - the bar is pre-rendered on the server,
|
|
271
|
+
* where there is no `window` or `sessionStorage`.
|
|
272
|
+
*
|
|
273
|
+
* The bar only WORKS IT OUT; the Account app's Personal Info page draws the
|
|
274
|
+
* Back button above its "Profile Info" title (owner's placement, DV-1874),
|
|
275
|
+
* reading this shared state.
|
|
276
|
+
*/
|
|
277
|
+
const accountReturn = useState<string>(ACCOUNT_RETURN_STATE, () => "");
|
|
278
|
+
|
|
279
|
+
onMounted(() => {
|
|
280
|
+
if (APP_NAME.toLowerCase() !== "account") return;
|
|
281
|
+
try {
|
|
282
|
+
const fromQuery = safeAccountReturn(route.query.return, String(APP_ACCOUNT));
|
|
283
|
+
if (fromQuery) sessionStorage.setItem(ACCOUNT_RETURN_KEY, fromQuery);
|
|
284
|
+
accountReturn.value =
|
|
285
|
+
fromQuery ||
|
|
286
|
+
safeAccountReturn(sessionStorage.getItem(ACCOUNT_RETURN_KEY), String(APP_ACCOUNT));
|
|
287
|
+
} catch {
|
|
288
|
+
// Storage blocked (private mode): fall back to the query alone.
|
|
289
|
+
accountReturn.value = safeAccountReturn(route.query.return, String(APP_ACCOUNT));
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
249
293
|
function logout() {
|
|
250
294
|
if (APP_NAME.toLowerCase() !== "main") {
|
|
251
295
|
redirect(APP_MAIN, "logout");
|
|
@@ -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,156 @@
|
|
|
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
|
+
<v-alert v-if="blocking" type="warning" variant="tonal" density="compact" class="mb-2" icon="mdi-lock-outline">
|
|
9
|
+
{{ blockingCount === 1 ? "1 item not returned yet." : `${blockingCount} items not returned yet.` }} Return {{ blockingCount === 1 ? "it" : "them" }} before completing.
|
|
10
|
+
</v-alert>
|
|
11
|
+
<!-- DV-1787: one short line per item (what is with whom, what came back); tap it for the details
|
|
12
|
+
and the return options, so the narrow Information panel stays light. -->
|
|
13
|
+
<div class="issued-items__list">
|
|
14
|
+
<button v-for="g in groups" :key="g.key" type="button" class="issued-items__sum" @click="openGroup(g.key)">
|
|
15
|
+
<span class="issued-items__sum-text">
|
|
16
|
+
<span class="issued-items__name">
|
|
17
|
+
{{ g.itemName }}
|
|
18
|
+
<span v-if="showNumber && g.workOrderNumber" class="text-caption text-medium-emphasis">· {{ g.workOrderNumber }}</span>
|
|
19
|
+
</span>
|
|
20
|
+
<span class="issued-items__meta d-block">
|
|
21
|
+
<template v-for="(p, i) in g.parts" :key="i">
|
|
22
|
+
<span v-if="i" class="text-medium-emphasis"> · </span>
|
|
23
|
+
<span :class="p.cls" class="font-weight-medium">{{ p.text }}</span>
|
|
24
|
+
</template>
|
|
25
|
+
<span v-if="!g.parts.length" class="text-medium-emphasis">Closed</span>
|
|
26
|
+
</span>
|
|
27
|
+
</span>
|
|
28
|
+
<v-icon v-if="g.overdue" icon="mdi-alarm" color="error" size="18" class="mr-1" />
|
|
29
|
+
<v-icon v-else-if="g.asked" icon="mdi-keyboard-return" color="primary" size="18" class="mr-1" />
|
|
30
|
+
<v-icon icon="mdi-chevron-right" size="20" class="text-medium-emphasis" />
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<!-- DV-1787: the item's details (totals, serial table, Received / Not Received / Ask to Return) -->
|
|
35
|
+
<InventoryCheckoutDetail v-model="detail.show" :rows="openRows" :subtitle="openRows[0]?.workOrderNumber || ''" @changed="load" />
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import useInventory from "../../composables/useInventory";
|
|
41
|
+
import { qtyUnit } from "../../utils/inventory-ack";
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
/** One of the two: the work order, or the feedback whose attached work orders are shown. */
|
|
45
|
+
workOrderId: { type: String, default: "" },
|
|
46
|
+
feedbackId: { type: String, default: "" },
|
|
47
|
+
/**
|
|
48
|
+
* Only on a page with a Complete button (management): warn that the items block completing.
|
|
49
|
+
* Service provider apps only Submit for review, so they leave it off.
|
|
50
|
+
*/
|
|
51
|
+
showCompletionBlock: { type: Boolean, default: false },
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const items = ref<TInventoryCheckout[]>([]);
|
|
55
|
+
const requireReturn = ref(false);
|
|
56
|
+
// A feedback can have more than one work order (re-opened): say which one each item was for.
|
|
57
|
+
const showNumber = computed(() => Boolean(props.feedbackId) && new Set(items.value.map((c) => c.workOrder)).size > 1);
|
|
58
|
+
const blockingCount = computed(() => items.value.filter((c) => c.status === "out" && c.returnDate).length);
|
|
59
|
+
const blocking = computed(() => props.showCompletionBlock && requireReturn.value && blockingCount.value > 0);
|
|
60
|
+
/** For the page's Complete button: true while items with a return date are out and the setting is on. */
|
|
61
|
+
const emit = defineEmits<{ blocking: [boolean] }>();
|
|
62
|
+
watch(() => requireReturn.value && blockingCount.value > 0, (v) => emit("blocking", v), { immediate: true });
|
|
63
|
+
|
|
64
|
+
// DV-1787: one line per item (and work order, when the feedback has several).
|
|
65
|
+
// colour per status, as in the details: with the person amber, return asked blue, returned green, written off red
|
|
66
|
+
const ENDED_WORDS: [string, string, string][] = [
|
|
67
|
+
["returned", "returned", "text-success"],
|
|
68
|
+
["written_off", "written off", "text-error"],
|
|
69
|
+
["used", "used", "text-medium-emphasis"],
|
|
70
|
+
];
|
|
71
|
+
const n = (v: unknown) => Number(v) || 0;
|
|
72
|
+
const groups = computed(() => {
|
|
73
|
+
const map = new Map<string, TInventoryCheckout[]>();
|
|
74
|
+
for (const c of items.value) {
|
|
75
|
+
const key = `${c.item}:${showNumber.value ? c.workOrder ?? "" : ""}`;
|
|
76
|
+
map.set(key, [...(map.get(key) ?? []), c]);
|
|
77
|
+
}
|
|
78
|
+
return [...map.entries()].map(([key, rows]) => {
|
|
79
|
+
const unit = rows[0].unit;
|
|
80
|
+
const withWhom = new Map<string, number>();
|
|
81
|
+
// With whom (not counting what is already asked to return), then asked, then what ended - they add up to what was issued.
|
|
82
|
+
for (const c of rows) {
|
|
83
|
+
const held = c.status === "out" ? Math.max(0, c.outQty - (c.returnAsked?.qty ?? 0)) : 0;
|
|
84
|
+
if (held > 0) withWhom.set(c.holderName, (withWhom.get(c.holderName) ?? 0) + held);
|
|
85
|
+
}
|
|
86
|
+
const parts = [...withWhom.entries()].map(([who, q]) => ({ text: `${qtyUnit(q, unit)} with ${who}`, cls: "text-warning" }));
|
|
87
|
+
const askedQty = rows.reduce((t, c) => t + (c.status === "out" ? (c.returnAsked?.qty ?? 0) : 0), 0);
|
|
88
|
+
if (askedQty) parts.push({ text: `${askedQty} return asked`, cls: "text-primary" });
|
|
89
|
+
for (const [k, word, cls] of ENDED_WORDS) {
|
|
90
|
+
const q = rows.reduce((s, c) => s + n(c.ended?.[k]), 0);
|
|
91
|
+
if (q) parts.push({ text: `${q} ${word}`, cls });
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
key,
|
|
95
|
+
itemName: rows[0].itemName,
|
|
96
|
+
workOrderNumber: rows[0].workOrderNumber,
|
|
97
|
+
parts,
|
|
98
|
+
overdue: rows.some((c) => c.status === "out" && c.overdue),
|
|
99
|
+
asked: rows.some((c) => c.status === "out" && c.returnRequest),
|
|
100
|
+
rows,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
const detail = reactive({ show: false, key: "" });
|
|
105
|
+
const openGroup = (key: string) => Object.assign(detail, { show: true, key });
|
|
106
|
+
const openGroupRow = computed(() => groups.value.find((g) => g.key === detail.key));
|
|
107
|
+
const openRows = computed(() => openGroupRow.value?.rows ?? []);
|
|
108
|
+
|
|
109
|
+
async function load() {
|
|
110
|
+
if (!props.workOrderId && !props.feedbackId) return;
|
|
111
|
+
try {
|
|
112
|
+
const res = await useInventory().getWorkOrderCheckouts(props.workOrderId ? { workOrder: props.workOrderId } : { feedback: props.feedbackId });
|
|
113
|
+
items.value = res.items ?? [];
|
|
114
|
+
requireReturn.value = Boolean(res.requireReturn);
|
|
115
|
+
} catch {
|
|
116
|
+
items.value = [];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
watch(() => [props.workOrderId, props.feedbackId], load);
|
|
120
|
+
onMounted(load);
|
|
121
|
+
defineExpose({ load });
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<style scoped>
|
|
125
|
+
.issued-items {
|
|
126
|
+
margin-top: 16px;
|
|
127
|
+
}
|
|
128
|
+
.issued-items__sum {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: center;
|
|
131
|
+
width: 100%;
|
|
132
|
+
text-align: left;
|
|
133
|
+
padding: 8px 4px;
|
|
134
|
+
border-bottom: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
|
|
135
|
+
border-radius: 4px;
|
|
136
|
+
}
|
|
137
|
+
.issued-items__sum:last-child {
|
|
138
|
+
border-bottom: 0;
|
|
139
|
+
}
|
|
140
|
+
.issued-items__sum:hover {
|
|
141
|
+
background: rgba(var(--v-theme-on-surface), 0.04);
|
|
142
|
+
}
|
|
143
|
+
.issued-items__sum-text {
|
|
144
|
+
flex: 1;
|
|
145
|
+
min-width: 0;
|
|
146
|
+
}
|
|
147
|
+
.issued-items__name {
|
|
148
|
+
font-weight: 500;
|
|
149
|
+
min-width: 0;
|
|
150
|
+
overflow-wrap: anywhere;
|
|
151
|
+
}
|
|
152
|
+
.issued-items__meta {
|
|
153
|
+
font-size: 0.875rem;
|
|
154
|
+
margin-top: 2px;
|
|
155
|
+
}
|
|
156
|
+
</style>
|
|
@@ -61,6 +61,26 @@ 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
|
+
/** `noSerialQty` given: only the chosen serials plus that many units without a serial come back. */
|
|
66
|
+
returnCheckout: (checkout: string, note = "", serials?: string[], noSerialQty?: number) =>
|
|
67
|
+
api(`/checkouts/${checkout}/return`, { method: "POST", body: { note, ...(serials?.length ? { serials } : {}), ...(noSerialQty !== undefined ? { noSerialQty } : {}) } }),
|
|
68
|
+
/** DV-1787: an item's serial numbers with their history, and adding serials to units on the shelf. */
|
|
69
|
+
getSerials: (item: string, status: "in_store" | "out" | "written_off" | "used" | "all" | "mine" = "all") =>
|
|
70
|
+
api<{ items: TInventorySerial[]; inStore: number; onHand: number }>(`/items/${item}/serials`, { query: status === "mine" ? { mine: true } : { status } }),
|
|
71
|
+
addSerials: (item: string, serials: string[]) => api(`/items/${item}/serials`, { method: "POST", body: { serials } }),
|
|
72
|
+
/** DV-1787: a store keeper sets, changes or clears (null) a checkout's return date. */
|
|
73
|
+
changeReturnDate: (checkout: string, returnDate: string | null, reason = "") =>
|
|
74
|
+
api(`/checkouts/${checkout}/return-date`, { method: "POST", body: { returnDate, reason } }),
|
|
75
|
+
/** DV-1787: the holder asks to return one checked-out item. */
|
|
76
|
+
requestCheckoutReturn: (checkout: string, note = "", serials?: string[], noSerialQty?: number) =>
|
|
77
|
+
api(`/checkouts/${checkout}/return-request`, { method: "POST", body: { note, ...(serials?.length ? { serials } : {}), ...(noSerialQty !== undefined ? { noSerialQty } : {}) } }),
|
|
78
|
+
/** DV-1787: the items issued for a work order (or a feedback's work orders), and whether they block completing it. */
|
|
79
|
+
getWorkOrderCheckouts: (query: { workOrder?: string; feedback?: string }) =>
|
|
80
|
+
api<{ items: TInventoryCheckout[]; requireReturn: boolean }>(`/work-order-checkouts`, { query }),
|
|
81
|
+
/** DV-1787: what is checked out (issued for a work order / to come back by a date), with overdue flags. */
|
|
82
|
+
getCheckouts: (store: string, query: { status?: "out" | "closed" | "all"; mine?: boolean; overdue?: boolean; page?: number; limit?: number; search?: string } = {}) =>
|
|
83
|
+
api<{ items: TInventoryCheckout[]; total: number; page: number; pages: number; counts: { out: number; overdue: number } }>(`/stores/${store}/checkouts`, { query }),
|
|
64
84
|
receiveReturn: (store: string, body: Record<string, any>) => api(`/stores/${store}/returns`, { method: "POST", body }),
|
|
65
85
|
recordUsage: (store: string, body: Record<string, any>) => api(`/stores/${store}/usage`, { method: "POST", body }),
|
|
66
86
|
/** Usage drafts: before photo now, after photo and submit after the job (stock is deducted on submit). */
|
|
@@ -91,10 +111,10 @@ export default function useInventory() {
|
|
|
91
111
|
acknowledgeRequest: (id: string) => api<TInventoryRequest>(`/requests/${id}/acknowledge`, { method: "POST", body: {} }),
|
|
92
112
|
notReceived: (id: string, reason: string) => api<TInventoryRequest>(`/requests/${id}/not-received`, { method: "POST", body: { reason } }),
|
|
93
113
|
/** 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[] }) =>
|
|
114
|
+
writeOff: (store: string, body: { from: "holding" | "store"; site?: string; item: string; qty: number; reason: string; remarks?: string; photos?: string[]; serials?: string[] }) =>
|
|
95
115
|
api<TInventoryTransaction>(`/stores/${store}/write-offs`, { method: "POST", body }),
|
|
96
116
|
/** 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 }) =>
|
|
117
|
+
requestReturn: (store: string, body: { site: string; item: string; qty: number; note?: string; serials?: string[] }) =>
|
|
98
118
|
api<TInventoryHandover>(`/stores/${store}/returns/request`, { method: "POST", body }),
|
|
99
119
|
takeOverDraft: (id: string) => api<TInventoryUsageDraft>(`/usage-drafts/${id}/take-over`, { method: "POST", body: {} }),
|
|
100
120
|
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.
|
|
5
|
+
"version": "4.190.0",
|
|
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.",
|