@7365admin1/layer-common 3.0.31-staging.18 → 3.0.31-staging.20
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/components/VisitorForm.vue +38 -49
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<div class="w-100 d-flex justify-space-between ga-2">
|
|
13
13
|
<span class="text-subtitle-1 w-100 font-weight-bold mb-3">{{
|
|
14
14
|
formTitle
|
|
15
|
-
|
|
15
|
+
}}</span>
|
|
16
16
|
<span v-if="withStep2 || withStep3" class="text-subtitle-2 font-weight-bold" style="text-wrap: nowrap">Step
|
|
17
17
|
<span class="text-primary-button">{{ contractorStep }}</span>/{{ withStep3 ? 3 : withStep2 ? 2 : 1 }}</span>
|
|
18
18
|
</div>
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
</v-row>
|
|
93
93
|
</v-col>
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
<v-col v-if="shouldShowField('contractorType')" cols="12">
|
|
96
96
|
<InputLabel class="text-capitalize" title="Contractor Type" required />
|
|
97
97
|
<v-combobox v-model="contractorTypeObj" v-model:search="contractorTypeInput" ref="contractorTypeCombo"
|
|
98
98
|
autocomplete="off" :hide-no-data="false" @update:focused="handleFocusedContractorType"
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
<v-list-item-title @click.stop="handleAddNewContractorType" class="d-flex align-center ga-1">
|
|
105
105
|
<span><v-icon icon="mdi-plus" /></span> Add "<strong>{{
|
|
106
106
|
contractorTypeInput
|
|
107
|
-
|
|
107
|
+
}}</strong>" as custom contractor type.
|
|
108
108
|
</v-list-item-title>
|
|
109
109
|
</v-list-item>
|
|
110
110
|
</template>
|
|
@@ -137,15 +137,11 @@
|
|
|
137
137
|
<InputLabel class="text-capitalize" title="Company Name" />
|
|
138
138
|
<v-combobox v-model="visitor.company" v-model:search="companyNameInput" ref="companyCombo"
|
|
139
139
|
autocomplete="off" :hide-no-data="false" :items="companyNames" item-value="value"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<template v-slot:no-data>
|
|
140
|
+
@update:model-value="handleSelectCompanyName" variant="outlined" density="comfortable" persistent-hint
|
|
141
|
+
small-chips>
|
|
142
|
+
<!-- <template v-slot:no-data>
|
|
143
143
|
<v-list-item>
|
|
144
|
-
<v-list-item-title v-if="
|
|
145
|
-
<v-progress-circular indeterminate size="20" class="mr-3" />
|
|
146
|
-
Searching companies…
|
|
147
|
-
</v-list-item-title>
|
|
148
|
-
<v-list-item-title v-else-if="companyNameInput" @click.stop="handleAddNewCompany"
|
|
144
|
+
<v-list-item-title v-if="companyNameInput" @click.stop="handleAddNewCompany"
|
|
149
145
|
class="d-flex align-center ga-1">
|
|
150
146
|
<span><v-icon icon="mdi-plus" /></span>Add "<strong>{{
|
|
151
147
|
companyNameInput
|
|
@@ -158,7 +154,7 @@
|
|
|
158
154
|
No companies available. Start typing to add a new one.
|
|
159
155
|
</v-list-item-title>
|
|
160
156
|
</v-list-item>
|
|
161
|
-
</template>
|
|
157
|
+
</template> -->
|
|
162
158
|
</v-combobox>
|
|
163
159
|
</v-col>
|
|
164
160
|
</template>
|
|
@@ -171,7 +167,7 @@
|
|
|
171
167
|
:loading="siteDataPending" variant="outlined" density="comfortable" persistent-hint small-chips>
|
|
172
168
|
<template v-slot:no-data>
|
|
173
169
|
<v-list-item>
|
|
174
|
-
<v-list-item-title v-if="
|
|
170
|
+
<v-list-item-title v-if="siteDataPending">
|
|
175
171
|
<v-progress-circular indeterminate size="20" class="mr-3" />
|
|
176
172
|
Searching companies…
|
|
177
173
|
</v-list-item-title>
|
|
@@ -179,7 +175,7 @@
|
|
|
179
175
|
class="d-flex align-center ga-1">
|
|
180
176
|
<span><v-icon icon="mdi-plus" /></span>Add "<strong>{{
|
|
181
177
|
companyNameInput
|
|
182
|
-
|
|
178
|
+
}}</strong>" as new company.
|
|
183
179
|
</v-list-item-title>
|
|
184
180
|
<v-list-item-title v-else-if="!companyNameInput && companyNames.length === 0">
|
|
185
181
|
Start typing to search for companies.
|
|
@@ -933,23 +929,34 @@ function getPersonPlateOptions(item: Partial<TPeople>) {
|
|
|
933
929
|
function findMatchingContactOption(options: string[], value?: string | null) {
|
|
934
930
|
const normalizedValue = value?.trim();
|
|
935
931
|
if (!normalizedValue) return "";
|
|
932
|
+
const compactValue = normalizedValue.replace(/\s/g, "");
|
|
936
933
|
|
|
937
934
|
return (
|
|
938
935
|
options.find((option) => option.trim() === normalizedValue) ||
|
|
939
|
-
options.find((option) => option.replace(/\s/g, "") ===
|
|
936
|
+
options.find((option) => option.replace(/\s/g, "") === compactValue) ||
|
|
937
|
+
options.find((option) => option.trim().includes(normalizedValue)) ||
|
|
938
|
+
options.find((option) => option.replace(/\s/g, "").includes(compactValue)) ||
|
|
940
939
|
""
|
|
941
940
|
);
|
|
942
941
|
}
|
|
943
942
|
|
|
943
|
+
function normalizePlateNumber(value?: string | null) {
|
|
944
|
+
return (value ?? "").replace(/[^A-Z0-9]/gi, "").toUpperCase();
|
|
945
|
+
}
|
|
946
|
+
|
|
944
947
|
function normalizePlateOption(value?: string | null) {
|
|
945
948
|
return (value || "").replace(/[^A-Z0-9]/gi, "").toUpperCase();
|
|
946
949
|
}
|
|
947
950
|
|
|
948
951
|
function findMatchingPlateOption(options: string[], value?: string | null) {
|
|
949
|
-
const normalizedValue =
|
|
952
|
+
const normalizedValue = normalizePlateNumber(value);
|
|
950
953
|
if (!normalizedValue) return "";
|
|
951
954
|
|
|
952
|
-
return
|
|
955
|
+
return (
|
|
956
|
+
options.find((option) => normalizePlateNumber(option) === normalizedValue) ||
|
|
957
|
+
options.find((option) => normalizePlateNumber(option).includes(normalizedValue)) ||
|
|
958
|
+
""
|
|
959
|
+
);
|
|
953
960
|
}
|
|
954
961
|
|
|
955
962
|
function applyNricSearchResult(
|
|
@@ -970,10 +977,18 @@ function applyNricSearchResult(
|
|
|
970
977
|
visitor.name = item.name || visitor.name;
|
|
971
978
|
visitor.contact = options.contacts || getPersonContactOptions(item)[0] || visitor.contact;
|
|
972
979
|
visitor.plateNumber = options.plateNumber || getPersonPlateOptions(item)[0] || visitor.plateNumber;
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
980
|
+
|
|
981
|
+
companyNames.value = Array.isArray(item.companyName) ? item.companyName : [];
|
|
982
|
+
|
|
983
|
+
if (item.companyName && item.companyName.length === 1) {
|
|
984
|
+
visitor.company = item.companyName?.[0] || visitor.company;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
if (item.companyName && item.companyName.length > 1) {
|
|
988
|
+
visitor.company = ""
|
|
976
989
|
}
|
|
990
|
+
|
|
991
|
+
|
|
977
992
|
// visitor.block = (item.block as any) ?? (visitor.block as any) ?? "";
|
|
978
993
|
// visitor.level = (item.level as any) ?? (visitor.level as any) ?? "";
|
|
979
994
|
// visitor.unit = item.unit ?? visitor.unit ?? "";
|
|
@@ -1040,21 +1055,9 @@ function confirmNricAutofillOptions() {
|
|
|
1040
1055
|
closeNricAutofillOptions();
|
|
1041
1056
|
}
|
|
1042
1057
|
|
|
1043
|
-
const {
|
|
1044
|
-
data: fetchCompanyListReq,
|
|
1045
|
-
refresh: fetchCompanyListRefresh,
|
|
1046
|
-
pending: fetchCompanyListPending,
|
|
1047
|
-
} = useLazyAsyncData(`fetch-company-list`, () => {
|
|
1048
|
-
if (!companyNameInput.value) return Promise.resolve(null);
|
|
1049
|
-
return searchCompanyList(companyNameInput.value);
|
|
1050
|
-
});
|
|
1051
1058
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
companyAutofillDataArray.value = arr;
|
|
1055
|
-
companyNames.value = arr?.flatMap((x) => x?.companyName);
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1059
|
+
|
|
1060
|
+
|
|
1058
1061
|
function getVisitorSearchItems(res: any): TVisitor[] {
|
|
1059
1062
|
const items =
|
|
1060
1063
|
res?.items ||
|
|
@@ -1165,18 +1168,6 @@ async function handleCheckout(visitorId: string) {
|
|
|
1165
1168
|
}
|
|
1166
1169
|
}
|
|
1167
1170
|
|
|
1168
|
-
const debounceFetchCompany = debounce(
|
|
1169
|
-
async () => fetchCompanyListRefresh(),
|
|
1170
|
-
200
|
|
1171
|
-
);
|
|
1172
|
-
|
|
1173
|
-
watch(companyNameInput, async (val) => {
|
|
1174
|
-
if (!val) {
|
|
1175
|
-
companyNames.value = [];
|
|
1176
|
-
return;
|
|
1177
|
-
}
|
|
1178
|
-
await debounceFetchCompany();
|
|
1179
|
-
});
|
|
1180
1171
|
|
|
1181
1172
|
function handleAutofillDataViaVehicleNumber(item: TPeople) {
|
|
1182
1173
|
currentAutofillSource.value = "vehicleNumber";
|
|
@@ -1185,9 +1176,7 @@ function handleAutofillDataViaVehicleNumber(item: TPeople) {
|
|
|
1185
1176
|
visitor.nric = item.nric;
|
|
1186
1177
|
visitor.contact = item.contact;
|
|
1187
1178
|
companyNames.value = item.companyName ?? [];
|
|
1188
|
-
|
|
1189
|
-
visitor.company = companyNames.value?.[0];
|
|
1190
|
-
}
|
|
1179
|
+
|
|
1191
1180
|
visitor.block = item.block ?? "";
|
|
1192
1181
|
visitor.level = item.level ?? "";
|
|
1193
1182
|
visitor.unit = item.unit ?? "";
|