hl-core 0.0.7 → 0.0.8-beta.10
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/.prettierrc +2 -1
- package/api/index.ts +562 -0
- package/api/interceptors.ts +38 -0
- package/components/Button/Btn.vue +57 -0
- package/components/Button/BtnIcon.vue +47 -0
- package/components/Button/ScrollButtons.vue +6 -0
- package/components/Button/SortArrow.vue +21 -0
- package/components/Complex/Content.vue +5 -0
- package/components/Complex/ContentBlock.vue +5 -0
- package/components/Complex/Page.vue +43 -0
- package/components/Dialog/Dialog.vue +76 -0
- package/components/Dialog/FamilyDialog.vue +39 -0
- package/components/Form/FormBlock.vue +139 -0
- package/components/Form/FormSection.vue +18 -0
- package/components/Form/FormTextSection.vue +20 -0
- package/components/Form/FormToggle.vue +52 -0
- package/components/Form/ManagerAttachment.vue +196 -0
- package/components/Form/ProductConditionsBlock.vue +72 -0
- package/components/Input/Datepicker.vue +41 -0
- package/components/Input/EmptyFormField.vue +5 -0
- package/components/Input/FileInput.vue +71 -0
- package/components/Input/FormInput.vue +183 -0
- package/components/Input/PanelInput.vue +133 -0
- package/components/Input/RoundedInput.vue +143 -0
- package/components/Layout/Drawer.vue +45 -0
- package/components/Layout/Header.vue +48 -0
- package/components/Layout/Loader.vue +35 -0
- package/components/Layout/SettingsPanel.vue +48 -0
- package/components/List/ListEmpty.vue +22 -0
- package/components/Menu/MenuNav.vue +108 -0
- package/components/Menu/MenuNavItem.vue +37 -0
- package/components/Pages/Anketa.vue +341 -0
- package/components/Pages/Auth.vue +91 -0
- package/components/Pages/Documents.vue +108 -0
- package/components/Pages/MemberForm.vue +1229 -0
- package/components/Pages/ProductAgreement.vue +18 -0
- package/components/Pages/ProductConditions.vue +659 -0
- package/components/Panel/PanelHandler.vue +233 -0
- package/components/Panel/PanelItem.vue +5 -0
- package/components/Panel/PanelSelectItem.vue +20 -0
- package/components/Transitions/FadeTransition.vue +5 -0
- package/components/Transitions/SlideTransition.vue +5 -0
- package/composables/axios.ts +11 -0
- package/composables/classes.ts +1179 -0
- package/composables/constants.ts +71 -0
- package/composables/index.ts +168 -2
- package/composables/styles.ts +48 -8
- package/configs/i18n.ts +19 -0
- package/layouts/clear.vue +3 -0
- package/layouts/default.vue +75 -0
- package/layouts/full.vue +6 -0
- package/locales/en.json +403 -0
- package/locales/kz.json +403 -0
- package/locales/ru.json +403 -0
- package/nuxt.config.ts +39 -5
- package/package.json +28 -10
- package/pages/500.vue +85 -0
- package/plugins/helperFunctionsPlugins.ts +19 -2
- package/plugins/storePlugin.ts +5 -7
- package/plugins/vuetifyPlugin.ts +15 -0
- package/store/data.store.js +2291 -8
- package/store/form.store.ts +8 -0
- package/store/member.store.ts +381 -0
- package/store/rules.js +52 -39
- package/tailwind.config.js +10 -0
- package/types/index.ts +317 -0
- package/app.vue +0 -3
- package/components/Button/GreenBtn.vue +0 -33
- package/store/app.store.js +0 -12
- package/store/messages.ts +0 -310
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { useDataStore } from './data.store';
|
|
3
|
+
import { useFormStore } from './form.store';
|
|
4
|
+
import { ErrorHandler } from '../composables';
|
|
5
|
+
import { AxiosError } from 'axios';
|
|
6
|
+
import { Member } from '../composables/classes';
|
|
7
|
+
|
|
8
|
+
export const useMemberStore = defineStore('members', {
|
|
9
|
+
state: () => ({
|
|
10
|
+
router: useRouter(),
|
|
11
|
+
dataStore: useDataStore(),
|
|
12
|
+
formStore: useFormStore(),
|
|
13
|
+
}),
|
|
14
|
+
actions: {
|
|
15
|
+
isStatementEditible(whichForm: string, showToaster: boolean = false) {
|
|
16
|
+
if (this.formStore.isDisabled[whichForm as keyof typeof this.formStore.isDisabled] === true) {
|
|
17
|
+
if (showToaster) this.dataStore.showToaster('error', this.dataStore.t('toaster.viewErrorText'), 2000);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
validateInitiator(showToaster: boolean = true) {
|
|
23
|
+
if (!this.dataStore.isInitiator()) {
|
|
24
|
+
if (showToaster) this.dataStore.showToaster('error', this.dataStore.t('toaster.viewErrorText'));
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
},
|
|
29
|
+
hasMemberData(whichForm: MemberKeys, whichIndex?: number, key: string = 'id', emptyValue: any = 0) {
|
|
30
|
+
if (!this.validateInitiator(false)) return false;
|
|
31
|
+
if (!this.isStatementEditible(whichForm)) return false;
|
|
32
|
+
return typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex][key] != emptyValue : this.formStore[whichForm][key] != emptyValue;
|
|
33
|
+
},
|
|
34
|
+
canMemberDeleted(whichForm: MemberKeys, whichIndex?: number) {
|
|
35
|
+
if (!whichForm) return false;
|
|
36
|
+
if (!this.isStatementEditible(whichForm)) return false;
|
|
37
|
+
if (!this.validateInitiator(false)) return false;
|
|
38
|
+
if (typeof whichIndex === 'number' && whichIndex > 0) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (this.dataStore.isTask() && this.dataStore.isProcessEditable(this.formStore.applicationData.statusCode)) {
|
|
42
|
+
if (whichForm !== this.formStore.policyholderFormKey) {
|
|
43
|
+
return this.hasMemberData(whichForm, whichIndex);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
},
|
|
48
|
+
getMemberFromStore(whichForm: MemberKeys, whichIndex?: number): Member | null {
|
|
49
|
+
switch (whichForm) {
|
|
50
|
+
case this.formStore.policyholderFormKey:
|
|
51
|
+
return this.formStore.policyholderForm;
|
|
52
|
+
case this.formStore.policyholdersRepresentativeFormKey:
|
|
53
|
+
return this.formStore.policyholdersRepresentativeForm;
|
|
54
|
+
case this.formStore.insuredFormKey:
|
|
55
|
+
return this.formStore.insuredForm[whichIndex!];
|
|
56
|
+
case this.formStore.beneficiaryFormKey:
|
|
57
|
+
return this.formStore.beneficiaryForm[whichIndex!];
|
|
58
|
+
case this.formStore.beneficialOwnerFormKey:
|
|
59
|
+
return this.formStore.beneficialOwnerForm[whichIndex!];
|
|
60
|
+
default:
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
getMemberFromApplication(whichForm: MemberKeys, whichIndex?: number) {
|
|
65
|
+
const id = typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex].id : this.formStore[whichForm].id;
|
|
66
|
+
switch (whichForm) {
|
|
67
|
+
case this.formStore.policyholderFormKey:
|
|
68
|
+
return this.formStore.applicationData.clientApp;
|
|
69
|
+
case this.formStore.policyholdersRepresentativeFormKey:
|
|
70
|
+
return this.formStore.applicationData.spokesmanApp;
|
|
71
|
+
case this.formStore.insuredFormKey: {
|
|
72
|
+
const inStore = this.formStore.applicationData.insuredApp.find((member: any) => member.insisId === id);
|
|
73
|
+
return !!inStore ? inStore : false;
|
|
74
|
+
}
|
|
75
|
+
case this.formStore.beneficiaryFormKey: {
|
|
76
|
+
const inStore = this.formStore.applicationData.beneficiaryApp.find((member: any) => member.insisId === id);
|
|
77
|
+
return !!inStore ? inStore : false;
|
|
78
|
+
}
|
|
79
|
+
case this.formStore.beneficialOwnerFormKey: {
|
|
80
|
+
const inStore = this.formStore.applicationData.beneficialOwnerApp.find((member: any) => member.insisId === id);
|
|
81
|
+
return !!inStore ? inStore : false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
getMemberClass(whichForm: MemberKeys) {
|
|
86
|
+
if (!whichForm) return false;
|
|
87
|
+
switch (whichForm) {
|
|
88
|
+
case this.formStore.policyholderFormKey:
|
|
89
|
+
return new PolicyholderForm();
|
|
90
|
+
case this.formStore.insuredFormKey:
|
|
91
|
+
return new InsuredForm();
|
|
92
|
+
case this.formStore.beneficiaryFormKey:
|
|
93
|
+
return new BeneficiaryForm();
|
|
94
|
+
case this.formStore.beneficialOwnerFormKey:
|
|
95
|
+
return new BeneficialOwnerForm();
|
|
96
|
+
case this.formStore.policyholdersRepresentativeFormKey:
|
|
97
|
+
return new PolicyholdersRepresentativeForm();
|
|
98
|
+
default:
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
getMemberCode(whichForm: MemberKeys) {
|
|
103
|
+
switch (whichForm) {
|
|
104
|
+
case this.formStore.policyholderFormKey:
|
|
105
|
+
return 'Client';
|
|
106
|
+
case this.formStore.insuredFormKey:
|
|
107
|
+
return 'Insured';
|
|
108
|
+
case this.formStore.beneficiaryFormKey:
|
|
109
|
+
return 'Beneficiary';
|
|
110
|
+
case this.formStore.beneficialOwnerFormKey:
|
|
111
|
+
return 'BeneficialOwner';
|
|
112
|
+
case this.formStore.policyholdersRepresentativeFormKey:
|
|
113
|
+
return 'Spokesman';
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
getMemberApplicationCode(whichForm: MemberKeys) {
|
|
117
|
+
switch (whichForm) {
|
|
118
|
+
case this.formStore.policyholderFormKey:
|
|
119
|
+
return 'clientApp';
|
|
120
|
+
case this.formStore.insuredFormKey:
|
|
121
|
+
return 'insuredApp';
|
|
122
|
+
case this.formStore.beneficiaryFormKey:
|
|
123
|
+
return 'beneficiaryApp';
|
|
124
|
+
case this.formStore.beneficialOwnerFormKey:
|
|
125
|
+
return 'beneficialOwnerApp';
|
|
126
|
+
case this.formStore.policyholdersRepresentativeFormKey:
|
|
127
|
+
return 'spokesmanApp';
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
clearMember(whichForm: MemberKeys, whichIndex?: number) {
|
|
131
|
+
if (!whichForm) return false;
|
|
132
|
+
if (!this.isStatementEditible(whichForm)) return false;
|
|
133
|
+
if (!this.validateInitiator()) return false;
|
|
134
|
+
if (whichForm === this.formStore.policyholderFormKey || whichForm === this.formStore.policyholdersRepresentativeFormKey) {
|
|
135
|
+
//@ts-ignore
|
|
136
|
+
this.formStore[whichForm] = this.getMemberClass(whichForm);
|
|
137
|
+
}
|
|
138
|
+
if (typeof whichIndex === 'number') {
|
|
139
|
+
if (this.formStore[whichForm].length === 1) {
|
|
140
|
+
this.formStore[whichForm][whichIndex] = this.getMemberClass(whichForm);
|
|
141
|
+
} else {
|
|
142
|
+
this.formStore[whichForm].splice(whichIndex, 1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
},
|
|
147
|
+
async deleteMember(taskId: string, whichForm: MemberKeys, whichIndex?: number, refetch: boolean = true) {
|
|
148
|
+
if (!whichForm) return false;
|
|
149
|
+
if (!this.isStatementEditible(whichForm)) return false;
|
|
150
|
+
if (!this.validateInitiator()) return false;
|
|
151
|
+
try {
|
|
152
|
+
const memberCode = this.getMemberCode(whichForm);
|
|
153
|
+
const memberData = this.getMemberFromApplication(whichForm, whichIndex);
|
|
154
|
+
if (!memberCode) return false;
|
|
155
|
+
if (typeof whichIndex !== 'number') {
|
|
156
|
+
if (whichForm === this.formStore.policyholdersRepresentativeFormKey) {
|
|
157
|
+
await this.dataStore.api.deleteMember(memberCode, this.formStore.applicationData.processInstanceId);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
if (memberData) await this.dataStore.api.deleteMember(memberCode, memberData.id as number);
|
|
161
|
+
}
|
|
162
|
+
if (memberData && refetch) await this.dataStore.getApplicationData(taskId, true, true, true, false);
|
|
163
|
+
return this.clearMember(whichForm, whichIndex);
|
|
164
|
+
} catch (err) {
|
|
165
|
+
console.log(err);
|
|
166
|
+
return ErrorHandler(err);
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
async transferPolicyholder(to: MemberKeys) {
|
|
170
|
+
if (!to) return false;
|
|
171
|
+
if (!this.validateInitiator()) return false;
|
|
172
|
+
const fromMember = this.formStore.policyholderForm;
|
|
173
|
+
const successTranser = ref<boolean>(false);
|
|
174
|
+
const toIndex = ref<number | null>(null);
|
|
175
|
+
const taskId = useRoute().params.taskId as string;
|
|
176
|
+
|
|
177
|
+
if (this.dataStore.members[this.getMemberApplicationCode(to)!].isMultiple === false) {
|
|
178
|
+
if (this.formStore[to][0].id !== 0 && this.formStore[to][0].iin !== fromMember.iin) {
|
|
179
|
+
await this.deleteMember(taskId, to, 0, false);
|
|
180
|
+
}
|
|
181
|
+
this.formStore[to][0] = fromMember;
|
|
182
|
+
toIndex.value = 0;
|
|
183
|
+
successTranser.value = true;
|
|
184
|
+
} else {
|
|
185
|
+
if (this.formStore[to].every((member: Member) => member.id !== 0)) {
|
|
186
|
+
this.formStore[to].push(fromMember);
|
|
187
|
+
toIndex.value = this.formStore[to].length - 1;
|
|
188
|
+
successTranser.value = true;
|
|
189
|
+
} else {
|
|
190
|
+
const index = this.formStore[to].findIndex((member: Member) => member.id === 0);
|
|
191
|
+
if (index !== -1) {
|
|
192
|
+
this.formStore[to][index] = fromMember;
|
|
193
|
+
toIndex.value = index;
|
|
194
|
+
successTranser.value = true;
|
|
195
|
+
} else {
|
|
196
|
+
this.formStore[to].push(fromMember);
|
|
197
|
+
toIndex.value = this.formStore[to].length - 1;
|
|
198
|
+
successTranser.value = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (successTranser.value === true) {
|
|
204
|
+
if (toIndex.value !== null && taskId !== '0' && this.formStore.applicationData.processInstanceId !== 0) {
|
|
205
|
+
const hasSaved = await this.dataStore.saveMember(this.formStore[to][toIndex.value], this.getMemberCode(to), this.getMemberFromApplication(to, toIndex.value));
|
|
206
|
+
if (hasSaved) {
|
|
207
|
+
await this.dataStore.getApplicationData(taskId, false, true, true, false);
|
|
208
|
+
this.dataStore.showToaster('success', this.dataStore.t('toaster.successSaved'));
|
|
209
|
+
this.dataStore.showToaster('warning', this.dataStore.t('toaster.formFieldEmptyWarning'), 3000);
|
|
210
|
+
return true;
|
|
211
|
+
} else {
|
|
212
|
+
this.dataStore.showToaster('error', this.dataStore.t('error.memberSave'));
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
this.dataStore.showToaster('error', this.dataStore.t('error.memberCopy'));
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
async retransferPolicyholder(from: MemberKeys) {
|
|
224
|
+
if (!from) return false;
|
|
225
|
+
if (!this.validateInitiator()) return false;
|
|
226
|
+
const client = this.formStore.policyholderForm;
|
|
227
|
+
const index = this.formStore[from].findIndex((member: Member) => member.id === client.id);
|
|
228
|
+
const taskId = useRoute().params.taskId as string;
|
|
229
|
+
if (index !== -1) {
|
|
230
|
+
const fromCode = this.getMemberApplicationCode(from);
|
|
231
|
+
const fromMember = this.formStore[from][index];
|
|
232
|
+
const applicationList = this.formStore.applicationData[fromCode!];
|
|
233
|
+
const fromIndex = applicationList && applicationList.length ? applicationList.findIndex((member: any) => member.insisId === fromMember.id) : null;
|
|
234
|
+
if (fromMember.id !== 0 && fromIndex !== -1) {
|
|
235
|
+
await this.deleteMember(taskId, from, index);
|
|
236
|
+
} else {
|
|
237
|
+
this.clearMember(from, index);
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
// @ts-ignore
|
|
241
|
+
this.formStore[from] = [this.getMemberClass(from)];
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
addMember(whichForm: MemberKeys) {
|
|
245
|
+
if (!whichForm) return false;
|
|
246
|
+
if (!this.isStatementEditible(whichForm)) return false;
|
|
247
|
+
if (!this.validateInitiator()) return false;
|
|
248
|
+
this.formStore[whichForm].push(this.getMemberClass(whichForm));
|
|
249
|
+
},
|
|
250
|
+
async getOtpStatus(iin: string, phone: string, processInstanceId: string | number | null = null) {
|
|
251
|
+
try {
|
|
252
|
+
const otpData = {
|
|
253
|
+
iin: iin.replace(/-/g, ''),
|
|
254
|
+
phoneNumber: formatPhone(phone),
|
|
255
|
+
type: 'AgreementOtp',
|
|
256
|
+
};
|
|
257
|
+
return await this.dataStore.api.getOtpStatus(
|
|
258
|
+
processInstanceId !== null && processInstanceId !== 0
|
|
259
|
+
? {
|
|
260
|
+
...otpData,
|
|
261
|
+
processInstanceId: processInstanceId,
|
|
262
|
+
}
|
|
263
|
+
: otpData,
|
|
264
|
+
);
|
|
265
|
+
} catch (err) {
|
|
266
|
+
return ErrorHandler(err);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
async checkOtp(member: Member) {
|
|
270
|
+
if (!member.otpTokenId || !member.otpCode || !member.phoneNumber) {
|
|
271
|
+
this.dataStore.showToaster('error', this.dataStore.t('error.noOtpCode'));
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
this.dataStore.isLoading = true;
|
|
276
|
+
const otpData = {
|
|
277
|
+
tokenId: member.otpTokenId,
|
|
278
|
+
phoneNumber: formatPhone(member.phoneNumber),
|
|
279
|
+
code: member.otpCode.replace(/\s/g, ''),
|
|
280
|
+
};
|
|
281
|
+
const otpResponse = await this.dataStore.api.checkOtp(otpData);
|
|
282
|
+
if (otpResponse !== null) {
|
|
283
|
+
if ('errMessage' in otpResponse && otpResponse.errMessage !== null) {
|
|
284
|
+
this.dataStore.showToaster('error', otpResponse.errMessage, 3000);
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if ('status' in otpResponse && !!otpResponse.status) {
|
|
288
|
+
// TODO Доработать и менять значение hasAgreement.value => true
|
|
289
|
+
this.dataStore.showToaster(otpResponse.status !== 2 ? 'error' : 'success', otpResponse.statusName, 3000);
|
|
290
|
+
if (otpResponse.status === 2) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return false;
|
|
296
|
+
} catch (err) {
|
|
297
|
+
ErrorHandler(err);
|
|
298
|
+
} finally {
|
|
299
|
+
this.dataStore.isLoading = false;
|
|
300
|
+
}
|
|
301
|
+
return null;
|
|
302
|
+
},
|
|
303
|
+
async sendOtp(member: Member, processInstanceId: string | number | null = null, onInit: boolean = false) {
|
|
304
|
+
if (!this.validateInitiator()) return null;
|
|
305
|
+
this.dataStore.isLoading = true;
|
|
306
|
+
let otpStatus: boolean = false;
|
|
307
|
+
let otpResponse: SendOtpResponse = {};
|
|
308
|
+
try {
|
|
309
|
+
if (member.iin && member.phoneNumber && member.iin.length === useMask().iin.length && member.phoneNumber.length === useMask().phone.length) {
|
|
310
|
+
const status = await this.getOtpStatus(member.iin, member.phoneNumber, processInstanceId);
|
|
311
|
+
if (status === true) {
|
|
312
|
+
this.dataStore.showToaster('success', this.dataStore.t('toaster.hasSuccessOtp'), 3000);
|
|
313
|
+
otpStatus = true;
|
|
314
|
+
this.dataStore.isLoading = false;
|
|
315
|
+
return { otpStatus, otpResponse };
|
|
316
|
+
} else if (status === false && onInit === false) {
|
|
317
|
+
const otpData = {
|
|
318
|
+
iin: member.iin.replace(/-/g, ''),
|
|
319
|
+
phoneNumber: formatPhone(member.phoneNumber),
|
|
320
|
+
type: 'AgreementOtp',
|
|
321
|
+
};
|
|
322
|
+
otpResponse = await this.dataStore.api.sendOtp(
|
|
323
|
+
processInstanceId !== null && processInstanceId !== 0
|
|
324
|
+
? {
|
|
325
|
+
...otpData,
|
|
326
|
+
processInstanceId: processInstanceId,
|
|
327
|
+
}
|
|
328
|
+
: otpData,
|
|
329
|
+
);
|
|
330
|
+
this.dataStore.isLoading = false;
|
|
331
|
+
if (!!otpResponse) {
|
|
332
|
+
if ('errMessage' in otpResponse && otpResponse.errMessage !== null) {
|
|
333
|
+
this.dataStore.showToaster('error', otpResponse.errMessage, 3000);
|
|
334
|
+
return { otpStatus };
|
|
335
|
+
}
|
|
336
|
+
if ('result' in otpResponse && otpResponse.result === null) {
|
|
337
|
+
if ('statusName' in otpResponse && !!otpResponse.statusName) {
|
|
338
|
+
this.dataStore.showToaster('error', otpResponse.statusName, 3000);
|
|
339
|
+
return { otpStatus };
|
|
340
|
+
}
|
|
341
|
+
if ('status' in otpResponse && !!otpResponse.status) {
|
|
342
|
+
this.dataStore.showToaster('error', otpResponse.status, 3000);
|
|
343
|
+
return { otpStatus };
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if ('tokenId' in otpResponse && otpResponse.tokenId) {
|
|
347
|
+
member.otpTokenId = otpResponse.tokenId;
|
|
348
|
+
this.dataStore.showToaster('success', this.dataStore.t('toaster.successOtp'), 3000);
|
|
349
|
+
}
|
|
350
|
+
} else {
|
|
351
|
+
this.dataStore.showToaster('error', this.dataStore.t('error.noOtpResponse'), 3000);
|
|
352
|
+
return { otpStatus };
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
if (onInit === false) {
|
|
357
|
+
this.dataStore.showToaster('error', this.dataStore.t('toaster.errorFormField', { text: 'Номер телефона, ИИН' }));
|
|
358
|
+
this.dataStore.isLoading = false;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return { otpStatus, otpResponse };
|
|
362
|
+
} catch (err) {
|
|
363
|
+
this.dataStore.isLoading = false;
|
|
364
|
+
if (err instanceof AxiosError)
|
|
365
|
+
if ('response' in err && err.response && err.response.data) {
|
|
366
|
+
if ('statusName' in err.response.data && !!err.response.data.statusName) {
|
|
367
|
+
this.dataStore.showToaster('error', this.dataStore.t('toaster.phoneNotFoundInBMG'), 3000);
|
|
368
|
+
return { otpStatus };
|
|
369
|
+
}
|
|
370
|
+
if ('status' in err.response.data && !!err.response.data.status) {
|
|
371
|
+
this.dataStore.showToaster('error', err.response.data.status, 3000);
|
|
372
|
+
return { otpStatus };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} finally {
|
|
376
|
+
this.dataStore.isLoading = false;
|
|
377
|
+
}
|
|
378
|
+
return { otpStatus, otpResponse };
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
});
|
package/store/rules.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i18n } from '@/configs/i18n';
|
|
2
|
+
import { formatDate } from '../composables';
|
|
3
|
+
|
|
4
|
+
const t = i18n.t;
|
|
2
5
|
|
|
3
6
|
export const rules = {
|
|
4
|
-
recalculationMultiply: [
|
|
5
|
-
|
|
6
|
-
(v !== null && v !== '' && v >= 100) ||
|
|
7
|
-
t('toaster.valueShouldBeHigher', { text: 100 }),
|
|
8
|
-
],
|
|
9
|
-
recalculationAdditive: [
|
|
10
|
-
v =>
|
|
11
|
-
(v !== null && v !== '' && v <= 100 && v >= 0) ||
|
|
12
|
-
t('toaster.valueShouldBeBetween', {
|
|
13
|
-
floor: 0,
|
|
14
|
-
ceil: 100,
|
|
15
|
-
}),
|
|
16
|
-
],
|
|
7
|
+
recalculationMultiply: [v => (v !== null && v !== '' && v >= 100) || t('toaster.valueShouldBeHigher', { text: '100' })],
|
|
8
|
+
recalculationAdditive: [v => (v !== null && v !== '' && v <= 100 && v >= 0) || t('toaster.valueShouldBeBetween', { floor: '0', ceil: '100' })],
|
|
17
9
|
required: [v => !!v || t('rules.required')],
|
|
18
10
|
objectRequired: [
|
|
19
11
|
v => {
|
|
@@ -23,20 +15,26 @@ export const rules = {
|
|
|
23
15
|
return t('rules.required');
|
|
24
16
|
},
|
|
25
17
|
],
|
|
18
|
+
agentDataRequired: [
|
|
19
|
+
v => {
|
|
20
|
+
if (!!v && 'fullName' in v && v.fullName != null) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return t('rules.required');
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
26
|
noResident: [
|
|
27
27
|
v => {
|
|
28
|
-
if (!!v && 'nameRu' in v && v.nameRu
|
|
28
|
+
if (!!v && 'nameRu' in v && v.nameRu === 'Нерезидент') {
|
|
29
29
|
return t('rules.noResident');
|
|
30
30
|
}
|
|
31
|
-
if (!!v && 'nameRu' in v && v.nameRu
|
|
31
|
+
if (!!v && 'nameRu' in v && !!v.nameRu) {
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
34
|
return t('rules.required');
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
|
-
cyrillic: [
|
|
38
|
-
v => v === null || /^[\u0400-\u04FF ]+$/.test(v) || t('rules.cyrillic'),
|
|
39
|
-
],
|
|
37
|
+
cyrillic: [v => v === null || /^[\u0400-\u04FF ]+$/.test(v) || t('rules.cyrillic')],
|
|
40
38
|
email: [
|
|
41
39
|
v => {
|
|
42
40
|
if (v === '' || v === null) {
|
|
@@ -45,9 +43,7 @@ export const rules = {
|
|
|
45
43
|
if (
|
|
46
44
|
String(v)
|
|
47
45
|
.toLowerCase()
|
|
48
|
-
.match(
|
|
49
|
-
/^(([^<>()[\]\\.,;=\s@"]+(\.[^<>()[\]\\.,;=\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
50
|
-
)
|
|
46
|
+
.match(/^(([^<>()[\]\\.,;=\s@"]+(\.[^<>()[\]\\.,;=\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)
|
|
51
47
|
) {
|
|
52
48
|
return true;
|
|
53
49
|
} else {
|
|
@@ -57,9 +53,7 @@ export const rules = {
|
|
|
57
53
|
},
|
|
58
54
|
],
|
|
59
55
|
numbers: [v => /^[0-9]+$/.test(v) || t('rules.numbers')],
|
|
60
|
-
numbersSymbols: [
|
|
61
|
-
v => /^([0-9])|(\W|_)+$/.test(v) || t('rules.numbersSymbols'),
|
|
62
|
-
],
|
|
56
|
+
numbersSymbols: [v => /^([0-9])|(\W|_)+$/.test(v) || t('rules.numbersSymbols')],
|
|
63
57
|
ageExceeds: [v => v < 50 || t('rules.ageExceeds')],
|
|
64
58
|
sums: [
|
|
65
59
|
v => {
|
|
@@ -72,7 +66,7 @@ export const rules = {
|
|
|
72
66
|
],
|
|
73
67
|
iinRight: [
|
|
74
68
|
v => {
|
|
75
|
-
if (v.length !==
|
|
69
|
+
if (v.length !== useMask().iin.length) {
|
|
76
70
|
return t('rules.iinRight');
|
|
77
71
|
}
|
|
78
72
|
return true;
|
|
@@ -84,7 +78,7 @@ export const rules = {
|
|
|
84
78
|
if (v === null || v == '') {
|
|
85
79
|
return true;
|
|
86
80
|
}
|
|
87
|
-
if (v && v.length ===
|
|
81
|
+
if (v && v.length === useMask().phone.length) {
|
|
88
82
|
return true;
|
|
89
83
|
} else {
|
|
90
84
|
return t('rules.phoneFormat');
|
|
@@ -94,11 +88,7 @@ export const rules = {
|
|
|
94
88
|
date: [
|
|
95
89
|
v => {
|
|
96
90
|
if (v === null || v == '') return true;
|
|
97
|
-
if (
|
|
98
|
-
/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(-|\.)(0[1-9]|1[0-2])(-|\.)(19[0-9]{2}|20[0-9][0-9])$/.test(
|
|
99
|
-
v,
|
|
100
|
-
)
|
|
101
|
-
) {
|
|
91
|
+
if (/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(-|\.)(0[1-9]|1[0-2])(-|\.)(19[0-9]{2}|20[0-9][0-9])$/.test(v)) {
|
|
102
92
|
return true;
|
|
103
93
|
} else {
|
|
104
94
|
return t('rules.date');
|
|
@@ -108,13 +98,8 @@ export const rules = {
|
|
|
108
98
|
age: [v => /^\d+$/.test(v) || t('rules.age')],
|
|
109
99
|
birthDate: [
|
|
110
100
|
v => {
|
|
111
|
-
if (new Date(formatDate(v)) > new Date(Date.now()))
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(-|\.)(0[1-9]|1[0-2])(-|\.)(19[0-9]{2}|20[0-9][0-9])$/.test(
|
|
115
|
-
v,
|
|
116
|
-
)
|
|
117
|
-
) {
|
|
101
|
+
if (new Date(formatDate(v)) > new Date(Date.now())) return t('rules.exceedDate');
|
|
102
|
+
if (/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(-|\.)(0[1-9]|1[0-2])(-|\.)(19[0-9]{2}|20[0-9][0-9])$/.test(v)) {
|
|
118
103
|
return true;
|
|
119
104
|
} else {
|
|
120
105
|
return t('rules.date');
|
|
@@ -128,6 +113,32 @@ export const rules = {
|
|
|
128
113
|
return t('rules.coverPeriod');
|
|
129
114
|
}
|
|
130
115
|
return true;
|
|
116
|
+
} else {
|
|
117
|
+
return t('rules.coverPeriod');
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
coverPeriodFrom2to20: [
|
|
122
|
+
v => {
|
|
123
|
+
if (v !== null) {
|
|
124
|
+
if (v < 2 || v > 20) {
|
|
125
|
+
return t('productConditionsForm.coverPeriodFrom2to20');
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
} else {
|
|
129
|
+
return t('productConditionsForm.coverPeriodFrom2to20');
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
coverPeriodFrom3to20: [
|
|
134
|
+
v => {
|
|
135
|
+
if (v !== null) {
|
|
136
|
+
if (v < 3 || v > 20) {
|
|
137
|
+
return t('productConditionsForm.coverPeriodFrom3to20');
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
} else {
|
|
141
|
+
return t('productConditionsForm.coverPeriodFrom3to20');
|
|
131
142
|
}
|
|
132
143
|
},
|
|
133
144
|
],
|
|
@@ -152,4 +163,6 @@ export const rules = {
|
|
|
152
163
|
}
|
|
153
164
|
},
|
|
154
165
|
],
|
|
166
|
+
policyholderAgeLimit: [v => v >= 18 || t('rules.policyholderAgeLimit')],
|
|
167
|
+
beneficiaryAgeLimit: [v => v <= 15 || t('rules.beneficiaryAgeLimit')],
|
|
155
168
|
};
|