hl-core 0.0.7-beta.2 → 0.0.7-beta.21
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 +323 -31
- package/api/interceptors.ts +10 -1
- package/components/Button/Btn.vue +7 -2
- package/components/Button/BtnIcon.vue +47 -0
- package/components/Button/ScrollButtons.vue +6 -0
- package/components/Complex/Content.vue +1 -1
- package/components/Complex/ContentBlock.vue +5 -0
- package/components/Complex/Page.vue +13 -2
- package/components/{Layout → Dialog}/Dialog.vue +7 -11
- package/components/Dialog/FamilyDialog.vue +39 -0
- package/components/Form/FormBlock.vue +114 -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/ProductConditionsBlock.vue +68 -0
- package/components/Input/EmptyFormField.vue +5 -0
- package/components/Input/FileInput.vue +71 -0
- package/components/Input/FormInput.vue +171 -0
- package/components/Input/PanelInput.vue +133 -0
- package/components/Input/RoundedInput.vue +40 -36
- package/components/Layout/Drawer.vue +44 -0
- package/components/Layout/Header.vue +26 -12
- package/components/Layout/Loader.vue +9 -6
- package/components/Layout/SettingsPanel.vue +48 -0
- package/components/List/ListEmpty.vue +22 -0
- package/components/Menu/MenuNav.vue +70 -30
- package/components/Menu/MenuNavItem.vue +8 -1
- package/components/Pages/Anketa.vue +333 -0
- package/components/Pages/Auth.vue +91 -0
- package/components/Pages/Documents.vue +108 -0
- package/components/Pages/MemberForm.vue +1138 -0
- package/components/Pages/ProductAgreement.vue +18 -0
- package/components/Pages/ProductConditions.vue +349 -0
- package/components/Panel/PanelItem.vue +5 -0
- package/components/Panel/PanelSelectItem.vue +20 -0
- package/components/Transitions/FadeTransition.vue +5 -0
- package/composables/classes.ts +413 -207
- package/composables/constants.ts +27 -12
- package/composables/index.ts +73 -35
- package/composables/styles.ts +31 -7
- package/layouts/clear.vue +1 -1
- package/layouts/default.vue +72 -6
- package/layouts/full.vue +6 -0
- package/nuxt.config.ts +5 -2
- package/package.json +17 -11
- package/pages/500.vue +85 -0
- package/plugins/helperFunctionsPlugins.ts +10 -2
- package/plugins/storePlugin.ts +6 -5
- package/store/data.store.js +1858 -527
- package/store/member.store.ts +291 -0
- package/store/messages.ts +152 -34
- package/store/rules.js +26 -28
- package/tailwind.config.js +10 -0
- package/types/index.ts +250 -0
- package/models/index.ts +0 -23
- /package/store/{form.store.js → form.store.ts} +0 -0
package/store/data.store.js
CHANGED
|
@@ -2,9 +2,10 @@ import { defineStore } from 'pinia';
|
|
|
2
2
|
import { t } from './messages';
|
|
3
3
|
import { rules } from './rules';
|
|
4
4
|
import { Toast, Types, Positions, ToastOptions } from './toast';
|
|
5
|
-
import { isValidGUID } from '../composables';
|
|
5
|
+
import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern, getNumber, getAgeByBirthDate } from '../composables';
|
|
6
6
|
import { DataStoreClass, Contragent } from '../composables/classes';
|
|
7
7
|
import { ApiClass } from '@/api';
|
|
8
|
+
import { useFormStore } from './form.store';
|
|
8
9
|
|
|
9
10
|
export const useDataStore = defineStore('data', {
|
|
10
11
|
state: () => ({
|
|
@@ -16,34 +17,63 @@ export const useDataStore = defineStore('data', {
|
|
|
16
17
|
toastPositions: Positions,
|
|
17
18
|
isValidGUID: isValidGUID,
|
|
18
19
|
router: useRouter(),
|
|
20
|
+
formStore: useFormStore(),
|
|
19
21
|
contragent: useContragentStore(),
|
|
20
22
|
api: new ApiClass(),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.toISOString()
|
|
24
|
-
.slice(0, -1),
|
|
23
|
+
yearEnding: year => yearEnding(year, constants.yearTitles, constants.yearCases),
|
|
24
|
+
currentDate: () => new Date(Date.now() - new Date().getTimezoneOffset() * 60 * 1000).toISOString().slice(0, -1),
|
|
25
25
|
showToaster: (type, msg, timeout) =>
|
|
26
26
|
Toast.useToast()(msg, {
|
|
27
27
|
...ToastOptions,
|
|
28
28
|
type: Types[type.toUpperCase()],
|
|
29
|
-
timeout:
|
|
30
|
-
typeof timeout === ('number' || 'boolean')
|
|
31
|
-
? timeout
|
|
32
|
-
: ToastOptions.timeout,
|
|
29
|
+
timeout: type === 'error' ? 6000 : typeof timeout === 'number' ? timeout : ToastOptions.timeout,
|
|
33
30
|
}),
|
|
34
31
|
}),
|
|
32
|
+
getters: {
|
|
33
|
+
isEFO: state => state.product === 'efo',
|
|
34
|
+
isBaiterek: state => state.product === 'baiterek',
|
|
35
|
+
isBolashak: state => state.product === 'bolashak',
|
|
36
|
+
isMycar: state => state.product === 'mycar',
|
|
37
|
+
isLifetrip: state => state.product === 'lifetrip',
|
|
38
|
+
isLiferenta: state => state.product === 'liferenta',
|
|
39
|
+
isPension: state => state.product === 'pension',
|
|
40
|
+
isGons: state => state.product === 'gons',
|
|
41
|
+
isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
|
|
42
|
+
},
|
|
35
43
|
actions: {
|
|
44
|
+
isIframe() {
|
|
45
|
+
try {
|
|
46
|
+
return window.self !== window.top;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
sendToParent(action, value) {
|
|
52
|
+
window.parent.postMessage({ action: action, value: value }, '*');
|
|
53
|
+
},
|
|
54
|
+
getChildIframe() {
|
|
55
|
+
return document.getElementById('product-iframe');
|
|
56
|
+
},
|
|
57
|
+
sendToChild(action, value) {
|
|
58
|
+
const childFrame = this.getChildIframe();
|
|
59
|
+
if (childFrame && childFrame.contentWindow && childFrame.contentWindow.postMessage) {
|
|
60
|
+
childFrame.contentWindow.postMessage({ action: action, value: value }, '*');
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
getFilesByIIN(iin) {
|
|
64
|
+
return iin ? this.formStore.signedDocumentList.filter(file => file.iin === iin && file.fileTypeName === 'Удостоверение личности') : null;
|
|
65
|
+
},
|
|
36
66
|
async getNewAccessToken() {
|
|
37
67
|
try {
|
|
38
68
|
const data = {
|
|
39
|
-
accessToken:
|
|
40
|
-
refreshToken:
|
|
69
|
+
accessToken: localStorage.getItem('accessToken'),
|
|
70
|
+
refreshToken: localStorage.getItem('refreshToken'),
|
|
41
71
|
};
|
|
42
72
|
const response = await this.api.getNewAccessToken(data);
|
|
43
73
|
this.accessToken = response.accessToken;
|
|
44
74
|
this.refreshToken = response.refreshToken;
|
|
45
|
-
localStorage.setItem('accessToken',
|
|
46
|
-
localStorage.setItem('refreshToken',
|
|
75
|
+
localStorage.setItem('accessToken', this.accessToken);
|
|
76
|
+
localStorage.setItem('refreshToken', this.refreshToken);
|
|
47
77
|
} catch (err) {
|
|
48
78
|
console.error(err);
|
|
49
79
|
}
|
|
@@ -62,8 +92,7 @@ export const useDataStore = defineStore('data', {
|
|
|
62
92
|
},
|
|
63
93
|
async loginUser(login, password, numAttempt) {
|
|
64
94
|
try {
|
|
65
|
-
const token =
|
|
66
|
-
|
|
95
|
+
const token = localStorage.getItem('accessToken') || null;
|
|
67
96
|
if (token && isValidToken(token)) {
|
|
68
97
|
this.accessToken = token;
|
|
69
98
|
this.getUserRoles();
|
|
@@ -78,42 +107,38 @@ export const useDataStore = defineStore('data', {
|
|
|
78
107
|
this.refreshToken = response.refreshToken;
|
|
79
108
|
this.getUserRoles();
|
|
80
109
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
'
|
|
94
|
-
|
|
95
|
-
|
|
110
|
+
if (this.controls.onAuth) {
|
|
111
|
+
const hasPermission =
|
|
112
|
+
this.isInitiator() ||
|
|
113
|
+
this.isUnderwriter() ||
|
|
114
|
+
this.isAdmin() ||
|
|
115
|
+
this.isCompliance() ||
|
|
116
|
+
this.isAnalyst() ||
|
|
117
|
+
this.isUpk() ||
|
|
118
|
+
this.isFinanceCenter() ||
|
|
119
|
+
this.isSupervisor() ||
|
|
120
|
+
this.isSupport();
|
|
121
|
+
if (hasPermission) {
|
|
122
|
+
localStorage.setItem('accessToken', this.accessToken);
|
|
123
|
+
localStorage.setItem('refreshToken', this.refreshToken);
|
|
124
|
+
} else {
|
|
125
|
+
this.showToaster('error', this.t('toaster.noProductPermission'), 5000);
|
|
126
|
+
this.accessToken = null;
|
|
127
|
+
this.refreshToken = null;
|
|
128
|
+
}
|
|
96
129
|
} else {
|
|
97
|
-
this.
|
|
98
|
-
|
|
99
|
-
this.t('toaster.noProductPermission'),
|
|
100
|
-
5000,
|
|
101
|
-
);
|
|
130
|
+
localStorage.setItem('accessToken', this.accessToken);
|
|
131
|
+
localStorage.setItem('refreshToken', this.refreshToken);
|
|
102
132
|
}
|
|
103
133
|
} catch (err) {
|
|
104
|
-
|
|
105
|
-
if ('response' in err) {
|
|
106
|
-
this.showToaster('error', err.response.data, 3000);
|
|
107
|
-
}
|
|
134
|
+
ErrorHandler(err);
|
|
108
135
|
}
|
|
109
136
|
},
|
|
110
137
|
getUserRoles() {
|
|
111
138
|
if (this.accessToken && this.user.roles.length === 0) {
|
|
112
139
|
const decoded = jwtDecode(this.accessToken);
|
|
113
140
|
this.user.id = decoded.sub;
|
|
114
|
-
this.user.fullName = `${decoded.lastName} ${decoded.firstName} ${
|
|
115
|
-
decoded.middleName ? decoded.middleName : ''
|
|
116
|
-
}`;
|
|
141
|
+
this.user.fullName = `${decoded.lastName} ${decoded.firstName} ${decoded.middleName ? decoded.middleName : ''}`;
|
|
117
142
|
const key = getKeyWithPattern(decoded, 'role');
|
|
118
143
|
if (key) {
|
|
119
144
|
const roles = decoded[key];
|
|
@@ -133,11 +158,7 @@ export const useDataStore = defineStore('data', {
|
|
|
133
158
|
return !!isRole;
|
|
134
159
|
},
|
|
135
160
|
isInitiator() {
|
|
136
|
-
return (
|
|
137
|
-
this.isRole(constants.roles.manager) ||
|
|
138
|
-
this.isRole(constants.roles.agent) ||
|
|
139
|
-
this.isRole(constants.roles.agentMycar)
|
|
140
|
-
);
|
|
161
|
+
return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank() || this.isServiceManager();
|
|
141
162
|
},
|
|
142
163
|
isManager() {
|
|
143
164
|
return this.isRole(constants.roles.manager);
|
|
@@ -151,6 +172,12 @@ export const useDataStore = defineStore('data', {
|
|
|
151
172
|
isAgent() {
|
|
152
173
|
return this.isRole(constants.roles.agent);
|
|
153
174
|
},
|
|
175
|
+
isManagerHalykBank() {
|
|
176
|
+
return this.isRole(constants.roles.managerHalykBank);
|
|
177
|
+
},
|
|
178
|
+
isServiceManager() {
|
|
179
|
+
return this.isRole(constants.roles.serviceManager);
|
|
180
|
+
},
|
|
154
181
|
isUnderwriter() {
|
|
155
182
|
return this.isRole(constants.roles.underwriter);
|
|
156
183
|
},
|
|
@@ -163,18 +190,47 @@ export const useDataStore = defineStore('data', {
|
|
|
163
190
|
isUpk() {
|
|
164
191
|
return this.isRole(constants.roles.upk);
|
|
165
192
|
},
|
|
193
|
+
isSupport() {
|
|
194
|
+
return this.isRole(constants.roles.support);
|
|
195
|
+
},
|
|
196
|
+
isFinanceCenter() {
|
|
197
|
+
return this.isRole(constants.roles.financeCenter);
|
|
198
|
+
},
|
|
199
|
+
isSupervisor() {
|
|
200
|
+
return this.isRole(constants.roles.supervisor);
|
|
201
|
+
},
|
|
166
202
|
isProcessEditable(statusCode) {
|
|
167
203
|
return !!constants.editableStatuses.find(status => status === statusCode);
|
|
168
204
|
},
|
|
205
|
+
isTask() {
|
|
206
|
+
return this.formStore.applicationData.processInstanceId !== 0 && this.formStore.applicationData.isTask;
|
|
207
|
+
},
|
|
208
|
+
async resetSelected(route) {
|
|
209
|
+
this.settings.open = false;
|
|
210
|
+
this.panel.open = false;
|
|
211
|
+
this.panelAction = null;
|
|
212
|
+
this.menu.selectedItem = new MenuItem();
|
|
213
|
+
if (route && route.name) {
|
|
214
|
+
await this.router.replace({ name: route.name });
|
|
215
|
+
}
|
|
216
|
+
},
|
|
169
217
|
async logoutUser() {
|
|
170
218
|
this.isLoading = true;
|
|
171
219
|
try {
|
|
172
|
-
const
|
|
220
|
+
const whichProduct = this.product;
|
|
221
|
+
const token = localStorage.getItem('accessToken') || null;
|
|
173
222
|
if (token) {
|
|
174
223
|
this.$reset();
|
|
175
224
|
localStorage.clear();
|
|
225
|
+
|
|
226
|
+
if (whichProduct === 'efo') {
|
|
227
|
+
await this.router.push({ name: 'Auth' });
|
|
228
|
+
} else {
|
|
229
|
+
this.sendToParent(constants.postActions.toAuth, null);
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
this.showToaster('error', this.t('toaster.undefinedError'), 3000);
|
|
176
233
|
}
|
|
177
|
-
await this.router.push({ name: 'Auth' });
|
|
178
234
|
} catch (err) {
|
|
179
235
|
console.log(err);
|
|
180
236
|
}
|
|
@@ -187,11 +243,17 @@ export const useDataStore = defineStore('data', {
|
|
|
187
243
|
if (!['pdf', 'docx'].includes(fileType)) {
|
|
188
244
|
const blob = new Blob([response], { type: `image/${fileType}` });
|
|
189
245
|
const url = window.URL.createObjectURL(blob);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
246
|
+
const link = document.createElement('a');
|
|
247
|
+
link.href = url;
|
|
248
|
+
if (mode === 'view') {
|
|
249
|
+
setTimeout(() => {
|
|
250
|
+
window.open(url, '_blank', `width=${screen.width},height=${screen.height},top=70`);
|
|
251
|
+
});
|
|
252
|
+
} else {
|
|
253
|
+
link.setAttribute('download', file.fileName);
|
|
254
|
+
document.body.appendChild(link);
|
|
255
|
+
link.click();
|
|
256
|
+
}
|
|
195
257
|
} else {
|
|
196
258
|
const blob = new Blob([response], {
|
|
197
259
|
type: `application/${fileType}`,
|
|
@@ -211,31 +273,78 @@ export const useDataStore = defineStore('data', {
|
|
|
211
273
|
}
|
|
212
274
|
});
|
|
213
275
|
} catch (err) {
|
|
214
|
-
|
|
276
|
+
ErrorHandler(err);
|
|
215
277
|
} finally {
|
|
216
278
|
this.isLoading = false;
|
|
217
279
|
}
|
|
218
280
|
},
|
|
219
|
-
async
|
|
281
|
+
async deleteFile(data) {
|
|
220
282
|
try {
|
|
221
|
-
|
|
222
|
-
|
|
283
|
+
await this.api.deleteFile(data);
|
|
284
|
+
this.showToaster('success', this.t('toaster.fileWasDeleted'), 3000);
|
|
285
|
+
} catch (err) {
|
|
286
|
+
this.showToaster('error', err.response.data, 2000);
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
async uploadFiles(data, load = false) {
|
|
290
|
+
try {
|
|
291
|
+
if (load) {
|
|
292
|
+
this.isLoading = true;
|
|
293
|
+
}
|
|
294
|
+
await this.api.uploadFiles(data);
|
|
295
|
+
return true;
|
|
296
|
+
} catch (err) {
|
|
297
|
+
return ErrorHandler(err);
|
|
298
|
+
} finally {
|
|
299
|
+
if (load) {
|
|
300
|
+
this.isLoading = false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
async getContragent(member, whichForm, whichIndex, load = true) {
|
|
305
|
+
if (load) {
|
|
306
|
+
this.isLoading = true;
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
let response;
|
|
310
|
+
let queryData = {
|
|
311
|
+
firstName: '',
|
|
312
|
+
lastName: '',
|
|
313
|
+
middleName: '',
|
|
314
|
+
};
|
|
315
|
+
queryData.iin = member.iin.replace(/-/g, '');
|
|
316
|
+
response = await this.api.getContragent(queryData);
|
|
317
|
+
if (response.totalItems > 0) {
|
|
318
|
+
if (response.totalItems.length === 1) {
|
|
319
|
+
await this.serializeContragentData(whichForm, response.items[0], whichIndex);
|
|
320
|
+
} else {
|
|
321
|
+
const sortedByRegistrationDate = response.items.sort((left, right) => new Date(right.registrationDate) - new Date(left.registrationDate));
|
|
322
|
+
await this.serializeContragentData(whichForm, sortedByRegistrationDate[0], whichIndex);
|
|
323
|
+
}
|
|
324
|
+
member.gotFromInsis = true;
|
|
223
325
|
} else {
|
|
224
|
-
this.
|
|
225
|
-
return this.dicFileTypeList;
|
|
326
|
+
this.userNotFound = true;
|
|
226
327
|
}
|
|
227
328
|
} catch (err) {
|
|
228
|
-
console.log(err
|
|
329
|
+
console.log(err);
|
|
330
|
+
}
|
|
331
|
+
if (load) {
|
|
332
|
+
this.isLoading = false;
|
|
229
333
|
}
|
|
230
334
|
},
|
|
231
|
-
async getContragentById(id, onlyGet = true) {
|
|
335
|
+
async getContragentById(id, whichForm, onlyGet = true, whichIndex = null) {
|
|
232
336
|
if (onlyGet) {
|
|
233
337
|
this.isLoading = true;
|
|
234
338
|
}
|
|
235
339
|
try {
|
|
340
|
+
if (this.isMycar && this.isAgentMycar() && whichForm === this.formStore.beneficiaryFormKey) {
|
|
341
|
+
await this.serializeContragentData(whichForm, this.formStore.applicationData.beneficiaryApp[0], whichIndex);
|
|
342
|
+
this.isLoading = false;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
236
345
|
const response = await this.api.getContragentById(id);
|
|
237
346
|
if (response.totalItems > 0) {
|
|
238
|
-
await this.serializeContragentData(response.items[0]);
|
|
347
|
+
await this.serializeContragentData(whichForm, response.items[0], whichIndex);
|
|
239
348
|
} else {
|
|
240
349
|
this.isLoading = false;
|
|
241
350
|
return false;
|
|
@@ -247,40 +356,58 @@ export const useDataStore = defineStore('data', {
|
|
|
247
356
|
this.isLoading = false;
|
|
248
357
|
}
|
|
249
358
|
},
|
|
250
|
-
async serializeContragentData(contragent) {
|
|
251
|
-
const [
|
|
252
|
-
{ value: data },
|
|
253
|
-
{ value: contacts },
|
|
254
|
-
{ value: documents },
|
|
255
|
-
{ value: address },
|
|
256
|
-
] = await Promise.allSettled([
|
|
359
|
+
async serializeContragentData(whichForm, contragent, whichIndex = null) {
|
|
360
|
+
const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
|
|
257
361
|
this.api.getContrAgentData(contragent.id),
|
|
258
362
|
this.api.getContrAgentContacts(contragent.id),
|
|
259
363
|
this.api.getContrAgentDocuments(contragent.id),
|
|
260
364
|
this.api.getContrAgentAddress(contragent.id),
|
|
261
365
|
]);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
366
|
+
if (whichIndex === null) {
|
|
367
|
+
this.formStore[whichForm].response = {
|
|
368
|
+
contragent: contragent,
|
|
369
|
+
};
|
|
370
|
+
if (data && data.length) {
|
|
371
|
+
this.formStore[whichForm].response.questionnaires = data;
|
|
372
|
+
}
|
|
373
|
+
if (contacts && contacts.length) {
|
|
374
|
+
this.formStore[whichForm].response.contacts = contacts;
|
|
375
|
+
}
|
|
376
|
+
if (documents && documents.length) {
|
|
377
|
+
this.formStore[whichForm].response.documents = documents;
|
|
378
|
+
}
|
|
379
|
+
if (address && address.length) {
|
|
380
|
+
this.formStore[whichForm].response.addresses = address;
|
|
381
|
+
}
|
|
273
382
|
}
|
|
274
|
-
if (
|
|
275
|
-
this.
|
|
383
|
+
if (whichIndex !== null) {
|
|
384
|
+
this.formStore[whichForm][whichIndex].response = {
|
|
385
|
+
contragent: contragent,
|
|
386
|
+
};
|
|
387
|
+
if (data && data.length) {
|
|
388
|
+
this.formStore[whichForm][whichIndex].response.questionnaires = data;
|
|
389
|
+
}
|
|
390
|
+
if (contacts && contacts.length) {
|
|
391
|
+
this.formStore[whichForm][whichIndex].response.contacts = contacts;
|
|
392
|
+
}
|
|
393
|
+
if (documents && documents.length) {
|
|
394
|
+
this.formStore[whichForm][whichIndex].response.documents = documents;
|
|
395
|
+
}
|
|
396
|
+
if (address && address.length) {
|
|
397
|
+
this.formStore[whichForm][whichIndex].response.addresses = address;
|
|
398
|
+
}
|
|
276
399
|
}
|
|
277
|
-
this.parseContragent(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
400
|
+
this.parseContragent(
|
|
401
|
+
whichForm,
|
|
402
|
+
{
|
|
403
|
+
personalData: contragent,
|
|
404
|
+
documents: documents,
|
|
405
|
+
contacts: contacts,
|
|
406
|
+
data: data,
|
|
407
|
+
address: address,
|
|
408
|
+
},
|
|
409
|
+
whichIndex,
|
|
410
|
+
);
|
|
284
411
|
},
|
|
285
412
|
async searchContragent(iin) {
|
|
286
413
|
this.isLoading = true;
|
|
@@ -303,133 +430,142 @@ export const useDataStore = defineStore('data', {
|
|
|
303
430
|
}
|
|
304
431
|
this.isLoading = false;
|
|
305
432
|
},
|
|
306
|
-
parseContragent(user) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
user.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
this.
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
this.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
433
|
+
parseContragent(whichForm, user, whichIndex = null) {
|
|
434
|
+
if (whichIndex === null) {
|
|
435
|
+
// Save User Personal Data
|
|
436
|
+
this.formStore[whichForm].verifyType = user.personalData.verifyType;
|
|
437
|
+
this.formStore[whichForm].verifyDate = user.personalData.verifyDate;
|
|
438
|
+
this.formStore[whichForm].iin = reformatIin(user.personalData.iin);
|
|
439
|
+
this.formStore[whichForm].age = user.personalData.age;
|
|
440
|
+
const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
|
|
441
|
+
this.formStore[whichForm].birthPlace = country && Object.keys(country).length ? country : new Value();
|
|
442
|
+
this.formStore[whichForm].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
|
|
443
|
+
this.formStore[whichForm].gender.id = user.personalData.gender;
|
|
444
|
+
this.formStore[whichForm].birthDate = reformatDate(user.personalData.birthDate);
|
|
445
|
+
this.formStore[whichForm].genderName = user.personalData.genderName;
|
|
446
|
+
this.formStore[whichForm].lastName = user.personalData.lastName;
|
|
447
|
+
this.formStore[whichForm].longName = user.personalData.longName;
|
|
448
|
+
this.formStore[whichForm].middleName = user.personalData.middleName ? user.personalData.middleName : '';
|
|
449
|
+
this.formStore[whichForm].firstName = user.personalData.firstName;
|
|
450
|
+
this.formStore[whichForm].id = user.personalData.id;
|
|
451
|
+
this.formStore[whichForm].type = user.personalData.type;
|
|
452
|
+
this.formStore[whichForm].registrationDate = user.personalData.registrationDate;
|
|
453
|
+
// Save User Documents Data
|
|
454
|
+
if ('documents' in user && user.documents.length) {
|
|
455
|
+
const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
|
|
456
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
|
|
457
|
+
this.formStore[whichForm].documentType = documentType ? documentType : new Value();
|
|
458
|
+
this.formStore[whichForm].documentNumber = user.documents[0].number;
|
|
459
|
+
this.formStore[whichForm].documentIssuers = documentIssuer ? documentIssuer : new Value();
|
|
460
|
+
this.formStore[whichForm].documentDate = reformatDate(user.documents[0].issueDate);
|
|
461
|
+
this.formStore[whichForm].documentExpire = reformatDate(user.documents[0].expireDate);
|
|
462
|
+
}
|
|
463
|
+
// Document detail (residency, economy code, etc..)
|
|
464
|
+
if ('data' in user && user.data.length) {
|
|
465
|
+
user.data.forEach(dataObject => {
|
|
466
|
+
this.searchFromList(whichForm, dataObject);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
if ('address' in user && user.address.length) {
|
|
470
|
+
const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
|
|
471
|
+
const province = this.states.find(i => i.ids === user.address[0].stateCode);
|
|
472
|
+
const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
|
|
473
|
+
const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
|
|
474
|
+
const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
|
|
475
|
+
this.formStore[whichForm].registrationCountry = country ? country : new Value();
|
|
476
|
+
this.formStore[whichForm].registrationStreet = user.address[0].streetName;
|
|
477
|
+
this.formStore[whichForm].registrationCity = city ? city : new Value();
|
|
478
|
+
this.formStore[whichForm].registrationNumberApartment = user.address[0].apartmentNumber;
|
|
479
|
+
this.formStore[whichForm].registrationNumberHouse = user.address[0].blockNumber;
|
|
480
|
+
this.formStore[whichForm].registrationProvince = province ? province : new Value();
|
|
481
|
+
this.formStore[whichForm].registrationRegionType = localityType ? localityType : new Value();
|
|
482
|
+
this.formStore[whichForm].registrationRegion = region ? region : new Value();
|
|
483
|
+
this.formStore[whichForm].registrationQuarter = user.address[0].kvartal;
|
|
484
|
+
this.formStore[whichForm].registrationMicroDistrict = user.address[0].microRaion;
|
|
485
|
+
}
|
|
486
|
+
if ('contacts' in user && user.contacts.length) {
|
|
487
|
+
user.contacts.forEach(contact => {
|
|
488
|
+
if (contact.type === 'EMAIL' && contact.value) {
|
|
489
|
+
this.formStore[whichForm].email = contact.value;
|
|
490
|
+
}
|
|
491
|
+
if (contact.type === 'MOBILE' && contact.value) {
|
|
492
|
+
let phoneNumber = contact.value.substring(1);
|
|
493
|
+
this.formStore[whichForm].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
|
|
494
|
+
}
|
|
495
|
+
if (contact.type === 'HOME' && contact.value) {
|
|
496
|
+
let homePhone = contact.value.substring(1);
|
|
497
|
+
this.formStore[whichForm].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
372
501
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
this.
|
|
391
|
-
this.
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
user.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
: new Value();
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
user.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
)
|
|
431
|
-
|
|
432
|
-
|
|
502
|
+
if (whichIndex !== null) {
|
|
503
|
+
// Save User Personal Data
|
|
504
|
+
this.formStore[whichForm][whichIndex].iin = reformatIin(user.personalData.iin);
|
|
505
|
+
this.formStore[whichForm][whichIndex].verifyType = user.personalData.verifyType;
|
|
506
|
+
this.formStore[whichForm][whichIndex].verifyDate = user.personalData.verifyDate;
|
|
507
|
+
this.formStore[whichForm][whichIndex].age = user.personalData.age;
|
|
508
|
+
const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.personalData.birthPlace, 'i')));
|
|
509
|
+
this.formStore[whichForm][whichIndex].birthPlace = country && Object.keys(country).length ? country : new Value();
|
|
510
|
+
this.formStore[whichForm][whichIndex].gender = this.gender.find(i => i.nameRu === user.personalData.genderName);
|
|
511
|
+
this.formStore[whichForm][whichIndex].gender.id = user.personalData.gender;
|
|
512
|
+
this.formStore[whichForm][whichIndex].birthDate = reformatDate(user.personalData.birthDate);
|
|
513
|
+
this.formStore[whichForm][whichIndex].genderName = user.personalData.genderName;
|
|
514
|
+
this.formStore[whichForm][whichIndex].lastName = user.personalData.lastName;
|
|
515
|
+
this.formStore[whichForm][whichIndex].longName = user.personalData.longName;
|
|
516
|
+
this.formStore[whichForm][whichIndex].middleName = user.personalData.middleName ? user.personalData.middleName : '';
|
|
517
|
+
this.formStore[whichForm][whichIndex].firstName = user.personalData.firstName;
|
|
518
|
+
this.formStore[whichForm][whichIndex].id = user.personalData.id;
|
|
519
|
+
this.formStore[whichForm][whichIndex].type = user.personalData.type;
|
|
520
|
+
this.formStore[whichForm][whichIndex].registrationDate = user.personalData.registrationDate;
|
|
521
|
+
// Save User Documents Data
|
|
522
|
+
if ('documents' in user && user.documents.length) {
|
|
523
|
+
const documentType = this.documentTypes.find(i => i.ids === user.documents[0].type);
|
|
524
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu === user.documents[0].issuerNameRu);
|
|
525
|
+
this.formStore[whichForm][whichIndex].documentType = documentType ? documentType : new Value();
|
|
526
|
+
this.formStore[whichForm][whichIndex].documentNumber = user.documents[0].number;
|
|
527
|
+
this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer ? documentIssuer : new Value();
|
|
528
|
+
this.formStore[whichForm][whichIndex].documentDate = reformatDate(user.documents[0].issueDate);
|
|
529
|
+
this.formStore[whichForm][whichIndex].documentExpire = reformatDate(user.documents[0].expireDate);
|
|
530
|
+
}
|
|
531
|
+
// Document detail (residency, economy code, etc..)
|
|
532
|
+
if ('data' in user && user.data.length) {
|
|
533
|
+
user.data.forEach(dataObject => {
|
|
534
|
+
this.searchFromList(whichForm, dataObject, whichIndex);
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
if ('address' in user && user.address.length) {
|
|
538
|
+
const country = this.countries.find(i => i.nameRu?.match(new RegExp(user.address.countryName, 'i')));
|
|
539
|
+
const province = this.states.find(i => i.ids === user.address[0].stateCode);
|
|
540
|
+
const localityType = this.localityTypes.find(i => i.nameRu === user.address[0].cityTypeName);
|
|
541
|
+
const city = this.cities.find(i => !!user.address[0].cityName && i.nameRu === user.address[0].cityName.replace('г.', ''));
|
|
542
|
+
const region = this.regions.find(i => !!user.address[0].regionCode && i.ids == user.address[0].regionCode);
|
|
543
|
+
this.formStore[whichForm][whichIndex].registrationCountry = country ? country : new Value();
|
|
544
|
+
this.formStore[whichForm][whichIndex].registrationStreet = user.address[0].streetName;
|
|
545
|
+
this.formStore[whichForm][whichIndex].registrationCity = city ? city : new Value();
|
|
546
|
+
this.formStore[whichForm][whichIndex].registrationNumberApartment = user.address[0].apartmentNumber;
|
|
547
|
+
this.formStore[whichForm][whichIndex].registrationNumberHouse = user.address[0].blockNumber;
|
|
548
|
+
this.formStore[whichForm][whichIndex].registrationProvince = province ? province : new Value();
|
|
549
|
+
this.formStore[whichForm][whichIndex].registrationRegionType = localityType ? localityType : new Value();
|
|
550
|
+
this.formStore[whichForm][whichIndex].registrationRegion = region ? region : new Value();
|
|
551
|
+
this.formStore[whichForm][whichIndex].registrationQuarter = user.address[0].kvartal;
|
|
552
|
+
this.formStore[whichForm][whichIndex].registrationMicroDistrict = user.address[0].microRaion;
|
|
553
|
+
}
|
|
554
|
+
if ('contacts' in user && user.contacts.length) {
|
|
555
|
+
user.contacts.forEach(contact => {
|
|
556
|
+
if (contact.type === 'EMAIL' && contact.value) {
|
|
557
|
+
this.formStore[whichForm][whichIndex].email = contact.value;
|
|
558
|
+
}
|
|
559
|
+
if (contact.type === 'MOBILE' && contact.value) {
|
|
560
|
+
let phoneNumber = contact.value.substring(1);
|
|
561
|
+
this.formStore[whichForm][whichIndex].phoneNumber = `+7 (${phoneNumber.slice(0, 3)}) ${phoneNumber.slice(3, 6)} ${phoneNumber.slice(6, 8)} ${phoneNumber.slice(8)}`;
|
|
562
|
+
}
|
|
563
|
+
if (contact.type === 'HOME' && contact.value) {
|
|
564
|
+
let homePhone = contact.value.substring(1);
|
|
565
|
+
this.formStore[whichForm][whichIndex].homePhone = `+7 (${homePhone.slice(0, 3)}) ${homePhone.slice(3, 6)} ${homePhone.slice(6, 8)} ${homePhone.slice(8)}`;
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
433
569
|
}
|
|
434
570
|
},
|
|
435
571
|
async alreadyInInsis(iin, firstName, lastName, middleName) {
|
|
@@ -445,11 +581,7 @@ export const useDataStore = defineStore('data', {
|
|
|
445
581
|
if (contragent.totalItems.length === 1) {
|
|
446
582
|
return contragent.items[0].id;
|
|
447
583
|
} else {
|
|
448
|
-
const sortedByRegistrationDate = contragent.items.sort(
|
|
449
|
-
(left, right) =>
|
|
450
|
-
new Date(right.registrationDate) -
|
|
451
|
-
new Date(left.registrationDate),
|
|
452
|
-
);
|
|
584
|
+
const sortedByRegistrationDate = contragent.items.sort((left, right) => new Date(right.registrationDate) - new Date(left.registrationDate));
|
|
453
585
|
return sortedByRegistrationDate[0].id;
|
|
454
586
|
}
|
|
455
587
|
} else {
|
|
@@ -460,54 +592,38 @@ export const useDataStore = defineStore('data', {
|
|
|
460
592
|
return false;
|
|
461
593
|
}
|
|
462
594
|
},
|
|
463
|
-
async saveContragent(user, onlySaveAction = true) {
|
|
464
|
-
this.isLoading =
|
|
465
|
-
const hasInsisId = await this.alreadyInInsis(
|
|
466
|
-
this.contragent.iin,
|
|
467
|
-
this.contragent.firstName,
|
|
468
|
-
this.contragent.lastName,
|
|
469
|
-
this.contragent.middleName,
|
|
470
|
-
);
|
|
595
|
+
async saveContragent(user, whichForm, whichIndex, onlySaveAction = true) {
|
|
596
|
+
this.isLoading = !onlySaveAction;
|
|
597
|
+
const hasInsisId = await this.alreadyInInsis(user.iin, user.firstName, user.lastName, user.middleName);
|
|
471
598
|
if (hasInsisId !== false) {
|
|
472
599
|
user.id = hasInsisId;
|
|
473
|
-
const [
|
|
474
|
-
{ value: data },
|
|
475
|
-
{ value: contacts },
|
|
476
|
-
{ value: documents },
|
|
477
|
-
{ value: address },
|
|
478
|
-
] = await Promise.allSettled([
|
|
600
|
+
const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
|
|
479
601
|
this.api.getContrAgentData(user.id),
|
|
480
602
|
this.api.getContrAgentContacts(user.id),
|
|
481
603
|
this.api.getContrAgentDocuments(user.id),
|
|
482
604
|
this.api.getContrAgentAddress(user.id),
|
|
483
605
|
]);
|
|
484
|
-
|
|
606
|
+
user.response = {};
|
|
485
607
|
if (data && data.length) {
|
|
486
|
-
|
|
608
|
+
user.response.questionnaires = data;
|
|
487
609
|
}
|
|
488
610
|
if (contacts && contacts.length) {
|
|
489
|
-
|
|
611
|
+
user.response.contacts = contacts;
|
|
490
612
|
}
|
|
491
613
|
if (documents && documents.length) {
|
|
492
|
-
|
|
614
|
+
user.response.documents = documents;
|
|
493
615
|
}
|
|
494
616
|
if (address && address.length) {
|
|
495
|
-
|
|
617
|
+
user.response.addresses = address;
|
|
496
618
|
}
|
|
497
619
|
}
|
|
498
|
-
|
|
499
620
|
try {
|
|
500
621
|
// ! SaveContragent -> Contragent
|
|
501
622
|
let contragentData = {
|
|
502
623
|
id: user.id,
|
|
503
624
|
type: user.type,
|
|
504
625
|
iin: user.iin.replace(/-/g, ''),
|
|
505
|
-
longName:
|
|
506
|
-
user.longName !== null
|
|
507
|
-
? user.longName
|
|
508
|
-
: user.lastName + user.firstName + user.middleName
|
|
509
|
-
? user.middleName
|
|
510
|
-
: '',
|
|
626
|
+
longName: user.longName !== null ? user.longName : user.lastName + user.firstName + user.middleName ? user.middleName : '',
|
|
511
627
|
lastName: user.lastName,
|
|
512
628
|
firstName: user.firstName,
|
|
513
629
|
middleName: user.middleName ? user.middleName : '',
|
|
@@ -521,12 +637,7 @@ export const useDataStore = defineStore('data', {
|
|
|
521
637
|
verifyDate: user.verifyDate,
|
|
522
638
|
};
|
|
523
639
|
// ! SaveContragent -> Questionnaires
|
|
524
|
-
let questionnaires = (({
|
|
525
|
-
economySectorCode,
|
|
526
|
-
countryOfCitizenship,
|
|
527
|
-
countryOfTaxResidency,
|
|
528
|
-
signOfResidency,
|
|
529
|
-
}) => ({
|
|
640
|
+
let questionnaires = (({ economySectorCode, countryOfCitizenship, countryOfTaxResidency, signOfResidency }) => ({
|
|
530
641
|
economySectorCode,
|
|
531
642
|
countryOfCitizenship,
|
|
532
643
|
countryOfTaxResidency,
|
|
@@ -545,12 +656,7 @@ export const useDataStore = defineStore('data', {
|
|
|
545
656
|
questName = 'Страна налогового резиденства';
|
|
546
657
|
}
|
|
547
658
|
return {
|
|
548
|
-
id:
|
|
549
|
-
'response' in user && 'questionnaires' in user.response
|
|
550
|
-
? user.response.questionnaires?.find(
|
|
551
|
-
i => i.questId == questionId,
|
|
552
|
-
).id
|
|
553
|
-
: question.id,
|
|
659
|
+
id: 'response' in user && 'questionnaires' in user.response ? user.response.questionnaires?.find(i => i.questId == questionId).id : question.id,
|
|
554
660
|
contragentId: user.id,
|
|
555
661
|
questAnswer: question.ids,
|
|
556
662
|
questId: questionId,
|
|
@@ -558,28 +664,46 @@ export const useDataStore = defineStore('data', {
|
|
|
558
664
|
questName: questName,
|
|
559
665
|
};
|
|
560
666
|
});
|
|
667
|
+
if (user.countryOfTaxResidency.ids !== '500014.3') {
|
|
668
|
+
user.addTaxResidency = new Value();
|
|
669
|
+
}
|
|
670
|
+
const addTaxResidency = 'response' in user && 'questionnaires' in user.response && user.response.questionnaires.find(i => i.questId === '507777');
|
|
671
|
+
if (user.addTaxResidency.nameRu !== null) {
|
|
672
|
+
questionariesData.push({
|
|
673
|
+
id: addTaxResidency ? addTaxResidency.id : 0,
|
|
674
|
+
contragentId: user.id,
|
|
675
|
+
questAnswer: user.addTaxResidency.ids,
|
|
676
|
+
questAnswerName: user.addTaxResidency.nameRu,
|
|
677
|
+
questName: 'Указать если налоговое резиденство выбрано другое',
|
|
678
|
+
questId: '507777',
|
|
679
|
+
});
|
|
680
|
+
} else {
|
|
681
|
+
if (addTaxResidency && addTaxResidency.questAnswer !== null) {
|
|
682
|
+
questionariesData.push({
|
|
683
|
+
id: addTaxResidency.id,
|
|
684
|
+
contragentId: user.id,
|
|
685
|
+
questAnswer: null,
|
|
686
|
+
questAnswerName: null,
|
|
687
|
+
questName: 'Указать если налоговое резиденство выбрано другое',
|
|
688
|
+
questId: '507777',
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
}
|
|
561
692
|
|
|
562
693
|
// ! SaveContragent -> Contacts
|
|
563
694
|
let contactsData = [];
|
|
564
695
|
if (user.phoneNumber !== '' && user.phoneNumber !== null) {
|
|
565
696
|
contactsData.push({
|
|
566
697
|
contragentId: user.id,
|
|
567
|
-
id:
|
|
568
|
-
'response' in user && 'contacts' in user.response
|
|
569
|
-
? user.response.contacts.find(i => i.type === 'MOBILE').id
|
|
570
|
-
: 0,
|
|
698
|
+
id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').id : 0,
|
|
571
699
|
newValue: '',
|
|
572
700
|
note: '',
|
|
573
701
|
primaryFlag: 'Y',
|
|
574
702
|
type: 'MOBILE',
|
|
575
703
|
typeName: 'Сотовый телефон',
|
|
576
704
|
value: formatPhone(user.phoneNumber),
|
|
577
|
-
verifyType:
|
|
578
|
-
|
|
579
|
-
: 'response' in user && 'contacts' in user.response
|
|
580
|
-
? user.response.contacts.find(i => i.type === 'MOBILE').verifyType
|
|
581
|
-
: null,
|
|
582
|
-
verifyDate: this.contragent.otpTokenId
|
|
705
|
+
verifyType: user.otpTokenId ? 'BMG' : 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').verifyType : null,
|
|
706
|
+
verifyDate: user.otpTokenId
|
|
583
707
|
? this.currentDate()
|
|
584
708
|
: 'response' in user && 'contacts' in user.response
|
|
585
709
|
? user.response.contacts.find(i => i.type === 'MOBILE').verifyDate
|
|
@@ -589,29 +713,19 @@ export const useDataStore = defineStore('data', {
|
|
|
589
713
|
if (user.email !== '' && user.email !== null) {
|
|
590
714
|
contactsData.push({
|
|
591
715
|
contragentId: user.id,
|
|
592
|
-
id:
|
|
593
|
-
'response' in user && 'contacts' in user.response
|
|
594
|
-
? user.response.contacts.find(i => i.type === 'EMAIL').id
|
|
595
|
-
: 0,
|
|
716
|
+
id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').id : 0,
|
|
596
717
|
newValue: '',
|
|
597
718
|
note: '',
|
|
598
719
|
primaryFlag: 'N',
|
|
599
720
|
type: 'EMAIL',
|
|
600
721
|
typeName: 'E-Mail',
|
|
601
|
-
value: user.email
|
|
602
|
-
? user.email
|
|
603
|
-
: 'response' in user && 'contacts' in user.response
|
|
604
|
-
? user.response.contacts.find(i => i.type === 'EMAIL').value
|
|
605
|
-
: '',
|
|
722
|
+
value: user.email ? user.email : 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'EMAIL').value : '',
|
|
606
723
|
});
|
|
607
724
|
}
|
|
608
725
|
if (user.homePhone !== '' && user.homePhone !== null) {
|
|
609
726
|
contactsData.push({
|
|
610
727
|
contragentId: user.id,
|
|
611
|
-
id:
|
|
612
|
-
'response' in user && 'contacts' in user.response
|
|
613
|
-
? user.response.contacts.find(i => i.type === 'HOME').id
|
|
614
|
-
: 0,
|
|
728
|
+
id: 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'HOME').id : 0,
|
|
615
729
|
newValue: '',
|
|
616
730
|
note: '',
|
|
617
731
|
primaryFlag: 'N',
|
|
@@ -629,10 +743,7 @@ export const useDataStore = defineStore('data', {
|
|
|
629
743
|
let documentsData = [];
|
|
630
744
|
documentsData.push({
|
|
631
745
|
contragentId: user.id,
|
|
632
|
-
id:
|
|
633
|
-
'response' in user && 'documents' in user.response
|
|
634
|
-
? user.response.documents[0].id
|
|
635
|
-
: 0,
|
|
746
|
+
id: 'response' in user && 'documents' in user.response ? user.response.documents[0].id : 0,
|
|
636
747
|
description: null,
|
|
637
748
|
expireDate: user.getDateByKey('documentExpire'),
|
|
638
749
|
issueDate: user.getDateByKey('documentDate'),
|
|
@@ -651,10 +762,7 @@ export const useDataStore = defineStore('data', {
|
|
|
651
762
|
// ! SaveContragent -> Addresses
|
|
652
763
|
let addressData = [];
|
|
653
764
|
addressData.push({
|
|
654
|
-
id:
|
|
655
|
-
'response' in user && 'addresses' in user.response
|
|
656
|
-
? user.response.addresses[0].id
|
|
657
|
-
: 0,
|
|
765
|
+
id: 'response' in user && 'addresses' in user.response ? user.response.addresses[0].id : 0,
|
|
658
766
|
contragentId: user.id,
|
|
659
767
|
countryCode: user.birthPlace.ids,
|
|
660
768
|
countryName: user.birthPlace.nameRu,
|
|
@@ -682,107 +790,242 @@ export const useDataStore = defineStore('data', {
|
|
|
682
790
|
documents: documentsData,
|
|
683
791
|
addresses: addressData,
|
|
684
792
|
};
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
} catch (saveErr) {
|
|
692
|
-
console.log(saveErr);
|
|
693
|
-
if ('response' in saveErr) {
|
|
694
|
-
this.showToaster('error', saveErr.response.data, 5000);
|
|
695
|
-
this.isLoading = false;
|
|
696
|
-
return false;
|
|
697
|
-
}
|
|
793
|
+
|
|
794
|
+
const personId = await this.api.saveContragent(data);
|
|
795
|
+
if (personId) {
|
|
796
|
+
await this.getContragentById(personId, whichForm, false, whichIndex);
|
|
797
|
+
user.otpTokenId = null;
|
|
698
798
|
}
|
|
699
799
|
} catch (err) {
|
|
700
|
-
console.log(err);
|
|
701
800
|
this.isLoading = false;
|
|
702
|
-
|
|
703
|
-
'error',
|
|
704
|
-
this.t('toaster.error') + err?.response?.data,
|
|
705
|
-
2000,
|
|
706
|
-
);
|
|
707
|
-
return false;
|
|
801
|
+
return ErrorHandler(err);
|
|
708
802
|
}
|
|
709
803
|
if (onlySaveAction) {
|
|
710
804
|
this.isLoading = false;
|
|
711
805
|
}
|
|
712
806
|
return true;
|
|
713
807
|
},
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
808
|
+
async saveMember(member, whichMember, memberFromApplicaiton) {
|
|
809
|
+
let data = {};
|
|
810
|
+
try {
|
|
811
|
+
data = {
|
|
812
|
+
processInstanceId: this.formStore.applicationData.processInstanceId,
|
|
813
|
+
insisId: member.id,
|
|
814
|
+
iin: member.iin.replace(/-/g, ''),
|
|
815
|
+
longName: member.longName,
|
|
816
|
+
isIpdl: member.signOfIPDL.nameRu == 'Да' ? true : false,
|
|
817
|
+
isTerror: member.isTerror,
|
|
818
|
+
isIpdlCompliance: null,
|
|
819
|
+
isTerrorCompliance: null,
|
|
820
|
+
};
|
|
821
|
+
data.id = memberFromApplicaiton && memberFromApplicaiton.id ? memberFromApplicaiton.id : null;
|
|
822
|
+
if (whichMember === 'Client') {
|
|
823
|
+
data.isInsured = this.formStore.isPolicyholderInsured;
|
|
824
|
+
data.isActOwnBehalf = this.formStore.isActOwnBehalf;
|
|
825
|
+
data.profession = member.job;
|
|
826
|
+
data.position = member.jobPosition;
|
|
827
|
+
data.jobName = member.jobPlace;
|
|
828
|
+
data.familyStatusId = member.familyStatus.id;
|
|
829
|
+
}
|
|
830
|
+
if (whichMember === 'Spokesman') {
|
|
831
|
+
if (!!memberFromApplicaiton && memberFromApplicaiton.iin !== data.iin) {
|
|
832
|
+
delete data.id;
|
|
833
|
+
await this.api.deleteMember('Spokesman', this.formStore.applicationData.processInstanceId);
|
|
834
|
+
}
|
|
835
|
+
data.migrationCard = member.migrationCard;
|
|
836
|
+
const migrationCardIssueDate = formatDate(member.migrationCardIssueDate);
|
|
837
|
+
if (migrationCardIssueDate) data.migrationCardIssueDate = migrationCardIssueDate.toISOString();
|
|
838
|
+
const migrationCardExpireDate = formatDate(member.migrationCardExpireDate);
|
|
839
|
+
if (migrationCardExpireDate) data.migrationCardExpireDate = migrationCardExpireDate.toISOString();
|
|
840
|
+
data.confirmDocType = member.confirmDocType;
|
|
841
|
+
data.confirmDocNumber = member.confirmDocNumber;
|
|
842
|
+
const confirmDocIssueDate = formatDate(member.confirmDocIssueDate);
|
|
843
|
+
if (confirmDocIssueDate) data.confirmDocIssueDate = confirmDocIssueDate.toISOString();
|
|
844
|
+
const confirmDocExpireDate = formatDate(member.confirmDocExpireDate);
|
|
845
|
+
if (confirmDocExpireDate) data.confirmDocExpireDate = confirmDocExpireDate.toISOString();
|
|
846
|
+
data.clientLongName = this.formStore.applicationData.clientApp.longName;
|
|
847
|
+
data.notaryLongName = member.notaryLongName;
|
|
848
|
+
data.notaryLicenseNumber = member.notaryLicenseNumber;
|
|
849
|
+
const notaryLicenseDate = formatDate(member.notaryLicenseDate);
|
|
850
|
+
if (notaryLicenseDate) data.notaryLicenseDate = notaryLicenseDate.toISOString();
|
|
851
|
+
data.notaryLicenseIssuer = member.notaryLicenseIssuer;
|
|
852
|
+
data.jurLongName = member.jurLongName;
|
|
853
|
+
data.fullNameRod = member.fullNameRod;
|
|
854
|
+
data.confirmDocTypeKz = member.confirmDocTypeKz;
|
|
855
|
+
data.confirmDocTypeRod = member.confirmDocTypeRod;
|
|
856
|
+
data.isNotary = member.isNotary;
|
|
857
|
+
}
|
|
858
|
+
if (whichMember === 'Insured') {
|
|
859
|
+
if (
|
|
860
|
+
this.formStore.applicationData &&
|
|
861
|
+
this.formStore.applicationData.insuredApp &&
|
|
862
|
+
this.formStore.applicationData.insuredApp.length &&
|
|
863
|
+
this.formStore.applicationData.insuredApp.every(i => i.iin !== data.iin) &&
|
|
864
|
+
data.id !== null
|
|
865
|
+
) {
|
|
866
|
+
await this.api.deleteMember('Insured', data.id);
|
|
867
|
+
delete data.id;
|
|
868
|
+
}
|
|
869
|
+
data.isDisability = this.formStore.isPolicyholderInsured ? false : member.isDisability.nameRu == 'Да';
|
|
870
|
+
data.disabilityGroupId = data.isDisability ? member.disabilityGroupId.id : null;
|
|
871
|
+
data.profession = member.job;
|
|
872
|
+
data.position = member.jobPosition;
|
|
873
|
+
data.jobName = member.jobPlace;
|
|
874
|
+
data.familyStatusId = member.familyStatus.id;
|
|
875
|
+
}
|
|
876
|
+
if (whichMember === 'Beneficiary') {
|
|
877
|
+
if (
|
|
878
|
+
this.formStore.applicationData &&
|
|
879
|
+
this.formStore.applicationData.beneficiaryApp &&
|
|
880
|
+
this.formStore.applicationData.beneficiaryApp.length &&
|
|
881
|
+
this.formStore.applicationData.beneficiaryApp.every(i => i.iin !== data.iin) &&
|
|
882
|
+
data.id !== null
|
|
883
|
+
) {
|
|
884
|
+
await this.api.deleteMember('Beneficiary', data.id);
|
|
885
|
+
delete data.id;
|
|
886
|
+
}
|
|
887
|
+
data.familyStatusId = member.familyStatus.id == 0 ? null : member.familyStatus.id;
|
|
888
|
+
data.percentage = Number(member.percentageOfPayoutAmount);
|
|
889
|
+
data.relationId = member.relationDegree.ids;
|
|
890
|
+
data.relationName = member.relationDegree.nameRu;
|
|
891
|
+
}
|
|
892
|
+
if (whichMember === 'BeneficialOwner') {
|
|
893
|
+
if (data.id === 0) {
|
|
894
|
+
data.id = null;
|
|
895
|
+
}
|
|
896
|
+
if (
|
|
897
|
+
this.formStore.applicationData &&
|
|
898
|
+
this.formStore.applicationData.beneficialOwnerApp &&
|
|
899
|
+
this.formStore.applicationData.beneficialOwnerApp.length &&
|
|
900
|
+
this.formStore.applicationData.beneficialOwnerApp.every(i => i.iin !== data.iin) &&
|
|
901
|
+
data.id !== null
|
|
902
|
+
) {
|
|
903
|
+
await this.api.deleteMember('BeneficialOwner', data.id);
|
|
904
|
+
delete data.id;
|
|
905
|
+
}
|
|
906
|
+
data.familyStatusId = member.familyStatus.id;
|
|
907
|
+
}
|
|
908
|
+
await this.api.setMember(whichMember, data);
|
|
909
|
+
return true;
|
|
910
|
+
} catch (err) {
|
|
911
|
+
return ErrorHandler(err, err.response?.data?.errors && Object.values(err.response?.data?.errors).join(' -> '));
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
searchFromList(whichForm, searchIt, whichIndex = null) {
|
|
915
|
+
const getQuestionariesData = () => {
|
|
916
|
+
switch (searchIt.questId) {
|
|
917
|
+
case '500003':
|
|
918
|
+
return [this.economySectorCode, 'economySectorCode'];
|
|
919
|
+
case '500011':
|
|
920
|
+
return [this.residents, 'signOfResidency'];
|
|
921
|
+
case '500012':
|
|
922
|
+
return [this.citizenshipCountries, 'countryOfCitizenship'];
|
|
923
|
+
case '500014':
|
|
924
|
+
return [this.taxCountries, 'countryOfTaxResidency'];
|
|
925
|
+
case '507777':
|
|
926
|
+
return [this.addTaxCountries, 'addTaxResidency'];
|
|
927
|
+
case '500147':
|
|
928
|
+
return [[]];
|
|
929
|
+
case '500148':
|
|
930
|
+
return [[]];
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
const [searchFrom, whichField] = getQuestionariesData();
|
|
935
|
+
if (searchFrom && searchFrom.length) {
|
|
936
|
+
const result = searchFrom.find(i => i.ids === searchIt.questAnswer);
|
|
937
|
+
if (whichIndex === null) {
|
|
938
|
+
this.formStore[whichForm][whichField] = result ? result : new Value();
|
|
939
|
+
} else {
|
|
940
|
+
this.formStore[whichForm][whichIndex][whichField] = result ? result : new Value();
|
|
724
941
|
}
|
|
725
942
|
}
|
|
726
943
|
},
|
|
727
|
-
async
|
|
728
|
-
|
|
944
|
+
async setSurvey(data) {
|
|
945
|
+
try {
|
|
946
|
+
this.isLoading = true;
|
|
947
|
+
const anketaToken = await this.api.setSurvey(data);
|
|
948
|
+
this.showToaster('success', this.t('toaster.successSaved'), 2000);
|
|
949
|
+
return anketaToken;
|
|
950
|
+
} catch (error) {
|
|
951
|
+
return ErrorHandler(err);
|
|
952
|
+
} finally {
|
|
953
|
+
this.isLoading = false;
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
async getFromApi(whichField, whichRequest, parameter, reset = false) {
|
|
957
|
+
const storageValue = JSON.parse(localStorage.getItem(whichField) || 'null');
|
|
958
|
+
const currentHour = new Date().getHours();
|
|
959
|
+
|
|
960
|
+
const getDataCondition = () => {
|
|
961
|
+
if (!storageValue) return true;
|
|
962
|
+
const hasHourKey = 'hour' in storageValue;
|
|
963
|
+
const hasModeKey = 'mode' in storageValue;
|
|
964
|
+
const hasValueKey = 'value' in storageValue;
|
|
965
|
+
if (storageValue && (hasHourKey === false || hasModeKey === false || hasValueKey === false)) return true;
|
|
966
|
+
if (storageValue && (storageValue.hour !== currentHour || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)) return true;
|
|
967
|
+
};
|
|
968
|
+
if (!!getDataCondition() || reset === true) {
|
|
969
|
+
this[whichField] = [];
|
|
729
970
|
try {
|
|
730
|
-
const response = await api[whichRequest](parameter);
|
|
971
|
+
const response = await this.api[whichRequest](parameter);
|
|
731
972
|
if (response) {
|
|
973
|
+
localStorage.setItem(
|
|
974
|
+
whichField,
|
|
975
|
+
JSON.stringify({
|
|
976
|
+
value: response,
|
|
977
|
+
hour: currentHour,
|
|
978
|
+
mode: import.meta.env.MODE,
|
|
979
|
+
}),
|
|
980
|
+
);
|
|
732
981
|
this[whichField] = response;
|
|
733
|
-
if (
|
|
734
|
-
this[whichField].length &&
|
|
735
|
-
this[whichField][this[whichField].length - 1].nameRu ==
|
|
736
|
-
'невключено'
|
|
737
|
-
) {
|
|
738
|
-
this[whichField].unshift(this[whichField].pop());
|
|
739
|
-
}
|
|
740
982
|
}
|
|
741
983
|
} catch (err) {
|
|
742
984
|
console.log(err);
|
|
743
985
|
}
|
|
986
|
+
} else {
|
|
987
|
+
this[whichField] = storageValue.value;
|
|
744
988
|
}
|
|
989
|
+
|
|
745
990
|
return this[whichField];
|
|
746
991
|
},
|
|
747
992
|
async getCountries() {
|
|
748
993
|
return await this.getFromApi('countries', 'getCountries');
|
|
749
994
|
},
|
|
750
995
|
async getCitizenshipCountries() {
|
|
751
|
-
return await this.getFromApi(
|
|
752
|
-
'citizenshipCountries',
|
|
753
|
-
'getCitizenshipCountries',
|
|
754
|
-
);
|
|
996
|
+
return await this.getFromApi('citizenshipCountries', 'getCitizenshipCountries');
|
|
755
997
|
},
|
|
756
998
|
async getTaxCountries() {
|
|
757
999
|
return await this.getFromApi('taxCountries', 'getTaxCountries');
|
|
758
1000
|
},
|
|
759
|
-
async
|
|
1001
|
+
async getAdditionalTaxCountries() {
|
|
1002
|
+
return await this.getFromApi('addTaxCountries', 'getAdditionalTaxCountries');
|
|
1003
|
+
},
|
|
1004
|
+
async getStates(key, member) {
|
|
760
1005
|
await this.getFromApi('states', 'getStates');
|
|
761
|
-
if (key &&
|
|
762
|
-
return this.states.filter(i => i.code ===
|
|
1006
|
+
if (key && member[key] && member[key].ids !== null) {
|
|
1007
|
+
return this.states.filter(i => i.code === member[key].ids);
|
|
763
1008
|
}
|
|
764
1009
|
return this.states;
|
|
765
1010
|
},
|
|
766
|
-
async getRegions(key) {
|
|
1011
|
+
async getRegions(key, member) {
|
|
767
1012
|
await this.getFromApi('regions', 'getRegions');
|
|
768
|
-
if (key &&
|
|
769
|
-
return this.regions.filter(i => i.code ===
|
|
1013
|
+
if (key && member[key] && member[key].ids !== null) {
|
|
1014
|
+
return this.regions.filter(i => i.code === member[key].ids);
|
|
770
1015
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
return this.regions.filter(i => i.code === registrationProvince.ids);
|
|
1016
|
+
if (member.registrationProvince.ids !== null) {
|
|
1017
|
+
return this.regions.filter(i => i.code === member.registrationProvince.ids);
|
|
774
1018
|
} else {
|
|
775
1019
|
return this.regions;
|
|
776
1020
|
}
|
|
777
1021
|
},
|
|
778
|
-
async getCities(key) {
|
|
1022
|
+
async getCities(key, member) {
|
|
779
1023
|
await this.getFromApi('cities', 'getCities');
|
|
780
|
-
if (key &&
|
|
781
|
-
return this.cities.filter(i => i.code ===
|
|
1024
|
+
if (key && member[key] && member[key].ids !== null) {
|
|
1025
|
+
return this.cities.filter(i => i.code === member[key].ids);
|
|
782
1026
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
return this.cities.filter(i => i.code === registrationProvince.ids);
|
|
1027
|
+
if (member.registrationProvince.ids !== null) {
|
|
1028
|
+
return this.cities.filter(i => i.code === member.registrationProvince.ids);
|
|
786
1029
|
} else {
|
|
787
1030
|
return this.cities;
|
|
788
1031
|
}
|
|
@@ -791,10 +1034,7 @@ export const useDataStore = defineStore('data', {
|
|
|
791
1034
|
return await this.getFromApi('localityTypes', 'getLocalityTypes');
|
|
792
1035
|
},
|
|
793
1036
|
async getDocumentTypes() {
|
|
794
|
-
const document_list = await this.getFromApi(
|
|
795
|
-
'documentTypes',
|
|
796
|
-
'getDocumentTypes',
|
|
797
|
-
);
|
|
1037
|
+
const document_list = await this.getFromApi('documentTypes', 'getDocumentTypes');
|
|
798
1038
|
await this.getDicFileTypeList();
|
|
799
1039
|
return document_list.filter(doc => {
|
|
800
1040
|
for (const dic of this.dicFileTypeList) {
|
|
@@ -804,6 +1044,18 @@ export const useDataStore = defineStore('data', {
|
|
|
804
1044
|
}
|
|
805
1045
|
});
|
|
806
1046
|
},
|
|
1047
|
+
async getDicFileTypeList() {
|
|
1048
|
+
try {
|
|
1049
|
+
if (this.dicFileTypeList.length) {
|
|
1050
|
+
return this.dicFileTypeList;
|
|
1051
|
+
} else {
|
|
1052
|
+
this.dicFileTypeList = await this.api.getDicFileTypeList();
|
|
1053
|
+
return this.dicFileTypeList;
|
|
1054
|
+
}
|
|
1055
|
+
} catch (err) {
|
|
1056
|
+
console.log(err.response.data);
|
|
1057
|
+
}
|
|
1058
|
+
},
|
|
807
1059
|
async getDocumentIssuers() {
|
|
808
1060
|
return await this.getFromApi('documentIssuers', 'getDocumentIssuers');
|
|
809
1061
|
},
|
|
@@ -812,60 +1064,67 @@ export const useDataStore = defineStore('data', {
|
|
|
812
1064
|
},
|
|
813
1065
|
async getSectorCodeList() {
|
|
814
1066
|
await this.getFromApi('economySectorCode', 'getSectorCode');
|
|
815
|
-
if (this.economySectorCode[1].ids != '500003.9') {
|
|
816
|
-
this.economySectorCode = this.economySectorCode.reverse();
|
|
817
|
-
}
|
|
818
1067
|
return this.economySectorCode;
|
|
819
1068
|
},
|
|
820
1069
|
async getFamilyStatuses() {
|
|
821
1070
|
return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
|
|
822
1071
|
},
|
|
823
1072
|
async getRelationTypes() {
|
|
1073
|
+
// TODO Remove this & add filtering in openPanel method
|
|
824
1074
|
await this.getFromApi('relations', 'getRelationTypes');
|
|
825
|
-
const filteredRelations = this.relations.filter(
|
|
826
|
-
|
|
827
|
-
);
|
|
828
|
-
const otherRelations = this.relations.filter(
|
|
829
|
-
i => Number(i.ids) < 6 || Number(i.ids) > 15,
|
|
830
|
-
);
|
|
1075
|
+
const filteredRelations = this.relations.filter(i => Number(i.ids) >= 6 && Number(i.ids) <= 15);
|
|
1076
|
+
const otherRelations = this.relations.filter(i => Number(i.ids) < 6 || Number(i.ids) > 15);
|
|
831
1077
|
return [...filteredRelations, ...otherRelations];
|
|
832
1078
|
},
|
|
1079
|
+
async getProcessIndexRate() {
|
|
1080
|
+
const response = await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
|
|
1081
|
+
return response ? response : [];
|
|
1082
|
+
},
|
|
833
1083
|
async getProcessCoverTypeSum(type) {
|
|
834
|
-
return await this.getFromApi(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
1084
|
+
return await this.getFromApi('processCoverTypeSum', 'getProcessCoverTypeSum', type);
|
|
1085
|
+
},
|
|
1086
|
+
async getProcessPaymentPeriod() {
|
|
1087
|
+
return await this.getFromApi('processPaymentPeriod', 'getProcessPaymentPeriod', this.processCode);
|
|
1088
|
+
},
|
|
1089
|
+
async getQuestionRefs(id) {
|
|
1090
|
+
return await this.getFromApi('questionRefs', 'getQuestionRefs', id, true);
|
|
1091
|
+
},
|
|
1092
|
+
async getProcessTariff() {
|
|
1093
|
+
return await this.getFromApi('processTariff', 'getProcessTariff');
|
|
1094
|
+
},
|
|
1095
|
+
async getAdditionalInsuranceTermsAnswers(questionId) {
|
|
1096
|
+
try {
|
|
1097
|
+
const answers = await this.api.getAdditionalInsuranceTermsAnswers(this.processCode, questionId);
|
|
1098
|
+
return answers;
|
|
1099
|
+
} catch (err) {
|
|
1100
|
+
console.log(err);
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
async getQuestionList(surveyType, processInstanceId, insuredId, baseField, secondaryField) {
|
|
1104
|
+
if (!this.formStore[baseField] || (this.formStore[baseField] && !this.formStore[baseField].length)) {
|
|
1105
|
+
try {
|
|
1106
|
+
const [{ value: baseQuestions }, { value: secondaryQuestions }] = await Promise.allSettled([
|
|
1107
|
+
this.api.getQuestionList(surveyType, processInstanceId, insuredId),
|
|
1108
|
+
this.api.getQuestionListSecond(`${surveyType}second`, processInstanceId, insuredId),
|
|
1109
|
+
]);
|
|
1110
|
+
this.formStore[baseField] = baseQuestions;
|
|
1111
|
+
this.formStore[secondaryField] = secondaryQuestions;
|
|
1112
|
+
} catch (err) {
|
|
1113
|
+
console.log(err);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
return this.formStore[baseField];
|
|
839
1117
|
},
|
|
840
1118
|
getNumberWithSpaces(n) {
|
|
841
|
-
return n === null
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
(typeof n === 'string' ? n : n.toFixed().toString()).replace(
|
|
845
|
-
/[^0-9]+/g,
|
|
846
|
-
'',
|
|
847
|
-
),
|
|
848
|
-
).toLocaleString('ru');
|
|
849
|
-
},
|
|
850
|
-
async getTaskList(
|
|
851
|
-
search = '',
|
|
852
|
-
groupCode = 'Work',
|
|
853
|
-
onlyGet = false,
|
|
854
|
-
needToReturn = false,
|
|
855
|
-
key = 'dateCreated',
|
|
856
|
-
processInstanceId = null,
|
|
857
|
-
) {
|
|
1119
|
+
return n === null ? null : Number((typeof n === 'string' ? n : n.toFixed().toString()).replace(/[^0-9]+/g, '')).toLocaleString('ru');
|
|
1120
|
+
},
|
|
1121
|
+
async getTaskList(search = '', groupCode = 'Work', onlyGet = false, needToReturn = false, key = 'dateCreated', processInstanceId = null, byOneProcess = null) {
|
|
858
1122
|
if (onlyGet === false) {
|
|
859
1123
|
this.isLoading = true;
|
|
860
1124
|
}
|
|
861
1125
|
try {
|
|
862
1126
|
const column = this.isColumnAsc[key] === null ? 'dateCreated' : key;
|
|
863
|
-
const direction =
|
|
864
|
-
this.isColumnAsc[key] === null
|
|
865
|
-
? 'desc'
|
|
866
|
-
: this.isColumnAsc[key] === true
|
|
867
|
-
? 'asc'
|
|
868
|
-
: 'desc';
|
|
1127
|
+
const direction = this.isColumnAsc[key] === null ? 'desc' : this.isColumnAsc[key] === true ? 'asc' : 'desc';
|
|
869
1128
|
const query = {
|
|
870
1129
|
pageIndex: processInstanceId === null ? this.historyPageIndex - 1 : 0,
|
|
871
1130
|
pageSize: this.historyPageSize,
|
|
@@ -875,11 +1134,11 @@ export const useDataStore = defineStore('data', {
|
|
|
875
1134
|
groupCode: groupCode,
|
|
876
1135
|
processCodes: Object.values(constants.products),
|
|
877
1136
|
};
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
);
|
|
1137
|
+
if (byOneProcess !== null) {
|
|
1138
|
+
delete query.processCodes;
|
|
1139
|
+
query.processCode = byOneProcess;
|
|
1140
|
+
}
|
|
1141
|
+
const taskList = await this.api.getTaskList(processInstanceId === null ? query : { ...query, processInstanceId: processInstanceId });
|
|
883
1142
|
if (needToReturn) {
|
|
884
1143
|
this.isLoading = false;
|
|
885
1144
|
return taskList.items;
|
|
@@ -932,6 +1191,7 @@ export const useDataStore = defineStore('data', {
|
|
|
932
1191
|
this.getCountries(),
|
|
933
1192
|
this.getCitizenshipCountries(),
|
|
934
1193
|
this.getTaxCountries(),
|
|
1194
|
+
this.getAdditionalTaxCountries(),
|
|
935
1195
|
this.getStates(),
|
|
936
1196
|
this.getRegions(),
|
|
937
1197
|
this.getCities(),
|
|
@@ -942,6 +1202,9 @@ export const useDataStore = defineStore('data', {
|
|
|
942
1202
|
this.getSectorCodeList(),
|
|
943
1203
|
this.getFamilyStatuses(),
|
|
944
1204
|
this.getRelationTypes(),
|
|
1205
|
+
this.getProcessIndexRate(),
|
|
1206
|
+
this.getProcessTariff(),
|
|
1207
|
+
this.getProcessPaymentPeriod(),
|
|
945
1208
|
]);
|
|
946
1209
|
},
|
|
947
1210
|
async getUserGroups() {
|
|
@@ -954,185 +1217,1253 @@ export const useDataStore = defineStore('data', {
|
|
|
954
1217
|
this.isLoading = false;
|
|
955
1218
|
}
|
|
956
1219
|
},
|
|
957
|
-
async
|
|
1220
|
+
async getProcessList() {
|
|
1221
|
+
this.isLoading = true;
|
|
958
1222
|
try {
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
};
|
|
964
|
-
return await this.api.getOtpStatus(
|
|
965
|
-
processInstanceId !== null && processInstanceId != 0
|
|
966
|
-
? {
|
|
967
|
-
...otpData,
|
|
968
|
-
processInstanceId: processInstanceId,
|
|
969
|
-
}
|
|
970
|
-
: otpData,
|
|
971
|
-
);
|
|
1223
|
+
const processList = await this.api.getProcessList();
|
|
1224
|
+
if (this.processList === null) {
|
|
1225
|
+
this.processList = processList;
|
|
1226
|
+
}
|
|
972
1227
|
} catch (err) {
|
|
973
1228
|
console.log(err);
|
|
974
|
-
this.showToaster('error', err.response.data, 3000);
|
|
975
1229
|
}
|
|
1230
|
+
this.isLoading = false;
|
|
976
1231
|
},
|
|
977
|
-
|
|
978
|
-
this.
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
this.
|
|
988
|
-
return
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1232
|
+
sortTaskList(key) {
|
|
1233
|
+
if (this.taskList.length !== 0) {
|
|
1234
|
+
if (key in this.isColumnAsc) {
|
|
1235
|
+
if (this.isColumnAsc[key] === true) {
|
|
1236
|
+
this.isColumnAsc = { ...InitialColumns() };
|
|
1237
|
+
this.isColumnAsc[key] = false;
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
if (this.isColumnAsc[key] === false) {
|
|
1241
|
+
this.isColumnAsc = { ...InitialColumns() };
|
|
1242
|
+
this.isColumnAsc[key] = null;
|
|
1243
|
+
return;
|
|
1244
|
+
}
|
|
1245
|
+
if (this.isColumnAsc[key] === null) {
|
|
1246
|
+
this.isColumnAsc = { ...InitialColumns() };
|
|
1247
|
+
this.isColumnAsc[key] = true;
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
},
|
|
1253
|
+
async searchAgentByName(name) {
|
|
1254
|
+
try {
|
|
1255
|
+
this.isLoading = true;
|
|
1256
|
+
this.AgentDataList = await this.api.searchAgentByName(name);
|
|
1257
|
+
if (!this.AgentDataList.length) {
|
|
1258
|
+
this.showToaster('error', this.t('toaster.notFound'), 1500);
|
|
1259
|
+
}
|
|
1260
|
+
} catch (err) {
|
|
1261
|
+
console.log(err);
|
|
1262
|
+
} finally {
|
|
1263
|
+
this.isLoading = false;
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
async setINSISWorkData() {
|
|
1267
|
+
const data = {
|
|
1268
|
+
id: this.formStore.applicationData.insisWorkDataApp.id,
|
|
1269
|
+
processInstanceId: this.formStore.applicationData.processInstanceId,
|
|
1270
|
+
agentId: this.formStore.AgentData.agentId,
|
|
1271
|
+
agentName: this.formStore.AgentData.fullName,
|
|
1272
|
+
salesChannel: this.formStore.applicationData.insisWorkDataApp.salesChannel,
|
|
1273
|
+
salesChannelName: this.formStore.applicationData.insisWorkDataApp.salesChannelName,
|
|
1274
|
+
insrType: this.formStore.applicationData.insisWorkDataApp.insrType,
|
|
1275
|
+
saleChanellPolicy: this.formStore.SaleChanellPolicy.ids,
|
|
1276
|
+
saleChanellPolicyName: this.formStore.SaleChanellPolicy.nameRu,
|
|
1277
|
+
regionPolicy: this.formStore.RegionPolicy.ids,
|
|
1278
|
+
regionPolicyName: this.formStore.RegionPolicy.nameRu,
|
|
1279
|
+
managerPolicy: this.formStore.ManagerPolicy.ids,
|
|
1280
|
+
managerPolicyName: this.formStore.ManagerPolicy.nameRu,
|
|
1281
|
+
insuranceProgramType: this.formStore.applicationData.insisWorkDataApp.insuranceProgramType,
|
|
1282
|
+
};
|
|
1283
|
+
try {
|
|
1284
|
+
this.isLoading = true;
|
|
1285
|
+
await this.api.setINSISWorkData(data);
|
|
1286
|
+
} catch (err) {
|
|
1287
|
+
console.log(err);
|
|
1288
|
+
} finally {
|
|
1289
|
+
this.isLoading = false;
|
|
1290
|
+
}
|
|
1291
|
+
},
|
|
1292
|
+
async filterManagerByRegion(dictName, filterName) {
|
|
1293
|
+
try {
|
|
1294
|
+
this.isLoading = true;
|
|
1295
|
+
this[`${dictName}List`] = await this.api.filterManagerByRegion(dictName, filterName);
|
|
1296
|
+
} catch (err) {
|
|
1297
|
+
console.log(err);
|
|
1298
|
+
} finally {
|
|
1299
|
+
this.isLoading = false;
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
async getUnderwritingCouncilData(id) {
|
|
1303
|
+
try {
|
|
1304
|
+
const response = await this.api.getUnderwritingCouncilData(id);
|
|
1305
|
+
this.formStore.affilationResolution.id = response.underwritingCouncilAppDto.id;
|
|
1306
|
+
this.formStore.affilationResolution.date = response.underwritingCouncilAppDto.date ? reformatDate(response.underwritingCouncilAppDto.date) : null;
|
|
1307
|
+
this.formStore.affilationResolution.number = response.underwritingCouncilAppDto.number ? response.underwritingCouncilAppDto.number : null;
|
|
1308
|
+
} catch (err) {
|
|
1309
|
+
console.log(err);
|
|
1310
|
+
}
|
|
1311
|
+
},
|
|
1312
|
+
async setConfirmation() {
|
|
1313
|
+
const data = {
|
|
1314
|
+
id: this.formStore.affilationResolution.id,
|
|
1315
|
+
processInstanceId: this.formStore.affilationResolution.processInstanceId,
|
|
1316
|
+
number: this.formStore.affilationResolution.number,
|
|
1317
|
+
date: formatDate(this.formStore.affilationResolution.date)?.toISOString(),
|
|
1318
|
+
};
|
|
1319
|
+
try {
|
|
1320
|
+
this.isLoading = true;
|
|
1321
|
+
await this.api.setConfirmation(data);
|
|
1322
|
+
this.showToaster('success', this.t('toaster.successSaved'));
|
|
1323
|
+
return true;
|
|
1324
|
+
} catch (err) {
|
|
1325
|
+
this.showToaster('error', this.t('toaster.error'));
|
|
1326
|
+
return false;
|
|
1327
|
+
} finally {
|
|
1328
|
+
this.isLoading = false;
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
async sendUnderwritingCouncilTask(data) {
|
|
1332
|
+
try {
|
|
1333
|
+
this.isLoading = true;
|
|
1334
|
+
await this.api.sendUnderwritingCouncilTask(data);
|
|
1335
|
+
this.showToaster('success', this.t('toaster.successOperation'), 5000);
|
|
1336
|
+
return true;
|
|
1337
|
+
} catch (err) {
|
|
1338
|
+
console.log(err);
|
|
1339
|
+
this.showToaster('error', this.t('toaster.error'), 5000);
|
|
1340
|
+
return false;
|
|
1341
|
+
} finally {
|
|
1342
|
+
this.isLoading = false;
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
async definedAnswers(filter, whichSurvey, value = null, index = null) {
|
|
1346
|
+
if (!this.formStore.definedAnswersId[whichSurvey].hasOwnProperty(filter)) {
|
|
1347
|
+
this.formStore.definedAnswersId[whichSurvey][filter] = await this.api.definedAnswers(filter);
|
|
1348
|
+
}
|
|
1349
|
+
if (value !== null && this.formStore.definedAnswersId[whichSurvey][filter].length) {
|
|
1350
|
+
const answer = this.formStore.definedAnswersId[whichSurvey][filter].find(answer => answer.nameRu === value);
|
|
1351
|
+
this.formStore[whichSurvey].body[index].first.answerId = answer.ids;
|
|
1352
|
+
}
|
|
1353
|
+
return this.formStore.definedAnswersId[whichSurvey];
|
|
1354
|
+
},
|
|
1355
|
+
async getPaymentTable(id) {
|
|
1356
|
+
try {
|
|
1357
|
+
const paymentResultTable = await this.api.calculatePremuim(id);
|
|
1358
|
+
if (paymentResultTable.length > 0) {
|
|
1359
|
+
this.paymentResultTable = paymentResultTable;
|
|
1360
|
+
} else {
|
|
1361
|
+
this.paymentResultTable = [];
|
|
1362
|
+
}
|
|
1363
|
+
} catch (err) {
|
|
1364
|
+
console.log(err);
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
async getDefaultCalculationData(showLoader = false) {
|
|
1368
|
+
this.isLoading = showLoader;
|
|
1369
|
+
try {
|
|
1370
|
+
const calculationData = await this.api.getDefaultCalculationData();
|
|
1371
|
+
return calculationData;
|
|
1372
|
+
} catch (err) {
|
|
1373
|
+
ErrorHandler(err);
|
|
1374
|
+
} finally {
|
|
1375
|
+
this.isLoading = false;
|
|
1376
|
+
}
|
|
1377
|
+
},
|
|
1378
|
+
async calculateWithoutApplication(showLoader = false) {
|
|
1379
|
+
this.isLoading = showLoader;
|
|
1380
|
+
try {
|
|
1381
|
+
const calculationData = {
|
|
1382
|
+
signDate: formatDate(this.formStore.productConditionsForm.signDate)?.toISOString(),
|
|
1383
|
+
birthDate: formatDate(this.formStore.productConditionsForm.birthDate)?.toISOString(),
|
|
1384
|
+
gender: this.formStore.productConditionsForm.gender.id,
|
|
1385
|
+
amount: getNumber(this.formStore.productConditionsForm.requestedSumInsured),
|
|
1386
|
+
premium: getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonth),
|
|
1387
|
+
coverPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1388
|
+
payPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1389
|
+
indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
|
|
1390
|
+
? this.formStore.productConditionsForm.processIndexRate.id
|
|
1391
|
+
: this.processIndexRate.find(i => i.code === '0')?.id,
|
|
1392
|
+
paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
|
|
1393
|
+
addCovers: this.formStore.additionalInsuranceTermsWithout,
|
|
1394
|
+
};
|
|
1395
|
+
console.log(calculationData);
|
|
1396
|
+
const calculationResponse = await this.api.calculateWithoutApplication(calculationData);
|
|
1397
|
+
this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
|
|
1398
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
|
|
1399
|
+
this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
|
|
1400
|
+
this.showToaster('success', this.t('toaster.calculated'), 1000);
|
|
1401
|
+
} catch (err) {
|
|
1402
|
+
ErrorHandler(err);
|
|
1403
|
+
} finally {
|
|
1404
|
+
this.isLoading = false;
|
|
1405
|
+
return !!this.formStore.productConditionsForm.requestedSumInsured && !!this.formStore.productConditionsForm.insurancePremiumPerMonth;
|
|
1406
|
+
}
|
|
1407
|
+
},
|
|
1408
|
+
async calculate(taskId) {
|
|
1409
|
+
this.isLoading = true;
|
|
1410
|
+
try {
|
|
1411
|
+
let form1 = {
|
|
1412
|
+
baiterekApp: null,
|
|
1413
|
+
policyAppDto: {
|
|
1414
|
+
id: this.formStore.applicationData.policyAppDto.id,
|
|
1415
|
+
processInstanceId: this.formStore.applicationData.policyAppDto.processInstanceId,
|
|
1416
|
+
policyId: null,
|
|
1417
|
+
policyNumber: null,
|
|
1418
|
+
contractDate: this.currentDate(),
|
|
1419
|
+
amount: this.formStore.productConditionsForm.requestedSumInsured != null ? Number(this.formStore.productConditionsForm.requestedSumInsured.replace(/\s/g, '')) : null,
|
|
1420
|
+
premium:
|
|
1421
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth != null
|
|
1422
|
+
? Number(this.formStore.productConditionsForm.insurancePremiumPerMonth.replace(/\s/g, ''))
|
|
1423
|
+
: null,
|
|
1424
|
+
isSpokesman: this.formStore.hasRepresentative,
|
|
1425
|
+
coverPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1426
|
+
payPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1427
|
+
annualIncome: this.formStore.productConditionsForm.annualIncome ? Number(this.formStore.productConditionsForm.annualIncome.replace(/\s/g, '')) : null,
|
|
1428
|
+
indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
|
|
1429
|
+
? this.formStore.productConditionsForm.processIndexRate.id
|
|
1430
|
+
: this.processIndexRate.find(i => i.code === '0')?.id,
|
|
1431
|
+
paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
|
|
1432
|
+
lifeMultiply: formatProcents(this.formStore.productConditionsForm.lifeMultiply),
|
|
1433
|
+
lifeAdditive: formatProcents(this.formStore.productConditionsForm.lifeAdditive),
|
|
1434
|
+
adbMultiply: formatProcents(this.formStore.productConditionsForm.adbMultiply),
|
|
1435
|
+
adbAdditive: formatProcents(this.formStore.productConditionsForm.adbAdditive),
|
|
1436
|
+
disabilityMultiply: formatProcents(this.formStore.productConditionsForm.disabilityMultiply),
|
|
1437
|
+
disabilityAdditive: formatProcents(this.formStore.productConditionsForm.adbAdditive),
|
|
1438
|
+
riskGroup: this.formStore.productConditionsForm.riskGroup?.id ? this.formStore.productConditionsForm.riskGroup.id : 1,
|
|
1439
|
+
},
|
|
1440
|
+
addCoversDto: this.formStore.additionalInsuranceTerms,
|
|
1441
|
+
};
|
|
1442
|
+
|
|
1443
|
+
try {
|
|
1444
|
+
let id = this.formStore.applicationData.processInstanceId;
|
|
1445
|
+
|
|
1446
|
+
await this.api.setApplication(form1);
|
|
1447
|
+
let result;
|
|
1448
|
+
try {
|
|
1449
|
+
result = await this.api.getCalculation(id);
|
|
1450
|
+
} catch (err) {
|
|
1451
|
+
this.showToaster('error', err?.response?.data, 5000);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
const applicationData = await this.api.getApplicationData(taskId);
|
|
1455
|
+
this.formStore.applicationData = applicationData;
|
|
1456
|
+
this.formStore.additionalInsuranceTerms = this.formStore.applicationData.addCoverDto;
|
|
1457
|
+
if (this.formStore.productConditionsForm.insurancePremiumPerMonth != null) {
|
|
1458
|
+
this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(result);
|
|
1459
|
+
} else {
|
|
1460
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result);
|
|
1461
|
+
}
|
|
1462
|
+
this.showToaster('success', this.t('toaster.calculated'), 1000);
|
|
1463
|
+
} catch (err) {
|
|
1464
|
+
console.log(err);
|
|
1465
|
+
}
|
|
1466
|
+
} catch (err) {
|
|
1467
|
+
ErrorHandler(err);
|
|
1468
|
+
console.log(err, 'error');
|
|
1469
|
+
}
|
|
1470
|
+
this.isLoading = false;
|
|
1471
|
+
},
|
|
1472
|
+
async startApplication(member) {
|
|
1473
|
+
try {
|
|
1474
|
+
const data = {
|
|
1475
|
+
clientId: member.id,
|
|
1476
|
+
iin: member.iin.replace(/-/g, ''),
|
|
1477
|
+
longName: member.longName,
|
|
1478
|
+
processCode: this.processCode,
|
|
1479
|
+
policyId: 0,
|
|
1480
|
+
};
|
|
1481
|
+
const response = await this.api.startApplication(data);
|
|
1482
|
+
this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
|
|
1483
|
+
return response.processInstanceId;
|
|
1484
|
+
} catch (err) {
|
|
1485
|
+
return ErrorHandler(err);
|
|
1486
|
+
}
|
|
1487
|
+
},
|
|
1488
|
+
async getApplicationData(taskId, onlyGet = true, setMembersField = true, fetchMembers = true, setProductConditions = true) {
|
|
1489
|
+
if (onlyGet) {
|
|
1490
|
+
this.isLoading = true;
|
|
1491
|
+
}
|
|
1492
|
+
try {
|
|
1493
|
+
const applicationData = await this.api.getApplicationData(taskId);
|
|
1494
|
+
if (this.processCode !== applicationData.processCode) {
|
|
1495
|
+
this.isLoading = false;
|
|
1496
|
+
this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
this.formStore.applicationData = applicationData;
|
|
1500
|
+
this.formStore.additionalInsuranceTerms = applicationData.addCoverDto;
|
|
1501
|
+
|
|
1502
|
+
this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
|
|
1503
|
+
this.formStore.applicationTaskId = taskId;
|
|
1504
|
+
this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
|
|
1505
|
+
this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
|
|
1506
|
+
this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
|
|
1507
|
+
this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
|
|
1508
|
+
this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
|
|
1509
|
+
this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
|
|
1510
|
+
|
|
1511
|
+
this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
|
|
1512
|
+
this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
|
|
1513
|
+
|
|
1514
|
+
const clientData = applicationData.clientApp;
|
|
1515
|
+
const insuredData = applicationData.insuredApp;
|
|
1516
|
+
const spokesmanData = applicationData.spokesmanApp;
|
|
1517
|
+
const beneficiaryData = applicationData.beneficiaryApp;
|
|
1518
|
+
const beneficialOwnerData = applicationData.beneficialOwnerApp;
|
|
1519
|
+
|
|
1520
|
+
this.formStore.isPolicyholderInsured = clientData.isInsured;
|
|
1521
|
+
this.formStore.isActOwnBehalf = clientData.isActOwnBehalf;
|
|
1522
|
+
this.formStore.hasRepresentative = !!applicationData.spokesmanApp;
|
|
1523
|
+
|
|
1524
|
+
const beneficiaryPolicyholderIndex = beneficiaryData.findIndex(i => i.insisId === clientData.insisId);
|
|
1525
|
+
this.formStore.isPolicyholderBeneficiary = beneficiaryPolicyholderIndex !== -1;
|
|
1526
|
+
|
|
1527
|
+
if (fetchMembers) {
|
|
1528
|
+
let allMembers = [
|
|
1529
|
+
{
|
|
1530
|
+
...clientData,
|
|
1531
|
+
key: this.formStore.policyholderFormKey,
|
|
1532
|
+
index: null,
|
|
1533
|
+
},
|
|
1534
|
+
];
|
|
1535
|
+
|
|
1536
|
+
if (spokesmanData) {
|
|
1537
|
+
allMembers.push({
|
|
1538
|
+
...spokesmanData,
|
|
1539
|
+
key: this.formStore.policyholdersRepresentativeFormKey,
|
|
1540
|
+
index: null,
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
if (insuredData && insuredData.length) {
|
|
1545
|
+
insuredData.forEach((member, index) => {
|
|
1546
|
+
const inStore = this.formStore.insuredForm.find(each => each.id == member.insisId);
|
|
1547
|
+
if (!inStore) {
|
|
1548
|
+
member.key = this.formStore.insuredFormKey;
|
|
1549
|
+
member.index = index;
|
|
1550
|
+
allMembers.push(member);
|
|
1551
|
+
if (this.formStore.insuredForm.length - 1 < index) {
|
|
1552
|
+
this.formStore.insuredForm.push(new InsuredForm());
|
|
1016
1553
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
if (beneficiaryData && beneficiaryData.length) {
|
|
1558
|
+
beneficiaryData.forEach((member, index) => {
|
|
1559
|
+
const inStore = this.formStore.beneficiaryForm.find(each => each.id == member.insisId);
|
|
1560
|
+
if (!inStore) {
|
|
1561
|
+
member.key = this.formStore.beneficiaryFormKey;
|
|
1562
|
+
member.index = index;
|
|
1563
|
+
allMembers.push(member);
|
|
1564
|
+
if (this.formStore.beneficiaryForm.length - 1 < index) {
|
|
1565
|
+
this.formStore.beneficiaryForm.push(new BeneficiaryForm());
|
|
1020
1566
|
}
|
|
1021
1567
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
if (beneficialOwnerData && beneficialOwnerData.length) {
|
|
1571
|
+
beneficialOwnerData.forEach((member, index) => {
|
|
1572
|
+
const inStore = this.formStore.beneficialOwnerForm.find(each => each.id == member.insisId);
|
|
1573
|
+
if (!inStore) {
|
|
1574
|
+
member.key = this.formStore.beneficialOwnerFormKey;
|
|
1575
|
+
member.index = index;
|
|
1576
|
+
allMembers.push(member);
|
|
1577
|
+
if (this.formStore.beneficialOwnerForm.length - 1 < index) {
|
|
1578
|
+
this.formStore.beneficialOwnerForm.push(new BeneficialOwnerForm());
|
|
1579
|
+
}
|
|
1025
1580
|
}
|
|
1026
|
-
}
|
|
1027
|
-
this.showToaster('error', this.t('toaster.undefinedError'), 3000);
|
|
1028
|
-
return { otpStatus };
|
|
1029
|
-
}
|
|
1581
|
+
});
|
|
1030
1582
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1583
|
+
|
|
1584
|
+
await Promise.allSettled(
|
|
1585
|
+
allMembers.map(async member => {
|
|
1586
|
+
await this.getContragentById(member.insisId, member.key, false, member.index);
|
|
1587
|
+
}),
|
|
1588
|
+
);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
if (setMembersField) {
|
|
1592
|
+
this.setMembersField(this.formStore.policyholderFormKey, 'clientApp');
|
|
1593
|
+
if (insuredData && insuredData.length) {
|
|
1594
|
+
insuredData.forEach((each, index) => {
|
|
1595
|
+
this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
|
|
1596
|
+
});
|
|
1040
1597
|
}
|
|
1598
|
+
|
|
1599
|
+
if (beneficiaryData && beneficiaryData.length) {
|
|
1600
|
+
beneficiaryData.forEach((each, index) => {
|
|
1601
|
+
this.setMembersFieldIndex(this.formStore.beneficiaryFormKey, 'beneficiaryApp', index);
|
|
1602
|
+
const relationDegree = this.relations.find(i => i.ids == each.relationId);
|
|
1603
|
+
this.formStore.beneficiaryForm[index].relationDegree = relationDegree ? relationDegree : new Value();
|
|
1604
|
+
this.formStore.beneficiaryForm[index].percentageOfPayoutAmount = each.percentage;
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
if (beneficialOwnerData && beneficialOwnerData.length) {
|
|
1609
|
+
beneficialOwnerData.forEach((each, index) => {
|
|
1610
|
+
this.setMembersFieldIndex(this.formStore.beneficialOwnerFormKey, 'beneficialOwnerApp', index);
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
if (!!spokesmanData) {
|
|
1615
|
+
this.formStore.policyholdersRepresentativeForm.signOfIPDL = spokesmanData.isIpdl ? this.ipdl[1] : this.ipdl[2];
|
|
1616
|
+
this.formStore.policyholdersRepresentativeForm.migrationCard = spokesmanData.migrationCard;
|
|
1617
|
+
this.formStore.policyholdersRepresentativeForm.migrationCardIssueDate = reformatDate(spokesmanData.migrationCardIssueDate);
|
|
1618
|
+
this.formStore.policyholdersRepresentativeForm.migrationCardExpireDate = reformatDate(spokesmanData.migrationCardExpireDate);
|
|
1619
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocType = spokesmanData.confirmDocType;
|
|
1620
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocNumber = spokesmanData.confirmDocNumber;
|
|
1621
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocIssueDate = reformatDate(spokesmanData.confirmDocIssueDate);
|
|
1622
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocExpireDate = reformatDate(spokesmanData.confirmDocExpireDate);
|
|
1623
|
+
this.formStore.policyholdersRepresentativeForm.notaryLongName = spokesmanData.notaryLongName;
|
|
1624
|
+
this.formStore.policyholdersRepresentativeForm.notaryLicenseNumber = spokesmanData.notaryLicenseNumber;
|
|
1625
|
+
this.formStore.policyholdersRepresentativeForm.notaryLicenseDate = reformatDate(spokesmanData.notaryLicenseDate);
|
|
1626
|
+
this.formStore.policyholdersRepresentativeForm.notaryLicenseIssuer = spokesmanData.notaryLicenseIssuer;
|
|
1627
|
+
this.formStore.policyholdersRepresentativeForm.jurLongName = spokesmanData.jurLongName;
|
|
1628
|
+
this.formStore.policyholdersRepresentativeForm.fullNameRod = spokesmanData.fullNameRod;
|
|
1629
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocTypeKz = spokesmanData.confirmDocTypeKz;
|
|
1630
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocTypeRod = spokesmanData.confirmDocTypeRod;
|
|
1631
|
+
this.formStore.policyholdersRepresentativeForm.isNotary = spokesmanData.isNotary;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
if (setProductConditions) {
|
|
1635
|
+
this.formStore.productConditionsForm.coverPeriod = applicationData.policyAppDto.coverPeriod;
|
|
1636
|
+
this.formStore.productConditionsForm.payPeriod = applicationData.policyAppDto.payPeriod;
|
|
1637
|
+
// this.formStore.productConditionsForm.annualIncome = applicationData.policyAppDto.annualIncome?.toString();
|
|
1638
|
+
this.formStore.productConditionsForm.lifeMultiply = parseProcents(applicationData.policyAppDto.lifeMultiply);
|
|
1639
|
+
this.formStore.productConditionsForm.lifeAdditive = parseProcents(applicationData.policyAppDto.lifeAdditive);
|
|
1640
|
+
this.formStore.productConditionsForm.adbMultiply = parseProcents(applicationData.policyAppDto.adbMultiply);
|
|
1641
|
+
this.formStore.productConditionsForm.adbAdditive = parseProcents(applicationData.policyAppDto.adbAdditive);
|
|
1642
|
+
this.formStore.productConditionsForm.disabilityMultiply = parseProcents(applicationData.policyAppDto.disabilityMultiply);
|
|
1643
|
+
this.formStore.productConditionsForm.disabilityAdditive = parseProcents(applicationData.policyAppDto.disabilityAdditive);
|
|
1644
|
+
|
|
1645
|
+
let processIndexRate = this.processIndexRate.find(item => item.id == applicationData.policyAppDto.indexRateId);
|
|
1646
|
+
this.formStore.productConditionsForm.processIndexRate = processIndexRate ? processIndexRate : this.processIndexRate.find(item => item.code === '0');
|
|
1647
|
+
|
|
1648
|
+
let paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
|
|
1649
|
+
this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
|
|
1650
|
+
|
|
1651
|
+
this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(
|
|
1652
|
+
applicationData.policyAppDto.amount === null ? null : applicationData.policyAppDto.amount,
|
|
1653
|
+
);
|
|
1654
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
|
|
1655
|
+
applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium,
|
|
1656
|
+
);
|
|
1657
|
+
|
|
1658
|
+
let riskGroup = this.riskGroup.find(item => {
|
|
1659
|
+
if (applicationData.policyAppDto.riskGroup == 0) {
|
|
1660
|
+
return true;
|
|
1661
|
+
}
|
|
1662
|
+
return item.id == applicationData.policyAppDto.riskGroup;
|
|
1663
|
+
});
|
|
1664
|
+
this.formStore.productConditionsForm.riskGroup = riskGroup ? riskGroup : this.riskGroup.find(item => item.id == 1);
|
|
1041
1665
|
}
|
|
1042
|
-
return { otpStatus, otpResponse };
|
|
1043
1666
|
} catch (err) {
|
|
1044
|
-
|
|
1667
|
+
console.log(err);
|
|
1045
1668
|
if ('response' in err) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1669
|
+
this.sendToParent(constants.postActions.toHomePage, err.response.data);
|
|
1670
|
+
this.isLoading = false;
|
|
1671
|
+
return false;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
if (onlyGet) {
|
|
1675
|
+
this.isLoading = false;
|
|
1676
|
+
}
|
|
1677
|
+
},
|
|
1678
|
+
async setApplication() {
|
|
1679
|
+
try {
|
|
1680
|
+
await this.api.setApplication(this.formStore.applicationData);
|
|
1681
|
+
} catch (err) {
|
|
1682
|
+
console.log(err);
|
|
1683
|
+
}
|
|
1684
|
+
},
|
|
1685
|
+
async deleteTask(taskId) {
|
|
1686
|
+
this.isLoading = true;
|
|
1687
|
+
try {
|
|
1688
|
+
const data = {
|
|
1689
|
+
taskId: taskId,
|
|
1690
|
+
decision: 'rejectclient',
|
|
1691
|
+
comment: 'Клиент отказался',
|
|
1692
|
+
};
|
|
1693
|
+
await this.api.sendTask(data);
|
|
1694
|
+
this.showToaster('success', this.t('toaster.applicationDeleted'), 2000);
|
|
1695
|
+
} catch (err) {
|
|
1696
|
+
if ('response' in err && err.response.data) {
|
|
1697
|
+
this.showToaster('error', this.t('toaster.error') + err.response.data, 2000);
|
|
1698
|
+
}
|
|
1699
|
+
console.log(err);
|
|
1700
|
+
}
|
|
1701
|
+
this.isLoading = false;
|
|
1702
|
+
},
|
|
1703
|
+
async sendTask(taskId, decision, comment = null) {
|
|
1704
|
+
this.isLoading = true;
|
|
1705
|
+
try {
|
|
1706
|
+
const data = {
|
|
1707
|
+
taskId: taskId,
|
|
1708
|
+
decision: decision,
|
|
1709
|
+
};
|
|
1710
|
+
await this.api.sendTask(comment === null ? data : { ...data, comment: comment });
|
|
1711
|
+
this.showToaster('success', this.t('toaster.successOperation'), 3000);
|
|
1712
|
+
this.isLoading = false;
|
|
1713
|
+
return true;
|
|
1714
|
+
} catch (err) {
|
|
1715
|
+
console.log(err);
|
|
1716
|
+
if ('response' in err && err.response.data) {
|
|
1717
|
+
this.showToaster('error', this.t('toaster.error') + err.response.data, 2000);
|
|
1718
|
+
}
|
|
1719
|
+
this.isLoading = false;
|
|
1720
|
+
return false;
|
|
1721
|
+
}
|
|
1722
|
+
},
|
|
1723
|
+
async handleTask(action, taskId, comment) {
|
|
1724
|
+
if (action && Object.keys(constants.actions).includes(action)) {
|
|
1725
|
+
switch (action) {
|
|
1726
|
+
case constants.actions.claim: {
|
|
1727
|
+
try {
|
|
1728
|
+
this.isLoading = true;
|
|
1729
|
+
await this.api.claimTask(this.formStore.applicationTaskId);
|
|
1730
|
+
await this.getApplicationData(taskId, false, false, false);
|
|
1731
|
+
this.showToaster('success', this.t('toaster.successOperation'), 3000);
|
|
1732
|
+
} catch (err) {
|
|
1733
|
+
console.log(err);
|
|
1734
|
+
if ('response' in err && err.response.data) {
|
|
1735
|
+
this.showToaster('error', err.response.data, 3000);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1056
1738
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1739
|
+
case constants.actions.reject:
|
|
1740
|
+
case constants.actions.return:
|
|
1741
|
+
case constants.actions.rejectclient:
|
|
1742
|
+
case constants.actions.accept: {
|
|
1743
|
+
try {
|
|
1744
|
+
await this.sendTask(taskId, action, comment);
|
|
1745
|
+
this.formStore.$reset();
|
|
1746
|
+
if (this.isEFO) {
|
|
1747
|
+
await this.router.push({ name: 'Insurance-Product' });
|
|
1748
|
+
} else {
|
|
1749
|
+
this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
|
|
1750
|
+
}
|
|
1751
|
+
} catch (err) {
|
|
1752
|
+
console.log(err);
|
|
1753
|
+
if ('response' in err && err.response.data) {
|
|
1754
|
+
this.showToaster('error', err.response.data, 3000);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1060
1757
|
}
|
|
1061
1758
|
}
|
|
1062
|
-
}
|
|
1759
|
+
} else {
|
|
1760
|
+
console.error('No handleTask action');
|
|
1761
|
+
}
|
|
1762
|
+
},
|
|
1763
|
+
async getInvoiceData(processInstanceId) {
|
|
1764
|
+
try {
|
|
1765
|
+
const response = await this.api.getInvoiceData(processInstanceId);
|
|
1766
|
+
if (response) {
|
|
1767
|
+
return response;
|
|
1768
|
+
} else {
|
|
1769
|
+
return false;
|
|
1770
|
+
}
|
|
1771
|
+
} catch (err) {
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
},
|
|
1775
|
+
async createInvoice() {
|
|
1776
|
+
try {
|
|
1777
|
+
const created = await this.api.createInvoice(this.formStore.applicationData.processInstanceId, this.formStore.applicationData.policyAppDto.premium);
|
|
1778
|
+
return !!created;
|
|
1779
|
+
} catch (err) {
|
|
1063
1780
|
this.isLoading = false;
|
|
1064
1781
|
}
|
|
1065
|
-
this.isLoading = false;
|
|
1066
|
-
return { otpStatus, otpResponse };
|
|
1067
1782
|
},
|
|
1068
|
-
async
|
|
1783
|
+
async sendToEpay() {
|
|
1069
1784
|
try {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1785
|
+
const response = await this.api.sendToEpay(this.formStore.applicationData.processInstanceId);
|
|
1786
|
+
if (response) {
|
|
1787
|
+
return response;
|
|
1788
|
+
}
|
|
1789
|
+
} catch (err) {
|
|
1790
|
+
console.log(err);
|
|
1791
|
+
}
|
|
1792
|
+
},
|
|
1793
|
+
setMembersField(whichForm, whichMember) {
|
|
1794
|
+
this.formStore[whichForm].familyStatus = this.findObject('familyStatuses', 'id', this.formStore.applicationData[whichMember].familyStatusId);
|
|
1795
|
+
this.formStore[whichForm].signOfIPDL = this.findObject(
|
|
1796
|
+
'ipdl',
|
|
1797
|
+
'nameRu',
|
|
1798
|
+
this.formStore.applicationData[whichMember].isIpdl === null ? null : this.formStore.applicationData[whichMember].isIpdl == true ? 'Да' : 'Нет',
|
|
1799
|
+
);
|
|
1800
|
+
if (!!this.formStore.applicationData[whichMember].profession) this.formStore[whichForm].job = this.formStore.applicationData[whichMember].profession;
|
|
1801
|
+
if (!!this.formStore.applicationData[whichMember].position) this.formStore[whichForm].jobPosition = this.formStore.applicationData[whichMember].position;
|
|
1802
|
+
if (!!this.formStore.applicationData[whichMember].jobName) this.formStore[whichForm].jobPlace = this.formStore.applicationData[whichMember].jobName;
|
|
1803
|
+
},
|
|
1804
|
+
setMembersFieldIndex(whichForm, whichMember, index) {
|
|
1805
|
+
if ('familyStatus' in this.formStore[whichForm][index]) {
|
|
1806
|
+
this.formStore[whichForm][index].familyStatus = this.findObject('familyStatuses', 'id', this.formStore.applicationData[whichMember][index].familyStatusId);
|
|
1807
|
+
}
|
|
1808
|
+
if ('signOfIPDL' in this.formStore[whichForm][index]) {
|
|
1809
|
+
this.formStore[whichForm][index].signOfIPDL = this.findObject(
|
|
1810
|
+
'ipdl',
|
|
1811
|
+
'nameRu',
|
|
1812
|
+
this.formStore.applicationData[whichMember][index].isIpdl === null ? null : this.formStore.applicationData[whichMember][index].isIpdl == true ? 'Да' : 'Нет',
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1815
|
+
if ('job' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].profession) {
|
|
1816
|
+
this.formStore[whichForm][index].job = this.formStore.applicationData[whichMember][index].profession;
|
|
1817
|
+
}
|
|
1818
|
+
if ('jobPosition' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].position) {
|
|
1819
|
+
this.formStore[whichForm][index].jobPosition = this.formStore.applicationData[whichMember][index].position;
|
|
1820
|
+
}
|
|
1821
|
+
if ('jobPlace' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].jobName) {
|
|
1822
|
+
this.formStore[whichForm][index].jobPlace = this.formStore.applicationData[whichMember][index].jobName;
|
|
1823
|
+
}
|
|
1824
|
+
},
|
|
1825
|
+
findObject(from, key, searchKey) {
|
|
1826
|
+
const found = this[from].find(i => i[key] == searchKey);
|
|
1827
|
+
return found || new Value();
|
|
1828
|
+
},
|
|
1829
|
+
async signToDocument(data) {
|
|
1830
|
+
try {
|
|
1831
|
+
if (this.formStore.signUrl) {
|
|
1832
|
+
return this.formStore.signUrl;
|
|
1833
|
+
}
|
|
1834
|
+
const result = await this.api.signToDocument(data);
|
|
1835
|
+
this.formStore.signUrl = result.uri;
|
|
1836
|
+
return this.formStore.signUrl;
|
|
1837
|
+
} catch (error) {
|
|
1838
|
+
this.showToaster('error', this.t('toaster.error') + error?.response?.data, 2000);
|
|
1839
|
+
}
|
|
1840
|
+
},
|
|
1841
|
+
sanitize(text) {
|
|
1842
|
+
if (text) {
|
|
1843
|
+
return text
|
|
1844
|
+
.replace(/\r?\n|\r/g, '')
|
|
1845
|
+
.replace(/\\/g, '')
|
|
1846
|
+
.replace(/"/g, '');
|
|
1847
|
+
}
|
|
1848
|
+
},
|
|
1849
|
+
async getSignedDocList(processInstanceId) {
|
|
1850
|
+
if (processInstanceId !== 0) {
|
|
1851
|
+
try {
|
|
1852
|
+
this.formStore.signedDocumentList = await this.api.getSignedDocList({
|
|
1853
|
+
processInstanceId: processInstanceId,
|
|
1854
|
+
});
|
|
1855
|
+
} catch (err) {
|
|
1856
|
+
console.log(err);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
},
|
|
1860
|
+
setFormsDisabled(isDisabled) {
|
|
1861
|
+
Object.keys(this.formStore.isDisabled).forEach(key => {
|
|
1862
|
+
this.formStore.isDisabled[key] = !!isDisabled;
|
|
1863
|
+
});
|
|
1864
|
+
},
|
|
1865
|
+
async reCalculate(processInstanceId, recalculationData, taskId, whichSum) {
|
|
1866
|
+
this.isLoading = true;
|
|
1867
|
+
try {
|
|
1868
|
+
const data = {
|
|
1869
|
+
processInstanceId: processInstanceId,
|
|
1870
|
+
...recalculationData,
|
|
1075
1871
|
};
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
|
|
1079
|
-
|
|
1872
|
+
const recalculatedValue = await this.api.reCalculate(data);
|
|
1873
|
+
if (!!recalculatedValue) {
|
|
1874
|
+
await this.getApplicationData(taskId, false, false, false);
|
|
1875
|
+
this.showToaster(
|
|
1876
|
+
'success',
|
|
1877
|
+
`${this.t('toaster.successRecalculation')}. ${whichSum == 'insurancePremiumPerMonth' ? 'Страховая премия' : 'Страховая сумма'}: ${this.getNumberWithSpaces(
|
|
1878
|
+
recalculatedValue,
|
|
1879
|
+
)}₸`,
|
|
1880
|
+
4000,
|
|
1881
|
+
);
|
|
1882
|
+
}
|
|
1883
|
+
} catch (err) {
|
|
1884
|
+
console.log(err);
|
|
1885
|
+
if ('response' in err) {
|
|
1886
|
+
this.showToaster('error', err?.response?.data, 5000);
|
|
1887
|
+
} else {
|
|
1888
|
+
this.showToaster('error', err, 5000);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
this.isLoading = false;
|
|
1892
|
+
},
|
|
1893
|
+
async getValidateClientESBD(data) {
|
|
1894
|
+
try {
|
|
1895
|
+
return await this.api.getValidateClientESBD(data);
|
|
1896
|
+
} catch (error) {
|
|
1897
|
+
this.isLoading = false;
|
|
1898
|
+
if ('response' in error && error.response.data) {
|
|
1899
|
+
this.showToaster('error', error.response.data, 5000);
|
|
1900
|
+
}
|
|
1901
|
+
console.log(error);
|
|
1902
|
+
return false;
|
|
1903
|
+
}
|
|
1904
|
+
},
|
|
1905
|
+
validateMultipleMembers(localKey, applicationKey, text) {
|
|
1906
|
+
if (this.formStore[localKey].length === this.formStore.applicationData[applicationKey].length) {
|
|
1907
|
+
if (this.formStore[localKey].length !== 0 && this.formStore.applicationData[applicationKey].length !== 0) {
|
|
1908
|
+
const localMembers = [...this.formStore[localKey]].sort((a, b) => a.id - b.id);
|
|
1909
|
+
const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.insisId - b.insisId);
|
|
1910
|
+
if (localMembers.every((each, index) => applicationMembers[index].insisId === each.id && applicationMembers[index].iin === each.iin.replace(/-/g, '')) === false) {
|
|
1911
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1912
|
+
return false;
|
|
1913
|
+
}
|
|
1914
|
+
if (localKey === this.formStore.beneficiaryFormKey) {
|
|
1915
|
+
const sumOfPercentage = localMembers.reduce((sum, member) => {
|
|
1916
|
+
return sum + Number(member.percentageOfPayoutAmount);
|
|
1917
|
+
}, 0);
|
|
1918
|
+
if (sumOfPercentage !== 100) {
|
|
1919
|
+
this.showToaster('error', this.t('toaster.errorSumOrPercentage'), 3000);
|
|
1920
|
+
return false;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
} else {
|
|
1925
|
+
if (this.formStore[localKey].some(i => i.iin !== null)) {
|
|
1926
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1927
|
+
return false;
|
|
1928
|
+
}
|
|
1929
|
+
if (this.formStore.applicationData[applicationKey].length !== 0) {
|
|
1930
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1931
|
+
return false;
|
|
1932
|
+
} else {
|
|
1933
|
+
if (this.formStore[localKey][0].iin !== null) {
|
|
1934
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1080
1935
|
return false;
|
|
1081
1936
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
return true;
|
|
1940
|
+
},
|
|
1941
|
+
async validateAllMembers(taskId, localCheck = false) {
|
|
1942
|
+
if (taskId == 0) {
|
|
1943
|
+
this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1946
|
+
if (this.formStore.policyholderForm.id !== this.formStore.applicationData.clientApp.insisId) {
|
|
1947
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', 'страхователя'), 3000);
|
|
1948
|
+
return false;
|
|
1949
|
+
}
|
|
1950
|
+
if (this.validateMultipleMembers(this.formStore.insuredFormKey, 'insuredApp', 'застрахованных') === false) {
|
|
1951
|
+
return false;
|
|
1952
|
+
}
|
|
1953
|
+
if (this.validateMultipleMembers(this.formStore.beneficiaryFormKey, 'beneficiaryApp', 'выгодоприобретателей') === false) {
|
|
1954
|
+
return false;
|
|
1955
|
+
}
|
|
1956
|
+
if (this.formStore.isActOwnBehalf === false) {
|
|
1957
|
+
if (this.validateMultipleMembers(this.formStore.beneficialOwnerFormKey, 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
|
|
1958
|
+
return false;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
if (this.formStore.hasRepresentative) {
|
|
1962
|
+
if (this.formStore.applicationData.spokesmanApp && this.formStore.policyholdersRepresentativeForm.id !== this.formStore.applicationData.spokesmanApp.insisId) {
|
|
1963
|
+
this.showToaster(
|
|
1964
|
+
'error',
|
|
1965
|
+
this.t('toaster.notSavedMember', {
|
|
1966
|
+
text: 'представителя страхователя',
|
|
1967
|
+
}),
|
|
1968
|
+
3000,
|
|
1969
|
+
);
|
|
1970
|
+
return false;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
|
|
1974
|
+
if (areValid) {
|
|
1975
|
+
await this.setINSISWorkData();
|
|
1976
|
+
} else {
|
|
1977
|
+
this.isLoading = false;
|
|
1978
|
+
this.showToaster('error', this.t('toaster.attachManagerError'), 3000);
|
|
1979
|
+
return false;
|
|
1980
|
+
}
|
|
1981
|
+
if (localCheck === false) {
|
|
1982
|
+
try {
|
|
1983
|
+
if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
|
|
1984
|
+
await Promise.allSettled(
|
|
1985
|
+
this.formStore.applicationData.beneficialOwnerApp.map(async member => {
|
|
1986
|
+
await this.api.deleteMember('BeneficialOwner', member.id);
|
|
1987
|
+
}),
|
|
1988
|
+
);
|
|
1989
|
+
}
|
|
1990
|
+
await this.getApplicationData(taskId, false);
|
|
1991
|
+
} catch (err) {
|
|
1992
|
+
console.log(err);
|
|
1993
|
+
this.showToaster('error', err, 5000);
|
|
1994
|
+
return false;
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
return true;
|
|
1999
|
+
},
|
|
2000
|
+
validateAnketa(whichSurvey) {
|
|
2001
|
+
const list = this.formStore[whichSurvey].body;
|
|
2002
|
+
if (!list || (list && list.length === 0)) return false;
|
|
2003
|
+
let notAnswered = 0;
|
|
2004
|
+
for (let x = 0; x < list.length; x++) {
|
|
2005
|
+
if ((list[x].first.definedAnswers === 'N' && !list[x].first.answerText) || (list[x].first.definedAnswers === 'Y' && !list[x].first.answerName)) {
|
|
2006
|
+
notAnswered = notAnswered + 1;
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
return notAnswered === 0;
|
|
2010
|
+
},
|
|
2011
|
+
async validateAllForms(taskId) {
|
|
2012
|
+
this.isLoading = true;
|
|
2013
|
+
const areMembersValid = await this.validateAllMembers(taskId);
|
|
2014
|
+
if (areMembersValid) {
|
|
2015
|
+
if (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) {
|
|
2016
|
+
const hasCritical = this.formStore.additionalInsuranceTerms?.find(cover => cover.coverTypeName === 'Критическое заболевание Застрахованного');
|
|
2017
|
+
if (hasCritical && hasCritical.coverSumName !== 'не включено') {
|
|
2018
|
+
await Promise.allSettled([
|
|
2019
|
+
this.getQuestionList(
|
|
2020
|
+
'health',
|
|
2021
|
+
this.formStore.applicationData.processInstanceId,
|
|
2022
|
+
this.formStore.applicationData.insuredApp[0].id,
|
|
2023
|
+
'surveyByHealthBase',
|
|
2024
|
+
'surveyByHealthSecond',
|
|
2025
|
+
),
|
|
2026
|
+
this.getQuestionList(
|
|
2027
|
+
'critical',
|
|
2028
|
+
this.formStore.applicationData.processInstanceId,
|
|
2029
|
+
this.formStore.applicationData.insuredApp[0].id,
|
|
2030
|
+
'surveyByCriticalBase',
|
|
2031
|
+
'surveyByCriticalSecond',
|
|
2032
|
+
),
|
|
2033
|
+
]);
|
|
2034
|
+
await Promise.allSettled([
|
|
2035
|
+
...this.formStore.surveyByHealthBase.body.map(async question => {
|
|
2036
|
+
await this.definedAnswers(question.first.id, 'surveyByHealthBase');
|
|
2037
|
+
}),
|
|
2038
|
+
...this.formStore.surveyByCriticalBase.body.map(async question => {
|
|
2039
|
+
await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
|
|
2040
|
+
}),
|
|
2041
|
+
]);
|
|
2042
|
+
} else {
|
|
2043
|
+
await Promise.allSettled([
|
|
2044
|
+
this.getQuestionList(
|
|
2045
|
+
'health',
|
|
2046
|
+
this.formStore.applicationData.processInstanceId,
|
|
2047
|
+
this.formStore.applicationData.insuredApp[0].id,
|
|
2048
|
+
'surveyByHealthBase',
|
|
2049
|
+
'surveyByHealthSecond',
|
|
2050
|
+
),
|
|
2051
|
+
]);
|
|
2052
|
+
await Promise.allSettled(
|
|
2053
|
+
this.surveyByHealthBase.body.map(async question => {
|
|
2054
|
+
await this.definedAnswers(question.first.id, 'surveyByHealthBase');
|
|
2055
|
+
}),
|
|
1088
2056
|
);
|
|
1089
|
-
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
if (this.validateAnketa('surveyByHealthBase')) {
|
|
2060
|
+
let hasCriticalAndItsValid = null;
|
|
2061
|
+
if (hasCritical && hasCritical.coverSumName !== 'не включено') {
|
|
2062
|
+
if (this.validateAnketa('surveyByCriticalBase')) {
|
|
2063
|
+
hasCriticalAndItsValid = true;
|
|
2064
|
+
} else {
|
|
2065
|
+
hasCriticalAndItsValid = false;
|
|
2066
|
+
this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
|
|
2067
|
+
}
|
|
2068
|
+
} else {
|
|
2069
|
+
hasCriticalAndItsValid = null;
|
|
2070
|
+
}
|
|
2071
|
+
if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
|
|
2072
|
+
this.isLoading = false;
|
|
1090
2073
|
return true;
|
|
1091
2074
|
}
|
|
2075
|
+
} else {
|
|
2076
|
+
this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
|
|
1092
2077
|
}
|
|
2078
|
+
} else {
|
|
2079
|
+
this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
|
|
1093
2080
|
}
|
|
1094
2081
|
return false;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
2082
|
+
}
|
|
2083
|
+
this.isLoading = false;
|
|
2084
|
+
return false;
|
|
2085
|
+
},
|
|
2086
|
+
async getFamilyInfo(iin, phoneNumber) {
|
|
2087
|
+
this.isLoading = true;
|
|
2088
|
+
try {
|
|
2089
|
+
const familyResponse = await this.api.getFamilyInfo({ iin: iin.replace(/-/g, ''), phoneNumber: formatPhone(phoneNumber) });
|
|
2090
|
+
if (familyResponse.status === 'PENDING') {
|
|
2091
|
+
this.showToaster('success', this.t('toaster.waitForClient'), 5000);
|
|
2092
|
+
this.isLoading = false;
|
|
2093
|
+
return;
|
|
1099
2094
|
}
|
|
2095
|
+
if (constants.gbdErrors.find(i => i === familyResponse.status)) {
|
|
2096
|
+
if (familyResponse.status === 'TIMEOUT') {
|
|
2097
|
+
this.showToaster('success', `${familyResponse.statusName}. Отправьте запрос еще раз`, 5000);
|
|
2098
|
+
} else {
|
|
2099
|
+
this.showToaster('error', familyResponse.statusName, 5000);
|
|
2100
|
+
}
|
|
2101
|
+
this.isLoading = false;
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2104
|
+
if (familyResponse.infoList && familyResponse.infoList.birthInfos && familyResponse.infoList.birthInfos.length) {
|
|
2105
|
+
const filteredBirthInfos = familyResponse.infoList.birthInfos.filter(
|
|
2106
|
+
member => member.childBirthDate && getAgeByBirthDate(member.childBirthDate) <= 15 && typeof member.childLifeStatus === 'number' && member.childLifeStatus === 0,
|
|
2107
|
+
);
|
|
2108
|
+
if (filteredBirthInfos && filteredBirthInfos.length) {
|
|
2109
|
+
this.formStore.birthInfos = filteredBirthInfos;
|
|
2110
|
+
this.showToaster('success', this.t('toaster.pickFamilyMember'), 3000);
|
|
2111
|
+
} else {
|
|
2112
|
+
this.formStore.birthInfos = [];
|
|
2113
|
+
this.showToaster('error', this.t('toaster.notFound'), 3000);
|
|
2114
|
+
}
|
|
2115
|
+
} else {
|
|
2116
|
+
this.formStore.birthInfos = [];
|
|
2117
|
+
this.showToaster('error', this.t('toaster.notFound'), 3000);
|
|
2118
|
+
}
|
|
2119
|
+
} catch (err) {
|
|
2120
|
+
ErrorHandler(err);
|
|
1100
2121
|
} finally {
|
|
1101
2122
|
this.isLoading = false;
|
|
1102
2123
|
}
|
|
1103
|
-
return null;
|
|
1104
2124
|
},
|
|
1105
|
-
async
|
|
2125
|
+
async getContragentFromGBDFL(iin, phoneNumber, whichForm, whichIndex) {
|
|
1106
2126
|
this.isLoading = true;
|
|
1107
2127
|
try {
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
|
|
2128
|
+
const data = {
|
|
2129
|
+
iin: iin.replace(/-/g, ''),
|
|
2130
|
+
phoneNumber: formatPhone(phoneNumber),
|
|
2131
|
+
};
|
|
2132
|
+
const gbdResponse = await this.api.getContragentFromGBDFL(data);
|
|
2133
|
+
if (gbdResponse.status === 'PENDING') {
|
|
2134
|
+
this.showToaster('success', this.t('toaster.waitForClient'), 5000);
|
|
2135
|
+
this.isLoading = false;
|
|
2136
|
+
return;
|
|
2137
|
+
}
|
|
2138
|
+
if (constants.gbdErrors.find(i => i === gbdResponse.status)) {
|
|
2139
|
+
if (gbdResponse.status === 'TIMEOUT') {
|
|
2140
|
+
this.showToaster('success', `${gbdResponse.statusName}. Отправьте запрос еще раз`, 5000);
|
|
2141
|
+
} else {
|
|
2142
|
+
this.showToaster('success', gbdResponse.statusName, 5000);
|
|
2143
|
+
}
|
|
2144
|
+
this.isLoading = false;
|
|
2145
|
+
return;
|
|
1111
2146
|
}
|
|
2147
|
+
const { person } = parseXML(gbdResponse.content, true, 'person');
|
|
2148
|
+
const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
|
|
2149
|
+
if (typeof whichIndex !== 'number') {
|
|
2150
|
+
if (this.formStore[whichForm].gosPersonData !== null && this.formStore[whichForm].gosPersonData.iin !== iin.replace(/-/g, '')) {
|
|
2151
|
+
this.formStore[whichForm].resetMember(false);
|
|
2152
|
+
}
|
|
2153
|
+
this.formStore[whichForm].gosPersonData = person;
|
|
2154
|
+
} else {
|
|
2155
|
+
if (this.formStore[whichForm][whichIndex].gosPersonData !== null && this.formStore[whichForm][whichIndex].gosPersonData.iin !== iin.replace(/-/g, '')) {
|
|
2156
|
+
this.formStore[whichForm][whichIndex].resetMember(false);
|
|
2157
|
+
}
|
|
2158
|
+
this.formStore[whichForm][whichIndex].gosPersonData = person;
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
await this.getContragent(typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex] : this.formStore[whichForm], whichForm, whichIndex, false);
|
|
2162
|
+
if (typeof whichIndex !== 'number') {
|
|
2163
|
+
this.formStore[whichForm].verifyDate = responseInfo.responseDate;
|
|
2164
|
+
this.formStore[whichForm].verifyType = 'GBDFL';
|
|
2165
|
+
} else {
|
|
2166
|
+
this.formStore[whichForm][whichIndex].verifyDate = responseInfo.responseDate;
|
|
2167
|
+
this.formStore[whichForm][whichIndex].verifyType = 'GBDFL';
|
|
2168
|
+
}
|
|
2169
|
+
await this.saveInStoreUserGBDFL(person, whichForm, whichIndex);
|
|
1112
2170
|
} catch (err) {
|
|
1113
2171
|
console.log(err);
|
|
2172
|
+
if ('response' in err) {
|
|
2173
|
+
this.showToaster('error', err.response.data, 3000);
|
|
2174
|
+
}
|
|
1114
2175
|
}
|
|
1115
2176
|
this.isLoading = false;
|
|
1116
2177
|
},
|
|
1117
|
-
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
2178
|
+
async saveInStoreUserGBDFL(person, whichForm, whichIndex = null) {
|
|
2179
|
+
if (whichIndex === null) {
|
|
2180
|
+
this.formStore[whichForm].firstName = person.name;
|
|
2181
|
+
this.formStore[whichForm].lastName = person.surname;
|
|
2182
|
+
this.formStore[whichForm].middleName = person.patronymic ? person.patronymic : '';
|
|
2183
|
+
this.formStore[whichForm].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
|
|
2184
|
+
this.formStore[whichForm].birthDate = reformatDate(person.birthDate);
|
|
2185
|
+
this.formStore[whichForm].genderName = person.gender.nameRu;
|
|
2186
|
+
|
|
2187
|
+
const gender = this.gender.find(i => i.id == person.gender.code);
|
|
2188
|
+
if (gender) this.formStore[whichForm].gender = gender;
|
|
2189
|
+
|
|
2190
|
+
const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
|
|
2191
|
+
if (birthPlace) this.formStore[whichForm].birthPlace = birthPlace;
|
|
2192
|
+
|
|
2193
|
+
const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
|
|
2194
|
+
if (countryOfCitizenship) this.formStore[whichForm].countryOfCitizenship = countryOfCitizenship;
|
|
2195
|
+
|
|
2196
|
+
const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
|
|
2197
|
+
if (regCountry) this.formStore[whichForm].registrationCountry = regCountry;
|
|
2198
|
+
|
|
2199
|
+
const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
|
|
2200
|
+
if (regProvince) this.formStore[whichForm].registrationProvince = regProvince;
|
|
2201
|
+
|
|
2202
|
+
if ('city' in person.regAddress && !!person.regAddress.city) {
|
|
2203
|
+
if (person.regAddress.city.includes(', ')) {
|
|
2204
|
+
const personCities = person.regAddress.city.split(', ');
|
|
2205
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2206
|
+
const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
|
|
2207
|
+
if (possibleCity) {
|
|
2208
|
+
this.formStore[whichForm].registrationCity = possibleCity;
|
|
2209
|
+
break;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
if (this.formStore[whichForm].registrationCity.nameRu === null) {
|
|
2213
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2214
|
+
const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
|
|
2215
|
+
if (possibleRegion) {
|
|
2216
|
+
this.formStore[whichForm].registrationRegion = possibleRegion;
|
|
2217
|
+
break;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
} else {
|
|
2222
|
+
const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
|
|
2223
|
+
if (regCity) this.formStore[whichForm].registrationCity = regCity;
|
|
2224
|
+
|
|
2225
|
+
if (this.formStore[whichForm].registrationCity.nameRu === null) {
|
|
2226
|
+
const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
|
|
2227
|
+
if (regRegion) this.formStore[whichForm].registrationRegion = regRegion;
|
|
2228
|
+
}
|
|
1124
2229
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
2230
|
+
}
|
|
2231
|
+
|
|
2232
|
+
if (this.formStore[whichForm].registrationCity.nameRu === null && this.formStore[whichForm].registrationRegion.nameRu === null) {
|
|
2233
|
+
const regCity = this.cities.find(
|
|
2234
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2235
|
+
);
|
|
2236
|
+
if (regCity) {
|
|
2237
|
+
this.formStore[whichForm].registrationCity = regCity;
|
|
2238
|
+
const regType = this.localityTypes.find(i => i.nameRu === 'город');
|
|
2239
|
+
if (regType) this.formStore[whichForm].registrationRegionType = regType;
|
|
2240
|
+
} else {
|
|
2241
|
+
const regRegion = this.regions.find(
|
|
2242
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2243
|
+
);
|
|
2244
|
+
if (regRegion) {
|
|
2245
|
+
this.formStore[whichForm].registrationRegion = regRegion;
|
|
2246
|
+
const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
|
|
2247
|
+
if (regType) this.formStore[whichForm].registrationRegionType = regType;
|
|
2248
|
+
}
|
|
1129
2249
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
if (person.regAddress.street.includes(', ')) {
|
|
2253
|
+
const personAddress = person.regAddress.street.split(', ');
|
|
2254
|
+
const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
|
|
2255
|
+
const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
|
|
2256
|
+
const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
|
|
2257
|
+
if (microDistrict) this.formStore[whichForm].registrationMicroDistrict = microDistrict;
|
|
2258
|
+
if (quarter) this.formStore[whichForm].registrationQuarter = quarter;
|
|
2259
|
+
if (street) this.formStore[whichForm].registrationStreet = street;
|
|
2260
|
+
} else {
|
|
2261
|
+
if (person.regAddress.street) this.formStore[whichForm].registrationStreet = person.regAddress.street;
|
|
2262
|
+
}
|
|
2263
|
+
if (person.regAddress.building) this.formStore[whichForm].registrationNumberHouse = person.regAddress.building;
|
|
2264
|
+
if (person.regAddress.flat) this.formStore[whichForm].registrationNumberApartment = person.regAddress.flat;
|
|
2265
|
+
|
|
2266
|
+
// TODO Доработать логику и для остальных
|
|
2267
|
+
if ('length' in person.documents.document) {
|
|
2268
|
+
const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
|
|
2269
|
+
if (validDocument) {
|
|
2270
|
+
const documentType = this.documentTypes.find(i => i.ids === '1UDL');
|
|
2271
|
+
if (documentType) this.formStore[whichForm].documentType = documentType;
|
|
2272
|
+
|
|
2273
|
+
this.formStore[whichForm].documentNumber = validDocument.number;
|
|
2274
|
+
this.formStore[whichForm].documentExpire = reformatDate(validDocument.endDate);
|
|
2275
|
+
this.formStore[whichForm].documentDate = reformatDate(validDocument.beginDate);
|
|
2276
|
+
this.formStore[whichForm].documentNumber = validDocument.number;
|
|
2277
|
+
|
|
2278
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2279
|
+
if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
|
|
2280
|
+
}
|
|
2281
|
+
} else {
|
|
2282
|
+
const documentType =
|
|
2283
|
+
person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
|
|
2284
|
+
? this.documentTypes.find(i => i.ids === '1UDL')
|
|
2285
|
+
: this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2286
|
+
? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2287
|
+
: new Value();
|
|
2288
|
+
if (documentType) this.formStore[whichForm].documentType = documentType;
|
|
2289
|
+
|
|
2290
|
+
const documentNumber = person.documents.document.number;
|
|
2291
|
+
if (documentNumber) this.formStore[whichForm].documentNumber = documentNumber;
|
|
2292
|
+
|
|
2293
|
+
const documentDate = person.documents.document.beginDate;
|
|
2294
|
+
if (documentDate) this.formStore[whichForm].documentDate = reformatDate(documentDate);
|
|
2295
|
+
|
|
2296
|
+
const documentExpire = person.documents.document.endDate;
|
|
2297
|
+
if (documentExpire) this.formStore[whichForm].documentExpire = reformatDate(documentExpire);
|
|
2298
|
+
|
|
2299
|
+
// TODO уточнить
|
|
2300
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2301
|
+
if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
|
|
2302
|
+
}
|
|
2303
|
+
const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
|
|
2304
|
+
if (economySectorCode) this.formStore[whichForm].economySectorCode = economySectorCode;
|
|
2305
|
+
} else {
|
|
2306
|
+
this.formStore[whichForm][whichIndex].firstName = person.name;
|
|
2307
|
+
this.formStore[whichForm][whichIndex].lastName = person.surname;
|
|
2308
|
+
this.formStore[whichForm][whichIndex].middleName = person.patronymic ? person.patronymic : '';
|
|
2309
|
+
this.formStore[whichForm][whichIndex].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
|
|
2310
|
+
this.formStore[whichForm][whichIndex].birthDate = reformatDate(person.birthDate);
|
|
2311
|
+
this.formStore[whichForm][whichIndex].genderName = person.gender.nameRu;
|
|
2312
|
+
|
|
2313
|
+
const gender = this.gender.find(i => i.id == person.gender.code);
|
|
2314
|
+
if (gender) this.formStore[whichForm][whichIndex].gender = gender;
|
|
2315
|
+
|
|
2316
|
+
const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
|
|
2317
|
+
if (birthPlace) this.formStore[whichForm][whichIndex].birthPlace = birthPlace;
|
|
2318
|
+
|
|
2319
|
+
const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
|
|
2320
|
+
if (countryOfCitizenship) this.formStore[whichForm][whichIndex].countryOfCitizenship = countryOfCitizenship;
|
|
2321
|
+
|
|
2322
|
+
const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
|
|
2323
|
+
if (regCountry) this.formStore[whichForm][whichIndex].registrationCountry = regCountry;
|
|
2324
|
+
|
|
2325
|
+
const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
|
|
2326
|
+
if (regProvince) this.formStore[whichForm][whichIndex].registrationProvince = regProvince;
|
|
2327
|
+
|
|
2328
|
+
if ('city' in person.regAddress && !!person.regAddress.city) {
|
|
2329
|
+
if (person.regAddress.city.includes(', ')) {
|
|
2330
|
+
const personCities = person.regAddress.city.split(', ');
|
|
2331
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2332
|
+
const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
|
|
2333
|
+
if (possibleCity) {
|
|
2334
|
+
this.formStore[whichForm][whichIndex].registrationCity = possibleCity;
|
|
2335
|
+
break;
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
|
|
2339
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2340
|
+
const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
|
|
2341
|
+
if (possibleRegion) {
|
|
2342
|
+
this.formStore[whichForm][whichIndex].registrationRegion = possibleRegion;
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
} else {
|
|
2348
|
+
const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
|
|
2349
|
+
if (regCity) this.formStore[whichForm][whichIndex].registrationCity = regCity;
|
|
2350
|
+
if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
|
|
2351
|
+
const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
|
|
2352
|
+
if (regRegion) this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
|
|
2353
|
+
}
|
|
1134
2354
|
}
|
|
1135
2355
|
}
|
|
2356
|
+
|
|
2357
|
+
if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null && this.formStore[whichForm][whichIndex].registrationRegion.nameRu === null) {
|
|
2358
|
+
const regCity = this.cities.find(
|
|
2359
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2360
|
+
);
|
|
2361
|
+
if (regCity) {
|
|
2362
|
+
this.formStore[whichForm][whichIndex].registrationCity = regCity;
|
|
2363
|
+
const regType = this.localityTypes.find(i => i.nameRu === 'город');
|
|
2364
|
+
if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
|
|
2365
|
+
} else {
|
|
2366
|
+
const regRegion = this.regions.find(
|
|
2367
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2368
|
+
);
|
|
2369
|
+
if (regRegion) {
|
|
2370
|
+
this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
|
|
2371
|
+
const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
|
|
2372
|
+
if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
if (person.regAddress.street.includes(', ')) {
|
|
2378
|
+
const personAddress = person.regAddress.street.split(', ');
|
|
2379
|
+
const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
|
|
2380
|
+
const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
|
|
2381
|
+
const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
|
|
2382
|
+
if (microDistrict) this.formStore[whichForm][whichIndex].registrationMicroDistrict = microDistrict;
|
|
2383
|
+
if (quarter) this.formStore[whichForm][whichIndex].registrationQuarter = quarter;
|
|
2384
|
+
if (street) this.formStore[whichForm][whichIndex].registrationStreet = street;
|
|
2385
|
+
} else {
|
|
2386
|
+
if (person.regAddress.street) this.formStore[whichForm][whichIndex].registrationStreet = person.regAddress.street;
|
|
2387
|
+
}
|
|
2388
|
+
if (person.regAddress.building) this.formStore[whichForm][whichIndex].registrationNumberHouse = person.regAddress.building;
|
|
2389
|
+
if (person.regAddress.flat) this.formStore[whichForm][whichIndex].registrationNumberApartment = person.regAddress.flat;
|
|
2390
|
+
|
|
2391
|
+
// TODO Доработать логику и для остальных
|
|
2392
|
+
if ('length' in person.documents.document) {
|
|
2393
|
+
const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
|
|
2394
|
+
if (validDocument) {
|
|
2395
|
+
const documentType = this.documentTypes.find(i => i.ids === '1UDL');
|
|
2396
|
+
if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
|
|
2397
|
+
this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
|
|
2398
|
+
this.formStore[whichForm][whichIndex].documentExpire = reformatDate(validDocument.endDate);
|
|
2399
|
+
this.formStore[whichForm][whichIndex].documentDate = reformatDate(validDocument.beginDate);
|
|
2400
|
+
this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
|
|
2401
|
+
|
|
2402
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2403
|
+
if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
|
|
2404
|
+
}
|
|
2405
|
+
} else {
|
|
2406
|
+
const documentType =
|
|
2407
|
+
person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
|
|
2408
|
+
? this.documentTypes.find(i => i.ids === '1UDL')
|
|
2409
|
+
: this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2410
|
+
? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2411
|
+
: new Value();
|
|
2412
|
+
if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
|
|
2413
|
+
|
|
2414
|
+
const documentNumber = person.documents.document.number;
|
|
2415
|
+
if (documentNumber) this.formStore[whichForm][whichIndex].documentNumber = documentNumber;
|
|
2416
|
+
|
|
2417
|
+
const documentDate = person.documents.document.beginDate;
|
|
2418
|
+
if (documentDate) this.formStore[whichForm][whichIndex].documentDate = reformatDate(documentDate);
|
|
2419
|
+
|
|
2420
|
+
const documentExpire = person.documents.document.endDate;
|
|
2421
|
+
if (documentExpire) this.formStore[whichForm][whichIndex].documentExpire = reformatDate(documentExpire);
|
|
2422
|
+
|
|
2423
|
+
// TODO уточнить
|
|
2424
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2425
|
+
if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
|
|
2426
|
+
}
|
|
2427
|
+
const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
|
|
2428
|
+
if (economySectorCode) this.formStore[whichForm][whichIndex].economySectorCode = economySectorCode;
|
|
2429
|
+
}
|
|
2430
|
+
},
|
|
2431
|
+
hasJobSection(whichForm) {
|
|
2432
|
+
switch (whichForm) {
|
|
2433
|
+
case this.formStore.beneficiaryFormKey:
|
|
2434
|
+
case this.formStore.beneficialOwnerFormKey:
|
|
2435
|
+
case this.formStore.policyholdersRepresentativeFormKey:
|
|
2436
|
+
return false;
|
|
2437
|
+
default:
|
|
2438
|
+
return true;
|
|
2439
|
+
}
|
|
2440
|
+
},
|
|
2441
|
+
hasBirthSection(whichForm) {
|
|
2442
|
+
if (this.isGons) return false;
|
|
2443
|
+
switch (whichForm) {
|
|
2444
|
+
case this.formStore.beneficiaryFormKey:
|
|
2445
|
+
return false;
|
|
2446
|
+
default:
|
|
2447
|
+
return true;
|
|
2448
|
+
}
|
|
2449
|
+
},
|
|
2450
|
+
hasPlaceSection(whichForm) {
|
|
2451
|
+
switch (whichForm) {
|
|
2452
|
+
default:
|
|
2453
|
+
return true;
|
|
2454
|
+
}
|
|
2455
|
+
},
|
|
2456
|
+
hasDocumentSection(whichForm) {
|
|
2457
|
+
switch (whichForm) {
|
|
2458
|
+
default:
|
|
2459
|
+
return true;
|
|
2460
|
+
}
|
|
2461
|
+
},
|
|
2462
|
+
hasContactSection(whichForm) {
|
|
2463
|
+
if (this.isGons) return false;
|
|
2464
|
+
switch (whichForm) {
|
|
2465
|
+
default:
|
|
2466
|
+
return true;
|
|
1136
2467
|
}
|
|
1137
2468
|
},
|
|
1138
2469
|
},
|