@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,83 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-list-group v-if="children && children.length">
|
|
3
|
+
<template #activator="{ props: groupProps }">
|
|
4
|
+
<v-list-item
|
|
5
|
+
v-bind="groupProps"
|
|
6
|
+
:prepend-icon="icon"
|
|
7
|
+
class="text-subtitle-2"
|
|
8
|
+
@click.stop="onParentClick"
|
|
9
|
+
>
|
|
10
|
+
{{ title }}
|
|
11
|
+
</v-list-item>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<NavigationItem
|
|
15
|
+
v-for="(child, childIndex) in children"
|
|
16
|
+
:key="`${child.title}-${childIndex}`"
|
|
17
|
+
:title="child.title"
|
|
18
|
+
:icon="child.icon"
|
|
19
|
+
:route="child.route"
|
|
20
|
+
:children="child.children"
|
|
21
|
+
/>
|
|
22
|
+
</v-list-group>
|
|
23
|
+
|
|
24
|
+
<v-list-item
|
|
25
|
+
v-else-if="props.route && props.route.name"
|
|
26
|
+
:prepend-icon="icon"
|
|
27
|
+
:to="props.route"
|
|
28
|
+
class="text-subtitle-2"
|
|
29
|
+
>
|
|
30
|
+
{{ title }}
|
|
31
|
+
</v-list-item>
|
|
32
|
+
|
|
33
|
+
<v-list-item
|
|
34
|
+
v-else-if="props.link"
|
|
35
|
+
:prepend-icon="icon"
|
|
36
|
+
:href="props.link"
|
|
37
|
+
class="text-subtitle-2"
|
|
38
|
+
>
|
|
39
|
+
{{ title }}
|
|
40
|
+
</v-list-item>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
const props = defineProps({
|
|
45
|
+
title: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true,
|
|
48
|
+
default: "Title",
|
|
49
|
+
},
|
|
50
|
+
icon: {
|
|
51
|
+
type: String,
|
|
52
|
+
required: false,
|
|
53
|
+
default: "",
|
|
54
|
+
},
|
|
55
|
+
route: {
|
|
56
|
+
type: Object as PropType<Record<string, any>>,
|
|
57
|
+
default() {
|
|
58
|
+
return { name: "" };
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
link: {
|
|
62
|
+
type: String,
|
|
63
|
+
required: false,
|
|
64
|
+
default: "",
|
|
65
|
+
},
|
|
66
|
+
children: {
|
|
67
|
+
type: Array<TNavigationItem>,
|
|
68
|
+
required: false,
|
|
69
|
+
default: () => [],
|
|
70
|
+
},
|
|
71
|
+
name: {
|
|
72
|
+
type: String,
|
|
73
|
+
required: false,
|
|
74
|
+
default: "",
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
function onParentClick() {
|
|
79
|
+
if (props.route && props.route.name) {
|
|
80
|
+
navigateTo(props.route);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-row no-gutters>
|
|
3
|
+
<v-form v-model="valid">
|
|
4
|
+
<v-row>
|
|
5
|
+
<v-col cols="6">
|
|
6
|
+
<InputLabel class="text-capitalize font-weight-bold" :title="title" :required="required" />
|
|
7
|
+
<v-text-field v-model.number="count" type="number" density="comfortable" :rules="rules" />
|
|
8
|
+
</v-col>
|
|
9
|
+
|
|
10
|
+
<v-col cols="6">
|
|
11
|
+
<v-btn color="primary" class="text-none mt-6" size="large" variant="flat"
|
|
12
|
+
:disabled="!valid || disabled" :loading="loading || updating" text="Save" @click="handleSave" />
|
|
13
|
+
</v-col>
|
|
14
|
+
</v-row>
|
|
15
|
+
</v-form>
|
|
16
|
+
<Snackbar v-model="toastObject.show" :text="toastObject.message" :color="toastObject.color" />
|
|
17
|
+
</v-row>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import useSiteSettings from '../composables/useSiteSettings';
|
|
22
|
+
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
title: { type: String, required: true },
|
|
25
|
+
required: { type: Boolean, default: true },
|
|
26
|
+
loading: { type: Boolean, default: false },
|
|
27
|
+
type: { type: String as PropType<'blocks' | 'guard_posts'>, required: true},
|
|
28
|
+
disabled: {type: Boolean, default: false},
|
|
29
|
+
siteId: { type: String, required: true }
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const { updateSite, setSiteGuardPosts } = useSiteSettings()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const count = defineModel<number>({ default: 0 });
|
|
36
|
+
const valid = ref(false);
|
|
37
|
+
const updating = ref(false)
|
|
38
|
+
|
|
39
|
+
const toastObject = reactive({
|
|
40
|
+
show: false,
|
|
41
|
+
message: "",
|
|
42
|
+
color: "",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
const emits = defineEmits(["success", "error"]);
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const { requiredRule } = useUtils();
|
|
50
|
+
|
|
51
|
+
function validNumber(value: number) {
|
|
52
|
+
return value > 0 || "Number must be greater than zero.";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const rules = computed(() => {
|
|
56
|
+
const arr = [];
|
|
57
|
+
if (props.required) {
|
|
58
|
+
arr.push(requiredRule);
|
|
59
|
+
arr.push(validNumber);
|
|
60
|
+
}
|
|
61
|
+
return arr;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
async function handleSave() {
|
|
68
|
+
if(!props.siteId){
|
|
69
|
+
return emits('error', 'Site ID is required')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
updating.value = true;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
if(props.type === 'blocks'){
|
|
76
|
+
await updateSite(props.siteId, { block: count.value});
|
|
77
|
+
handleSuccess('The number of blocks has been updated successfully!')
|
|
78
|
+
} else if (props.type) {
|
|
79
|
+
await setSiteGuardPosts(props.siteId, count.value)
|
|
80
|
+
handleSuccess('The number of guard posts has been updated successfully!')
|
|
81
|
+
|
|
82
|
+
} else {
|
|
83
|
+
throw new Error('Invalid type Prop provided.')
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
emits('success')
|
|
87
|
+
} catch (error: any) {
|
|
88
|
+
const message = error?.data?.message || `Error updating ${props.type.replace('_', ' ')}`;
|
|
89
|
+
handleError(message)
|
|
90
|
+
} finally {
|
|
91
|
+
updating.value = false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const handleSuccess = (message: string) => {
|
|
96
|
+
toastObject.show = true;
|
|
97
|
+
toastObject.message = message;
|
|
98
|
+
toastObject.color = "success";
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const handleError = (message: string) => {
|
|
102
|
+
toastObject.show = true;
|
|
103
|
+
toastObject.message = message;
|
|
104
|
+
toastObject.color = "error";
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
</script>
|
|
@@ -0,0 +1,290 @@
|
|
|
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 }} Online Form
|
|
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="Attachment" />
|
|
14
|
+
<v-select
|
|
15
|
+
v-model="onlineForm.attachment"
|
|
16
|
+
:items="attachments"
|
|
17
|
+
item-title="name"
|
|
18
|
+
item-value="attachment"
|
|
19
|
+
density="comfortable"
|
|
20
|
+
type="text"
|
|
21
|
+
/>
|
|
22
|
+
</v-col>
|
|
23
|
+
|
|
24
|
+
<v-col cols="12" class="px-6">
|
|
25
|
+
<InputLabel class="text-capitalize" title="Name" />
|
|
26
|
+
<v-text-field
|
|
27
|
+
v-model.trim="onlineForm.name"
|
|
28
|
+
density="comfortable"
|
|
29
|
+
></v-text-field>
|
|
30
|
+
</v-col>
|
|
31
|
+
|
|
32
|
+
<template v-for="(inputLabel, inputLabelIndex) in onlineForm.inputs">
|
|
33
|
+
<v-row class="px-6">
|
|
34
|
+
<v-col cols="6">
|
|
35
|
+
<InputLabel
|
|
36
|
+
class="text-capitalize"
|
|
37
|
+
:title="`Label ${+inputLabelIndex + 1}`"
|
|
38
|
+
/>
|
|
39
|
+
<v-text-field
|
|
40
|
+
v-model.trim="inputLabel.label"
|
|
41
|
+
density="comfortable"
|
|
42
|
+
></v-text-field>
|
|
43
|
+
</v-col>
|
|
44
|
+
<v-col cols="6">
|
|
45
|
+
<InputLabel
|
|
46
|
+
class="text-capitalize"
|
|
47
|
+
:title="`Data Type ${+inputLabelIndex + 1}`"
|
|
48
|
+
/>
|
|
49
|
+
<v-select v-model="inputLabel.dataType" :items="dataTypes" />
|
|
50
|
+
</v-col>
|
|
51
|
+
<v-col cols="6">
|
|
52
|
+
<InputLabel
|
|
53
|
+
class="text-capitalize"
|
|
54
|
+
:title="`Required ${+inputLabelIndex + 1}`"
|
|
55
|
+
/>
|
|
56
|
+
<v-checkbox v-model="inputLabel.required" />
|
|
57
|
+
</v-col>
|
|
58
|
+
<v-col cols="6">
|
|
59
|
+
<InputLabel
|
|
60
|
+
class="text-capitalize"
|
|
61
|
+
:title="`Multiple ${+inputLabelIndex + 1}`"
|
|
62
|
+
/>
|
|
63
|
+
<v-checkbox v-model="inputLabel.multiple" />
|
|
64
|
+
</v-col>
|
|
65
|
+
<v-col cols="6">
|
|
66
|
+
<v-btn
|
|
67
|
+
block
|
|
68
|
+
color="red"
|
|
69
|
+
variant="text"
|
|
70
|
+
class="text-none font-weight-bold"
|
|
71
|
+
text="Remove"
|
|
72
|
+
:disabled="onlineForm.inputs.length === 1"
|
|
73
|
+
@click="onlineForm.inputs.splice(inputLabelIndex, 1)"
|
|
74
|
+
/>
|
|
75
|
+
</v-col>
|
|
76
|
+
</v-row>
|
|
77
|
+
<v-divider class="my-3" />
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<v-col cols="12" class="px-6">
|
|
81
|
+
<v-btn
|
|
82
|
+
block
|
|
83
|
+
color="primary"
|
|
84
|
+
variant="text"
|
|
85
|
+
class="text-none font-weight-bold"
|
|
86
|
+
text="Add"
|
|
87
|
+
@click="addNewInput"
|
|
88
|
+
></v-btn>
|
|
89
|
+
</v-col>
|
|
90
|
+
|
|
91
|
+
<v-col cols="12">
|
|
92
|
+
<v-row no-gutters>
|
|
93
|
+
<v-col cols="12" class="text-center">
|
|
94
|
+
<span
|
|
95
|
+
class="text-none text-subtitle-2 font-weight-medium text-error"
|
|
96
|
+
>
|
|
97
|
+
{{ message }}
|
|
98
|
+
</span>
|
|
99
|
+
</v-col>
|
|
100
|
+
</v-row>
|
|
101
|
+
</v-col>
|
|
102
|
+
</v-form>
|
|
103
|
+
</v-card-text>
|
|
104
|
+
<v-toolbar density="compact">
|
|
105
|
+
<v-row no-gutters>
|
|
106
|
+
<v-col cols="6">
|
|
107
|
+
<v-btn
|
|
108
|
+
tile
|
|
109
|
+
block
|
|
110
|
+
variant="text"
|
|
111
|
+
class="text-none"
|
|
112
|
+
size="48"
|
|
113
|
+
@click="cancel"
|
|
114
|
+
>
|
|
115
|
+
Cancel
|
|
116
|
+
</v-btn>
|
|
117
|
+
</v-col>
|
|
118
|
+
<v-col cols="6">
|
|
119
|
+
<v-btn
|
|
120
|
+
tile
|
|
121
|
+
block
|
|
122
|
+
variant="flat"
|
|
123
|
+
color="black"
|
|
124
|
+
class="text-none"
|
|
125
|
+
size="48"
|
|
126
|
+
:disabled="
|
|
127
|
+
!validForm ||
|
|
128
|
+
disable ||
|
|
129
|
+
onlineForm.attachment.length == 0 ||
|
|
130
|
+
onlineForm.name == ''
|
|
131
|
+
"
|
|
132
|
+
@click="submit"
|
|
133
|
+
:loading="disable"
|
|
134
|
+
>
|
|
135
|
+
{{ prop.mode === "edit" ? "Update" : "Submit" }}
|
|
136
|
+
</v-btn>
|
|
137
|
+
</v-col>
|
|
138
|
+
</v-row>
|
|
139
|
+
</v-toolbar>
|
|
140
|
+
</v-card>
|
|
141
|
+
</template>
|
|
142
|
+
<script setup lang="ts">
|
|
143
|
+
const prop = defineProps({
|
|
144
|
+
mode: {
|
|
145
|
+
type: String,
|
|
146
|
+
default: "add",
|
|
147
|
+
},
|
|
148
|
+
onlineForm: {
|
|
149
|
+
type: Object as PropType<TOnlineForm>,
|
|
150
|
+
default: () => ({
|
|
151
|
+
name: "",
|
|
152
|
+
attachment: "",
|
|
153
|
+
inputs: [
|
|
154
|
+
{
|
|
155
|
+
label: "",
|
|
156
|
+
dataType: "",
|
|
157
|
+
required: true,
|
|
158
|
+
multiple: false,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
status: "active",
|
|
162
|
+
}),
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const emit = defineEmits(["cancel", "success"]);
|
|
167
|
+
|
|
168
|
+
const validForm = ref(false);
|
|
169
|
+
const disable = ref(false);
|
|
170
|
+
const message = ref("");
|
|
171
|
+
|
|
172
|
+
const route = useRoute();
|
|
173
|
+
const siteId = route.params.site as string;
|
|
174
|
+
const orgId = route.params.org as string;
|
|
175
|
+
|
|
176
|
+
const attachments = ref<any>([
|
|
177
|
+
{
|
|
178
|
+
_id: "",
|
|
179
|
+
name: "",
|
|
180
|
+
attachment: "",
|
|
181
|
+
type: "",
|
|
182
|
+
},
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
const { getDocumentsBySiteId: _getAllDocuments } = useDocument();
|
|
186
|
+
const { add: _add, updateOnlineFormById: _update } = useOnlineForm();
|
|
187
|
+
|
|
188
|
+
const onlineForm = ref<Record<string, any>>({
|
|
189
|
+
name: "",
|
|
190
|
+
attachment: "",
|
|
191
|
+
inputs: [
|
|
192
|
+
{
|
|
193
|
+
label: "Name",
|
|
194
|
+
dataType: "Text Input",
|
|
195
|
+
required: true,
|
|
196
|
+
multiple: false,
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
status: "active",
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const dataTypes = ref([
|
|
203
|
+
"Text Input",
|
|
204
|
+
"Text Area",
|
|
205
|
+
"Date Input",
|
|
206
|
+
"Select",
|
|
207
|
+
"Checkbox",
|
|
208
|
+
]);
|
|
209
|
+
|
|
210
|
+
const {
|
|
211
|
+
data: getDocumentReq,
|
|
212
|
+
refresh: getDocuments,
|
|
213
|
+
status: getAllReqStatus,
|
|
214
|
+
} = useLazyAsyncData("get-all-documents", () =>
|
|
215
|
+
_getAllDocuments(siteId, "Online Form")
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
watchEffect(() => {
|
|
219
|
+
if (getDocumentReq.value) {
|
|
220
|
+
attachments.value = getDocumentReq.value;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
if (prop.mode === "edit") {
|
|
225
|
+
onlineForm.value.attachment = prop.onlineForm.attachment;
|
|
226
|
+
onlineForm.value.name = prop.onlineForm.name;
|
|
227
|
+
onlineForm.value.inputs = prop.onlineForm.inputs;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
watch(
|
|
231
|
+
() => onlineForm.value.attachment,
|
|
232
|
+
(newVal) => {
|
|
233
|
+
if (newVal) {
|
|
234
|
+
const val = attachments.value.find(
|
|
235
|
+
(attachment: any) => attachment.attachment === newVal
|
|
236
|
+
);
|
|
237
|
+
onlineForm.value.name = val.name;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
function cancel() {
|
|
243
|
+
emit("cancel");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function addNewInput() {
|
|
247
|
+
onlineForm.value.inputs.push({
|
|
248
|
+
label: "",
|
|
249
|
+
dataType: "",
|
|
250
|
+
required: true,
|
|
251
|
+
multiple: false,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async function submit() {
|
|
256
|
+
// console.log("submit", onlineForm.value);
|
|
257
|
+
disable.value = true;
|
|
258
|
+
try {
|
|
259
|
+
if (prop.mode === "add") {
|
|
260
|
+
const payload = {
|
|
261
|
+
name: onlineForm.value.name,
|
|
262
|
+
attachment: onlineForm.value.attachment,
|
|
263
|
+
inputs: onlineForm.value.inputs,
|
|
264
|
+
status: "active",
|
|
265
|
+
org: orgId,
|
|
266
|
+
site: siteId,
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
await _add(payload);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (prop.mode === "edit") {
|
|
273
|
+
const payload = {
|
|
274
|
+
name: onlineForm.value.name,
|
|
275
|
+
attachment: onlineForm.value.attachment,
|
|
276
|
+
inputs: onlineForm.value.inputs,
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
await _update(prop.onlineForm._id ?? "", payload);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
emit("success");
|
|
283
|
+
} catch (error: any) {
|
|
284
|
+
message.value =
|
|
285
|
+
error.response?._data?.message || "Failed to create document";
|
|
286
|
+
} finally {
|
|
287
|
+
disable.value = false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
</script>
|