@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,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card width="100%" :disabled="loading" :loading="loading">
|
|
3
|
+
<v-card-text style="max-height: 100vh; overflow-y: auto" class="pa-5 my-5 px-7 text-center">
|
|
4
|
+
<span> {{ promptTitle }}</span>
|
|
5
|
+
|
|
6
|
+
<span v-if="message" class="text-error mt-2">
|
|
7
|
+
{{ message }} Do you want to delete anyway?
|
|
8
|
+
</span>
|
|
9
|
+
</v-card-text>
|
|
10
|
+
|
|
11
|
+
<v-toolbar class="pa-0" density="compact">
|
|
12
|
+
<v-row no-gutters>
|
|
13
|
+
<v-col cols="6" class="pa-0">
|
|
14
|
+
<v-btn block variant="text" class="text-none" size="large" tile @click="emit('close')"
|
|
15
|
+
height="48">
|
|
16
|
+
Cancel
|
|
17
|
+
</v-btn>
|
|
18
|
+
</v-col>
|
|
19
|
+
|
|
20
|
+
<v-col cols="6" class="pa-0">
|
|
21
|
+
<v-btn block tile variant="flat" class="text-none" size="large" height="48" color="black"
|
|
22
|
+
@click="emit('delete')">
|
|
23
|
+
Delete
|
|
24
|
+
</v-btn>
|
|
25
|
+
</v-col>
|
|
26
|
+
</v-row>
|
|
27
|
+
</v-toolbar>
|
|
28
|
+
</v-card>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
const props = defineProps({
|
|
33
|
+
message: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: ""
|
|
36
|
+
},
|
|
37
|
+
promptTitle: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: "Are you sure want to delete this? "
|
|
40
|
+
},
|
|
41
|
+
loading: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const emit = defineEmits(["close", "delete"])
|
|
48
|
+
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<style scoped></style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card width="100%" :disabled="loading" :loading="loading">
|
|
3
|
+
<v-card-text style="max-height: 100vh; overflow-y: auto" class="pa-5 my-5 px-7 text-center">
|
|
4
|
+
<v-row no-gutters>
|
|
5
|
+
<v-col cols="12" class="font-weight-bold text-h6">{{ promptTitle }}</v-col>
|
|
6
|
+
<v-col cols="12" class="mt-5">
|
|
7
|
+
<span>
|
|
8
|
+
By proceeding, your previous user inputs will be replaced.
|
|
9
|
+
</span>
|
|
10
|
+
</v-col>
|
|
11
|
+
</v-row>
|
|
12
|
+
</v-card-text>
|
|
13
|
+
|
|
14
|
+
<v-toolbar class="pa-0" density="compact">
|
|
15
|
+
<v-row no-gutters>
|
|
16
|
+
<v-col cols="6" class="pa-0">
|
|
17
|
+
<v-btn block variant="text" class="text-none" size="large" tile @click="emit('close')" height="48">
|
|
18
|
+
Cancel
|
|
19
|
+
</v-btn>
|
|
20
|
+
</v-col>
|
|
21
|
+
|
|
22
|
+
<v-col cols="6" class="pa-0">
|
|
23
|
+
<v-btn block tile variant="flat" class="text-none" size="large" height="48" color="black"
|
|
24
|
+
@click="emit('proceed')">
|
|
25
|
+
Proceed
|
|
26
|
+
</v-btn>
|
|
27
|
+
</v-col>
|
|
28
|
+
</v-row>
|
|
29
|
+
</v-toolbar>
|
|
30
|
+
</v-card>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
const props = defineProps({
|
|
35
|
+
promptTitle: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "Update user details? "
|
|
38
|
+
},
|
|
39
|
+
loading: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const emit = defineEmits(["close", "proceed"])
|
|
46
|
+
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style scoped></style>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card width="100%">
|
|
3
|
+
<v-toolbar>
|
|
4
|
+
<template v-if="$slots.header">
|
|
5
|
+
<slot name="header" :title="title" :onClose="onClose" />
|
|
6
|
+
</template>
|
|
7
|
+
<template v-else>
|
|
8
|
+
<v-row no-gutters class="fill-height px-6" align="center">
|
|
9
|
+
<span class="font-weight-bold text-h5 text-capitalize">{{
|
|
10
|
+
title
|
|
11
|
+
}}</span>
|
|
12
|
+
</v-row>
|
|
13
|
+
</template>
|
|
14
|
+
</v-toolbar>
|
|
15
|
+
|
|
16
|
+
<v-card-text style="max-height: 100vh; overflow-y: auto" class="pb-0" :class="contentNoPadding ? 'pa-0' : ''">
|
|
17
|
+
<slot name="content" />
|
|
18
|
+
</v-card-text>
|
|
19
|
+
|
|
20
|
+
<v-toolbar class="pa-0" density="compact">
|
|
21
|
+
<v-row no-gutters>
|
|
22
|
+
<v-col cols="6" class="pa-0">
|
|
23
|
+
<v-btn
|
|
24
|
+
block
|
|
25
|
+
variant="text"
|
|
26
|
+
class="text-none"
|
|
27
|
+
size="large"
|
|
28
|
+
@click="emit('close')"
|
|
29
|
+
height="48"
|
|
30
|
+
>
|
|
31
|
+
Close
|
|
32
|
+
</v-btn>
|
|
33
|
+
</v-col>
|
|
34
|
+
|
|
35
|
+
<v-col cols="6" class="pa-0" >
|
|
36
|
+
<v-menu contained>
|
|
37
|
+
<template #activator="{ props }">
|
|
38
|
+
<v-btn
|
|
39
|
+
block
|
|
40
|
+
variant="flat"
|
|
41
|
+
color="black"
|
|
42
|
+
class="text-none"
|
|
43
|
+
height="48"
|
|
44
|
+
v-bind="props"
|
|
45
|
+
tile
|
|
46
|
+
>
|
|
47
|
+
More actions
|
|
48
|
+
</v-btn>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<v-list class="pa-0">
|
|
52
|
+
<v-list-item v-if="canUpdate" @click="emit('edit')">
|
|
53
|
+
<v-list-item-title class="text-subtitle-2">
|
|
54
|
+
{{ editButtonLabel }}
|
|
55
|
+
</v-list-item-title>
|
|
56
|
+
</v-list-item>
|
|
57
|
+
|
|
58
|
+
<v-list-item v-if="canDelete" @click="emit('delete')" class="text-red">
|
|
59
|
+
<v-list-item-title class="text-subtitle-2">
|
|
60
|
+
{{ deleteButtonLabel }}
|
|
61
|
+
</v-list-item-title>
|
|
62
|
+
</v-list-item>
|
|
63
|
+
</v-list>
|
|
64
|
+
</v-menu>
|
|
65
|
+
</v-col>
|
|
66
|
+
</v-row>
|
|
67
|
+
</v-toolbar>
|
|
68
|
+
</v-card>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
const prop = defineProps({
|
|
73
|
+
canUpdate: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: true,
|
|
76
|
+
},
|
|
77
|
+
canDelete: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: true,
|
|
80
|
+
},
|
|
81
|
+
editButtonLabel: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: "Edit",
|
|
84
|
+
},
|
|
85
|
+
deleteButtonLabel: {
|
|
86
|
+
type: String,
|
|
87
|
+
default: "Delete",
|
|
88
|
+
},
|
|
89
|
+
title: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: "Details",
|
|
92
|
+
},
|
|
93
|
+
contentNoPadding: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
default: false,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const emit = defineEmits(["close", "edit", "delete"]);
|
|
100
|
+
const { canUpdate, editButtonLabel, deleteButtonLabel, title } = prop;
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<style scoped></style>
|
|
@@ -0,0 +1,187 @@
|
|
|
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 }} Document
|
|
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-col cols="12" class="px-6">
|
|
13
|
+
<InputLabel class="text-capitalize" title="Document Attachment" />
|
|
14
|
+
<InputFileV2
|
|
15
|
+
v-model="document.attachment"
|
|
16
|
+
:multiple="false"
|
|
17
|
+
:max-length="10"
|
|
18
|
+
title="Upload PDF Files"
|
|
19
|
+
accept=".pdf, .doc, .docx, .xls, .xlsx, .txt"
|
|
20
|
+
/>
|
|
21
|
+
</v-col>
|
|
22
|
+
|
|
23
|
+
<v-col cols="12" class="px-6">
|
|
24
|
+
<InputLabel class="text-capitalize" title="Document Name" />
|
|
25
|
+
<v-text-field
|
|
26
|
+
v-model.trim="document.name"
|
|
27
|
+
density="comfortable"
|
|
28
|
+
></v-text-field>
|
|
29
|
+
</v-col>
|
|
30
|
+
|
|
31
|
+
<v-col cols="12" class="px-6">
|
|
32
|
+
<InputLabel class="text-capitalize" title="Document Type" />
|
|
33
|
+
<v-select
|
|
34
|
+
v-model="document.type"
|
|
35
|
+
:items="documentTypes"
|
|
36
|
+
density="comfortable"
|
|
37
|
+
/>
|
|
38
|
+
</v-col>
|
|
39
|
+
|
|
40
|
+
<v-col cols="12">
|
|
41
|
+
<v-row no-gutters>
|
|
42
|
+
<v-col cols="12" class="text-center">
|
|
43
|
+
<span
|
|
44
|
+
class="text-none text-subtitle-2 font-weight-medium text-error"
|
|
45
|
+
>
|
|
46
|
+
{{ message }}
|
|
47
|
+
</span>
|
|
48
|
+
</v-col>
|
|
49
|
+
</v-row>
|
|
50
|
+
</v-col>
|
|
51
|
+
</v-form>
|
|
52
|
+
</v-card-text>
|
|
53
|
+
|
|
54
|
+
<v-toolbar density="compact">
|
|
55
|
+
<v-row no-gutters>
|
|
56
|
+
<v-col cols="6">
|
|
57
|
+
<v-btn
|
|
58
|
+
tile
|
|
59
|
+
block
|
|
60
|
+
variant="text"
|
|
61
|
+
class="text-none"
|
|
62
|
+
size="48"
|
|
63
|
+
@click="cancel"
|
|
64
|
+
:disabled="disable"
|
|
65
|
+
>
|
|
66
|
+
Cancel
|
|
67
|
+
</v-btn>
|
|
68
|
+
</v-col>
|
|
69
|
+
|
|
70
|
+
<v-col cols="6">
|
|
71
|
+
<v-btn
|
|
72
|
+
tile
|
|
73
|
+
block
|
|
74
|
+
variant="flat"
|
|
75
|
+
color="black"
|
|
76
|
+
class="text-none"
|
|
77
|
+
size="48"
|
|
78
|
+
:disabled="
|
|
79
|
+
!validForm ||
|
|
80
|
+
disable ||
|
|
81
|
+
document.attachment.length == 0 ||
|
|
82
|
+
document.name == ''
|
|
83
|
+
"
|
|
84
|
+
@click="submit"
|
|
85
|
+
:loading="disable"
|
|
86
|
+
>
|
|
87
|
+
Submit
|
|
88
|
+
</v-btn>
|
|
89
|
+
</v-col>
|
|
90
|
+
</v-row>
|
|
91
|
+
</v-toolbar>
|
|
92
|
+
</v-card>
|
|
93
|
+
</template>
|
|
94
|
+
<script setup lang="ts">
|
|
95
|
+
const prop = defineProps({
|
|
96
|
+
mode: {
|
|
97
|
+
type: String,
|
|
98
|
+
default: "add",
|
|
99
|
+
},
|
|
100
|
+
document: {
|
|
101
|
+
type: Object as PropType<TDocument>,
|
|
102
|
+
default: () => ({
|
|
103
|
+
name: "",
|
|
104
|
+
attachment: [],
|
|
105
|
+
type: "",
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const emit = defineEmits(["cancel", "success"]);
|
|
111
|
+
|
|
112
|
+
const { add, updateById } = useDocument();
|
|
113
|
+
const { getFileById } = useFile();
|
|
114
|
+
|
|
115
|
+
const validForm = ref(false);
|
|
116
|
+
const disable = ref(false);
|
|
117
|
+
const message = ref("");
|
|
118
|
+
|
|
119
|
+
const documentTypes = ref(["Online Form", "Other"]);
|
|
120
|
+
|
|
121
|
+
const document = ref<Record<string, any>>({
|
|
122
|
+
name: "",
|
|
123
|
+
attachment: [],
|
|
124
|
+
type: "",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const route = useRoute();
|
|
128
|
+
const siteId = route.params.site as string;
|
|
129
|
+
const orgId = route.params.org as string;
|
|
130
|
+
|
|
131
|
+
if (prop.mode === "edit") {
|
|
132
|
+
document.value.name = prop.document.name;
|
|
133
|
+
document.value.attachment = [prop.document.attachment];
|
|
134
|
+
document.value.type = prop.document.type;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
watch(
|
|
138
|
+
() => document.value.attachment,
|
|
139
|
+
async (newVal) => {
|
|
140
|
+
if (newVal && prop.mode !== "edit") {
|
|
141
|
+
const fileData = await getFileById(newVal);
|
|
142
|
+
if (fileData) {
|
|
143
|
+
document.value.name = fileData.data.name;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
function cancel() {
|
|
150
|
+
// createMore.value = false;
|
|
151
|
+
message.value = "";
|
|
152
|
+
emit("cancel");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function submit() {
|
|
156
|
+
disable.value = true;
|
|
157
|
+
try {
|
|
158
|
+
if (prop.mode === "add") {
|
|
159
|
+
const payload = {
|
|
160
|
+
name: document.value.name,
|
|
161
|
+
attachment: document.value.attachment,
|
|
162
|
+
type: document.value.type || "Other",
|
|
163
|
+
status: "active",
|
|
164
|
+
org: orgId,
|
|
165
|
+
site: siteId,
|
|
166
|
+
};
|
|
167
|
+
await add(payload);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (prop.mode === "edit") {
|
|
171
|
+
const payload = {
|
|
172
|
+
name: document.value.name,
|
|
173
|
+
attachment: document.value.attachment,
|
|
174
|
+
type: document.value.type,
|
|
175
|
+
};
|
|
176
|
+
await updateById(prop.document._id ?? "", payload);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
emit("success");
|
|
180
|
+
} catch (error: any) {
|
|
181
|
+
message.value =
|
|
182
|
+
error.response?._data?.message || "Failed to create document";
|
|
183
|
+
} finally {
|
|
184
|
+
disable.value = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
</script>
|