@7365admin1/layer-common 4.17.0 → 4.17.1-staging.331
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 +4 -4
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +193 -43
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +779 -213
- package/components/InventoryImportDialog.vue +117 -0
- package/components/InventoryItemDetail.vue +158 -0
- package/components/InventoryItemDialog.vue +125 -0
- package/components/InventoryLinesDialog.vue +288 -0
- package/components/InventoryMain.vue +226 -0
- package/components/InventoryMyStockTab.vue +114 -0
- package/components/InventoryPhotoInput.vue +70 -0
- package/components/InventoryReportsTab.vue +181 -0
- package/components/InventoryRequestsTab.vue +218 -0
- package/components/InventorySettingsTab.vue +94 -0
- package/components/InventoryStockTab.vue +177 -0
- package/components/InventoryTechniciansTab.vue +81 -0
- package/components/InventoryUsageDialog.vue +203 -0
- package/components/InvitationClientForm.vue +19 -1
- package/components/Layout/Header.vue +26 -0
- package/components/NotificationBell.vue +321 -0
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useCleaningPermission.ts +2 -7
- package/composables/useCommonPermission.ts +22 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +97 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/useInventory.ts +97 -0
- package/composables/useInventoryPermission.ts +31 -0
- package/composables/useLandscapingPermission.ts +2 -6
- package/composables/useMechanicalElectricalPermission.ts +2 -0
- package/composables/useNotification.ts +78 -0
- package/composables/usePeople.ts +19 -0
- package/composables/usePestControlPermission.ts +2 -0
- package/composables/usePoolMaintenancePermission.ts +2 -0
- package/composables/usePropertyPermission.ts +2 -0
- package/composables/useSecurityPermission.ts +10 -7
- package/composables/useWebUsb.ts +14 -11
- package/constants/permissions.ts +1 -1
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/inventory.d.ts +89 -0
- package/types/people.d.ts +4 -1
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/materialSymbols.ts +3 -0
- package/utils/module-routes.ts +1 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="d-flex flex-wrap ga-2 align-center">
|
|
4
|
+
<div v-for="(id, i) in model" :key="id" class="inventory-photo">
|
|
5
|
+
<v-img :src="getFileUrl(id)" width="72" height="72" cover class="rounded" />
|
|
6
|
+
<v-btn icon="mdi-close" size="x-small" variant="flat" class="inventory-photo__remove" :aria-label="`Remove photo ${i + 1}`" @click="remove(i)" />
|
|
7
|
+
</div>
|
|
8
|
+
<v-btn
|
|
9
|
+
v-if="model.length < max"
|
|
10
|
+
variant="outlined"
|
|
11
|
+
class="text-none screen-btn-ghost"
|
|
12
|
+
prepend-icon="mdi-camera-plus-outline"
|
|
13
|
+
:loading="uploading"
|
|
14
|
+
@click="picker?.click()"
|
|
15
|
+
>
|
|
16
|
+
{{ label }}
|
|
17
|
+
</v-btn>
|
|
18
|
+
</div>
|
|
19
|
+
<input ref="picker" type="file" accept="image/*" multiple hidden @change="upload" />
|
|
20
|
+
<div v-if="error" class="text-caption text-error mt-1">{{ error }}</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import useFile from "../composables/useFile";
|
|
26
|
+
|
|
27
|
+
const model = defineModel<string[]>({ default: () => [] });
|
|
28
|
+
defineProps({
|
|
29
|
+
label: { type: String, default: "Add photo" },
|
|
30
|
+
max: { type: Number, default: 5 },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const { addFile, getFileUrl } = useFile();
|
|
34
|
+
const picker = ref<HTMLInputElement>();
|
|
35
|
+
const uploading = ref(false);
|
|
36
|
+
const error = ref("");
|
|
37
|
+
|
|
38
|
+
async function upload(event: Event) {
|
|
39
|
+
const files = Array.from((event.target as HTMLInputElement).files ?? []);
|
|
40
|
+
(event.target as HTMLInputElement).value = "";
|
|
41
|
+
if (!files.length) return;
|
|
42
|
+
uploading.value = true;
|
|
43
|
+
error.value = "";
|
|
44
|
+
try {
|
|
45
|
+
for (const file of files.slice(0, 5 - model.value.length)) {
|
|
46
|
+
const res = await addFile(file);
|
|
47
|
+
if (res?.id) model.value = [...model.value, res.id as string];
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
error.value = "A photo could not be uploaded. Please try again.";
|
|
51
|
+
} finally {
|
|
52
|
+
uploading.value = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function remove(index: number) {
|
|
57
|
+
model.value = model.value.filter((_, i) => i !== index);
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<style scoped>
|
|
62
|
+
.inventory-photo {
|
|
63
|
+
position: relative;
|
|
64
|
+
}
|
|
65
|
+
.inventory-photo__remove {
|
|
66
|
+
position: absolute;
|
|
67
|
+
top: -6px;
|
|
68
|
+
right: -6px;
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="d-flex flex-wrap ga-3 align-center mb-3">
|
|
4
|
+
<v-btn-toggle v-model="report" mandatory density="comfortable" variant="outlined" divided>
|
|
5
|
+
<v-btn value="movement" class="text-none">Stock Movement</v-btn>
|
|
6
|
+
<v-btn value="usage" class="text-none">Usage</v-btn>
|
|
7
|
+
<v-btn value="technicians" class="text-none">Technicians</v-btn>
|
|
8
|
+
</v-btn-toggle>
|
|
9
|
+
<v-text-field v-model="month" type="month" label="Month" density="compact" hide-details style="max-width: 180px" />
|
|
10
|
+
<v-select
|
|
11
|
+
v-if="report === 'usage' && sites.length > 1"
|
|
12
|
+
v-model="site"
|
|
13
|
+
:items="[{ _id: '', name: 'All properties' }, ...sites]"
|
|
14
|
+
item-title="name"
|
|
15
|
+
item-value="_id"
|
|
16
|
+
density="compact"
|
|
17
|
+
hide-details
|
|
18
|
+
style="max-width: 220px"
|
|
19
|
+
/>
|
|
20
|
+
<v-select
|
|
21
|
+
v-if="report === 'usage'"
|
|
22
|
+
v-model="locationType"
|
|
23
|
+
:items="[
|
|
24
|
+
{ value: '', title: 'Tenant units and common areas' },
|
|
25
|
+
{ value: 'tenant_unit', title: 'Tenant units only' },
|
|
26
|
+
{ value: 'common_area', title: 'Common areas only' },
|
|
27
|
+
]"
|
|
28
|
+
density="compact"
|
|
29
|
+
hide-details
|
|
30
|
+
style="max-width: 260px"
|
|
31
|
+
/>
|
|
32
|
+
<v-spacer />
|
|
33
|
+
<v-btn class="text-none screen-btn-ghost" variant="outlined" prepend-icon="mdi-file-excel-outline" :loading="exporting" @click="exportExcel">
|
|
34
|
+
Export Excel
|
|
35
|
+
</v-btn>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<p class="text-caption text-medium-emphasis mb-2">{{ help[report] }}</p>
|
|
39
|
+
<div v-if="report === 'usage' && rows.length" class="text-body-2 font-weight-medium mb-2">
|
|
40
|
+
{{ rows.length }} record(s) · {{ totals.qty }} item(s) used · Total cost {{ money(totals.cost) }}
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<v-data-table
|
|
44
|
+
:headers="headers[report]"
|
|
45
|
+
:items="rows"
|
|
46
|
+
:loading="loading"
|
|
47
|
+
density="compact"
|
|
48
|
+
:items-per-page="50"
|
|
49
|
+
class="border rounded"
|
|
50
|
+
no-data-text="Nothing recorded in this period."
|
|
51
|
+
>
|
|
52
|
+
<template #item.date="{ value }">{{ standardFormatDate(value) }}</template>
|
|
53
|
+
<template #item.locationType="{ value }">{{ value === "tenant_unit" ? "Tenant unit" : "Common area" }}</template>
|
|
54
|
+
<template #item.unitCost="{ value }">{{ money(value) }}</template>
|
|
55
|
+
<template #item.totalCost="{ value }">{{ money(value) }}</template>
|
|
56
|
+
<template #item.receivedCost="{ value }">{{ money(value) }}</template>
|
|
57
|
+
<template #item.usedCost="{ value }">{{ money(value) }}</template>
|
|
58
|
+
<template #item.closing="{ item }">
|
|
59
|
+
<span :class="item.reorderLevel && item.closing <= item.reorderLevel ? 'text-error font-weight-bold' : 'font-weight-medium'">{{ item.closing }}</span>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
</v-data-table>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<script setup lang="ts">
|
|
67
|
+
import useInventory, { saveBlob } from "../composables/useInventory";
|
|
68
|
+
import useUtils from "../composables/useUtils";
|
|
69
|
+
|
|
70
|
+
const props = defineProps({
|
|
71
|
+
store: { type: Object as PropType<TInventoryStore>, required: true },
|
|
72
|
+
sites: { type: Array as PropType<{ _id: string; name: string }[]>, default: () => [] },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const api = useInventory();
|
|
76
|
+
const { standardFormatDate } = useUtils();
|
|
77
|
+
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
78
|
+
|
|
79
|
+
const now = new Date();
|
|
80
|
+
const month = ref(`${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}`);
|
|
81
|
+
const report = ref<"movement" | "usage" | "technicians">("movement");
|
|
82
|
+
const site = ref("");
|
|
83
|
+
const locationType = ref("");
|
|
84
|
+
const rows = ref<any[]>([]);
|
|
85
|
+
const totals = reactive({ qty: 0, cost: 0 });
|
|
86
|
+
const loading = ref(false);
|
|
87
|
+
const exporting = ref(false);
|
|
88
|
+
|
|
89
|
+
const money = (v: number) => (v === undefined || v === null ? "—" : `$${Number(v).toFixed(2)}`);
|
|
90
|
+
|
|
91
|
+
const help: Record<string, string> = {
|
|
92
|
+
movement: "For each item: stock at the start of the month, what came in, what was issued and returned, count differences, and stock at the end.",
|
|
93
|
+
usage: "Every recorded usage: where it was used, for which tenant, by whom, and the cost. Use this for tenant billing.",
|
|
94
|
+
technicians: "For each person: stock they held at the start, took, used, returned, and hold at the end of the month.",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const headers: Record<string, any[]> = {
|
|
98
|
+
movement: [
|
|
99
|
+
{ title: "Item", key: "name" },
|
|
100
|
+
{ title: "Unit", key: "unit" },
|
|
101
|
+
{ title: "Start", key: "opening" },
|
|
102
|
+
{ title: "Received", key: "received" },
|
|
103
|
+
{ title: "Purchase cost", key: "receivedCost" },
|
|
104
|
+
{ title: "Issued", key: "issued" },
|
|
105
|
+
{ title: "Returned", key: "returned" },
|
|
106
|
+
{ title: "Count diff.", key: "adjusted" },
|
|
107
|
+
{ title: "End", key: "closing" },
|
|
108
|
+
{ title: "Used", key: "usedByTechnicians" },
|
|
109
|
+
{ title: "Usage cost", key: "usedCost" },
|
|
110
|
+
],
|
|
111
|
+
usage: [
|
|
112
|
+
{ title: "Date", key: "date" },
|
|
113
|
+
{ title: "Property", key: "siteName" },
|
|
114
|
+
{ title: "Where", key: "locationType" },
|
|
115
|
+
{ title: "Unit / Area", key: "location" },
|
|
116
|
+
{ title: "Tenant", key: "tenantName" },
|
|
117
|
+
{ title: "Item", key: "itemName" },
|
|
118
|
+
{ title: "Unit", key: "unit" },
|
|
119
|
+
{ title: "Qty", key: "qty" },
|
|
120
|
+
{ title: "Unit price", key: "unitCost" },
|
|
121
|
+
{ title: "Total", key: "totalCost" },
|
|
122
|
+
{ title: "Technician", key: "technician" },
|
|
123
|
+
{ title: "Reference", key: "reference" },
|
|
124
|
+
{ title: "Remarks", key: "remarks" },
|
|
125
|
+
],
|
|
126
|
+
technicians: [
|
|
127
|
+
{ title: "Name", key: "technician" },
|
|
128
|
+
{ title: "Item", key: "itemName" },
|
|
129
|
+
{ title: "Unit", key: "unit" },
|
|
130
|
+
{ title: "Holding at start", key: "opening" },
|
|
131
|
+
{ title: "Taken", key: "taken" },
|
|
132
|
+
{ title: "Used", key: "used" },
|
|
133
|
+
{ title: "Returned", key: "returned" },
|
|
134
|
+
{ title: "Holding at end", key: "closing" },
|
|
135
|
+
{ title: "In hand now", key: "inHandNow" },
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
function period(): TInventoryPeriod {
|
|
140
|
+
const [y, m] = month.value.split("-").map(Number);
|
|
141
|
+
const from = new Date(y, m - 1, 1, 0, 0, 0, 0);
|
|
142
|
+
const to = new Date(y, m, 0, 23, 59, 59, 999);
|
|
143
|
+
return {
|
|
144
|
+
from: from.toISOString(),
|
|
145
|
+
to: to.toISOString(),
|
|
146
|
+
...(report.value === "usage" && site.value ? { site: site.value } : {}),
|
|
147
|
+
...(report.value === "usage" && locationType.value ? { locationType: locationType.value } : {}),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function load() {
|
|
152
|
+
if (!month.value) return;
|
|
153
|
+
loading.value = true;
|
|
154
|
+
try {
|
|
155
|
+
const res = await api.getReport(props.store._id, report.value, period());
|
|
156
|
+
rows.value = res.rows;
|
|
157
|
+
totals.qty = res.totalQty ?? 0;
|
|
158
|
+
totals.cost = res.totalCost ?? 0;
|
|
159
|
+
} catch (error: any) {
|
|
160
|
+
rows.value = [];
|
|
161
|
+
notify(error?.data?.message || "Could not load the report.", "error");
|
|
162
|
+
} finally {
|
|
163
|
+
loading.value = false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function exportExcel() {
|
|
168
|
+
exporting.value = true;
|
|
169
|
+
try {
|
|
170
|
+
const blob = await api.exportReport(props.store._id, report.value, period());
|
|
171
|
+
saveBlob(blob, `${props.store.name} - ${report.value} - ${month.value}.xlsx`);
|
|
172
|
+
} catch {
|
|
173
|
+
notify("Could not export the report.", "error");
|
|
174
|
+
} finally {
|
|
175
|
+
exporting.value = false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
watch([report, month, site, locationType, () => props.store._id], load);
|
|
180
|
+
onMounted(load);
|
|
181
|
+
</script>
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="d-flex flex-wrap ga-2 align-center mb-3">
|
|
4
|
+
<v-btn-toggle v-model="status" mandatory density="comfortable" variant="outlined" divided>
|
|
5
|
+
<v-btn value="pending" class="text-none">Waiting</v-btn>
|
|
6
|
+
<v-btn value="issued" class="text-none">Issued</v-btn>
|
|
7
|
+
<v-btn value="rejected" class="text-none">Rejected</v-btn>
|
|
8
|
+
<v-btn value="" class="text-none">All</v-btn>
|
|
9
|
+
</v-btn-toggle>
|
|
10
|
+
<v-spacer />
|
|
11
|
+
<v-btn v-if="store.access.canRequest && !store.access.canManage" class="text-none screen-btn-primary" variant="flat" prepend-icon="mdi-cart-arrow-down" @click="showRequest = true">
|
|
12
|
+
Request Stock
|
|
13
|
+
</v-btn>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<v-progress-linear v-if="loading" indeterminate color="primary" />
|
|
17
|
+
<div v-else-if="!requests.length" class="text-center text-medium-emphasis py-10">
|
|
18
|
+
{{ status === "pending" ? "No requests waiting." : "No requests to show." }}
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<AppCard v-for="r in requests" :key="r._id" class="pa-4 mb-3">
|
|
22
|
+
<div class="d-flex flex-wrap align-center ga-2 mb-2">
|
|
23
|
+
<div class="font-weight-medium">{{ r.requestedByName || "Someone" }}</div>
|
|
24
|
+
<div class="text-caption text-medium-emphasis">{{ standardFormatDateTime(r.createdAt) }}</div>
|
|
25
|
+
<v-chip size="small" :color="chip[r.status].color" variant="tonal">{{ chip[r.status].label }}</v-chip>
|
|
26
|
+
<v-spacer />
|
|
27
|
+
<template v-if="r.status === 'pending'">
|
|
28
|
+
<v-btn v-if="store.access.canApprove" class="text-none screen-btn-primary" variant="flat" @click="openDecision(r)">Review</v-btn>
|
|
29
|
+
<v-btn v-else-if="isMine(r)" class="text-none screen-btn-ghost" variant="outlined" :loading="busyId === r._id" @click="cancel(r)">Cancel</v-btn>
|
|
30
|
+
</template>
|
|
31
|
+
</div>
|
|
32
|
+
<div v-for="l in r.lines" :key="String(l.item)" class="text-body-2">
|
|
33
|
+
{{ l.itemName }} — {{ r.status === "issued" ? `${l.issuedQty} of ${l.qty}` : l.qty }} {{ l.unit }}
|
|
34
|
+
</div>
|
|
35
|
+
<div v-if="r.reference || r.remarks" class="text-caption text-medium-emphasis mt-1">{{ [r.reference, r.remarks].filter(Boolean).join(" · ") }}</div>
|
|
36
|
+
<div v-if="r.decidedByName" class="text-caption mt-1">
|
|
37
|
+
{{ r.status === "issued" ? "Issued" : "Rejected" }} by {{ r.decidedByName }}{{ r.decisionRemarks ? `: ${r.decisionRemarks}` : "" }}
|
|
38
|
+
</div>
|
|
39
|
+
</AppCard>
|
|
40
|
+
|
|
41
|
+
<div class="text-center" v-if="page < pages">
|
|
42
|
+
<v-btn variant="text" class="text-none" :loading="loading" @click="load(page + 1)">Show more</v-btn>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<v-dialog v-model="decision.show" max-width="620" persistent scrollable>
|
|
46
|
+
<v-card v-if="decision.request" class="screen-modal">
|
|
47
|
+
<v-card-title class="d-flex align-center">
|
|
48
|
+
Request from {{ decision.request.requestedByName }}
|
|
49
|
+
<v-spacer />
|
|
50
|
+
<v-btn icon="mdi-close" variant="text" class="screen-modal__close" aria-label="Close" @click="decision.show = false" />
|
|
51
|
+
</v-card-title>
|
|
52
|
+
<v-card-text class="screen-modal__body">
|
|
53
|
+
<p class="text-body-2 text-medium-emphasis mb-3">Hand over the items, then approve. You can give less than asked.</p>
|
|
54
|
+
<v-form ref="decisionForm">
|
|
55
|
+
<div v-for="l in decision.lines" :key="l.item" class="d-flex align-center ga-3 mb-1">
|
|
56
|
+
<div class="flex-grow-1">
|
|
57
|
+
<div class="font-weight-medium">{{ l.itemName }}</div>
|
|
58
|
+
<div class="text-caption text-medium-emphasis">Asked {{ l.qty }} · In store {{ l.onHand ?? "…" }} {{ l.unit }}</div>
|
|
59
|
+
</div>
|
|
60
|
+
<v-text-field
|
|
61
|
+
v-model.number="l.give"
|
|
62
|
+
type="number"
|
|
63
|
+
min="0"
|
|
64
|
+
:max="l.qty"
|
|
65
|
+
label="Give"
|
|
66
|
+
density="comfortable"
|
|
67
|
+
style="max-width: 120px"
|
|
68
|
+
:rules="[(v: any) => (Number.isInteger(Number(v)) && Number(v) >= 0 && Number(v) <= l.qty) || `0 to ${l.qty}`]"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
<InputLabel title="Remarks" class="mb-1 mt-2" />
|
|
72
|
+
<v-textarea v-model="decision.remarks" rows="2" auto-grow density="comfortable" placeholder="Required when rejecting" />
|
|
73
|
+
</v-form>
|
|
74
|
+
</v-card-text>
|
|
75
|
+
<div class="screen-modal__footer">
|
|
76
|
+
<v-btn class="screen-btn-ghost" variant="outlined" color="error" :loading="decision.busy === 'reject'" :disabled="!!decision.busy" @click="reject">Reject</v-btn>
|
|
77
|
+
<v-btn class="screen-btn-primary" variant="flat" :loading="decision.busy === 'approve'" :disabled="!!decision.busy" @click="approve">Approve and issue</v-btn>
|
|
78
|
+
</div>
|
|
79
|
+
</v-card>
|
|
80
|
+
</v-dialog>
|
|
81
|
+
|
|
82
|
+
<InventoryLinesDialog v-model="showRequest" mode="request" :store="store" :site-id="siteId" @done="changed" />
|
|
83
|
+
</div>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
import useInventory from "../composables/useInventory";
|
|
88
|
+
import useUtils from "../composables/useUtils";
|
|
89
|
+
import useLocalAuth from "../composables/useLocalAuth";
|
|
90
|
+
|
|
91
|
+
const props = defineProps({
|
|
92
|
+
store: { type: Object as PropType<TInventoryStore>, required: true },
|
|
93
|
+
siteId: { type: String, required: true },
|
|
94
|
+
});
|
|
95
|
+
const emit = defineEmits(["changed"]);
|
|
96
|
+
|
|
97
|
+
const api = useInventory();
|
|
98
|
+
const { standardFormatDateTime } = useUtils();
|
|
99
|
+
const { currentUser } = useLocalAuth();
|
|
100
|
+
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
101
|
+
|
|
102
|
+
const chip: Record<string, { label: string; color: string }> = {
|
|
103
|
+
pending: { label: "Waiting", color: "warning" },
|
|
104
|
+
issued: { label: "Issued", color: "success" },
|
|
105
|
+
rejected: { label: "Rejected", color: "error" },
|
|
106
|
+
cancelled: { label: "Cancelled", color: "grey" },
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const status = ref("pending");
|
|
110
|
+
const requests = ref<TInventoryRequest[]>([]);
|
|
111
|
+
const page = ref(1);
|
|
112
|
+
const pages = ref(0);
|
|
113
|
+
const loading = ref(false);
|
|
114
|
+
const busyId = ref("");
|
|
115
|
+
const showRequest = ref(false);
|
|
116
|
+
|
|
117
|
+
const isMine = (r: TInventoryRequest) => String(r.requestedBy) === String(currentUser.value?._id);
|
|
118
|
+
|
|
119
|
+
async function load(p = 1) {
|
|
120
|
+
loading.value = true;
|
|
121
|
+
try {
|
|
122
|
+
const res = await api.getRequests(props.store._id, { page: p, limit: 20, status: status.value || undefined });
|
|
123
|
+
requests.value = p === 1 ? res.items : [...requests.value, ...res.items];
|
|
124
|
+
page.value = p;
|
|
125
|
+
pages.value = res.pages;
|
|
126
|
+
} catch {
|
|
127
|
+
if (p === 1) requests.value = [];
|
|
128
|
+
} finally {
|
|
129
|
+
loading.value = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function changed() {
|
|
134
|
+
load(1);
|
|
135
|
+
emit("changed");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function cancel(r: TInventoryRequest) {
|
|
139
|
+
busyId.value = r._id;
|
|
140
|
+
try {
|
|
141
|
+
await api.cancelRequest(r._id);
|
|
142
|
+
notify("Request cancelled.");
|
|
143
|
+
changed();
|
|
144
|
+
} catch (error: any) {
|
|
145
|
+
notify(error?.data?.message || "Could not cancel.", "error");
|
|
146
|
+
} finally {
|
|
147
|
+
busyId.value = "";
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const decisionForm = ref();
|
|
152
|
+
const decision = reactive({
|
|
153
|
+
show: false,
|
|
154
|
+
request: null as TInventoryRequest | null,
|
|
155
|
+
lines: [] as { item: string; itemName: string; unit: string; qty: number; give: number; onHand?: number }[],
|
|
156
|
+
remarks: "",
|
|
157
|
+
busy: "" as "" | "approve" | "reject",
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
async function openDecision(r: TInventoryRequest) {
|
|
161
|
+
Object.assign(decision, {
|
|
162
|
+
show: true,
|
|
163
|
+
request: r,
|
|
164
|
+
remarks: "",
|
|
165
|
+
busy: "",
|
|
166
|
+
lines: r.lines.map((l) => ({ item: String(l.item), itemName: l.itemName, unit: l.unit, qty: l.qty, give: l.qty, onHand: undefined })),
|
|
167
|
+
});
|
|
168
|
+
try {
|
|
169
|
+
const res = await api.getItems(props.store._id, { limit: 200, includeInactive: true });
|
|
170
|
+
for (const line of decision.lines) {
|
|
171
|
+
const found = res.items.find((i) => i._id === line.item);
|
|
172
|
+
line.onHand = found?.onHand ?? 0;
|
|
173
|
+
line.give = Math.min(line.qty, line.onHand);
|
|
174
|
+
}
|
|
175
|
+
} catch {
|
|
176
|
+
/* quantities stay as asked; the server still refuses anything not in store */
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async function approve() {
|
|
181
|
+
const { valid } = await decisionForm.value.validate();
|
|
182
|
+
if (!valid || !decision.request) return;
|
|
183
|
+
decision.busy = "approve";
|
|
184
|
+
try {
|
|
185
|
+
await api.approveRequest(decision.request._id, {
|
|
186
|
+
lines: decision.lines.map((l) => ({ item: l.item, qty: Number(l.give) })),
|
|
187
|
+
remarks: decision.remarks,
|
|
188
|
+
});
|
|
189
|
+
notify("Approved. The stock is now with the requester.");
|
|
190
|
+
decision.show = false;
|
|
191
|
+
changed();
|
|
192
|
+
} catch (error: any) {
|
|
193
|
+
notify(error?.data?.message || "Could not approve.", "error");
|
|
194
|
+
} finally {
|
|
195
|
+
decision.busy = "";
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function reject() {
|
|
200
|
+
if (!decision.request) return;
|
|
201
|
+
if (!decision.remarks.trim()) return notify("Please give a reason for rejecting.", "error");
|
|
202
|
+
decision.busy = "reject";
|
|
203
|
+
try {
|
|
204
|
+
await api.rejectRequest(decision.request._id, decision.remarks.trim());
|
|
205
|
+
notify("Request rejected.");
|
|
206
|
+
decision.show = false;
|
|
207
|
+
changed();
|
|
208
|
+
} catch (error: any) {
|
|
209
|
+
notify(error?.data?.message || "Could not reject.", "error");
|
|
210
|
+
} finally {
|
|
211
|
+
decision.busy = "";
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
watch(status, () => load(1));
|
|
216
|
+
watch(() => props.store._id, () => load(1));
|
|
217
|
+
onMounted(() => load(1));
|
|
218
|
+
</script>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AppCard class="pa-6" style="max-width: 720px">
|
|
3
|
+
<v-form ref="form">
|
|
4
|
+
<InputLabel title="Store name" required class="mb-1" />
|
|
5
|
+
<v-text-field v-model="name" :rules="[requiredRule]" density="comfortable" />
|
|
6
|
+
|
|
7
|
+
<template v-if="orgSites.length > 1 || sites.length > 1">
|
|
8
|
+
<InputLabel title="Properties this store supplies" required class="mb-1" />
|
|
9
|
+
<v-select
|
|
10
|
+
v-model="sites"
|
|
11
|
+
:items="siteItems"
|
|
12
|
+
item-title="name"
|
|
13
|
+
item-value="_id"
|
|
14
|
+
multiple
|
|
15
|
+
chips
|
|
16
|
+
density="comfortable"
|
|
17
|
+
:rules="[(v: string[]) => v.length > 0 || 'Choose at least one property']"
|
|
18
|
+
hint="Keep one property per store unless they share one store room."
|
|
19
|
+
persistent-hint
|
|
20
|
+
class="mb-4"
|
|
21
|
+
/>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<v-divider class="my-4" />
|
|
25
|
+
<div class="text-subtitle-1 mb-1">Service365 app</div>
|
|
26
|
+
<p class="text-body-2 text-medium-emphasis mb-2">
|
|
27
|
+
Let residents and tenants see the materials used in their own unit (item, quantity, date and work order).
|
|
28
|
+
</p>
|
|
29
|
+
<v-switch v-model="showInResidentApp" color="primary" hide-details label="Show materials used in the Service365 app" />
|
|
30
|
+
<v-switch v-model="showCostInResidentApp" :disabled="!showInResidentApp" color="primary" hide-details label="Also show the cost" />
|
|
31
|
+
|
|
32
|
+
<div class="d-flex mt-6">
|
|
33
|
+
<v-btn class="text-none screen-btn-primary" variant="flat" :loading="saving" @click="save">Save settings</v-btn>
|
|
34
|
+
</div>
|
|
35
|
+
</v-form>
|
|
36
|
+
</AppCard>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import useInventory from "../composables/useInventory";
|
|
41
|
+
import useUtils from "../composables/useUtils";
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
store: { type: Object as PropType<TInventoryStore>, required: true },
|
|
45
|
+
orgSites: { type: Array as PropType<{ _id: string; name: string }[]>, default: () => [] },
|
|
46
|
+
});
|
|
47
|
+
const emit = defineEmits(["saved"]);
|
|
48
|
+
|
|
49
|
+
const { updateStore } = useInventory();
|
|
50
|
+
const { requiredRule } = useUtils();
|
|
51
|
+
const notify = inject<(text: string, color?: string) => void>("inventoryNotify", () => {});
|
|
52
|
+
|
|
53
|
+
const form = ref();
|
|
54
|
+
const saving = ref(false);
|
|
55
|
+
const name = ref("");
|
|
56
|
+
const sites = ref<string[]>([]);
|
|
57
|
+
const showInResidentApp = ref(false);
|
|
58
|
+
const showCostInResidentApp = ref(false);
|
|
59
|
+
|
|
60
|
+
const siteItems = computed(() => {
|
|
61
|
+
const known = new Map(props.orgSites.map((s) => [s._id, s.name]));
|
|
62
|
+
for (const id of props.store.sites) if (!known.has(id)) known.set(id, "Current property");
|
|
63
|
+
return [...known].map(([_id, name]) => ({ _id, name }));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
function reset() {
|
|
67
|
+
name.value = props.store.name;
|
|
68
|
+
sites.value = [...props.store.sites];
|
|
69
|
+
showInResidentApp.value = props.store.showInResidentApp;
|
|
70
|
+
showCostInResidentApp.value = props.store.showCostInResidentApp;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function save() {
|
|
74
|
+
const { valid } = await form.value.validate();
|
|
75
|
+
if (!valid) return;
|
|
76
|
+
saving.value = true;
|
|
77
|
+
try {
|
|
78
|
+
await updateStore(props.store._id, {
|
|
79
|
+
name: name.value,
|
|
80
|
+
sites: sites.value,
|
|
81
|
+
showInResidentApp: showInResidentApp.value,
|
|
82
|
+
showCostInResidentApp: showInResidentApp.value && showCostInResidentApp.value,
|
|
83
|
+
});
|
|
84
|
+
notify("Settings saved.");
|
|
85
|
+
emit("saved");
|
|
86
|
+
} catch (error: any) {
|
|
87
|
+
notify(error?.data?.message || "Could not save the settings.", "error");
|
|
88
|
+
} finally {
|
|
89
|
+
saving.value = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
watch(() => props.store, reset, { immediate: true });
|
|
94
|
+
</script>
|