hl-core 0.0.7-beta.2 → 0.0.7-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +2 -1
- package/api/index.ts +295 -20
- package/api/interceptors.ts +10 -1
- package/components/Button/Btn.vue +7 -2
- package/components/Button/BtnIcon.vue +47 -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/Documents.vue +107 -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 +41 -0
- package/components/Form/MemberForm.vue +1132 -0
- package/components/Form/ProductConditions.vue +343 -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 +170 -0
- package/components/Input/PanelInput.vue +132 -0
- package/components/Input/RoundedInput.vue +39 -36
- package/components/Layout/Drawer.vue +42 -0
- package/components/Layout/Header.vue +25 -11
- 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/Panel/PanelItem.vue +5 -0
- package/components/Panel/PanelSelectItem.vue +20 -0
- package/components/Transitions/FadeTransition.vue +5 -0
- package/composables/classes.ts +401 -201
- package/composables/constants.ts +27 -12
- package/composables/index.ts +72 -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 +1871 -526
- 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 +120 -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.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,244 @@ 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
|
},
|
|
944
|
+
async setSurvey(data) {
|
|
945
|
+
try {
|
|
946
|
+
this.isLoading = true;
|
|
947
|
+
const anketaToken = await this.api.setSurvey(data);
|
|
948
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
949
|
+
this.showToaster('success', this.t('toaster.successSaved'), 2000);
|
|
950
|
+
return anketaToken;
|
|
951
|
+
} catch (error) {
|
|
952
|
+
ErrorHandler(err);
|
|
953
|
+
} finally {
|
|
954
|
+
this.isLoading = false;
|
|
955
|
+
}
|
|
956
|
+
},
|
|
727
957
|
async getFromApi(whichField, whichRequest, parameter) {
|
|
728
|
-
|
|
958
|
+
const storageValue = JSON.parse(localStorage.getItem(whichField) || 'null');
|
|
959
|
+
const currentHour = new Date().getHours();
|
|
960
|
+
|
|
961
|
+
const getDataCondition = () => {
|
|
962
|
+
if (!storageValue) return true;
|
|
963
|
+
const hasHourKey = 'hour' in storageValue;
|
|
964
|
+
const hasModeKey = 'mode' in storageValue;
|
|
965
|
+
const hasValueKey = 'value' in storageValue;
|
|
966
|
+
if (storageValue && (hasHourKey === false || hasModeKey === false || hasValueKey === false)) return true;
|
|
967
|
+
if (storageValue && (storageValue.hour !== currentHour || storageValue.mode !== import.meta.env.MODE || storageValue.value.length === 0)) return true;
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
if (getDataCondition()) {
|
|
971
|
+
this[whichField] = [];
|
|
729
972
|
try {
|
|
730
|
-
const response = await api[whichRequest](parameter);
|
|
973
|
+
const response = await this.api[whichRequest](parameter);
|
|
731
974
|
if (response) {
|
|
975
|
+
localStorage.setItem(
|
|
976
|
+
whichField,
|
|
977
|
+
JSON.stringify({
|
|
978
|
+
value: response,
|
|
979
|
+
hour: currentHour,
|
|
980
|
+
mode: import.meta.env.MODE,
|
|
981
|
+
}),
|
|
982
|
+
);
|
|
732
983
|
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
984
|
}
|
|
741
985
|
} catch (err) {
|
|
742
986
|
console.log(err);
|
|
743
987
|
}
|
|
988
|
+
} else {
|
|
989
|
+
this[whichField] = storageValue.value;
|
|
744
990
|
}
|
|
991
|
+
|
|
745
992
|
return this[whichField];
|
|
746
993
|
},
|
|
747
994
|
async getCountries() {
|
|
748
995
|
return await this.getFromApi('countries', 'getCountries');
|
|
749
996
|
},
|
|
750
997
|
async getCitizenshipCountries() {
|
|
751
|
-
return await this.getFromApi(
|
|
752
|
-
'citizenshipCountries',
|
|
753
|
-
'getCitizenshipCountries',
|
|
754
|
-
);
|
|
998
|
+
return await this.getFromApi('citizenshipCountries', 'getCitizenshipCountries');
|
|
755
999
|
},
|
|
756
1000
|
async getTaxCountries() {
|
|
757
1001
|
return await this.getFromApi('taxCountries', 'getTaxCountries');
|
|
758
1002
|
},
|
|
759
|
-
async
|
|
1003
|
+
async getAdditionalTaxCountries() {
|
|
1004
|
+
return await this.getFromApi('addTaxCountries', 'getAdditionalTaxCountries');
|
|
1005
|
+
},
|
|
1006
|
+
async getStates(key, member) {
|
|
760
1007
|
await this.getFromApi('states', 'getStates');
|
|
761
|
-
if (key &&
|
|
762
|
-
return this.states.filter(i => i.code ===
|
|
1008
|
+
if (key && member[key] && member[key].ids !== null) {
|
|
1009
|
+
return this.states.filter(i => i.code === member[key].ids);
|
|
763
1010
|
}
|
|
764
1011
|
return this.states;
|
|
765
1012
|
},
|
|
766
|
-
async getRegions(key) {
|
|
1013
|
+
async getRegions(key, member) {
|
|
767
1014
|
await this.getFromApi('regions', 'getRegions');
|
|
768
|
-
if (key &&
|
|
769
|
-
return this.regions.filter(i => i.code ===
|
|
1015
|
+
if (key && member[key] && member[key].ids !== null) {
|
|
1016
|
+
return this.regions.filter(i => i.code === member[key].ids);
|
|
770
1017
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
return this.regions.filter(i => i.code === registrationProvince.ids);
|
|
1018
|
+
if (member.registrationProvince.ids !== null) {
|
|
1019
|
+
return this.regions.filter(i => i.code === member.registrationProvince.ids);
|
|
774
1020
|
} else {
|
|
775
1021
|
return this.regions;
|
|
776
1022
|
}
|
|
777
1023
|
},
|
|
778
|
-
async getCities(key) {
|
|
1024
|
+
async getCities(key, member) {
|
|
779
1025
|
await this.getFromApi('cities', 'getCities');
|
|
780
|
-
if (key &&
|
|
781
|
-
return this.cities.filter(i => i.code ===
|
|
1026
|
+
if (key && member[key] && member[key].ids !== null) {
|
|
1027
|
+
return this.cities.filter(i => i.code === member[key].ids);
|
|
782
1028
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
return this.cities.filter(i => i.code === registrationProvince.ids);
|
|
1029
|
+
if (member.registrationProvince.ids !== null) {
|
|
1030
|
+
return this.cities.filter(i => i.code === member.registrationProvince.ids);
|
|
786
1031
|
} else {
|
|
787
1032
|
return this.cities;
|
|
788
1033
|
}
|
|
@@ -791,10 +1036,7 @@ export const useDataStore = defineStore('data', {
|
|
|
791
1036
|
return await this.getFromApi('localityTypes', 'getLocalityTypes');
|
|
792
1037
|
},
|
|
793
1038
|
async getDocumentTypes() {
|
|
794
|
-
const document_list = await this.getFromApi(
|
|
795
|
-
'documentTypes',
|
|
796
|
-
'getDocumentTypes',
|
|
797
|
-
);
|
|
1039
|
+
const document_list = await this.getFromApi('documentTypes', 'getDocumentTypes');
|
|
798
1040
|
await this.getDicFileTypeList();
|
|
799
1041
|
return document_list.filter(doc => {
|
|
800
1042
|
for (const dic of this.dicFileTypeList) {
|
|
@@ -804,6 +1046,18 @@ export const useDataStore = defineStore('data', {
|
|
|
804
1046
|
}
|
|
805
1047
|
});
|
|
806
1048
|
},
|
|
1049
|
+
async getDicFileTypeList() {
|
|
1050
|
+
try {
|
|
1051
|
+
if (this.dicFileTypeList.length) {
|
|
1052
|
+
return this.dicFileTypeList;
|
|
1053
|
+
} else {
|
|
1054
|
+
this.dicFileTypeList = await this.api.getDicFileTypeList();
|
|
1055
|
+
return this.dicFileTypeList;
|
|
1056
|
+
}
|
|
1057
|
+
} catch (err) {
|
|
1058
|
+
console.log(err.response.data);
|
|
1059
|
+
}
|
|
1060
|
+
},
|
|
807
1061
|
async getDocumentIssuers() {
|
|
808
1062
|
return await this.getFromApi('documentIssuers', 'getDocumentIssuers');
|
|
809
1063
|
},
|
|
@@ -812,60 +1066,68 @@ export const useDataStore = defineStore('data', {
|
|
|
812
1066
|
},
|
|
813
1067
|
async getSectorCodeList() {
|
|
814
1068
|
await this.getFromApi('economySectorCode', 'getSectorCode');
|
|
815
|
-
if (this.economySectorCode[1].ids != '500003.9') {
|
|
816
|
-
this.economySectorCode = this.economySectorCode.reverse();
|
|
817
|
-
}
|
|
818
1069
|
return this.economySectorCode;
|
|
819
1070
|
},
|
|
820
1071
|
async getFamilyStatuses() {
|
|
821
1072
|
return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
|
|
822
1073
|
},
|
|
823
1074
|
async getRelationTypes() {
|
|
1075
|
+
// TODO Remove this & add filtering in openPanel method
|
|
824
1076
|
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
|
-
);
|
|
1077
|
+
const filteredRelations = this.relations.filter(i => Number(i.ids) >= 6 && Number(i.ids) <= 15);
|
|
1078
|
+
const otherRelations = this.relations.filter(i => Number(i.ids) < 6 || Number(i.ids) > 15);
|
|
831
1079
|
return [...filteredRelations, ...otherRelations];
|
|
832
1080
|
},
|
|
1081
|
+
async getProcessIndexRate() {
|
|
1082
|
+
const response = await this.getFromApi('processIndexRate', 'getProcessIndexRate', this.processCode);
|
|
1083
|
+
return response ? response : [];
|
|
1084
|
+
},
|
|
833
1085
|
async getProcessCoverTypeSum(type) {
|
|
834
|
-
return await this.getFromApi(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
1086
|
+
return await this.getFromApi('processCoverTypeSum', 'getProcessCoverTypeSum', type);
|
|
1087
|
+
},
|
|
1088
|
+
async getProcessPaymentPeriod() {
|
|
1089
|
+
return await this.getFromApi('processPaymentPeriod', 'getProcessPaymentPeriod', this.processCode);
|
|
1090
|
+
},
|
|
1091
|
+
async getQuestionRefs(id) {
|
|
1092
|
+
return await this.getFromApi('questionRefs', 'getQuestionRefs', id);
|
|
1093
|
+
},
|
|
1094
|
+
async getProcessTariff() {
|
|
1095
|
+
return await this.getFromApi('processTariff', 'getProcessTariff');
|
|
1096
|
+
},
|
|
1097
|
+
async getAdditionalInsuranceTermsAnswers(questionId) {
|
|
1098
|
+
try {
|
|
1099
|
+
const answers = await this.api.getAdditionalInsuranceTermsAnswers(this.processCode, questionId);
|
|
1100
|
+
answers.unshift(answers.pop());
|
|
1101
|
+
return answers;
|
|
1102
|
+
} catch (err) {
|
|
1103
|
+
console.log(err);
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
async getQuestionList(surveyType, processInstanceId, insuredId, baseField, secondaryField) {
|
|
1107
|
+
if (!this[baseField].length) {
|
|
1108
|
+
try {
|
|
1109
|
+
const [{ value: baseQuestions }, { value: secondaryQuestions }] = await Promise.allSettled([
|
|
1110
|
+
this.api.getQuestionList(surveyType, processInstanceId, insuredId),
|
|
1111
|
+
this.api.getQuestionList(`${surveyType}second`, processInstanceId, insuredId),
|
|
1112
|
+
]);
|
|
1113
|
+
this[baseField] = baseQuestions;
|
|
1114
|
+
this[secondaryField] = secondaryQuestions;
|
|
1115
|
+
} catch (err) {
|
|
1116
|
+
console.log(err);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
return this[baseField];
|
|
839
1120
|
},
|
|
840
1121
|
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
|
-
) {
|
|
1122
|
+
return n === null ? null : Number((typeof n === 'string' ? n : n.toFixed().toString()).replace(/[^0-9]+/g, '')).toLocaleString('ru');
|
|
1123
|
+
},
|
|
1124
|
+
async getTaskList(search = '', groupCode = 'Work', onlyGet = false, needToReturn = false, key = 'dateCreated', processInstanceId = null, byOneProcess = null) {
|
|
858
1125
|
if (onlyGet === false) {
|
|
859
1126
|
this.isLoading = true;
|
|
860
1127
|
}
|
|
861
1128
|
try {
|
|
862
1129
|
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';
|
|
1130
|
+
const direction = this.isColumnAsc[key] === null ? 'desc' : this.isColumnAsc[key] === true ? 'asc' : 'desc';
|
|
869
1131
|
const query = {
|
|
870
1132
|
pageIndex: processInstanceId === null ? this.historyPageIndex - 1 : 0,
|
|
871
1133
|
pageSize: this.historyPageSize,
|
|
@@ -875,11 +1137,11 @@ export const useDataStore = defineStore('data', {
|
|
|
875
1137
|
groupCode: groupCode,
|
|
876
1138
|
processCodes: Object.values(constants.products),
|
|
877
1139
|
};
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
);
|
|
1140
|
+
if (byOneProcess !== null) {
|
|
1141
|
+
delete query.processCodes;
|
|
1142
|
+
query.processCode = byOneProcess;
|
|
1143
|
+
}
|
|
1144
|
+
const taskList = await this.api.getTaskList(processInstanceId === null ? query : { ...query, processInstanceId: processInstanceId });
|
|
883
1145
|
if (needToReturn) {
|
|
884
1146
|
this.isLoading = false;
|
|
885
1147
|
return taskList.items;
|
|
@@ -932,6 +1194,7 @@ export const useDataStore = defineStore('data', {
|
|
|
932
1194
|
this.getCountries(),
|
|
933
1195
|
this.getCitizenshipCountries(),
|
|
934
1196
|
this.getTaxCountries(),
|
|
1197
|
+
this.getAdditionalTaxCountries(),
|
|
935
1198
|
this.getStates(),
|
|
936
1199
|
this.getRegions(),
|
|
937
1200
|
this.getCities(),
|
|
@@ -942,6 +1205,9 @@ export const useDataStore = defineStore('data', {
|
|
|
942
1205
|
this.getSectorCodeList(),
|
|
943
1206
|
this.getFamilyStatuses(),
|
|
944
1207
|
this.getRelationTypes(),
|
|
1208
|
+
this.getProcessIndexRate(),
|
|
1209
|
+
this.getProcessTariff(),
|
|
1210
|
+
this.getProcessPaymentPeriod(),
|
|
945
1211
|
]);
|
|
946
1212
|
},
|
|
947
1213
|
async getUserGroups() {
|
|
@@ -954,185 +1220,1264 @@ export const useDataStore = defineStore('data', {
|
|
|
954
1220
|
this.isLoading = false;
|
|
955
1221
|
}
|
|
956
1222
|
},
|
|
957
|
-
async
|
|
1223
|
+
async getProcessList() {
|
|
1224
|
+
this.isLoading = true;
|
|
958
1225
|
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
|
-
);
|
|
1226
|
+
const processList = await this.api.getProcessList();
|
|
1227
|
+
if (this.processList === null) {
|
|
1228
|
+
this.processList = processList;
|
|
1229
|
+
}
|
|
972
1230
|
} catch (err) {
|
|
973
1231
|
console.log(err);
|
|
974
|
-
this.showToaster('error', err.response.data, 3000);
|
|
975
1232
|
}
|
|
1233
|
+
this.isLoading = false;
|
|
976
1234
|
},
|
|
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
|
-
|
|
1235
|
+
sortTaskList(key) {
|
|
1236
|
+
if (this.taskList.length !== 0) {
|
|
1237
|
+
if (key in this.isColumnAsc) {
|
|
1238
|
+
if (this.isColumnAsc[key] === true) {
|
|
1239
|
+
this.isColumnAsc = { ...InitialColumns() };
|
|
1240
|
+
this.isColumnAsc[key] = false;
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
if (this.isColumnAsc[key] === false) {
|
|
1244
|
+
this.isColumnAsc = { ...InitialColumns() };
|
|
1245
|
+
this.isColumnAsc[key] = null;
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
if (this.isColumnAsc[key] === null) {
|
|
1249
|
+
this.isColumnAsc = { ...InitialColumns() };
|
|
1250
|
+
this.isColumnAsc[key] = true;
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
async searchAgentByName(name) {
|
|
1257
|
+
try {
|
|
1258
|
+
this.isLoading = true;
|
|
1259
|
+
this.AgentDataList = await this.api.searchAgentByName(name);
|
|
1260
|
+
if (!this.AgentDataList.length) {
|
|
1261
|
+
this.showToaster('error', this.t('toaster.notFound'), 1500);
|
|
1262
|
+
}
|
|
1263
|
+
} catch (err) {
|
|
1264
|
+
console.log(err);
|
|
1265
|
+
} finally {
|
|
1266
|
+
this.isLoading = false;
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
async setINSISWorkData() {
|
|
1270
|
+
const data = {
|
|
1271
|
+
id: this.formStore.applicationData.insisWorkDataApp.id,
|
|
1272
|
+
processInstanceId: this.formStore.applicationData.processInstanceId,
|
|
1273
|
+
agentId: this.formStore.AgentData.agentId,
|
|
1274
|
+
agentName: this.formStore.AgentData.fullName,
|
|
1275
|
+
salesChannel: this.formStore.applicationData.insisWorkDataApp.salesChannel,
|
|
1276
|
+
salesChannelName: this.formStore.applicationData.insisWorkDataApp.salesChannelName,
|
|
1277
|
+
insrType: this.formStore.applicationData.insisWorkDataApp.insrType,
|
|
1278
|
+
saleChanellPolicy: this.formStore.SaleChanellPolicy.ids,
|
|
1279
|
+
saleChanellPolicyName: this.formStore.SaleChanellPolicy.nameRu,
|
|
1280
|
+
regionPolicy: this.formStore.RegionPolicy.ids,
|
|
1281
|
+
regionPolicyName: this.formStore.RegionPolicy.nameRu,
|
|
1282
|
+
managerPolicy: this.formStore.ManagerPolicy.ids,
|
|
1283
|
+
managerPolicyName: this.formStore.ManagerPolicy.nameRu,
|
|
1284
|
+
insuranceProgramType: this.formStore.applicationData.insisWorkDataApp.insuranceProgramType,
|
|
1285
|
+
};
|
|
1286
|
+
try {
|
|
1287
|
+
this.isLoading = true;
|
|
1288
|
+
await this.api.setINSISWorkData(data);
|
|
1289
|
+
} catch (err) {
|
|
1290
|
+
console.log(err);
|
|
1291
|
+
} finally {
|
|
1292
|
+
this.isLoading = false;
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
async getDictionaryItems(dictName) {
|
|
1296
|
+
try {
|
|
1297
|
+
this.isLoading = true;
|
|
1298
|
+
if (!this[`${dictName}List`].length) {
|
|
1299
|
+
this[`${dictName}List`] = await this.api.getDictionaryItems(dictName);
|
|
1300
|
+
}
|
|
1301
|
+
} catch (err) {
|
|
1302
|
+
console.log(err);
|
|
1303
|
+
} finally {
|
|
1304
|
+
this.isLoading = false;
|
|
1305
|
+
}
|
|
1306
|
+
},
|
|
1307
|
+
async filterManagerByRegion(dictName, filterName) {
|
|
1308
|
+
try {
|
|
1309
|
+
this.isLoading = true;
|
|
1310
|
+
this[`${dictName}List`] = await this.api.filterManagerByRegion(dictName, filterName);
|
|
1311
|
+
} catch (err) {
|
|
1312
|
+
console.log(err);
|
|
1313
|
+
} finally {
|
|
1314
|
+
this.isLoading = false;
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
async getUnderwritingCouncilData(id) {
|
|
1318
|
+
try {
|
|
1319
|
+
const response = await this.api.getUnderwritingCouncilData(id);
|
|
1320
|
+
this.affilationResolution.id = response.underwritingCouncilAppDto.id;
|
|
1321
|
+
this.affilationResolution.date = response.underwritingCouncilAppDto.date ? reformatDate(response.underwritingCouncilAppDto.date) : null;
|
|
1322
|
+
this.affilationResolution.number = response.underwritingCouncilAppDto.number ? response.underwritingCouncilAppDto.number : null;
|
|
1323
|
+
} catch (err) {
|
|
1324
|
+
console.log(err);
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1327
|
+
async setConfirmation() {
|
|
1328
|
+
const data = {
|
|
1329
|
+
id: this.affilationResolution.id,
|
|
1330
|
+
processInstanceId: this.affilationResolution.processInstanceId,
|
|
1331
|
+
number: this.affilationResolution.number,
|
|
1332
|
+
date: formatDate(this.affilationResolution.date)?.toISOString(),
|
|
1333
|
+
};
|
|
1334
|
+
try {
|
|
1335
|
+
this.isLoading = true;
|
|
1336
|
+
await this.api.setConfirmation(data);
|
|
1337
|
+
this.showToaster('success', this.t('toaster.successSaved'));
|
|
1338
|
+
return true;
|
|
1339
|
+
} catch (err) {
|
|
1340
|
+
this.showToaster('error', this.t('toaster.error'));
|
|
1341
|
+
return false;
|
|
1342
|
+
} finally {
|
|
1343
|
+
this.isLoading = false;
|
|
1344
|
+
}
|
|
1345
|
+
},
|
|
1346
|
+
async sendUnderwritingCouncilTask(data) {
|
|
1347
|
+
try {
|
|
1348
|
+
this.isLoading = true;
|
|
1349
|
+
await this.api.sendUnderwritingCouncilTask(data);
|
|
1350
|
+
this.showToaster('success', this.t('toaster.successOperation'), 5000);
|
|
1351
|
+
return true;
|
|
1352
|
+
} catch (err) {
|
|
1353
|
+
console.log(err);
|
|
1354
|
+
this.showToaster('error', this.t('toaster.error'), 5000);
|
|
1355
|
+
return false;
|
|
1356
|
+
} finally {
|
|
1357
|
+
this.isLoading = false;
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
async definedAnswers(filter, whichSurvey, value = null, index = null) {
|
|
1361
|
+
if (!this.definedAnswersId[whichSurvey].hasOwnProperty(filter)) {
|
|
1362
|
+
this.definedAnswersId[whichSurvey][filter] = await this.api.definedAnswers(filter);
|
|
1363
|
+
}
|
|
1364
|
+
if (value !== null && this.definedAnswersId[whichSurvey][filter].length) {
|
|
1365
|
+
const answer = this.definedAnswersId[whichSurvey][filter].find(answer => answer.nameRu === value);
|
|
1366
|
+
this[whichSurvey].body[index].first.answerId = answer.ids;
|
|
1367
|
+
}
|
|
1368
|
+
return this.definedAnswersId[whichSurvey];
|
|
1369
|
+
},
|
|
1370
|
+
async getPaymentTable(id) {
|
|
1371
|
+
try {
|
|
1372
|
+
const paymentResultTable = await this.api.calculatePremuim(id);
|
|
1373
|
+
if (paymentResultTable.length > 0) {
|
|
1374
|
+
this.paymentResultTable = paymentResultTable;
|
|
1375
|
+
} else {
|
|
1376
|
+
this.paymentResultTable = [];
|
|
1377
|
+
}
|
|
1378
|
+
} catch (err) {
|
|
1379
|
+
console.log(err);
|
|
1380
|
+
}
|
|
1381
|
+
},
|
|
1382
|
+
async getDefaultCalculationData(showLoader = false) {
|
|
1383
|
+
this.isLoading = showLoader;
|
|
1384
|
+
try {
|
|
1385
|
+
const calculationData = await this.api.getDefaultCalculationData();
|
|
1386
|
+
return calculationData;
|
|
1387
|
+
} catch (err) {
|
|
1388
|
+
ErrorHandler(err);
|
|
1389
|
+
} finally {
|
|
1390
|
+
this.isLoading = false;
|
|
1391
|
+
}
|
|
1392
|
+
},
|
|
1393
|
+
async calculateWithoutApplication(showLoader = false) {
|
|
1394
|
+
this.isLoading = showLoader;
|
|
1395
|
+
try {
|
|
1396
|
+
const calculationData = {
|
|
1397
|
+
signDate: formatDate(this.formStore.productConditionsForm.signDate)?.toISOString(),
|
|
1398
|
+
birthDate: formatDate(this.formStore.productConditionsForm.birthDate)?.toISOString(),
|
|
1399
|
+
gender: this.formStore.productConditionsForm.gender.id,
|
|
1400
|
+
amount: getNumber(this.formStore.productConditionsForm.requestedSumInsured),
|
|
1401
|
+
premium: getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonth),
|
|
1402
|
+
coverPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1403
|
+
payPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1404
|
+
indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
|
|
1405
|
+
? this.formStore.productConditionsForm.processIndexRate.id
|
|
1406
|
+
: this.processIndexRate.find(i => i.code === '0')?.id,
|
|
1407
|
+
paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
|
|
1408
|
+
addCovers: this.additionalInsuranceTermsWithout,
|
|
1409
|
+
};
|
|
1410
|
+
const calculationResponse = await this.api.calculateWithoutApplication(calculationData);
|
|
1411
|
+
this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
|
|
1412
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
|
|
1413
|
+
this.additionalInsuranceTermsWithout = calculationResponse.addCovers;
|
|
1414
|
+
this.showToaster('success', this.t('toaster.calculated'), 1000);
|
|
1415
|
+
} catch (err) {
|
|
1416
|
+
ErrorHandler(err);
|
|
1417
|
+
} finally {
|
|
1418
|
+
this.isLoading = false;
|
|
1419
|
+
return !!this.formStore.productConditionsForm.requestedSumInsured && !!this.formStore.productConditionsForm.insurancePremiumPerMonth;
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1422
|
+
async calculate(taskId) {
|
|
1423
|
+
this.isLoading = true;
|
|
1424
|
+
try {
|
|
1425
|
+
let form1 = {
|
|
1426
|
+
baiterekApp: null,
|
|
1427
|
+
policyAppDto: {
|
|
1428
|
+
id: this.formStore.applicationData.policyAppDto.id,
|
|
1429
|
+
processInstanceId: this.formStore.applicationData.policyAppDto.processInstanceId,
|
|
1430
|
+
policyId: null,
|
|
1431
|
+
policyNumber: null,
|
|
1432
|
+
contractDate: this.currentDate(),
|
|
1433
|
+
amount: this.formStore.productConditionsForm.requestedSumInsured != null ? Number(this.formStore.productConditionsForm.requestedSumInsured.replace(/\s/g, '')) : null,
|
|
1434
|
+
premium:
|
|
1435
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth != null
|
|
1436
|
+
? Number(this.formStore.productConditionsForm.insurancePremiumPerMonth.replace(/\s/g, ''))
|
|
1437
|
+
: null,
|
|
1438
|
+
isSpokesman: this.formStore.hasRepresentative,
|
|
1439
|
+
coverPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1440
|
+
payPeriod: this.formStore.productConditionsForm.coverPeriod,
|
|
1441
|
+
annualIncome: this.formStore.productConditionsForm.annualIncome ? Number(this.formStore.productConditionsForm.annualIncome.replace(/\s/g, '')) : null,
|
|
1442
|
+
indexRateId: this.formStore.productConditionsForm.processIndexRate?.id
|
|
1443
|
+
? this.formStore.productConditionsForm.processIndexRate.id
|
|
1444
|
+
: this.processIndexRate.find(i => i.code === '0')?.id,
|
|
1445
|
+
paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
|
|
1446
|
+
lifeMultiply: formatProcents(this.formStore.productConditionsForm.lifeMultiply),
|
|
1447
|
+
lifeAdditive: formatProcents(this.formStore.productConditionsForm.lifeAdditive),
|
|
1448
|
+
adbMultiply: formatProcents(this.formStore.productConditionsForm.adbMultiply),
|
|
1449
|
+
adbAdditive: formatProcents(this.formStore.productConditionsForm.adbAdditive),
|
|
1450
|
+
disabilityMultiply: formatProcents(this.formStore.productConditionsForm.disabilityMultiply),
|
|
1451
|
+
disabilityAdditive: formatProcents(this.formStore.productConditionsForm.adbAdditive),
|
|
1452
|
+
riskGroup: this.formStore.productConditionsForm.riskGroup?.id ? this.formStore.productConditionsForm.riskGroup.id : 1,
|
|
1453
|
+
},
|
|
1454
|
+
addCoversDto: this.additionalInsuranceTerms,
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
try {
|
|
1458
|
+
let id = this.formStore.applicationData.processInstanceId;
|
|
1459
|
+
|
|
1460
|
+
await this.api.setApplication(form1);
|
|
1461
|
+
let result;
|
|
1462
|
+
try {
|
|
1463
|
+
result = await this.api.getCalculation(id);
|
|
1464
|
+
} catch (err) {
|
|
1465
|
+
this.showToaster('error', err?.response?.data, 5000);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
const applicationData = await this.api.getApplicationData(taskId);
|
|
1469
|
+
this.formStore.applicationData = applicationData;
|
|
1470
|
+
this.additionalInsuranceTerms = this.formStore.applicationData.addCoverDto;
|
|
1471
|
+
if (this.formStore.productConditionsForm.insurancePremiumPerMonth != null) {
|
|
1472
|
+
this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(result);
|
|
1473
|
+
} else {
|
|
1474
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(result);
|
|
1475
|
+
}
|
|
1476
|
+
this.showToaster('success', this.t('toaster.calculated'), 1000);
|
|
1477
|
+
} catch (err) {
|
|
1478
|
+
console.log(err);
|
|
1479
|
+
}
|
|
1480
|
+
} catch (err) {
|
|
1481
|
+
ErrorHandler(err);
|
|
1482
|
+
console.log(err, 'error');
|
|
1483
|
+
}
|
|
1484
|
+
this.isLoading = false;
|
|
1485
|
+
},
|
|
1486
|
+
async startApplication(member) {
|
|
1487
|
+
try {
|
|
1488
|
+
const data = {
|
|
1489
|
+
clientId: member.id,
|
|
1490
|
+
iin: member.iin.replace(/-/g, ''),
|
|
1491
|
+
longName: member.longName,
|
|
1492
|
+
processCode: this.processCode,
|
|
1493
|
+
policyId: 0,
|
|
1494
|
+
};
|
|
1495
|
+
const response = await this.api.startApplication(data);
|
|
1496
|
+
this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
|
|
1497
|
+
return response.processInstanceId;
|
|
1498
|
+
} catch (err) {
|
|
1499
|
+
return ErrorHandler(err);
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
async getApplicationData(taskId, onlyGet = true, setMembersField = true, fetchMembers = true, setProductConditions = true) {
|
|
1503
|
+
if (onlyGet) {
|
|
1504
|
+
this.isLoading = true;
|
|
1505
|
+
}
|
|
1506
|
+
try {
|
|
1507
|
+
const applicationData = await this.api.getApplicationData(taskId);
|
|
1508
|
+
if (this.processCode !== applicationData.processCode) {
|
|
1509
|
+
this.isLoading = false;
|
|
1510
|
+
this.sendToParent(constants.postActions.toHomePage, this.t('toaster.noSuchProduct'));
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1513
|
+
this.formStore.applicationData = applicationData;
|
|
1514
|
+
this.additionalInsuranceTerms = applicationData.addCoverDto;
|
|
1515
|
+
|
|
1516
|
+
this.formStore.canBeClaimed = await this.api.isClaimTask(taskId);
|
|
1517
|
+
this.formStore.applicationTaskId = taskId;
|
|
1518
|
+
this.formStore.RegionPolicy.nameRu = applicationData.insisWorkDataApp.regionPolicyName;
|
|
1519
|
+
this.formStore.RegionPolicy.ids = applicationData.insisWorkDataApp.regionPolicy;
|
|
1520
|
+
this.formStore.ManagerPolicy.nameRu = applicationData.insisWorkDataApp.managerPolicyName;
|
|
1521
|
+
this.formStore.ManagerPolicy.ids = applicationData.insisWorkDataApp.managerPolicy;
|
|
1522
|
+
this.formStore.SaleChanellPolicy.nameRu = applicationData.insisWorkDataApp.saleChanellPolicyName;
|
|
1523
|
+
this.formStore.SaleChanellPolicy.ids = applicationData.insisWorkDataApp.saleChanellPolicy;
|
|
1524
|
+
|
|
1525
|
+
this.formStore.AgentData.fullName = applicationData.insisWorkDataApp.agentName;
|
|
1526
|
+
this.formStore.AgentData.agentId = applicationData.insisWorkDataApp.agentId;
|
|
1527
|
+
|
|
1528
|
+
const clientData = applicationData.clientApp;
|
|
1529
|
+
const insuredData = applicationData.insuredApp;
|
|
1530
|
+
const spokesmanData = applicationData.spokesmanApp;
|
|
1531
|
+
const beneficiaryData = applicationData.beneficiaryApp;
|
|
1532
|
+
const beneficialOwnerData = applicationData.beneficialOwnerApp;
|
|
1533
|
+
|
|
1534
|
+
this.formStore.isPolicyholderInsured = clientData.isInsured;
|
|
1535
|
+
this.formStore.isActOwnBehalf = clientData.isActOwnBehalf;
|
|
1536
|
+
this.formStore.hasRepresentative = !!applicationData.spokesmanApp;
|
|
1537
|
+
|
|
1538
|
+
const beneficiaryPolicyholderIndex = beneficiaryData.findIndex(i => i.insisId === clientData.insisId);
|
|
1539
|
+
this.formStore.isPolicyholderBeneficiary = beneficiaryPolicyholderIndex !== -1;
|
|
1540
|
+
|
|
1541
|
+
if (fetchMembers) {
|
|
1542
|
+
let allMembers = [
|
|
1543
|
+
{
|
|
1544
|
+
...clientData,
|
|
1545
|
+
key: this.formStore.policyholderFormKey,
|
|
1546
|
+
index: null,
|
|
1547
|
+
},
|
|
1548
|
+
];
|
|
1549
|
+
|
|
1550
|
+
if (spokesmanData) {
|
|
1551
|
+
allMembers.push({
|
|
1552
|
+
...spokesmanData,
|
|
1553
|
+
key: this.formStore.policyholdersRepresentativeFormKey,
|
|
1554
|
+
index: null,
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
if (insuredData && insuredData.length) {
|
|
1559
|
+
insuredData.forEach((member, index) => {
|
|
1560
|
+
const inStore = this.formStore.insuredForm.find(each => each.id == member.insisId);
|
|
1561
|
+
if (!inStore) {
|
|
1562
|
+
member.key = this.formStore.insuredFormKey;
|
|
1563
|
+
member.index = index;
|
|
1564
|
+
allMembers.push(member);
|
|
1565
|
+
if (this.formStore.insuredForm.length - 1 < index) {
|
|
1566
|
+
this.formStore.insuredForm.push(new InsuredForm());
|
|
1016
1567
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
if (beneficiaryData && beneficiaryData.length) {
|
|
1572
|
+
beneficiaryData.forEach((member, index) => {
|
|
1573
|
+
const inStore = this.formStore.beneficiaryForm.find(each => each.id == member.insisId);
|
|
1574
|
+
if (!inStore) {
|
|
1575
|
+
member.key = this.formStore.beneficiaryFormKey;
|
|
1576
|
+
member.index = index;
|
|
1577
|
+
allMembers.push(member);
|
|
1578
|
+
if (this.formStore.beneficiaryForm.length - 1 < index) {
|
|
1579
|
+
this.formStore.beneficiaryForm.push(new BeneficiaryForm());
|
|
1020
1580
|
}
|
|
1021
1581
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
if (beneficialOwnerData && beneficialOwnerData.length) {
|
|
1585
|
+
beneficialOwnerData.forEach((member, index) => {
|
|
1586
|
+
const inStore = this.formStore.beneficialOwnerForm.find(each => each.id == member.insisId);
|
|
1587
|
+
if (!inStore) {
|
|
1588
|
+
member.key = this.formStore.beneficialOwnerFormKey;
|
|
1589
|
+
member.index = index;
|
|
1590
|
+
allMembers.push(member);
|
|
1591
|
+
if (this.formStore.beneficialOwnerForm.length - 1 < index) {
|
|
1592
|
+
this.formStore.beneficialOwnerForm.push(new BeneficialOwnerForm());
|
|
1593
|
+
}
|
|
1025
1594
|
}
|
|
1026
|
-
}
|
|
1027
|
-
this.showToaster('error', this.t('toaster.undefinedError'), 3000);
|
|
1028
|
-
return { otpStatus };
|
|
1029
|
-
}
|
|
1595
|
+
});
|
|
1030
1596
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1597
|
+
|
|
1598
|
+
await Promise.allSettled(
|
|
1599
|
+
allMembers.map(async member => {
|
|
1600
|
+
await this.getContragentById(member.insisId, member.key, false, member.index);
|
|
1601
|
+
}),
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
if (setMembersField) {
|
|
1606
|
+
this.setMembersField(this.formStore.policyholderFormKey, 'clientApp');
|
|
1607
|
+
if (insuredData && insuredData.length) {
|
|
1608
|
+
insuredData.forEach((each, index) => {
|
|
1609
|
+
this.setMembersFieldIndex(this.formStore.insuredFormKey, 'insuredApp', index);
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
if (beneficiaryData && beneficiaryData.length) {
|
|
1614
|
+
beneficiaryData.forEach((each, index) => {
|
|
1615
|
+
this.setMembersFieldIndex(this.formStore.beneficiaryFormKey, 'beneficiaryApp', index);
|
|
1616
|
+
const relationDegree = this.relations.find(i => i.ids == each.relationId);
|
|
1617
|
+
this.formStore.beneficiaryForm[index].relationDegree = relationDegree ? relationDegree : new Value();
|
|
1618
|
+
this.formStore.beneficiaryForm[index].percentageOfPayoutAmount = each.percentage;
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
if (beneficialOwnerData && beneficialOwnerData.length) {
|
|
1623
|
+
beneficialOwnerData.forEach((each, index) => {
|
|
1624
|
+
this.setMembersFieldIndex(this.formStore.beneficialOwnerFormKey, 'beneficialOwnerApp', index);
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
if (!!spokesmanData) {
|
|
1629
|
+
this.formStore.policyholdersRepresentativeForm.signOfIPDL = spokesmanData.isIpdl ? this.ipdl[1] : this.ipdl[2];
|
|
1630
|
+
this.formStore.policyholdersRepresentativeForm.migrationCard = spokesmanData.migrationCard;
|
|
1631
|
+
this.formStore.policyholdersRepresentativeForm.migrationCardIssueDate = reformatDate(spokesmanData.migrationCardIssueDate);
|
|
1632
|
+
this.formStore.policyholdersRepresentativeForm.migrationCardExpireDate = reformatDate(spokesmanData.migrationCardExpireDate);
|
|
1633
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocType = spokesmanData.confirmDocType;
|
|
1634
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocNumber = spokesmanData.confirmDocNumber;
|
|
1635
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocIssueDate = reformatDate(spokesmanData.confirmDocIssueDate);
|
|
1636
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocExpireDate = reformatDate(spokesmanData.confirmDocExpireDate);
|
|
1637
|
+
this.formStore.policyholdersRepresentativeForm.notaryLongName = spokesmanData.notaryLongName;
|
|
1638
|
+
this.formStore.policyholdersRepresentativeForm.notaryLicenseNumber = spokesmanData.notaryLicenseNumber;
|
|
1639
|
+
this.formStore.policyholdersRepresentativeForm.notaryLicenseDate = reformatDate(spokesmanData.notaryLicenseDate);
|
|
1640
|
+
this.formStore.policyholdersRepresentativeForm.notaryLicenseIssuer = spokesmanData.notaryLicenseIssuer;
|
|
1641
|
+
this.formStore.policyholdersRepresentativeForm.jurLongName = spokesmanData.jurLongName;
|
|
1642
|
+
this.formStore.policyholdersRepresentativeForm.fullNameRod = spokesmanData.fullNameRod;
|
|
1643
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocTypeKz = spokesmanData.confirmDocTypeKz;
|
|
1644
|
+
this.formStore.policyholdersRepresentativeForm.confirmDocTypeRod = spokesmanData.confirmDocTypeRod;
|
|
1645
|
+
this.formStore.policyholdersRepresentativeForm.isNotary = spokesmanData.isNotary;
|
|
1040
1646
|
}
|
|
1041
1647
|
}
|
|
1042
|
-
|
|
1648
|
+
if (setProductConditions) {
|
|
1649
|
+
this.formStore.productConditionsForm.coverPeriod = applicationData.policyAppDto.coverPeriod;
|
|
1650
|
+
this.formStore.productConditionsForm.payPeriod = applicationData.policyAppDto.payPeriod;
|
|
1651
|
+
// this.formStore.productConditionsForm.annualIncome = applicationData.policyAppDto.annualIncome?.toString();
|
|
1652
|
+
this.formStore.productConditionsForm.lifeMultiply = parseProcents(applicationData.policyAppDto.lifeMultiply);
|
|
1653
|
+
this.formStore.productConditionsForm.lifeAdditive = parseProcents(applicationData.policyAppDto.lifeAdditive);
|
|
1654
|
+
this.formStore.productConditionsForm.adbMultiply = parseProcents(applicationData.policyAppDto.adbMultiply);
|
|
1655
|
+
this.formStore.productConditionsForm.adbAdditive = parseProcents(applicationData.policyAppDto.adbAdditive);
|
|
1656
|
+
this.formStore.productConditionsForm.disabilityMultiply = parseProcents(applicationData.policyAppDto.disabilityMultiply);
|
|
1657
|
+
this.formStore.productConditionsForm.disabilityAdditive = parseProcents(applicationData.policyAppDto.disabilityAdditive);
|
|
1658
|
+
|
|
1659
|
+
let processIndexRate = this.processIndexRate.find(item => item.id == applicationData.policyAppDto.indexRateId);
|
|
1660
|
+
this.formStore.productConditionsForm.processIndexRate = processIndexRate ? processIndexRate : this.processIndexRate.find(item => item.code === '0');
|
|
1661
|
+
|
|
1662
|
+
let paymentPeriod = this.processPaymentPeriod.find(item => item.id == applicationData.policyAppDto.paymentPeriodId);
|
|
1663
|
+
this.formStore.productConditionsForm.paymentPeriod = paymentPeriod ? paymentPeriod : new Value();
|
|
1664
|
+
|
|
1665
|
+
this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(
|
|
1666
|
+
applicationData.policyAppDto.amount === null ? null : applicationData.policyAppDto.amount,
|
|
1667
|
+
);
|
|
1668
|
+
this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(
|
|
1669
|
+
applicationData.policyAppDto.premium === null ? null : applicationData.policyAppDto.premium,
|
|
1670
|
+
);
|
|
1671
|
+
|
|
1672
|
+
let riskGroup = this.riskGroup.find(item => {
|
|
1673
|
+
if (applicationData.policyAppDto.riskGroup == 0) {
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
return item.id == applicationData.policyAppDto.riskGroup;
|
|
1677
|
+
});
|
|
1678
|
+
this.formStore.productConditionsForm.riskGroup = riskGroup ? riskGroup : this.riskGroup.find(item => item.id == 1);
|
|
1679
|
+
}
|
|
1043
1680
|
} catch (err) {
|
|
1044
|
-
|
|
1681
|
+
console.log(err);
|
|
1045
1682
|
if ('response' in err) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1683
|
+
this.sendToParent(constants.postActions.toHomePage, err.response.data);
|
|
1684
|
+
this.isLoading = false;
|
|
1685
|
+
return false;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
if (onlyGet) {
|
|
1689
|
+
this.isLoading = false;
|
|
1690
|
+
}
|
|
1691
|
+
},
|
|
1692
|
+
async setApplication() {
|
|
1693
|
+
try {
|
|
1694
|
+
await this.api.setApplication(this.formStore.applicationData);
|
|
1695
|
+
} catch (err) {
|
|
1696
|
+
console.log(err);
|
|
1697
|
+
}
|
|
1698
|
+
},
|
|
1699
|
+
async deleteTask(taskId) {
|
|
1700
|
+
this.isLoading = true;
|
|
1701
|
+
try {
|
|
1702
|
+
const data = {
|
|
1703
|
+
taskId: taskId,
|
|
1704
|
+
decision: 'rejectclient',
|
|
1705
|
+
comment: 'Клиент отказался',
|
|
1706
|
+
};
|
|
1707
|
+
await this.api.sendTask(data);
|
|
1708
|
+
this.showToaster('success', this.t('toaster.applicationDeleted'), 2000);
|
|
1709
|
+
} catch (err) {
|
|
1710
|
+
if ('response' in err && err.response.data) {
|
|
1711
|
+
this.showToaster('error', this.t('toaster.error') + err.response.data, 2000);
|
|
1712
|
+
}
|
|
1713
|
+
console.log(err);
|
|
1714
|
+
}
|
|
1715
|
+
this.isLoading = false;
|
|
1716
|
+
},
|
|
1717
|
+
async sendTask(taskId, decision, comment = null) {
|
|
1718
|
+
this.isLoading = true;
|
|
1719
|
+
try {
|
|
1720
|
+
const data = {
|
|
1721
|
+
taskId: taskId,
|
|
1722
|
+
decision: decision,
|
|
1723
|
+
};
|
|
1724
|
+
await this.api.sendTask(comment === null ? data : { ...data, comment: comment });
|
|
1725
|
+
this.showToaster('success', this.t('toaster.successOperation'), 3000);
|
|
1726
|
+
this.isLoading = false;
|
|
1727
|
+
return true;
|
|
1728
|
+
} catch (err) {
|
|
1729
|
+
console.log(err);
|
|
1730
|
+
if ('response' in err && err.response.data) {
|
|
1731
|
+
this.showToaster('error', this.t('toaster.error') + err.response.data, 2000);
|
|
1732
|
+
}
|
|
1733
|
+
this.isLoading = false;
|
|
1734
|
+
return false;
|
|
1735
|
+
}
|
|
1736
|
+
},
|
|
1737
|
+
async handleTask(action, taskId, comment) {
|
|
1738
|
+
if (action && Object.keys(constants.actions).includes(action)) {
|
|
1739
|
+
switch (action) {
|
|
1740
|
+
case constants.actions.claim: {
|
|
1741
|
+
try {
|
|
1742
|
+
this.isLoading = true;
|
|
1743
|
+
await this.api.claimTask(this.formStore.applicationTaskId);
|
|
1744
|
+
await this.getApplicationData(taskId, false, false, false);
|
|
1745
|
+
this.showToaster('success', this.t('toaster.successOperation'), 3000);
|
|
1746
|
+
} catch (err) {
|
|
1747
|
+
console.log(err);
|
|
1748
|
+
if ('response' in err && err.response.data) {
|
|
1749
|
+
this.showToaster('error', err.response.data, 3000);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1056
1752
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1753
|
+
case constants.actions.reject:
|
|
1754
|
+
case constants.actions.return:
|
|
1755
|
+
case constants.actions.rejectclient:
|
|
1756
|
+
case constants.actions.accept: {
|
|
1757
|
+
try {
|
|
1758
|
+
await this.sendTask(taskId, action, comment);
|
|
1759
|
+
this.formStore.$reset();
|
|
1760
|
+
if (this.isEFO) {
|
|
1761
|
+
await this.router.push({ name: 'Insurance-Product' });
|
|
1762
|
+
} else {
|
|
1763
|
+
this.sendToParent(constants.postActions.toHomePage, this.t('toaster.successOperation') + 'SUCCESS');
|
|
1764
|
+
}
|
|
1765
|
+
} catch (err) {
|
|
1766
|
+
console.log(err);
|
|
1767
|
+
if ('response' in err && err.response.data) {
|
|
1768
|
+
this.showToaster('error', err.response.data, 3000);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1060
1771
|
}
|
|
1061
1772
|
}
|
|
1062
|
-
}
|
|
1773
|
+
} else {
|
|
1774
|
+
console.error('No handleTask action');
|
|
1775
|
+
}
|
|
1776
|
+
},
|
|
1777
|
+
async getInvoiceData(processInstanceId) {
|
|
1778
|
+
try {
|
|
1779
|
+
const response = await this.api.getInvoiceData(processInstanceId);
|
|
1780
|
+
if (response) {
|
|
1781
|
+
return response;
|
|
1782
|
+
} else {
|
|
1783
|
+
return false;
|
|
1784
|
+
}
|
|
1785
|
+
} catch (err) {
|
|
1786
|
+
return false;
|
|
1787
|
+
}
|
|
1788
|
+
},
|
|
1789
|
+
async createInvoice() {
|
|
1790
|
+
try {
|
|
1791
|
+
const created = await this.api.createInvoice(this.formStore.applicationData.processInstanceId, this.formStore.applicationData.policyAppDto.premium);
|
|
1792
|
+
return !!created;
|
|
1793
|
+
} catch (err) {
|
|
1063
1794
|
this.isLoading = false;
|
|
1064
1795
|
}
|
|
1065
|
-
this.isLoading = false;
|
|
1066
|
-
return { otpStatus, otpResponse };
|
|
1067
1796
|
},
|
|
1068
|
-
async
|
|
1797
|
+
async sendToEpay() {
|
|
1069
1798
|
try {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1799
|
+
const response = await this.api.sendToEpay(this.formStore.applicationData.processInstanceId);
|
|
1800
|
+
if (response) {
|
|
1801
|
+
return response;
|
|
1802
|
+
}
|
|
1803
|
+
} catch (err) {
|
|
1804
|
+
console.log(err);
|
|
1805
|
+
}
|
|
1806
|
+
},
|
|
1807
|
+
setMembersField(whichForm, whichMember) {
|
|
1808
|
+
this.formStore[whichForm].familyStatus = this.findObject('familyStatuses', 'id', this.formStore.applicationData[whichMember].familyStatusId);
|
|
1809
|
+
this.formStore[whichForm].signOfIPDL = this.findObject(
|
|
1810
|
+
'ipdl',
|
|
1811
|
+
'nameRu',
|
|
1812
|
+
this.formStore.applicationData[whichMember].isIpdl === null ? null : this.formStore.applicationData[whichMember].isIpdl == true ? 'Да' : 'Нет',
|
|
1813
|
+
);
|
|
1814
|
+
if (!!this.formStore.applicationData[whichMember].profession) this.formStore[whichForm].job = this.formStore.applicationData[whichMember].profession;
|
|
1815
|
+
if (!!this.formStore.applicationData[whichMember].position) this.formStore[whichForm].jobPosition = this.formStore.applicationData[whichMember].position;
|
|
1816
|
+
if (!!this.formStore.applicationData[whichMember].jobName) this.formStore[whichForm].jobPlace = this.formStore.applicationData[whichMember].jobName;
|
|
1817
|
+
},
|
|
1818
|
+
setMembersFieldIndex(whichForm, whichMember, index) {
|
|
1819
|
+
if ('familyStatus' in this.formStore[whichForm][index]) {
|
|
1820
|
+
this.formStore[whichForm][index].familyStatus = this.findObject('familyStatuses', 'id', this.formStore.applicationData[whichMember][index].familyStatusId);
|
|
1821
|
+
}
|
|
1822
|
+
if ('signOfIPDL' in this.formStore[whichForm][index]) {
|
|
1823
|
+
this.formStore[whichForm][index].signOfIPDL = this.findObject(
|
|
1824
|
+
'ipdl',
|
|
1825
|
+
'nameRu',
|
|
1826
|
+
this.formStore.applicationData[whichMember][index].isIpdl === null ? null : this.formStore.applicationData[whichMember][index].isIpdl == true ? 'Да' : 'Нет',
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
if ('job' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].profession) {
|
|
1830
|
+
this.formStore[whichForm][index].job = this.formStore.applicationData[whichMember][index].profession;
|
|
1831
|
+
}
|
|
1832
|
+
if ('jobPosition' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].position) {
|
|
1833
|
+
this.formStore[whichForm][index].jobPosition = this.formStore.applicationData[whichMember][index].position;
|
|
1834
|
+
}
|
|
1835
|
+
if ('jobPlace' in this.formStore[whichForm][index] && !!this.formStore.applicationData[whichMember][index].jobName) {
|
|
1836
|
+
this.formStore[whichForm][index].jobPlace = this.formStore.applicationData[whichMember][index].jobName;
|
|
1837
|
+
}
|
|
1838
|
+
},
|
|
1839
|
+
findObject(from, key, searchKey) {
|
|
1840
|
+
const found = this[from].find(i => i[key] == searchKey);
|
|
1841
|
+
return found || new Value();
|
|
1842
|
+
},
|
|
1843
|
+
async signToDocument(data) {
|
|
1844
|
+
try {
|
|
1845
|
+
if (this.signUrl) {
|
|
1846
|
+
return this.signUrl;
|
|
1847
|
+
}
|
|
1848
|
+
const result = await this.api.signToDocument(data);
|
|
1849
|
+
this.signUrl = result.uri;
|
|
1850
|
+
return this.signUrl;
|
|
1851
|
+
} catch (error) {
|
|
1852
|
+
this.showToaster('error', this.t('toaster.error') + error?.response?.data, 2000);
|
|
1853
|
+
}
|
|
1854
|
+
},
|
|
1855
|
+
sanitize(text) {
|
|
1856
|
+
if (text) {
|
|
1857
|
+
return text
|
|
1858
|
+
.replace(/\r?\n|\r/g, '')
|
|
1859
|
+
.replace(/\\/g, '')
|
|
1860
|
+
.replace(/"/g, '');
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
async getSignedDocList(processInstanceId) {
|
|
1864
|
+
if (processInstanceId !== 0) {
|
|
1865
|
+
try {
|
|
1866
|
+
this.signedDocumentList = await this.api.getSignedDocList({
|
|
1867
|
+
processInstanceId: processInstanceId,
|
|
1868
|
+
});
|
|
1869
|
+
} catch (err) {
|
|
1870
|
+
console.log(err);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
},
|
|
1874
|
+
setFormsDisabled(isDisabled) {
|
|
1875
|
+
Object.keys(this.formStore.isDisabled).forEach(key => {
|
|
1876
|
+
this.formStore.isDisabled[key] = !!isDisabled;
|
|
1877
|
+
});
|
|
1878
|
+
},
|
|
1879
|
+
async reCalculate(processInstanceId, recalculationData, taskId, whichSum) {
|
|
1880
|
+
this.isLoading = true;
|
|
1881
|
+
try {
|
|
1882
|
+
const data = {
|
|
1883
|
+
processInstanceId: processInstanceId,
|
|
1884
|
+
...recalculationData,
|
|
1075
1885
|
};
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
|
|
1079
|
-
|
|
1886
|
+
const recalculatedValue = await this.api.reCalculate(data);
|
|
1887
|
+
if (!!recalculatedValue) {
|
|
1888
|
+
await this.getApplicationData(taskId, false, false, false);
|
|
1889
|
+
this.showToaster(
|
|
1890
|
+
'success',
|
|
1891
|
+
`${this.t('toaster.successRecalculation')}. ${whichSum == 'insurancePremiumPerMonth' ? 'Страховая премия' : 'Страховая сумма'}: ${this.getNumberWithSpaces(
|
|
1892
|
+
recalculatedValue,
|
|
1893
|
+
)}₸`,
|
|
1894
|
+
4000,
|
|
1895
|
+
);
|
|
1896
|
+
}
|
|
1897
|
+
} catch (err) {
|
|
1898
|
+
console.log(err);
|
|
1899
|
+
if ('response' in err) {
|
|
1900
|
+
this.showToaster('error', err?.response?.data, 5000);
|
|
1901
|
+
} else {
|
|
1902
|
+
this.showToaster('error', err, 5000);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
this.isLoading = false;
|
|
1906
|
+
},
|
|
1907
|
+
async getValidateClientESBD(data) {
|
|
1908
|
+
try {
|
|
1909
|
+
return await this.api.getValidateClientESBD(data);
|
|
1910
|
+
} catch (error) {
|
|
1911
|
+
this.isLoading = false;
|
|
1912
|
+
if ('response' in error && error.response.data) {
|
|
1913
|
+
this.showToaster('error', error.response.data, 5000);
|
|
1914
|
+
}
|
|
1915
|
+
console.log(error);
|
|
1916
|
+
return false;
|
|
1917
|
+
}
|
|
1918
|
+
},
|
|
1919
|
+
validateMultipleMembers(localKey, applicationKey, text) {
|
|
1920
|
+
if (this.formStore[localKey].length === this.formStore.applicationData[applicationKey].length) {
|
|
1921
|
+
if (this.formStore[localKey].length !== 0 && this.formStore.applicationData[applicationKey].length !== 0) {
|
|
1922
|
+
const localMembers = [...this.formStore[localKey]].sort((a, b) => a.id - b.id);
|
|
1923
|
+
const applicationMembers = [...this.formStore.applicationData[applicationKey]].sort((a, b) => a.insisId - b.insisId);
|
|
1924
|
+
if (localMembers.every((each, index) => applicationMembers[index].insisId === each.id && applicationMembers[index].iin === each.iin.replace(/-/g, '')) === false) {
|
|
1925
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1080
1926
|
return false;
|
|
1081
1927
|
}
|
|
1082
|
-
if (
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
3000
|
|
1928
|
+
if (localKey === this.formStore.beneficiaryFormKey) {
|
|
1929
|
+
const sumOfPercentage = localMembers.reduce((sum, member) => {
|
|
1930
|
+
return sum + Number(member.percentageOfPayoutAmount);
|
|
1931
|
+
}, 0);
|
|
1932
|
+
if (sumOfPercentage !== 100) {
|
|
1933
|
+
this.showToaster('error', this.t('toaster.errorSumOrPercentage'), 3000);
|
|
1934
|
+
return false;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
} else {
|
|
1939
|
+
if (this.formStore[localKey].some(i => i.iin !== null)) {
|
|
1940
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1941
|
+
return false;
|
|
1942
|
+
}
|
|
1943
|
+
if (this.formStore.applicationData[applicationKey].length !== 0) {
|
|
1944
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1945
|
+
return false;
|
|
1946
|
+
} else {
|
|
1947
|
+
if (this.formStore[localKey][0].iin !== null) {
|
|
1948
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', text), 3000);
|
|
1949
|
+
return false;
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
return true;
|
|
1954
|
+
},
|
|
1955
|
+
async validateAllMembers(taskId, localCheck = false) {
|
|
1956
|
+
if (taskId == 0) {
|
|
1957
|
+
this.showToaster('error', this.t('toaster.needToRunStatement'), 2000);
|
|
1958
|
+
return false;
|
|
1959
|
+
}
|
|
1960
|
+
if (this.formStore.policyholderForm.id !== this.formStore.applicationData.clientApp.insisId) {
|
|
1961
|
+
this.showToaster('error', this.t('toaster.notSavedMember').replace('{text}', 'страхователя'), 3000);
|
|
1962
|
+
return false;
|
|
1963
|
+
}
|
|
1964
|
+
if (this.validateMultipleMembers(this.formStore.insuredFormKey, 'insuredApp', 'застрахованных') === false) {
|
|
1965
|
+
return false;
|
|
1966
|
+
}
|
|
1967
|
+
if (this.validateMultipleMembers(this.formStore.beneficiaryFormKey, 'beneficiaryApp', 'выгодоприобретателей') === false) {
|
|
1968
|
+
return false;
|
|
1969
|
+
}
|
|
1970
|
+
if (this.formStore.isActOwnBehalf === false) {
|
|
1971
|
+
if (this.validateMultipleMembers(this.formStore.beneficialOwnerFormKey, 'beneficialOwnerApp', 'бенефициарных собственников') === false) {
|
|
1972
|
+
return false;
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
if (this.formStore.hasRepresentative) {
|
|
1976
|
+
if (this.formStore.applicationData.spokesmanApp && this.formStore.policyholdersRepresentativeForm.id !== this.formStore.applicationData.spokesmanApp.insisId) {
|
|
1977
|
+
this.showToaster(
|
|
1978
|
+
'error',
|
|
1979
|
+
this.t('toaster.notSavedMember', {
|
|
1980
|
+
text: 'представителя страхователя',
|
|
1981
|
+
}),
|
|
1982
|
+
3000,
|
|
1983
|
+
);
|
|
1984
|
+
return false;
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
const areValid = this.formStore.SaleChanellPolicy.nameRu && this.formStore.RegionPolicy.nameRu && this.formStore.ManagerPolicy.nameRu && this.formStore.AgentData.fullName;
|
|
1988
|
+
if (areValid) {
|
|
1989
|
+
await this.setINSISWorkData();
|
|
1990
|
+
} else {
|
|
1991
|
+
this.isLoading = false;
|
|
1992
|
+
this.showToaster('error', this.t('toaster.attachManagerError'), 3000);
|
|
1993
|
+
return false;
|
|
1994
|
+
}
|
|
1995
|
+
if (localCheck === false) {
|
|
1996
|
+
try {
|
|
1997
|
+
if (this.formStore.isActOwnBehalf === true && this.formStore.applicationData.beneficialOwnerApp.length !== 0) {
|
|
1998
|
+
await Promise.allSettled(
|
|
1999
|
+
this.formStore.applicationData.beneficialOwnerApp.map(async member => {
|
|
2000
|
+
await this.api.deleteMember('BeneficialOwner', member.id);
|
|
2001
|
+
}),
|
|
1088
2002
|
);
|
|
1089
|
-
|
|
2003
|
+
}
|
|
2004
|
+
await this.getApplicationData(taskId, false);
|
|
2005
|
+
} catch (err) {
|
|
2006
|
+
console.log(err);
|
|
2007
|
+
this.showToaster('error', err, 5000);
|
|
2008
|
+
return false;
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
return true;
|
|
2013
|
+
},
|
|
2014
|
+
validateAnketa(whichSurvey) {
|
|
2015
|
+
const list = this[whichSurvey].body;
|
|
2016
|
+
if (!list || (list && list.length === 0)) return false;
|
|
2017
|
+
let notAnswered = 0;
|
|
2018
|
+
for (let x = 0; x < list.length; x++) {
|
|
2019
|
+
if ((list[x].first.definedAnswers === 'N' && !list[x].first.answerText) || (list[x].first.definedAnswers === 'Y' && !list[x].first.answerName)) {
|
|
2020
|
+
notAnswered = notAnswered + 1;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
return notAnswered === 0;
|
|
2024
|
+
},
|
|
2025
|
+
async validateAllForms(taskId) {
|
|
2026
|
+
this.isLoading = true;
|
|
2027
|
+
const areMembersValid = await this.validateAllMembers(taskId);
|
|
2028
|
+
if (areMembersValid) {
|
|
2029
|
+
if (!!this.formStore.productConditionsForm.insurancePremiumPerMonth && !!this.formStore.productConditionsForm.requestedSumInsured) {
|
|
2030
|
+
const hasCritical = this.additionalInsuranceTerms?.find(cover => cover.coverTypeName === 'Критическое заболевание Застрахованного');
|
|
2031
|
+
if (hasCritical && hasCritical.coverSumName !== 'не включено') {
|
|
2032
|
+
await Promise.allSettled([
|
|
2033
|
+
this.getQuestionList(
|
|
2034
|
+
'health',
|
|
2035
|
+
this.formStore.applicationData.processInstanceId,
|
|
2036
|
+
this.formStore.applicationData.insuredApp[0].id,
|
|
2037
|
+
'surveyByHealthBase',
|
|
2038
|
+
'surveyByHealthSecond',
|
|
2039
|
+
),
|
|
2040
|
+
this.getQuestionList(
|
|
2041
|
+
'critical',
|
|
2042
|
+
this.formStore.applicationData.processInstanceId,
|
|
2043
|
+
this.formStore.applicationData.insuredApp[0].id,
|
|
2044
|
+
'surveyByCriticalBase',
|
|
2045
|
+
'surveyByCriticalSecond',
|
|
2046
|
+
),
|
|
2047
|
+
]);
|
|
2048
|
+
await Promise.allSettled([
|
|
2049
|
+
...this.surveyByHealthBase.body.map(async question => {
|
|
2050
|
+
await this.definedAnswers(question.first.id, 'surveyByHealthBase');
|
|
2051
|
+
}),
|
|
2052
|
+
...this.surveyByCriticalBase.body.map(async question => {
|
|
2053
|
+
await this.definedAnswers(question.first.id, 'surveyByCriticalBase');
|
|
2054
|
+
}),
|
|
2055
|
+
]);
|
|
2056
|
+
} else {
|
|
2057
|
+
await Promise.allSettled([
|
|
2058
|
+
this.getQuestionList(
|
|
2059
|
+
'health',
|
|
2060
|
+
this.formStore.applicationData.processInstanceId,
|
|
2061
|
+
this.formStore.applicationData.insuredApp[0].id,
|
|
2062
|
+
'surveyByHealthBase',
|
|
2063
|
+
'surveyByHealthSecond',
|
|
2064
|
+
),
|
|
2065
|
+
]);
|
|
2066
|
+
await Promise.allSettled(
|
|
2067
|
+
this.surveyByHealthBase.body.map(async question => {
|
|
2068
|
+
await this.definedAnswers(question.first.id, 'surveyByHealthBase');
|
|
2069
|
+
}),
|
|
2070
|
+
);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
if (this.validateAnketa('surveyByHealthBase')) {
|
|
2074
|
+
let hasCriticalAndItsValid = null;
|
|
2075
|
+
if (hasCritical && hasCritical.coverSumName !== 'не включено') {
|
|
2076
|
+
if (this.validateAnketa('surveyByCriticalBase')) {
|
|
2077
|
+
hasCriticalAndItsValid = true;
|
|
2078
|
+
} else {
|
|
2079
|
+
hasCriticalAndItsValid = false;
|
|
2080
|
+
this.showToaster('error', this.t('toaster.emptyCriticalAnketa'), 3000);
|
|
2081
|
+
}
|
|
2082
|
+
} else {
|
|
2083
|
+
hasCriticalAndItsValid = null;
|
|
2084
|
+
}
|
|
2085
|
+
if (hasCriticalAndItsValid === true || hasCriticalAndItsValid === null) {
|
|
2086
|
+
this.isLoading = false;
|
|
1090
2087
|
return true;
|
|
1091
2088
|
}
|
|
2089
|
+
} else {
|
|
2090
|
+
this.showToaster('error', this.t('toaster.emptyHealthAnketa'), 3000);
|
|
1092
2091
|
}
|
|
2092
|
+
} else {
|
|
2093
|
+
this.showToaster('error', this.t('toaster.emptyProductConditions'), 3000);
|
|
1093
2094
|
}
|
|
1094
2095
|
return false;
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
2096
|
+
}
|
|
2097
|
+
this.isLoading = false;
|
|
2098
|
+
return false;
|
|
2099
|
+
},
|
|
2100
|
+
async getFamilyInfo(iin, phoneNumber) {
|
|
2101
|
+
this.isLoading = true;
|
|
2102
|
+
try {
|
|
2103
|
+
const familyResponse = await this.api.getFamilyInfo({ iin: iin.replace(/-/g, ''), phoneNumber: formatPhone(phoneNumber) });
|
|
2104
|
+
if (familyResponse.status === 'PENDING') {
|
|
2105
|
+
this.showToaster('success', this.t('toaster.waitForClient'), 5000);
|
|
2106
|
+
this.isLoading = false;
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
if (constants.gbdErrors.find(i => i === familyResponse.status)) {
|
|
2110
|
+
if (familyResponse.status === 'TIMEOUT') {
|
|
2111
|
+
this.showToaster('success', `${familyResponse.statusName}. Отправьте запрос еще раз`, 5000);
|
|
2112
|
+
} else {
|
|
2113
|
+
this.showToaster('error', familyResponse.statusName, 5000);
|
|
2114
|
+
}
|
|
2115
|
+
this.isLoading = false;
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2118
|
+
if (familyResponse.infoList && familyResponse.infoList.birthInfos && familyResponse.infoList.birthInfos.length) {
|
|
2119
|
+
const filteredBirthInfos = familyResponse.infoList.birthInfos.filter(
|
|
2120
|
+
member => member.childBirthDate && getAgeByBirthDate(member.childBirthDate) <= 15 && typeof member.childLifeStatus === 'number' && member.childLifeStatus === 0,
|
|
2121
|
+
);
|
|
2122
|
+
if (filteredBirthInfos && filteredBirthInfos.length) {
|
|
2123
|
+
this.formStore.birthInfos = filteredBirthInfos;
|
|
2124
|
+
this.showToaster('success', this.t('toaster.pickFamilyMember'), 3000);
|
|
2125
|
+
} else {
|
|
2126
|
+
this.formStore.birthInfos = [];
|
|
2127
|
+
this.showToaster('error', this.t('toaster.notFound'), 3000);
|
|
2128
|
+
}
|
|
2129
|
+
} else {
|
|
2130
|
+
this.formStore.birthInfos = [];
|
|
2131
|
+
this.showToaster('error', this.t('toaster.notFound'), 3000);
|
|
1099
2132
|
}
|
|
2133
|
+
} catch (err) {
|
|
2134
|
+
ErrorHandler(err);
|
|
1100
2135
|
} finally {
|
|
1101
2136
|
this.isLoading = false;
|
|
1102
2137
|
}
|
|
1103
|
-
return null;
|
|
1104
2138
|
},
|
|
1105
|
-
async
|
|
2139
|
+
async getContragentFromGBDFL(iin, phoneNumber, whichForm, whichIndex) {
|
|
1106
2140
|
this.isLoading = true;
|
|
1107
2141
|
try {
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
|
|
2142
|
+
const data = {
|
|
2143
|
+
iin: iin.replace(/-/g, ''),
|
|
2144
|
+
phoneNumber: formatPhone(phoneNumber),
|
|
2145
|
+
};
|
|
2146
|
+
const gbdResponse = await this.api.getContragentFromGBDFL(data);
|
|
2147
|
+
if (gbdResponse.status === 'PENDING') {
|
|
2148
|
+
this.showToaster('success', this.t('toaster.waitForClient'), 5000);
|
|
2149
|
+
this.isLoading = false;
|
|
2150
|
+
return;
|
|
1111
2151
|
}
|
|
2152
|
+
if (constants.gbdErrors.find(i => i === gbdResponse.status)) {
|
|
2153
|
+
if (gbdResponse.status === 'TIMEOUT') {
|
|
2154
|
+
this.showToaster('success', `${gbdResponse.statusName}. Отправьте запрос еще раз`, 5000);
|
|
2155
|
+
} else {
|
|
2156
|
+
this.showToaster('success', gbdResponse.statusName, 5000);
|
|
2157
|
+
}
|
|
2158
|
+
this.isLoading = false;
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
const { person } = parseXML(gbdResponse.content, true, 'person');
|
|
2162
|
+
const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
|
|
2163
|
+
if (typeof whichIndex !== 'number') {
|
|
2164
|
+
if (this.formStore[whichForm].gosPersonData !== null && this.formStore[whichForm].gosPersonData.iin !== iin.replace(/-/g, '')) {
|
|
2165
|
+
this.formStore[whichForm].resetMember(false);
|
|
2166
|
+
}
|
|
2167
|
+
this.formStore[whichForm].gosPersonData = person;
|
|
2168
|
+
} else {
|
|
2169
|
+
if (this.formStore[whichForm][whichIndex].gosPersonData !== null && this.formStore[whichForm][whichIndex].gosPersonData.iin !== iin.replace(/-/g, '')) {
|
|
2170
|
+
this.formStore[whichForm][whichIndex].resetMember(false);
|
|
2171
|
+
}
|
|
2172
|
+
this.formStore[whichForm][whichIndex].gosPersonData = person;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
await this.getContragent(typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex] : this.formStore[whichForm], whichForm, whichIndex, false);
|
|
2176
|
+
if (typeof whichIndex !== 'number') {
|
|
2177
|
+
this.formStore[whichForm].verifyDate = responseInfo.responseDate;
|
|
2178
|
+
this.formStore[whichForm].verifyType = 'GBDFL';
|
|
2179
|
+
} else {
|
|
2180
|
+
this.formStore[whichForm][whichIndex].verifyDate = responseInfo.responseDate;
|
|
2181
|
+
this.formStore[whichForm][whichIndex].verifyType = 'GBDFL';
|
|
2182
|
+
}
|
|
2183
|
+
await this.saveInStoreUserGBDFL(person, whichForm, whichIndex);
|
|
1112
2184
|
} catch (err) {
|
|
1113
2185
|
console.log(err);
|
|
2186
|
+
if ('response' in err) {
|
|
2187
|
+
this.showToaster('error', err.response.data, 3000);
|
|
2188
|
+
}
|
|
1114
2189
|
}
|
|
1115
2190
|
this.isLoading = false;
|
|
1116
2191
|
},
|
|
1117
|
-
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
2192
|
+
async saveInStoreUserGBDFL(person, whichForm, whichIndex = null) {
|
|
2193
|
+
if (whichIndex === null) {
|
|
2194
|
+
this.formStore[whichForm].firstName = person.name;
|
|
2195
|
+
this.formStore[whichForm].lastName = person.surname;
|
|
2196
|
+
this.formStore[whichForm].middleName = person.patronymic ? person.patronymic : '';
|
|
2197
|
+
this.formStore[whichForm].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
|
|
2198
|
+
this.formStore[whichForm].birthDate = reformatDate(person.birthDate);
|
|
2199
|
+
this.formStore[whichForm].genderName = person.gender.nameRu;
|
|
2200
|
+
|
|
2201
|
+
const gender = this.gender.find(i => i.id == person.gender.code);
|
|
2202
|
+
if (gender) this.formStore[whichForm].gender = gender;
|
|
2203
|
+
|
|
2204
|
+
const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
|
|
2205
|
+
if (birthPlace) this.formStore[whichForm].birthPlace = birthPlace;
|
|
2206
|
+
|
|
2207
|
+
const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
|
|
2208
|
+
if (countryOfCitizenship) this.formStore[whichForm].countryOfCitizenship = countryOfCitizenship;
|
|
2209
|
+
|
|
2210
|
+
const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
|
|
2211
|
+
if (regCountry) this.formStore[whichForm].registrationCountry = regCountry;
|
|
2212
|
+
|
|
2213
|
+
const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
|
|
2214
|
+
if (regProvince) this.formStore[whichForm].registrationProvince = regProvince;
|
|
2215
|
+
|
|
2216
|
+
if ('city' in person.regAddress && !!person.regAddress.city) {
|
|
2217
|
+
if (person.regAddress.city.includes(', ')) {
|
|
2218
|
+
const personCities = person.regAddress.city.split(', ');
|
|
2219
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2220
|
+
const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
|
|
2221
|
+
if (possibleCity) {
|
|
2222
|
+
this.formStore[whichForm].registrationCity = possibleCity;
|
|
2223
|
+
break;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
if (this.formStore[whichForm].registrationCity.nameRu === null) {
|
|
2227
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2228
|
+
const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
|
|
2229
|
+
if (possibleRegion) {
|
|
2230
|
+
this.formStore[whichForm].registrationRegion = possibleRegion;
|
|
2231
|
+
break;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
} else {
|
|
2236
|
+
const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
|
|
2237
|
+
if (regCity) this.formStore[whichForm].registrationCity = regCity;
|
|
2238
|
+
|
|
2239
|
+
if (this.formStore[whichForm].registrationCity.nameRu === null) {
|
|
2240
|
+
const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
|
|
2241
|
+
if (regRegion) this.formStore[whichForm].registrationRegion = regRegion;
|
|
2242
|
+
}
|
|
1124
2243
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
if (this.formStore[whichForm].registrationCity.nameRu === null && this.formStore[whichForm].registrationRegion.nameRu === null) {
|
|
2247
|
+
const regCity = this.cities.find(
|
|
2248
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2249
|
+
);
|
|
2250
|
+
if (regCity) {
|
|
2251
|
+
this.formStore[whichForm].registrationCity = regCity;
|
|
2252
|
+
const regType = this.localityTypes.find(i => i.nameRu === 'город');
|
|
2253
|
+
if (regType) this.formStore[whichForm].registrationRegionType = regType;
|
|
2254
|
+
} else {
|
|
2255
|
+
const regRegion = this.regions.find(
|
|
2256
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2257
|
+
);
|
|
2258
|
+
if (regRegion) {
|
|
2259
|
+
this.formStore[whichForm].registrationRegion = regRegion;
|
|
2260
|
+
const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
|
|
2261
|
+
if (regType) this.formStore[whichForm].registrationRegionType = regType;
|
|
2262
|
+
}
|
|
1129
2263
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
if (person.regAddress.street.includes(', ')) {
|
|
2267
|
+
const personAddress = person.regAddress.street.split(', ');
|
|
2268
|
+
const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
|
|
2269
|
+
const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
|
|
2270
|
+
const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
|
|
2271
|
+
if (microDistrict) this.formStore[whichForm].registrationMicroDistrict = microDistrict;
|
|
2272
|
+
if (quarter) this.formStore[whichForm].registrationQuarter = quarter;
|
|
2273
|
+
if (street) this.formStore[whichForm].registrationStreet = street;
|
|
2274
|
+
} else {
|
|
2275
|
+
if (person.regAddress.street) this.formStore[whichForm].registrationStreet = person.regAddress.street;
|
|
2276
|
+
}
|
|
2277
|
+
if (person.regAddress.building) this.formStore[whichForm].registrationNumberHouse = person.regAddress.building;
|
|
2278
|
+
if (person.regAddress.flat) this.formStore[whichForm].registrationNumberApartment = person.regAddress.flat;
|
|
2279
|
+
|
|
2280
|
+
// TODO Доработать логику и для остальных
|
|
2281
|
+
if ('length' in person.documents.document) {
|
|
2282
|
+
const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
|
|
2283
|
+
if (validDocument) {
|
|
2284
|
+
const documentType = this.documentTypes.find(i => i.ids === '1UDL');
|
|
2285
|
+
if (documentType) this.formStore[whichForm].documentType = documentType;
|
|
2286
|
+
|
|
2287
|
+
this.formStore[whichForm].documentNumber = validDocument.number;
|
|
2288
|
+
this.formStore[whichForm].documentExpire = reformatDate(validDocument.endDate);
|
|
2289
|
+
this.formStore[whichForm].documentDate = reformatDate(validDocument.beginDate);
|
|
2290
|
+
this.formStore[whichForm].documentNumber = validDocument.number;
|
|
2291
|
+
|
|
2292
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2293
|
+
if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
|
|
1134
2294
|
}
|
|
2295
|
+
} else {
|
|
2296
|
+
const documentType =
|
|
2297
|
+
person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
|
|
2298
|
+
? this.documentTypes.find(i => i.ids === '1UDL')
|
|
2299
|
+
: this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2300
|
+
? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2301
|
+
: new Value();
|
|
2302
|
+
if (documentType) this.formStore[whichForm].documentType = documentType;
|
|
2303
|
+
|
|
2304
|
+
const documentNumber = person.documents.document.number;
|
|
2305
|
+
if (documentNumber) this.formStore[whichForm].documentNumber = documentNumber;
|
|
2306
|
+
|
|
2307
|
+
const documentDate = person.documents.document.beginDate;
|
|
2308
|
+
if (documentDate) this.formStore[whichForm].documentDate = reformatDate(documentDate);
|
|
2309
|
+
|
|
2310
|
+
const documentExpire = person.documents.document.endDate;
|
|
2311
|
+
if (documentExpire) this.formStore[whichForm].documentExpire = reformatDate(documentExpire);
|
|
2312
|
+
|
|
2313
|
+
// TODO уточнить
|
|
2314
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2315
|
+
if (documentIssuer) this.formStore[whichForm].documentIssuers = documentIssuer;
|
|
1135
2316
|
}
|
|
2317
|
+
const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
|
|
2318
|
+
if (economySectorCode) this.formStore[whichForm].economySectorCode = economySectorCode;
|
|
2319
|
+
} else {
|
|
2320
|
+
this.formStore[whichForm][whichIndex].firstName = person.name;
|
|
2321
|
+
this.formStore[whichForm][whichIndex].lastName = person.surname;
|
|
2322
|
+
this.formStore[whichForm][whichIndex].middleName = person.patronymic ? person.patronymic : '';
|
|
2323
|
+
this.formStore[whichForm][whichIndex].longName = `${person.surname} ${person.name} ${person.patronymic ? person.patronymic : ''}`;
|
|
2324
|
+
this.formStore[whichForm][whichIndex].birthDate = reformatDate(person.birthDate);
|
|
2325
|
+
this.formStore[whichForm][whichIndex].genderName = person.gender.nameRu;
|
|
2326
|
+
|
|
2327
|
+
const gender = this.gender.find(i => i.id == person.gender.code);
|
|
2328
|
+
if (gender) this.formStore[whichForm][whichIndex].gender = gender;
|
|
2329
|
+
|
|
2330
|
+
const birthPlace = this.countries.find(i => i.nameRu.match(new RegExp(person.birthPlace.country.nameRu, 'i')));
|
|
2331
|
+
if (birthPlace) this.formStore[whichForm][whichIndex].birthPlace = birthPlace;
|
|
2332
|
+
|
|
2333
|
+
const countryOfCitizenship = this.citizenshipCountries.find(i => i.nameRu.match(new RegExp(person.citizenship.nameRu, 'i')));
|
|
2334
|
+
if (countryOfCitizenship) this.formStore[whichForm][whichIndex].countryOfCitizenship = countryOfCitizenship;
|
|
2335
|
+
|
|
2336
|
+
const regCountry = this.countries.find(i => i.nameRu.match(new RegExp(person.regAddress.country.nameRu, 'i')));
|
|
2337
|
+
if (regCountry) this.formStore[whichForm][whichIndex].registrationCountry = regCountry;
|
|
2338
|
+
|
|
2339
|
+
const regProvince = this.states.find(i => i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')));
|
|
2340
|
+
if (regProvince) this.formStore[whichForm][whichIndex].registrationProvince = regProvince;
|
|
2341
|
+
|
|
2342
|
+
if ('city' in person.regAddress && !!person.regAddress.city) {
|
|
2343
|
+
if (person.regAddress.city.includes(', ')) {
|
|
2344
|
+
const personCities = person.regAddress.city.split(', ');
|
|
2345
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2346
|
+
const possibleCity = this.cities.find(i => i.nameRu.includes(personCities[i]));
|
|
2347
|
+
if (possibleCity) {
|
|
2348
|
+
this.formStore[whichForm][whichIndex].registrationCity = possibleCity;
|
|
2349
|
+
break;
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
|
|
2353
|
+
for (let i = 0; i < personCities.length; ++i) {
|
|
2354
|
+
const possibleRegion = this.regions.find(i => i.nameRu.includes(personCities[i]));
|
|
2355
|
+
if (possibleRegion) {
|
|
2356
|
+
this.formStore[whichForm][whichIndex].registrationRegion = possibleRegion;
|
|
2357
|
+
break;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
} else {
|
|
2362
|
+
const regCity = this.cities.find(i => i.nameRu.match(new RegExp(person.regAddress.city, 'i')));
|
|
2363
|
+
if (regCity) this.formStore[whichForm][whichIndex].registrationCity = regCity;
|
|
2364
|
+
if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null) {
|
|
2365
|
+
const regRegion = this.regions.find(i => i.nameRu.match(new RegExp(person.regAddress.city), 'i'));
|
|
2366
|
+
if (regRegion) this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
if (this.formStore[whichForm][whichIndex].registrationCity.nameRu === null && this.formStore[whichForm][whichIndex].registrationRegion.nameRu === null) {
|
|
2372
|
+
const regCity = this.cities.find(
|
|
2373
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu, 'i')) || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2374
|
+
);
|
|
2375
|
+
if (regCity) {
|
|
2376
|
+
this.formStore[whichForm][whichIndex].registrationCity = regCity;
|
|
2377
|
+
const regType = this.localityTypes.find(i => i.nameRu === 'город');
|
|
2378
|
+
if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
|
|
2379
|
+
} else {
|
|
2380
|
+
const regRegion = this.regions.find(
|
|
2381
|
+
i => i.nameRu.match(new RegExp(person.regAddress.region.nameRu), 'i') || i.nameRu.match(new RegExp(person.regAddress.district.nameRu, 'i')),
|
|
2382
|
+
);
|
|
2383
|
+
if (regRegion) {
|
|
2384
|
+
this.formStore[whichForm][whichIndex].registrationRegion = regRegion;
|
|
2385
|
+
const regType = this.localityTypes.find(i => (i.nameRu === i.nameRu) === 'село' || i.nameRu === 'поселок');
|
|
2386
|
+
if (regType) this.formStore[whichForm][whichIndex].registrationRegionType = regType;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
if (person.regAddress.street.includes(', ')) {
|
|
2392
|
+
const personAddress = person.regAddress.street.split(', ');
|
|
2393
|
+
const microDistrict = personAddress.find(i => i.match(new RegExp('микрорайон', 'i')));
|
|
2394
|
+
const quarter = personAddress.find(i => i.match(new RegExp('квартал', 'i')));
|
|
2395
|
+
const street = personAddress.find(i => i.match(new RegExp('улица', 'i')));
|
|
2396
|
+
if (microDistrict) this.formStore[whichForm][whichIndex].registrationMicroDistrict = microDistrict;
|
|
2397
|
+
if (quarter) this.formStore[whichForm][whichIndex].registrationQuarter = quarter;
|
|
2398
|
+
if (street) this.formStore[whichForm][whichIndex].registrationStreet = street;
|
|
2399
|
+
} else {
|
|
2400
|
+
if (person.regAddress.street) this.formStore[whichForm][whichIndex].registrationStreet = person.regAddress.street;
|
|
2401
|
+
}
|
|
2402
|
+
if (person.regAddress.building) this.formStore[whichForm][whichIndex].registrationNumberHouse = person.regAddress.building;
|
|
2403
|
+
if (person.regAddress.flat) this.formStore[whichForm][whichIndex].registrationNumberApartment = person.regAddress.flat;
|
|
2404
|
+
|
|
2405
|
+
// TODO Доработать логику и для остальных
|
|
2406
|
+
if ('length' in person.documents.document) {
|
|
2407
|
+
const validDocument = person.documents.document.find(i => new Date(i.endDate) > new Date(Date.now()) && i.status.code === '00' && i.type.code === '002');
|
|
2408
|
+
if (validDocument) {
|
|
2409
|
+
const documentType = this.documentTypes.find(i => i.ids === '1UDL');
|
|
2410
|
+
if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
|
|
2411
|
+
this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
|
|
2412
|
+
this.formStore[whichForm][whichIndex].documentExpire = reformatDate(validDocument.endDate);
|
|
2413
|
+
this.formStore[whichForm][whichIndex].documentDate = reformatDate(validDocument.beginDate);
|
|
2414
|
+
this.formStore[whichForm][whichIndex].documentNumber = validDocument.number;
|
|
2415
|
+
|
|
2416
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2417
|
+
if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
|
|
2418
|
+
}
|
|
2419
|
+
} else {
|
|
2420
|
+
const documentType =
|
|
2421
|
+
person.documents.document.type.nameRu === 'УДОСТОВЕРЕНИЕ РК'
|
|
2422
|
+
? this.documentTypes.find(i => i.ids === '1UDL')
|
|
2423
|
+
: this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2424
|
+
? this.documentTypes.find(i => i.nameRu.match(new RegExp(person.documents.document.type.nameRu, 'i')))
|
|
2425
|
+
: new Value();
|
|
2426
|
+
if (documentType) this.formStore[whichForm][whichIndex].documentType = documentType;
|
|
2427
|
+
|
|
2428
|
+
const documentNumber = person.documents.document.number;
|
|
2429
|
+
if (documentNumber) this.formStore[whichForm][whichIndex].documentNumber = documentNumber;
|
|
2430
|
+
|
|
2431
|
+
const documentDate = person.documents.document.beginDate;
|
|
2432
|
+
if (documentDate) this.formStore[whichForm][whichIndex].documentDate = reformatDate(documentDate);
|
|
2433
|
+
|
|
2434
|
+
const documentExpire = person.documents.document.endDate;
|
|
2435
|
+
if (documentExpire) this.formStore[whichForm][whichIndex].documentExpire = reformatDate(documentExpire);
|
|
2436
|
+
|
|
2437
|
+
// TODO уточнить
|
|
2438
|
+
const documentIssuer = this.documentIssuers.find(i => i.nameRu.match(new RegExp('МВД РК', 'i')));
|
|
2439
|
+
if (documentIssuer) this.formStore[whichForm][whichIndex].documentIssuers = documentIssuer;
|
|
2440
|
+
}
|
|
2441
|
+
const economySectorCode = this.economySectorCode.find(i => i.ids === '500003.9');
|
|
2442
|
+
if (economySectorCode) this.formStore[whichForm][whichIndex].economySectorCode = economySectorCode;
|
|
2443
|
+
}
|
|
2444
|
+
},
|
|
2445
|
+
hasJobSection(whichForm) {
|
|
2446
|
+
switch (whichForm) {
|
|
2447
|
+
case this.formStore.beneficiaryFormKey:
|
|
2448
|
+
case this.formStore.beneficialOwnerFormKey:
|
|
2449
|
+
case this.formStore.policyholdersRepresentativeFormKey:
|
|
2450
|
+
return false;
|
|
2451
|
+
default:
|
|
2452
|
+
return true;
|
|
2453
|
+
}
|
|
2454
|
+
},
|
|
2455
|
+
hasBirthSection(whichForm) {
|
|
2456
|
+
if (this.isGons) return false;
|
|
2457
|
+
switch (whichForm) {
|
|
2458
|
+
case this.formStore.beneficiaryFormKey:
|
|
2459
|
+
return false;
|
|
2460
|
+
default:
|
|
2461
|
+
return true;
|
|
2462
|
+
}
|
|
2463
|
+
},
|
|
2464
|
+
hasPlaceSection(whichForm) {
|
|
2465
|
+
switch (whichForm) {
|
|
2466
|
+
default:
|
|
2467
|
+
return true;
|
|
2468
|
+
}
|
|
2469
|
+
},
|
|
2470
|
+
hasDocumentSection(whichForm) {
|
|
2471
|
+
switch (whichForm) {
|
|
2472
|
+
default:
|
|
2473
|
+
return true;
|
|
2474
|
+
}
|
|
2475
|
+
},
|
|
2476
|
+
hasContactSection(whichForm) {
|
|
2477
|
+
if (this.isGons) return false;
|
|
2478
|
+
switch (whichForm) {
|
|
2479
|
+
default:
|
|
2480
|
+
return true;
|
|
1136
2481
|
}
|
|
1137
2482
|
},
|
|
1138
2483
|
},
|