@7365admin1/layer-common 1.8.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/.changeset/README.md +8 -0
- package/.changeset/config.json +11 -0
- package/.editorconfig +12 -0
- package/.github/workflows/main.yml +17 -0
- package/.github/workflows/publish.yml +39 -0
- package/.nuxtrc +1 -0
- package/.playground/app.vue +41 -0
- package/.playground/eslint.config.mjs +6 -0
- package/.playground/nuxt.config.ts +22 -0
- package/.playground/pages/feedback.vue +30 -0
- package/CHANGELOG.md +263 -0
- package/README.md +73 -0
- package/app.vue +3 -0
- package/components/AccessCardAddForm.vue +363 -0
- package/components/AccessManagement.vue +420 -0
- package/components/Avatar/Main.vue +68 -0
- package/components/BillingMain.vue +66 -0
- package/components/BtnUploadFile.vue +139 -0
- package/components/BuildingForm.vue +303 -0
- package/components/BuildingManagement/buildings.vue +335 -0
- package/components/BuildingManagement/units.vue +350 -0
- package/components/BuildingUnitFormAdd.vue +441 -0
- package/components/BuildingUnitFormEdit.vue +429 -0
- package/components/CameraForm.vue +264 -0
- package/components/CameraMain.vue +352 -0
- package/components/Card/DeleteConfirmation.vue +51 -0
- package/components/Card/MemberInfoSummary.vue +44 -0
- package/components/Card/Toggle.vue +25 -0
- package/components/Chat/Bubbles.vue +53 -0
- package/components/Chat/Information.vue +416 -0
- package/components/Chat/ListCard.vue +62 -0
- package/components/Chat/Message.vue +158 -0
- package/components/Chat/Navigation.vue +150 -0
- package/components/ConfirmDialog.vue +66 -0
- package/components/Container/Standard.vue +33 -0
- package/components/DashboardPlaceholder.vue +1524 -0
- package/components/Dialog/DeleteConfirmation.vue +51 -0
- package/components/Dialog/ReplaceAutofillPrompt.vue +49 -0
- package/components/Dialog/UpdateMoreAction.vue +103 -0
- package/components/DocumentForm.vue +187 -0
- package/components/DocumentManagement.vue +376 -0
- package/components/Editor.vue +95 -0
- package/components/EntryPassMain.vue +518 -0
- package/components/Feedback/Form.vue +173 -0
- package/components/FeedbackDetail.vue +599 -0
- package/components/FeedbackMain.vue +588 -0
- package/components/FormDialog.vue +65 -0
- package/components/ImageCarousel.vue +138 -0
- package/components/Input/Date.vue +177 -0
- package/components/Input/DateTimePicker.vue +131 -0
- package/components/Input/File.vue +236 -0
- package/components/Input/FileV2.vue +234 -0
- package/components/Input/InputPhoneNumberV2.vue +164 -0
- package/components/Input/ListGroupSelection.vue +96 -0
- package/components/Input/NRICNumber.vue +53 -0
- package/components/Input/NewDate.vue +123 -0
- package/components/Input/Number.vue +124 -0
- package/components/Input/Password.vue +22 -0
- package/components/Input/PhoneNumber.vue +188 -0
- package/components/Input/VehicleNumber.vue +49 -0
- package/components/InputLabel.vue +22 -0
- package/components/InvitationForm.vue +359 -0
- package/components/InvitationMain.vue +310 -0
- package/components/Layout/Header.vue +129 -0
- package/components/Layout/NavigationDrawer.vue +44 -0
- package/components/ListItem.vue +35 -0
- package/components/ListView.vue +87 -0
- package/components/LocalPagination.vue +31 -0
- package/components/MemberMain.vue +459 -0
- package/components/NFC/NFCPatrolReportMain.vue +591 -0
- package/components/NFC/NFCPatrolRouteForm.vue +596 -0
- package/components/NFC/NFCPatrolRouteMain.vue +539 -0
- package/components/NFC/NFCTagForm.vue +236 -0
- package/components/NFC/NFCTagMain.vue +337 -0
- package/components/NFC/PatrolSettings.vue +130 -0
- package/components/NavigationItem.vue +83 -0
- package/components/NumberSettingField.vue +107 -0
- package/components/OnlineFormConfigurationForm.vue +290 -0
- package/components/OnlineFormsConfiguration.vue +429 -0
- package/components/PeopleForm.vue +452 -0
- package/components/PlaceholderComponent.vue +34 -0
- package/components/RolePermissionFormCreate.vue +161 -0
- package/components/RolePermissionFormPreviewUpdate.vue +183 -0
- package/components/RolePermissionMain.vue +361 -0
- package/components/SearchVehicleNumberUser.vue +91 -0
- package/components/ServiceProviderFormCreate.vue +154 -0
- package/components/ServiceProviderMain.vue +547 -0
- package/components/SignaturePad.vue +73 -0
- package/components/Snackbar.vue +23 -0
- package/components/SpecificAttr.vue +53 -0
- package/components/SupplyManagement.vue +292 -0
- package/components/SwitchContext.vue +108 -0
- package/components/TableList.vue +150 -0
- package/components/TableListSecondary.vue +164 -0
- package/components/TableMain.vue +142 -0
- package/components/TableWithButton.vue +94 -0
- package/components/VehicleUpdateMoreAction.vue +84 -0
- package/components/VideoPlayer.vue +125 -0
- package/components/VisitorForm.vue +659 -0
- package/components/VisitorFormSelection.vue +53 -0
- package/components/VisitorManagement.vue +490 -0
- package/components/WorkOrder/Create.vue +284 -0
- package/components/WorkOrder/Detail.vue +71 -0
- package/components/WorkOrder/ListView.vue +96 -0
- package/components/WorkOrder/Main.vue +489 -0
- package/components/Workorder.vue +1 -0
- package/composables/useAddress.ts +107 -0
- package/composables/useBuilding.ts +250 -0
- package/composables/useBuildingUnit.ts +116 -0
- package/composables/useCard.ts +46 -0
- package/composables/useCommonPermission.ts +207 -0
- package/composables/useCustomer.ts +113 -0
- package/composables/useCustomerSite.ts +56 -0
- package/composables/useDashboard.ts +31 -0
- package/composables/useDashboardData.ts +425 -0
- package/composables/useDocument.ts +57 -0
- package/composables/useFacility.ts +246 -0
- package/composables/useFeedback.ts +119 -0
- package/composables/useFile.ts +55 -0
- package/composables/useInvoice.ts +18 -0
- package/composables/useLocal.ts +131 -0
- package/composables/useLocalAuth.ts +137 -0
- package/composables/useLocalSetup.ts +13 -0
- package/composables/useMember.ts +111 -0
- package/composables/useNFCPatrolRoute.ts +77 -0
- package/composables/useNFCPatrolSettings.ts +19 -0
- package/composables/useNFCPatrolTag.ts +53 -0
- package/composables/useOnlineForm.ts +67 -0
- package/composables/useOrg.ts +129 -0
- package/composables/usePDFDownload.ts +25 -0
- package/composables/usePaymentMethod.ts +101 -0
- package/composables/usePeople.ts +81 -0
- package/composables/usePermission.ts +54 -0
- package/composables/usePhoneCountries.ts +561 -0
- package/composables/usePrice.ts +15 -0
- package/composables/usePromoCode.ts +36 -0
- package/composables/useRecapPermission.ts +26 -0
- package/composables/useRole.ts +104 -0
- package/composables/useSecurityUtils.ts +18 -0
- package/composables/useServiceProvider.ts +224 -0
- package/composables/useSite.ts +109 -0
- package/composables/useSiteEntryPassSettings.ts +46 -0
- package/composables/useSiteSettings.ts +123 -0
- package/composables/useSubscription.ts +150 -0
- package/composables/useUser.ts +132 -0
- package/composables/useUtils.ts +445 -0
- package/composables/useVerification.ts +34 -0
- package/composables/useVisitor.ts +120 -0
- package/composables/useWorkOrder.ts +85 -0
- package/error.vue +41 -0
- package/layouts/plain.vue +7 -0
- package/middleware/01.auth.ts +20 -0
- package/middleware/02.org.ts +21 -0
- package/middleware/03.customer.ts +13 -0
- package/middleware/member.ts +4 -0
- package/nuxt.config.ts +54 -0
- package/package.json +39 -0
- package/pages/index.vue +3 -0
- package/pages/payment-method-linked.vue +31 -0
- package/pages/require-customer.vue +56 -0
- package/pages/require-organization-membership.vue +47 -0
- package/pages/unauthorized.vue +29 -0
- package/plugins/API.ts +21 -0
- package/plugins/iconify.client.ts +5 -0
- package/plugins/secure-member.client.ts +86 -0
- package/plugins/vuetify.ts +62 -0
- package/public/bg-camera.jpg +0 -0
- package/public/bg-city.jpg +0 -0
- package/public/bg-condo.jpg +0 -0
- package/public/images/icons/delete-icon.png +0 -0
- package/public/sprite.svg +1 -0
- package/tsconfig.json +3 -0
- package/types/address.d.ts +13 -0
- package/types/building.d.ts +27 -0
- package/types/camera.d.ts +31 -0
- package/types/card.d.ts +22 -0
- package/types/customer.d.ts +27 -0
- package/types/document.d.ts +6 -0
- package/types/feedback.d.ts +68 -0
- package/types/local.d.ts +74 -0
- package/types/member.d.ts +21 -0
- package/types/online-form.d.ts +15 -0
- package/types/org.d.ts +13 -0
- package/types/people.d.ts +24 -0
- package/types/permission.d.ts +25 -0
- package/types/phone-number.d.ts +10 -0
- package/types/price.d.ts +17 -0
- package/types/promo-code.d.ts +19 -0
- package/types/role.d.ts +11 -0
- package/types/select.d.ts +4 -0
- package/types/service-provider.d.ts +15 -0
- package/types/site.d.ts +20 -0
- package/types/subscription.d.ts +23 -0
- package/types/user.d.ts +19 -0
- package/types/verification.d.ts +20 -0
- package/types/visitor.d.ts +42 -0
- package/types/work-order.d.ts +42 -0
- package/utils/phoneMasks.ts +1703 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card width="100%">
|
|
3
|
+
<v-toolbar>
|
|
4
|
+
<v-row no-gutters class="fill-height px-6" align="center">
|
|
5
|
+
<span class="font-weight-bold text-h5 text-capitalize">
|
|
6
|
+
{{ prop.mode }} Building
|
|
7
|
+
</span>
|
|
8
|
+
</v-row>
|
|
9
|
+
</v-toolbar>
|
|
10
|
+
<v-card-text style="max-height: 100vh; overflow-y: auto" class="pa-0">
|
|
11
|
+
<v-form v-model="validForm" :disabled="disable">
|
|
12
|
+
<v-row no-gutters class="px-6 pt-4">
|
|
13
|
+
<v-col cols="12" class="mt-2">
|
|
14
|
+
<v-row no-gutters>
|
|
15
|
+
<InputLabel
|
|
16
|
+
class="text-capitalize font-weight-bold"
|
|
17
|
+
title="Name"
|
|
18
|
+
required
|
|
19
|
+
/>
|
|
20
|
+
<v-col cols="12">
|
|
21
|
+
<v-text-field
|
|
22
|
+
v-model="building.name"
|
|
23
|
+
density="comfortable"
|
|
24
|
+
:rules="[requiredRule]"
|
|
25
|
+
></v-text-field>
|
|
26
|
+
</v-col>
|
|
27
|
+
</v-row>
|
|
28
|
+
</v-col>
|
|
29
|
+
|
|
30
|
+
<v-col cols="12">
|
|
31
|
+
<v-row>
|
|
32
|
+
<v-col cols="6" class="mt-2">
|
|
33
|
+
<v-row no-gutters>
|
|
34
|
+
<InputLabel
|
|
35
|
+
class="text-capitalize font-weight-bold"
|
|
36
|
+
title="Block"
|
|
37
|
+
required
|
|
38
|
+
/>
|
|
39
|
+
<v-col cols="12">
|
|
40
|
+
<v-select
|
|
41
|
+
v-model.number="building.block"
|
|
42
|
+
:items="blocks"
|
|
43
|
+
density="comfortable"
|
|
44
|
+
:rules="[
|
|
45
|
+
requiredRule,
|
|
46
|
+
() =>
|
|
47
|
+
(building.block && building.block > 0) ||
|
|
48
|
+
'Block is required',
|
|
49
|
+
]"
|
|
50
|
+
type="number"
|
|
51
|
+
></v-select>
|
|
52
|
+
</v-col>
|
|
53
|
+
</v-row>
|
|
54
|
+
</v-col>
|
|
55
|
+
|
|
56
|
+
<v-col cols="6" class="mt-2">
|
|
57
|
+
<v-row no-gutters>
|
|
58
|
+
<InputLabel
|
|
59
|
+
class="text-capitalize font-weight-bold"
|
|
60
|
+
title="Levels"
|
|
61
|
+
required
|
|
62
|
+
/>
|
|
63
|
+
<v-col cols="12">
|
|
64
|
+
<v-text-field
|
|
65
|
+
v-model.number="buildingLevels"
|
|
66
|
+
density="comfortable"
|
|
67
|
+
:rules="[requiredRule]"
|
|
68
|
+
type="number"
|
|
69
|
+
@update:model-value="setBuildingLevels()"
|
|
70
|
+
></v-text-field>
|
|
71
|
+
</v-col>
|
|
72
|
+
</v-row>
|
|
73
|
+
</v-col>
|
|
74
|
+
</v-row>
|
|
75
|
+
</v-col>
|
|
76
|
+
|
|
77
|
+
<v-col v-if="buildingLevels" cols="12">
|
|
78
|
+
<v-row justify="center">
|
|
79
|
+
<v-col cols="6">
|
|
80
|
+
<v-btn
|
|
81
|
+
block
|
|
82
|
+
color="primary"
|
|
83
|
+
variant="text"
|
|
84
|
+
class="text-none font-weight-bold"
|
|
85
|
+
text="Set level labels"
|
|
86
|
+
@click="show = !show"
|
|
87
|
+
></v-btn>
|
|
88
|
+
</v-col>
|
|
89
|
+
</v-row>
|
|
90
|
+
</v-col>
|
|
91
|
+
</v-row>
|
|
92
|
+
|
|
93
|
+
<v-expand-transition>
|
|
94
|
+
<v-row v-show="show" no-gutters class="px-6">
|
|
95
|
+
<template
|
|
96
|
+
v-for="(level, levelIndex) in building.levels"
|
|
97
|
+
:key="levelIndex"
|
|
98
|
+
>
|
|
99
|
+
<v-col cols="12">
|
|
100
|
+
<v-row no-gutters>
|
|
101
|
+
<InputLabel
|
|
102
|
+
class="text-capitalize font-weight-bold"
|
|
103
|
+
:title="`Level ${levelIndex + 1}`"
|
|
104
|
+
/>
|
|
105
|
+
<v-col cols="12">
|
|
106
|
+
<v-text-field
|
|
107
|
+
v-model.trim="building.levels[levelIndex]"
|
|
108
|
+
density="comfortable"
|
|
109
|
+
></v-text-field>
|
|
110
|
+
</v-col>
|
|
111
|
+
</v-row>
|
|
112
|
+
</v-col>
|
|
113
|
+
</template>
|
|
114
|
+
</v-row>
|
|
115
|
+
</v-expand-transition>
|
|
116
|
+
|
|
117
|
+
<v-col cols="12" class="px-6">
|
|
118
|
+
<InputLabel class="text-capitalize" title="Building Floor plan" />
|
|
119
|
+
<InputFileV2 v-model="building.buildingFloorPlan" :multiple="true" :max-length="10" title="Upload Images" />
|
|
120
|
+
</v-col>
|
|
121
|
+
|
|
122
|
+
<v-col cols="12" class="mt-2">
|
|
123
|
+
<v-checkbox v-model="createMore" density="comfortable" hide-details>
|
|
124
|
+
<template #label>
|
|
125
|
+
<span class="text-subtitle-2 font-weight-bold">
|
|
126
|
+
Create more
|
|
127
|
+
</span>
|
|
128
|
+
</template>
|
|
129
|
+
</v-checkbox>
|
|
130
|
+
</v-col>
|
|
131
|
+
|
|
132
|
+
<v-col cols="12">
|
|
133
|
+
<v-row no-gutters>
|
|
134
|
+
<v-col cols="12" class="text-center">
|
|
135
|
+
<span
|
|
136
|
+
class="text-none text-subtitle-2 font-weight-medium text-error"
|
|
137
|
+
>
|
|
138
|
+
{{ message }}
|
|
139
|
+
</span>
|
|
140
|
+
</v-col>
|
|
141
|
+
</v-row>
|
|
142
|
+
</v-col>
|
|
143
|
+
</v-form>
|
|
144
|
+
</v-card-text>
|
|
145
|
+
|
|
146
|
+
<v-toolbar density="compact">
|
|
147
|
+
<v-row no-gutters>
|
|
148
|
+
<v-col cols="6">
|
|
149
|
+
<v-btn
|
|
150
|
+
tile
|
|
151
|
+
block
|
|
152
|
+
variant="text"
|
|
153
|
+
class="text-none"
|
|
154
|
+
size="48"
|
|
155
|
+
@click="cancel"
|
|
156
|
+
:disabled="disable"
|
|
157
|
+
>
|
|
158
|
+
Cancel
|
|
159
|
+
</v-btn>
|
|
160
|
+
</v-col>
|
|
161
|
+
|
|
162
|
+
<v-col cols="6">
|
|
163
|
+
<v-btn
|
|
164
|
+
tile
|
|
165
|
+
block
|
|
166
|
+
variant="flat"
|
|
167
|
+
color="black"
|
|
168
|
+
class="text-none"
|
|
169
|
+
size="48"
|
|
170
|
+
:disabled="!validForm || disable"
|
|
171
|
+
@click="submit"
|
|
172
|
+
:loading="disable"
|
|
173
|
+
>
|
|
174
|
+
Submit
|
|
175
|
+
</v-btn>
|
|
176
|
+
</v-col>
|
|
177
|
+
</v-row>
|
|
178
|
+
</v-toolbar>
|
|
179
|
+
</v-card>
|
|
180
|
+
</template>
|
|
181
|
+
|
|
182
|
+
<script setup lang="ts">
|
|
183
|
+
const prop = defineProps({
|
|
184
|
+
site: {
|
|
185
|
+
type: String,
|
|
186
|
+
default: "",
|
|
187
|
+
},
|
|
188
|
+
mode: {
|
|
189
|
+
type: String,
|
|
190
|
+
default: "add",
|
|
191
|
+
},
|
|
192
|
+
building: {
|
|
193
|
+
type: Object as PropType<TBuilding>,
|
|
194
|
+
default: () => ({
|
|
195
|
+
site: "",
|
|
196
|
+
name: "",
|
|
197
|
+
block: null,
|
|
198
|
+
levels: [],
|
|
199
|
+
buildingFloorPlan: []
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
const { getSiteById } = useSite();
|
|
205
|
+
|
|
206
|
+
const site = ref<TSite | null>(null);
|
|
207
|
+
|
|
208
|
+
const { data: getSiteReq } = useLazyAsyncData(
|
|
209
|
+
"get-site-by-id-" + prop.site,
|
|
210
|
+
async () => getSiteById(prop.site)
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
watchEffect(() => {
|
|
214
|
+
if (getSiteReq.value) {
|
|
215
|
+
site.value = getSiteReq.value;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const blocks = computed(() => {
|
|
220
|
+
if (!site.value) return [];
|
|
221
|
+
return Array.from({ length: site.value?.metadata?.block || 0 }, (_, i) => i + 1);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const emit = defineEmits(["cancel", "success", "success:create-more"]);
|
|
225
|
+
|
|
226
|
+
const validForm = ref(false);
|
|
227
|
+
|
|
228
|
+
const buildingLevels = ref(0);
|
|
229
|
+
|
|
230
|
+
const show = ref(false);
|
|
231
|
+
|
|
232
|
+
function setBuildingLevels() {
|
|
233
|
+
building.value.levels.length = 0;
|
|
234
|
+
for (let index = 0; index < buildingLevels.value; index++) {
|
|
235
|
+
building.value.levels.push(`Lvl${index + 1}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const building = ref<TBuilding>({
|
|
240
|
+
site: "",
|
|
241
|
+
name: "",
|
|
242
|
+
block: null,
|
|
243
|
+
levels: [],
|
|
244
|
+
buildingFloorPlan: []
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
building.value.site = prop.site;
|
|
248
|
+
if (prop.mode === "edit") {
|
|
249
|
+
building.value = JSON.parse(JSON.stringify(prop.building));
|
|
250
|
+
buildingLevels.value = building.value.levels.length;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const createMore = ref(false);
|
|
254
|
+
const disable = ref(false);
|
|
255
|
+
|
|
256
|
+
const { requiredRule } = useUtils();
|
|
257
|
+
|
|
258
|
+
const message = ref("");
|
|
259
|
+
|
|
260
|
+
const { createBuilding, updateById } = useBuilding();
|
|
261
|
+
|
|
262
|
+
async function submit() {
|
|
263
|
+
disable.value = true;
|
|
264
|
+
|
|
265
|
+
try {
|
|
266
|
+
if (prop.mode === "add") {
|
|
267
|
+
await createBuilding(building.value);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (prop.mode === "edit") {
|
|
271
|
+
await updateById(building.value._id ?? "", {
|
|
272
|
+
name: building.value.name,
|
|
273
|
+
block: building.value.block,
|
|
274
|
+
levels: building.value.levels,
|
|
275
|
+
buildingFloorPlan: building.value.buildingFloorPlan
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (createMore.value) {
|
|
280
|
+
building.value.levels = [];
|
|
281
|
+
building.value.name = "";
|
|
282
|
+
building.value.block = null;
|
|
283
|
+
|
|
284
|
+
message.value = "";
|
|
285
|
+
emit("success:create-more");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
emit("success");
|
|
290
|
+
} catch (error: any) {
|
|
291
|
+
message.value =
|
|
292
|
+
error.response?._data?.message || "Failed to create building";
|
|
293
|
+
} finally {
|
|
294
|
+
disable.value = false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function cancel() {
|
|
299
|
+
createMore.value = false;
|
|
300
|
+
message.value = "";
|
|
301
|
+
emit("cancel");
|
|
302
|
+
}
|
|
303
|
+
</script>
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-row no-gutters>
|
|
3
|
+
<v-col cols="12" class="mb-2">
|
|
4
|
+
<v-row no-gutters>
|
|
5
|
+
<v-btn class="text-none" rounded="pill" variant="tonal" @click="setBuilding()" size="large"
|
|
6
|
+
v-if="canCreate && canCreateBuilding">
|
|
7
|
+
Add Building
|
|
8
|
+
</v-btn>
|
|
9
|
+
</v-row>
|
|
10
|
+
</v-col>
|
|
11
|
+
<v-col cols="12">
|
|
12
|
+
<v-card width="100%" variant="outlined" border="thin" rounded="lg" :loading="loading">
|
|
13
|
+
<v-toolbar density="compact" color="grey-lighten-4">
|
|
14
|
+
<template #prepend>
|
|
15
|
+
<v-btn fab icon density="comfortable" @click="getBuildings()">
|
|
16
|
+
<v-icon>mdi-refresh</v-icon>
|
|
17
|
+
</v-btn>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<template #append>
|
|
21
|
+
<v-row no-gutters justify="end" align="center">
|
|
22
|
+
<span class="mr-2 text-caption text-fontgray">
|
|
23
|
+
{{ pageRange }}
|
|
24
|
+
</span>
|
|
25
|
+
<local-pagination v-model="page" :length="pages" @update:value="getBuildings()" />
|
|
26
|
+
</v-row>
|
|
27
|
+
</template>
|
|
28
|
+
</v-toolbar>
|
|
29
|
+
|
|
30
|
+
<v-data-table :headers="headers" :items="items" item-value="_id" items-per-page="20" fixed-header
|
|
31
|
+
hide-default-footer hide-default-header @click:row="tableRowClickHandler"
|
|
32
|
+
style="max-height: calc(100vh - (200px))">
|
|
33
|
+
<template #item.createdAt="{ value }">
|
|
34
|
+
{{ new Date(value).toLocaleDateString() }}
|
|
35
|
+
</template>
|
|
36
|
+
</v-data-table>
|
|
37
|
+
</v-card>
|
|
38
|
+
</v-col>
|
|
39
|
+
|
|
40
|
+
<!-- Create Dialog -->
|
|
41
|
+
<v-dialog v-model="createDialog" width="450" persistent>
|
|
42
|
+
<BuildingForm :site="site" @cancel="createDialog = false" @success="successCreate()"
|
|
43
|
+
@success:create-more="getBuildings()" />
|
|
44
|
+
</v-dialog>
|
|
45
|
+
|
|
46
|
+
<!-- Edit Dialog -->
|
|
47
|
+
<v-dialog v-model="editDialog" width="450" persistent>
|
|
48
|
+
<BuildingForm :site="site" mode="edit" @cancel="editDialog = false" @success="successUpdate()"
|
|
49
|
+
:building="selectedBuilding" />
|
|
50
|
+
</v-dialog>
|
|
51
|
+
|
|
52
|
+
<!-- Preview Dialog -->
|
|
53
|
+
<v-dialog v-if="canViewBuildingDetails" v-model="previewDialog" width="450" persistent>
|
|
54
|
+
<v-card width="100%">
|
|
55
|
+
<v-card-text style="max-height: 100vh; overflow-y: auto" class="pb-0">
|
|
56
|
+
<v-row no-gutters class="mb-4">
|
|
57
|
+
<v-col cols="12">
|
|
58
|
+
<strong>Name:</strong> {{ selectedBuilding?.name ?? "N/A" }}
|
|
59
|
+
</v-col>
|
|
60
|
+
|
|
61
|
+
<v-col cols="12">
|
|
62
|
+
<strong>Block:</strong>
|
|
63
|
+
{{ selectedBuilding?.block ?? "N/A" }}
|
|
64
|
+
</v-col>
|
|
65
|
+
|
|
66
|
+
<v-col cols="12">
|
|
67
|
+
<strong>Levels:</strong>
|
|
68
|
+
{{ selectedBuilding?.levels.length ?? "N/A" }}
|
|
69
|
+
</v-col>
|
|
70
|
+
<template v-if="selectedBuilding?.buildingFloorPlan.length > 0">
|
|
71
|
+
<v-col cols="12">
|
|
72
|
+
<strong>Building Floor Plan:</strong>
|
|
73
|
+
</v-col>
|
|
74
|
+
<v-col cols="12">
|
|
75
|
+
<InputFileV2 :model-value="selectedBuilding?.buildingFloorPlan" view-mode />
|
|
76
|
+
</v-col>
|
|
77
|
+
</template>
|
|
78
|
+
</v-row>
|
|
79
|
+
</v-card-text>
|
|
80
|
+
|
|
81
|
+
<v-toolbar class="pa-0" density="compact">
|
|
82
|
+
<v-row no-gutters>
|
|
83
|
+
<v-col cols="6" class="pa-0">
|
|
84
|
+
<v-btn block variant="text" class="text-none" size="large" @click="previewDialog = false" height="48">
|
|
85
|
+
Close
|
|
86
|
+
</v-btn>
|
|
87
|
+
</v-col>
|
|
88
|
+
|
|
89
|
+
<v-col cols="6" class="pa-0" v-if="canUpdate">
|
|
90
|
+
<v-menu>
|
|
91
|
+
<template #activator="{ props }">
|
|
92
|
+
<v-btn block variant="flat" color="black" class="text-none" height="48" v-bind="props" tile
|
|
93
|
+
:disabled="!canUpdateBuilding && !canDeleteBuilding">
|
|
94
|
+
More actions
|
|
95
|
+
</v-btn>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<v-list class="pa-0">
|
|
99
|
+
<v-list-item v-if="canUpdateBuilding" @click="openEditDialog()">
|
|
100
|
+
<v-list-item-title class="text-subtitle-2">
|
|
101
|
+
Edit Building
|
|
102
|
+
</v-list-item-title>
|
|
103
|
+
</v-list-item>
|
|
104
|
+
|
|
105
|
+
<v-list-item v-if="canDeleteBuilding" @click="openDeleteDialog()" class="text-red">
|
|
106
|
+
<v-list-item-title class="text-subtitle-2">
|
|
107
|
+
Delete Building
|
|
108
|
+
</v-list-item-title>
|
|
109
|
+
</v-list-item>
|
|
110
|
+
</v-list>
|
|
111
|
+
</v-menu>
|
|
112
|
+
</v-col>
|
|
113
|
+
</v-row>
|
|
114
|
+
</v-toolbar>
|
|
115
|
+
</v-card>
|
|
116
|
+
</v-dialog>
|
|
117
|
+
|
|
118
|
+
<v-dialog v-model="confirmDialog" :loading="deleteLoading" width="450" persistent>
|
|
119
|
+
<v-card width="100%">
|
|
120
|
+
<v-toolbar density="compact" class="pl-4">
|
|
121
|
+
<span class="font-weight-medium text-h5">Delete Building</span>
|
|
122
|
+
</v-toolbar>
|
|
123
|
+
|
|
124
|
+
<v-card-text>
|
|
125
|
+
<p class="text-subtitle-2 text-center">
|
|
126
|
+
Are you sure you want to delete this building? This action cannot be
|
|
127
|
+
undone.
|
|
128
|
+
</p>
|
|
129
|
+
|
|
130
|
+
<v-row v-if="message" no-gutters justify="center" class="mt-4">
|
|
131
|
+
<span class="text-caption text-error text-center">
|
|
132
|
+
{{ message }}
|
|
133
|
+
</span>
|
|
134
|
+
</v-row>
|
|
135
|
+
</v-card-text>
|
|
136
|
+
|
|
137
|
+
<v-toolbar density="compact">
|
|
138
|
+
<v-row no-gutters>
|
|
139
|
+
<v-col cols="6">
|
|
140
|
+
<v-btn tile block size="48" variant="text" class="text-none" @click="confirmDialog = false"
|
|
141
|
+
:disabled="deleteLoading">
|
|
142
|
+
Close
|
|
143
|
+
</v-btn>
|
|
144
|
+
</v-col>
|
|
145
|
+
<v-col cols="6">
|
|
146
|
+
<v-btn tile block size="48" color="black" variant="flat" class="text-none" @click="handleDeleteBuilding"
|
|
147
|
+
:loading="deleteLoading">
|
|
148
|
+
Delete Building
|
|
149
|
+
</v-btn>
|
|
150
|
+
</v-col>
|
|
151
|
+
</v-row>
|
|
152
|
+
</v-toolbar>
|
|
153
|
+
</v-card>
|
|
154
|
+
</v-dialog>
|
|
155
|
+
|
|
156
|
+
<Snackbar v-model="messageSnackbar" :text="message" :color="messageColor" />
|
|
157
|
+
</v-row>
|
|
158
|
+
</template>
|
|
159
|
+
|
|
160
|
+
<script setup lang="ts">
|
|
161
|
+
definePageMeta({
|
|
162
|
+
middleware: ["01-auth", "02-org"],
|
|
163
|
+
memberOnly: true,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const props = defineProps({
|
|
167
|
+
headers: {
|
|
168
|
+
type: Array as PropType<Array<Record<string, any>>>,
|
|
169
|
+
default: () => [
|
|
170
|
+
{
|
|
171
|
+
title: "Name",
|
|
172
|
+
value: "name",
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
title: "Director",
|
|
176
|
+
value: "directorName",
|
|
177
|
+
},
|
|
178
|
+
{ title: "Action", value: "action-table" },
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
canCreate: {
|
|
182
|
+
type: Boolean,
|
|
183
|
+
default: true,
|
|
184
|
+
},
|
|
185
|
+
canUpdate: {
|
|
186
|
+
type: Boolean,
|
|
187
|
+
default: true,
|
|
188
|
+
},
|
|
189
|
+
canDelete: {
|
|
190
|
+
type: Boolean,
|
|
191
|
+
default: true,
|
|
192
|
+
},
|
|
193
|
+
canCreateBuilding: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
default: true,
|
|
196
|
+
},
|
|
197
|
+
canUpdateBuilding: {
|
|
198
|
+
type: Boolean,
|
|
199
|
+
default: true,
|
|
200
|
+
},
|
|
201
|
+
canDeleteBuilding: {
|
|
202
|
+
type: Boolean,
|
|
203
|
+
default: true,
|
|
204
|
+
},
|
|
205
|
+
canViewBuildingDetails: {
|
|
206
|
+
type: Boolean,
|
|
207
|
+
default: true,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const site = (useRoute().params.site as string) ?? "";
|
|
212
|
+
const status = (useRoute().params.status as string) ?? "active";
|
|
213
|
+
|
|
214
|
+
const { headerSearch } = useLocal();
|
|
215
|
+
const { getAll: _getBuildings, deleteById } = useBuilding();
|
|
216
|
+
|
|
217
|
+
const page = ref(1);
|
|
218
|
+
const pages = ref(0);
|
|
219
|
+
const pageRange = ref("-- - -- of --");
|
|
220
|
+
|
|
221
|
+
const message = ref("");
|
|
222
|
+
const messageSnackbar = ref(false);
|
|
223
|
+
const messageColor = ref("");
|
|
224
|
+
|
|
225
|
+
const items = ref<Array<Record<string, any>>>([]);
|
|
226
|
+
|
|
227
|
+
const {
|
|
228
|
+
data: getBuildingReq,
|
|
229
|
+
refresh: getBuildings,
|
|
230
|
+
status: getBuildingReqStatus,
|
|
231
|
+
} = useLazyAsyncData(
|
|
232
|
+
"buildings-get-all",
|
|
233
|
+
() =>
|
|
234
|
+
_getBuildings({
|
|
235
|
+
page: page.value,
|
|
236
|
+
search: headerSearch.value,
|
|
237
|
+
status,
|
|
238
|
+
site,
|
|
239
|
+
}),
|
|
240
|
+
{
|
|
241
|
+
watch: [page, headerSearch],
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
const loading = computed(() => getBuildingReqStatus.value === "pending");
|
|
246
|
+
|
|
247
|
+
watchEffect(() => {
|
|
248
|
+
if (getBuildingReq.value) {
|
|
249
|
+
items.value = getBuildingReq.value.items;
|
|
250
|
+
pages.value = getBuildingReq.value.pages;
|
|
251
|
+
pageRange.value = getBuildingReq.value.pageRange;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const createDialog = ref(false);
|
|
256
|
+
const editDialog = ref(false);
|
|
257
|
+
const previewDialog = ref(false);
|
|
258
|
+
const selectedBuilding = ref<TBuilding>({
|
|
259
|
+
_id: "",
|
|
260
|
+
site: "",
|
|
261
|
+
name: "",
|
|
262
|
+
block: null,
|
|
263
|
+
levels: [],
|
|
264
|
+
buildingFloorPlan: [],
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
function tableRowClickHandler(_: any, data: any) {
|
|
268
|
+
selectedBuilding.value = data.item as TBuilding;
|
|
269
|
+
previewDialog.value = true;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function successCreate() {
|
|
273
|
+
createDialog.value = false;
|
|
274
|
+
getBuildings();
|
|
275
|
+
showMessage("Building created successfully!", "success");
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function successUpdate() {
|
|
279
|
+
editDialog.value = false;
|
|
280
|
+
previewDialog.value = false;
|
|
281
|
+
getBuildings();
|
|
282
|
+
showMessage("Building updated successfully!", "success");
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function openEditDialog() {
|
|
286
|
+
editDialog.value = true;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const confirmDialog = ref(false);
|
|
290
|
+
const selectedBuildingId = ref<string | null>(null);
|
|
291
|
+
const deleteLoading = ref(false);
|
|
292
|
+
|
|
293
|
+
function openDeleteDialog() {
|
|
294
|
+
confirmDialog.value = true;
|
|
295
|
+
message.value = "";
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function showMessage(msg: string, color: string) {
|
|
299
|
+
message.value = msg;
|
|
300
|
+
messageColor.value = color;
|
|
301
|
+
messageSnackbar.value = true;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function handleDeleteBuilding() {
|
|
305
|
+
deleteLoading.value = true;
|
|
306
|
+
try {
|
|
307
|
+
await deleteById(selectedBuilding.value._id ?? "");
|
|
308
|
+
await getBuildings();
|
|
309
|
+
selectedBuildingId.value = null;
|
|
310
|
+
confirmDialog.value = false;
|
|
311
|
+
previewDialog.value = false
|
|
312
|
+
} catch (error: any) {
|
|
313
|
+
message.value =
|
|
314
|
+
error?.response?._data?.message || "Failed to delete region";
|
|
315
|
+
} finally {
|
|
316
|
+
deleteLoading.value = false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function setBuilding({
|
|
321
|
+
mode = "create",
|
|
322
|
+
dialog = true,
|
|
323
|
+
data = {} as TBuilding,
|
|
324
|
+
} = {}) {
|
|
325
|
+
if (mode === "create") {
|
|
326
|
+
createDialog.value = dialog;
|
|
327
|
+
} else if (mode === "edit") {
|
|
328
|
+
editDialog.value = dialog;
|
|
329
|
+
selectedBuilding.value = data;
|
|
330
|
+
} else if (mode === "preview") {
|
|
331
|
+
previewDialog.value = dialog;
|
|
332
|
+
selectedBuilding.value = data;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
</script>
|