hl-core 0.0.7 → 0.0.8-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/.prettierrc +2 -1
  2. package/api/index.ts +562 -0
  3. package/api/interceptors.ts +38 -0
  4. package/components/Button/Btn.vue +57 -0
  5. package/components/Button/BtnIcon.vue +47 -0
  6. package/components/Button/ScrollButtons.vue +6 -0
  7. package/components/Button/SortArrow.vue +21 -0
  8. package/components/Complex/Content.vue +5 -0
  9. package/components/Complex/ContentBlock.vue +5 -0
  10. package/components/Complex/Page.vue +43 -0
  11. package/components/Dialog/Dialog.vue +76 -0
  12. package/components/Dialog/FamilyDialog.vue +39 -0
  13. package/components/Form/FormBlock.vue +139 -0
  14. package/components/Form/FormSection.vue +18 -0
  15. package/components/Form/FormTextSection.vue +20 -0
  16. package/components/Form/FormToggle.vue +52 -0
  17. package/components/Form/ManagerAttachment.vue +196 -0
  18. package/components/Form/ProductConditionsBlock.vue +72 -0
  19. package/components/Input/Datepicker.vue +41 -0
  20. package/components/Input/EmptyFormField.vue +5 -0
  21. package/components/Input/FileInput.vue +71 -0
  22. package/components/Input/FormInput.vue +183 -0
  23. package/components/Input/PanelInput.vue +133 -0
  24. package/components/Input/RoundedInput.vue +143 -0
  25. package/components/Layout/Drawer.vue +45 -0
  26. package/components/Layout/Header.vue +48 -0
  27. package/components/Layout/Loader.vue +35 -0
  28. package/components/Layout/SettingsPanel.vue +48 -0
  29. package/components/List/ListEmpty.vue +22 -0
  30. package/components/Menu/MenuNav.vue +108 -0
  31. package/components/Menu/MenuNavItem.vue +37 -0
  32. package/components/Pages/Anketa.vue +341 -0
  33. package/components/Pages/Auth.vue +91 -0
  34. package/components/Pages/Documents.vue +108 -0
  35. package/components/Pages/MemberForm.vue +1229 -0
  36. package/components/Pages/ProductAgreement.vue +18 -0
  37. package/components/Pages/ProductConditions.vue +659 -0
  38. package/components/Panel/PanelHandler.vue +233 -0
  39. package/components/Panel/PanelItem.vue +5 -0
  40. package/components/Panel/PanelSelectItem.vue +20 -0
  41. package/components/Transitions/FadeTransition.vue +5 -0
  42. package/components/Transitions/SlideTransition.vue +5 -0
  43. package/composables/axios.ts +11 -0
  44. package/composables/classes.ts +1179 -0
  45. package/composables/constants.ts +71 -0
  46. package/composables/index.ts +168 -2
  47. package/composables/styles.ts +48 -8
  48. package/configs/i18n.ts +19 -0
  49. package/layouts/clear.vue +3 -0
  50. package/layouts/default.vue +75 -0
  51. package/layouts/full.vue +6 -0
  52. package/locales/en.json +403 -0
  53. package/locales/kz.json +403 -0
  54. package/locales/ru.json +403 -0
  55. package/nuxt.config.ts +39 -5
  56. package/package.json +28 -10
  57. package/pages/500.vue +85 -0
  58. package/plugins/helperFunctionsPlugins.ts +19 -2
  59. package/plugins/storePlugin.ts +5 -7
  60. package/plugins/vuetifyPlugin.ts +15 -0
  61. package/store/data.store.js +2291 -8
  62. package/store/form.store.ts +8 -0
  63. package/store/member.store.ts +381 -0
  64. package/store/rules.js +52 -39
  65. package/tailwind.config.js +10 -0
  66. package/types/index.ts +317 -0
  67. package/app.vue +0 -3
  68. package/components/Button/GreenBtn.vue +0 -33
  69. package/store/app.store.js +0 -12
  70. package/store/messages.ts +0 -310
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <base-content :title="$t('agreementBlock.title')" class="!w-full">
3
+ <p class="h-full p-4 lg:p-8 leading-8 font-medium" :class="[$libStyles.scrollPage, $libStyles.textSimple]">&nbsp;&nbsp;&nbsp;&nbsp; {{ $t('agreementBlock.text') }}</p>
4
+ </base-content>
5
+ </template>
6
+
7
+ <script lang="ts">
8
+ export default defineComponent({
9
+ setup() {
10
+ const dataStore = useDataStore();
11
+
12
+ onUnmounted(() => {
13
+ dataStore.panel.open = false;
14
+ dataStore.panelAction = null;
15
+ });
16
+ },
17
+ });
18
+ </script>
@@ -0,0 +1,659 @@
1
+ <template>
2
+ <section class="flex flex-col gap-4 px-[10px]">
3
+ <v-form ref="vForm" @submit="submitForm" class="max-h-[82svh] overflow-y-scroll">
4
+ <base-form-section v-if="$dataStore.isGons" :title="$t('productConditionsForm.requestedProductConditions')" :class="[$libStyles.textSimple]">
5
+ <base-form-text-section
6
+ class="mb-4"
7
+ title="Инвалидность I или II группы по причине несчастного случая, начиная с третьего года по любой причине, с освобождением от уплаты страховых взносов"
8
+ subtitle="Равна страховой сумме по основному покрытию"
9
+ ></base-form-text-section>
10
+ <base-form-text-section
11
+ title="Если лицо, назначенное Выгодоприобретателем, на дату осуществления Страховщиком страховой выплаты не достигло совершеннолетия (восемнадцатилетнего возраста), страховая
12
+ выплата подлежит осуществлению:"
13
+ subtitle="Если несовершеннолетний не достиг возраста 14 лет - законному представителю в соответствии с законодательством Республики Казахстан"
14
+ ></base-form-text-section>
15
+ </base-form-section>
16
+ <base-form-section v-if="isUnderwriterRole" :title="$t('recalculationInfo')">
17
+ <base-form-input
18
+ v-model="productConditionsForm.lifeMultiply"
19
+ :maska="$maska.numbers"
20
+ :clearable="isRecalculationDisabled === false"
21
+ :label="$t('percent') + `Life Multiply`"
22
+ :readonly="isRecalculationDisabled"
23
+ :rules="$dataStore.rules.recalculationMultiply"
24
+ ></base-form-input>
25
+ <base-form-input
26
+ v-model="productConditionsForm.lifeAdditive"
27
+ :maska="$maska.numbers"
28
+ :clearable="isRecalculationDisabled === false"
29
+ :label="$t('percent') + `Life Additive`"
30
+ :readonly="isRecalculationDisabled"
31
+ :rules="$dataStore.rules.recalculationAdditive"
32
+ ></base-form-input>
33
+ <base-form-input
34
+ v-model="productConditionsForm.adbMultiply"
35
+ :maska="$maska.numbers"
36
+ :clearable="isRecalculationDisabled === false"
37
+ :label="$t('percent') + `Adb Multiply`"
38
+ :readonly="isRecalculationDisabled"
39
+ :rules="$dataStore.rules.recalculationMultiply"
40
+ ></base-form-input>
41
+ <base-form-input
42
+ v-model="productConditionsForm.adbAdditive"
43
+ :maska="$maska.numbers"
44
+ :clearable="isRecalculationDisabled === false"
45
+ :label="$t('percent') + `Adb Additive`"
46
+ :readonly="isRecalculationDisabled"
47
+ :rules="$dataStore.rules.recalculationAdditive"
48
+ ></base-form-input>
49
+ <base-form-input
50
+ v-model="productConditionsForm.disabilityMultiply"
51
+ :maska="$maska.numbers"
52
+ :clearable="isRecalculationDisabled === false"
53
+ :label="$t('percent') + `Disability Multiply`"
54
+ :readonly="isRecalculationDisabled"
55
+ :rules="$dataStore.rules.recalculationMultiply"
56
+ ></base-form-input>
57
+ <base-form-input
58
+ v-model="productConditionsForm.disabilityAdditive"
59
+ :maska="$maska.numbers"
60
+ :clearable="isRecalculationDisabled === false"
61
+ :label="$t('percent') + `Disability Additive`"
62
+ :readonly="isRecalculationDisabled"
63
+ :rules="$dataStore.rules.recalculationAdditive"
64
+ >
65
+ </base-form-input>
66
+ <base-panel-input
67
+ v-model="productConditionsForm.riskGroup"
68
+ :value="productConditionsForm.riskGroup.nameRu"
69
+ :label="$t('productConditionsForm.riskGroup')"
70
+ :clearable="isRecalculationDisabled === false"
71
+ :readonly="isRecalculationDisabled"
72
+ append-inner-icon="mdi mdi-chevron-right"
73
+ @append="openPanel($t('productConditionsForm.riskGroup'), $dataStore.riskGroup, 'riskGroup')"
74
+ ></base-panel-input>
75
+ </base-form-section>
76
+ <base-form-section :title="$t('generalConditions')">
77
+ <div v-if="isRecalculation && $route.params.taskId === '0'">
78
+ <base-form-input
79
+ v-model="productConditionsForm.signDate"
80
+ :maska="$maska.date"
81
+ :clearable="false"
82
+ :readonly="true"
83
+ :label="$t('form.signDate')"
84
+ append-inner-icon="mdi mdi-calendar-blank-outline"
85
+ ></base-form-input>
86
+ <base-form-input
87
+ v-model="productConditionsForm.birthDate"
88
+ :maska="$maska.date"
89
+ :readonly="isDisabled"
90
+ :clearable="!isDisabled"
91
+ :label="$t('form.birthDate')"
92
+ :rules="$rules.required.concat($rules.birthDate)"
93
+ append-inner-icon="mdi mdi-calendar-blank-outline"
94
+ ></base-form-input>
95
+ <base-panel-input
96
+ v-model="productConditionsForm.gender"
97
+ :value="productConditionsForm.gender.nameRu"
98
+ :readonly="isDisabled"
99
+ :clearable="!isDisabled"
100
+ :label="$t('form.gender')"
101
+ :rules="$rules.objectRequired"
102
+ append-inner-icon="mdi mdi-chevron-right"
103
+ @append="openPanel($t('form.gender'), $dataStore.gender, 'gender')"
104
+ ></base-panel-input>
105
+ </div>
106
+ <base-form-input
107
+ v-model="productConditionsForm.coverPeriod"
108
+ :maska="$maska.numbers"
109
+ :readonly="isDisabled"
110
+ :clearable="!isDisabled"
111
+ :rules="coverPeriodRule"
112
+ :label="$t($dataStore.isGons ? 'productConditionsForm.coverPeriodFrom3to20' : 'productConditionsForm.coverPeriod')"
113
+ ></base-form-input>
114
+ <base-panel-input
115
+ v-if="hasPaymentPeriod"
116
+ v-model="productConditionsForm.paymentPeriod"
117
+ :value="productConditionsForm.paymentPeriod.nameRu"
118
+ :readonly="isDisabled"
119
+ :clearable="!isDisabled"
120
+ :rules="$rules.objectRequired"
121
+ :label="$t('productConditionsForm.processPaymentPeriod')"
122
+ append-inner-icon="mdi mdi-chevron-right"
123
+ @append="openPanel($t('productConditionsForm.processPaymentPeriod'), $dataStore.processPaymentPeriod, 'paymentPeriod', $dataStore.getProcessPaymentPeriod)"
124
+ ></base-panel-input>
125
+ <base-panel-input
126
+ v-if="hasProcessIndexRate"
127
+ v-model="productConditionsForm.processIndexRate"
128
+ :value="productConditionsForm.processIndexRate.nameRu"
129
+ :readonly="isDisabled"
130
+ :clearable="!isDisabled"
131
+ :rules="$rules.objectRequired"
132
+ :label="$t('productConditionsForm.processIndexRate')"
133
+ append-inner-icon="mdi mdi-chevron-right"
134
+ @append="openPanel($t('productConditionsForm.processIndexRate'), $dataStore.processIndexRate, 'processIndexRate', $dataStore.getProcessIndexRate)"
135
+ ></base-panel-input>
136
+ <base-form-input
137
+ v-model="productConditionsForm.requestedSumInsured"
138
+ :readonly="isDisabled"
139
+ :clearable="!isDisabled"
140
+ :rules="requestedSumInsured"
141
+ :label="$t('productConditionsForm.requestedSumInsured')"
142
+ @input="onInputSum"
143
+ ></base-form-input>
144
+ <base-form-input
145
+ v-if="hasRequestedSumInsuredInDollar"
146
+ v-model="productConditionsForm.requestedSumInsuredInDollar"
147
+ :readonly="isDisabled"
148
+ :clearable="!isDisabled"
149
+ :rules="requestedSumInsured"
150
+ :label="$t('productConditionsForm.requestedSumInsuredInDollar')"
151
+ :suffix="$constants.currencySymbols.usd"
152
+ @input="onInputSumDollar"
153
+ ></base-form-input>
154
+ <base-form-input
155
+ v-model="productConditionsForm.insurancePremiumPerMonth"
156
+ :readonly="isDisabled"
157
+ :clearable="!isDisabled"
158
+ :rules="insurancePremiumPerMonth"
159
+ :label="$t('productConditionsForm.insurancePremiumAmount')"
160
+ :suffix="$constants.currencySymbols.kzt"
161
+ @input="onInputInsurancePremiumPerMonth"
162
+ ></base-form-input>
163
+ <base-form-input
164
+ v-if="hasInsurancePremiumPerMonthInDollar"
165
+ v-model="productConditionsForm.insurancePremiumPerMonthInDollar"
166
+ :readonly="isDisabled"
167
+ :clearable="!isDisabled"
168
+ :rules="insurancePremiumPerMonth"
169
+ :label="$t('productConditionsForm.insurancePremiumAmountInDollar')"
170
+ :suffix="constants.currencySymbols.usd"
171
+ @input="onInputInsurancePremiumPerMonthInDollar"
172
+ ></base-form-input>
173
+ <base-form-input
174
+ v-if="hasCurrency && $dataStore.currencies.usd"
175
+ v-model="$dataStore.currencies.usd"
176
+ :readonly="true"
177
+ :label="$t('productConditionsForm.dollarExchangeRateNBRK')"
178
+ :suffix="$constants.currencySymbols.kzt"
179
+ ></base-form-input>
180
+ </base-form-section>
181
+ <base-form-section v-if="additionalTerms && additionalTerms.length" :title="$t('productConditionsForm.additional')">
182
+ <div v-for="(term, index) of additionalTerms" :key="index">
183
+ <base-panel-input
184
+ v-model="additionalTerms[index]"
185
+ :value="term.coverSumName"
186
+ :readonly="isDisabled"
187
+ :clearable="!isDisabled"
188
+ :label="term.coverTypeName"
189
+ append-inner-icon="mdi mdi-chevron-right"
190
+ @append="openTermPanel(term.coverTypeName, $dataStore.getAdditionalInsuranceTermsAnswers, term.coverTypeId, index)"
191
+ ></base-panel-input>
192
+ </div>
193
+ </base-form-section>
194
+ </v-form>
195
+ <base-btn
196
+ v-if="!isDisabled && isTask && ($dataStore.isInitiator() || $dataStore.isUnderwriter())"
197
+ :loading="isCalculating"
198
+ :text="$t('buttons.calculate')"
199
+ @click="submitForm"
200
+ ></base-btn>
201
+ <div v-if="$dataStore.isTask() && $dataStore.isUnderwriter() && !isRecalculationDisabled" class="flex gap-3">
202
+ <base-btn :text="$t('buttons.calcSum')" type="submit" @click.prevent="underwriterCalculate('sum')" :loading="isCalculating" />
203
+ <base-btn :text="$t('buttons.calcPremium')" type="submit" @click.prevent="underwriterCalculate('premium')" :loading="isCalculating" />
204
+ </div>
205
+ <Teleport v-if="isPanelOpen" to="#panel-actions">
206
+ <div :class="[$libStyles.scrollPage]" class="flex flex-col items-center">
207
+ <base-rounded-input v-model="searchQuery" :label="$t('labels.search')" class="w-full p-2" :hide-details="true"></base-rounded-input>
208
+ <div v-if="panelList && isPanelLoading === false" class="w-full flex flex-col gap-2 p-2">
209
+ <base-panel-select-item :text="$t('form.notChosen')" :selected="panelValue.nameRu === null" @click="pickPanelValue(new Value())"></base-panel-select-item>
210
+ <base-panel-select-item
211
+ v-for="(item, index) of panelList.filter(i => i.nameRu && (i.nameRu as string).match(new RegExp(searchQuery, 'i')))"
212
+ :key="index"
213
+ :text="(item.nameRu as string)"
214
+ :selected="item.nameRu === panelValue.nameRu"
215
+ @click="pickPanelValue(item)"
216
+ ></base-panel-select-item>
217
+ </div>
218
+ <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50"></base-loader>
219
+ </div>
220
+ </Teleport>
221
+ <Teleport v-if="isTermsPanelOpen" to="#panel-actions">
222
+ <div :class="[$libStyles.scrollPage]" class="flex flex-col items-center">
223
+ <base-rounded-input v-model="searchQuery" :label="$t('labels.search')" class="w-full p-2" :hide-details="true"></base-rounded-input>
224
+ <div v-if="panelList && isPanelLoading === false" class="w-full flex flex-col gap-2 p-2">
225
+ <base-panel-select-item
226
+ v-for="(item, index) of panelList.filter(i => i.nameRu && (i.nameRu as string).match(new RegExp(searchQuery, 'i')))"
227
+ :key="index"
228
+ :text="(item.nameRu as string)"
229
+ :selected="item.nameRu === termValue?.coverSumName"
230
+ @click="pickTermValue(item)"
231
+ ></base-panel-select-item>
232
+ </div>
233
+ <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50"></base-loader>
234
+ </div>
235
+ </Teleport>
236
+ </section>
237
+ </template>
238
+
239
+ <script lang="ts">
240
+ import { Value } from '@/composables/classes';
241
+
242
+ export default defineComponent({
243
+ props: {
244
+ isRecalculation: {
245
+ type: Boolean,
246
+ default: false,
247
+ },
248
+ },
249
+ setup(props) {
250
+ const vForm = ref<any>();
251
+ const route = useRoute();
252
+ const router = useRouter();
253
+ const formStore = useFormStore();
254
+ const dataStore = useDataStore();
255
+ const memberStore = useMemberStore();
256
+
257
+ const isCalculating = ref<boolean>(false);
258
+ const isPanelLoading = ref<boolean>(false);
259
+ const isPanelOpen = ref<boolean>(false);
260
+ const isTermsPanelOpen = ref<boolean>(false);
261
+ const panelValue = ref<Value>(new Value());
262
+ const termValue = ref<AddCover>();
263
+ const panelList = ref<Value[]>([]);
264
+ const productConditionsForm = formStore.productConditionsForm;
265
+ const currentPanel = ref<keyof typeof productConditionsForm>();
266
+ const currentIndex = ref<number>();
267
+ const searchQuery = ref<string>('');
268
+ const whichSum = ref<'insurancePremiumPerMonth' | 'requestedSumInsured' | ''>('');
269
+
270
+ const additionalTerms = ref<AddCover[]>([]);
271
+ const isUnderwriterForm = computed(() => {
272
+ if (route.params.taskId === '0 ' || props.isRecalculation === true) {
273
+ return false;
274
+ } else {
275
+ return formStore.applicationData.statusCode === 'UnderwriterForm';
276
+ }
277
+ });
278
+ const isDisabled = computed(() => !memberStore.isStatementEditible(formStore.productConditionsFormKey));
279
+ const isTask = computed(() => (route.params.taskId === '0' && props.isRecalculation === true) || dataStore.isTask());
280
+ const isRecalculationDisabled = computed(() => formStore.isDisabled.recalculationForm);
281
+ const isUnderwriterRole = computed(() => dataStore.isUnderwriter() || dataStore.isAdmin() || dataStore.isSupport());
282
+ const insurancePremiumPerMonth = computed(() => (!!productConditionsForm.insurancePremiumPerMonth ? dataStore.rules.required.concat(dataStore.rules.sums) : []));
283
+ const requestedSumInsured = computed(() => (!!productConditionsForm.requestedSumInsured ? dataStore.rules.required.concat(dataStore.rules.sums) : []));
284
+ const hasProcessIndexRate = computed(() => {
285
+ if (dataStore.isGons || dataStore.isKazyna) {
286
+ return false;
287
+ }
288
+ return true;
289
+ });
290
+ const hasPaymentPeriod = computed(() => {
291
+ if (dataStore.isKazyna) {
292
+ return false;
293
+ }
294
+ return true;
295
+ });
296
+ const hasRequestedSumInsuredInDollar = computed(() => {
297
+ if (dataStore.isKazyna) {
298
+ return true;
299
+ }
300
+ return false;
301
+ });
302
+ const hasInsurancePremiumPerMonthInDollar = computed(() => {
303
+ if (dataStore.isKazyna) {
304
+ return true;
305
+ }
306
+ return false;
307
+ });
308
+ const hasCurrency = computed(() => {
309
+ if (dataStore.isKazyna) {
310
+ return true;
311
+ }
312
+ return false;
313
+ });
314
+ const coverPeriodRule = computed(() => {
315
+ const baseCondition = dataStore.rules.required.concat(dataStore.rules.numbers);
316
+ if (dataStore.isGons) {
317
+ return baseCondition.concat(dataStore.rules.coverPeriodFrom3to20);
318
+ }
319
+ if (dataStore.isKazyna) {
320
+ return baseCondition.concat(dataStore.rules.coverPeriodFrom2to20);
321
+ }
322
+ return baseCondition;
323
+ });
324
+
325
+ const pickPanelValue = (item: Value) => {
326
+ dataStore.panel.open = false;
327
+ isPanelOpen.value = false;
328
+ if (!currentPanel.value) return;
329
+ // @ts-ignore
330
+ productConditionsForm[currentPanel.value] = item.nameRu === null ? new Value() : item;
331
+ };
332
+
333
+ const pickTermValue = (item: Value) => {
334
+ dataStore.panel.open = false;
335
+ isTermsPanelOpen.value = false;
336
+ if (typeof currentIndex.value !== 'number') return;
337
+ additionalTerms.value[currentIndex.value].coverSumId = item.id as string;
338
+ additionalTerms.value[currentIndex.value].coverSumName = item.nameRu as string;
339
+ };
340
+
341
+ const openPanel = async (title: string, list: Value[], key: string, asyncFunction?: Function, filterKey?: string) => {
342
+ if (!isDisabled.value || (key === 'riskGroup' && !isRecalculationDisabled.value)) {
343
+ searchQuery.value = '';
344
+ currentPanel.value = key as keyof typeof productConditionsForm;
345
+ isPanelOpen.value = true;
346
+ isTermsPanelOpen.value = false;
347
+ dataStore.panelAction = null;
348
+ dataStore.panel.open = true;
349
+ dataStore.panel.title = title;
350
+
351
+ let newList = list;
352
+ if (asyncFunction) {
353
+ isPanelLoading.value = true;
354
+ newList = await asyncFunction(filterKey, formStore.productConditionsFormKey);
355
+ }
356
+ panelList.value = filterList(newList, key);
357
+ // @ts-ignore
358
+ panelValue.value = productConditionsForm[currentPanel.value];
359
+ isPanelLoading.value = false;
360
+ } else {
361
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
362
+ }
363
+ };
364
+
365
+ const filterList = (list: Value[], key: string) => {
366
+ if (dataStore.isBaiterek) {
367
+ if (dataStore.isManagerHalykBank()) {
368
+ if (key === 'paymentPeriod') return list.filter(i => i.code !== 'single');
369
+ }
370
+ }
371
+ return list;
372
+ };
373
+
374
+ const openTermPanel = async (title: string, asyncFunction: Function, questionId: string, index: number) => {
375
+ if (!isDisabled.value) {
376
+ searchQuery.value = '';
377
+ currentIndex.value = index;
378
+ isPanelOpen.value = false;
379
+ isTermsPanelOpen.value = true;
380
+ dataStore.panelAction = null;
381
+ dataStore.panel.open = true;
382
+ dataStore.panel.title = title;
383
+
384
+ let newList;
385
+ if (asyncFunction) {
386
+ isPanelLoading.value = true;
387
+ newList = await asyncFunction(questionId);
388
+ }
389
+ panelList.value = newList;
390
+ // @ts-ignore
391
+ termValue.value = additionalTerms.value[index];
392
+ isPanelLoading.value = false;
393
+ } else {
394
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
395
+ }
396
+ };
397
+
398
+ const underwriterCalculate = async (type: 'sum' | 'premium') => {
399
+ if (!type) return;
400
+ if (type === 'sum') {
401
+ whichSum.value = 'insurancePremiumPerMonth';
402
+ }
403
+ if (type === 'premium') {
404
+ whichSum.value = 'requestedSumInsured';
405
+ }
406
+ await submitForm();
407
+ };
408
+
409
+ const pickCalculation = async (type: 'insurancePremiumPerMonth' | 'requestedSumInsured') => {
410
+ if (!type) return false;
411
+ whichSum.value = type;
412
+ await submitForm();
413
+ };
414
+
415
+ const onInputInsurancePremiumPerMonth = (event: Event) => {
416
+ if (event.target && 'value' in event.target && event.target.value && dataStore.currencies.usd) {
417
+ const calculatedPremiumDollar = getNumber(event.target.value as string);
418
+ if (calculatedPremiumDollar) {
419
+ productConditionsForm.insurancePremiumPerMonth = dataStore.getNumberWithSpaces(productConditionsForm.insurancePremiumPerMonth);
420
+ productConditionsForm.insurancePremiumPerMonthInDollar = dataStore.getNumberWithSpaces(calculatedPremiumDollar / dataStore.currencies.usd);
421
+ }
422
+ }
423
+ };
424
+
425
+ const onInputInsurancePremiumPerMonthInDollar = (event: Event) => {
426
+ if (event.target && 'value' in event.target && event.target.value && dataStore.currencies.usd) {
427
+ const calculatedPremium = getNumber(event.target.value as string);
428
+ if (calculatedPremium) {
429
+ productConditionsForm.insurancePremiumPerMonthInDollar = dataStore.getNumberWithSpaces(productConditionsForm.insurancePremiumPerMonthInDollar);
430
+ productConditionsForm.insurancePremiumPerMonth = dataStore.getNumberWithSpaces(calculatedPremium * dataStore.currencies.usd);
431
+ }
432
+ }
433
+ };
434
+
435
+ const onInputSum = (event: Event) => {
436
+ if (event.target && 'value' in event.target && event.target.value && dataStore.currencies.usd) {
437
+ const calculatedSumDollar = getNumber(event.target.value as string);
438
+ if (calculatedSumDollar) {
439
+ productConditionsForm.requestedSumInsured = dataStore.getNumberWithSpaces(productConditionsForm.requestedSumInsured);
440
+ productConditionsForm.requestedSumInsuredInDollar = dataStore.getNumberWithSpaces(calculatedSumDollar / dataStore.currencies.usd);
441
+ }
442
+ }
443
+ };
444
+
445
+ const onInputSumDollar = (event: Event) => {
446
+ if (event.target && 'value' in event.target && event.target.value && dataStore.currencies.usd) {
447
+ const calculatedSum = getNumber(event.target.value as string);
448
+ if (calculatedSum) {
449
+ productConditionsForm.requestedSumInsuredInDollar = dataStore.getNumberWithSpaces(productConditionsForm.requestedSumInsuredInDollar);
450
+ productConditionsForm.requestedSumInsured = dataStore.getNumberWithSpaces(calculatedSum * dataStore.currencies.usd);
451
+ }
452
+ }
453
+ };
454
+
455
+ const submitForm = async () => {
456
+ vForm.value.validate().then(async (v: { valid: Boolean; errors: any }) => {
457
+ if (v.valid) {
458
+ if (whichSum.value === 'requestedSumInsured') {
459
+ productConditionsForm.insurancePremiumPerMonth = null;
460
+ }
461
+ if (whichSum.value === 'insurancePremiumPerMonth') {
462
+ productConditionsForm.requestedSumInsured = null;
463
+ }
464
+ if (productConditionsForm.requestedSumInsured !== '' && productConditionsForm.requestedSumInsured != null) {
465
+ productConditionsForm.insurancePremiumPerMonth = null;
466
+ if (props.isRecalculation) whichSum.value = 'requestedSumInsured';
467
+ }
468
+ if (productConditionsForm.insurancePremiumPerMonth !== '' && productConditionsForm.insurancePremiumPerMonth != null) {
469
+ productConditionsForm.requestedSumInsured = null;
470
+ if (props.isRecalculation) whichSum.value = 'insurancePremiumPerMonth';
471
+ }
472
+
473
+ if (!whichSum.value && isUnderwriterForm.value === false) {
474
+ dataStore.showToaster('error', dataStore.t('toaster.emptyProductConditions'));
475
+ return;
476
+ }
477
+
478
+ if (isUnderwriterForm.value) {
479
+ type recalculationInfo = {
480
+ lifeMultiply: string | null;
481
+ lifeAdditive: string | null;
482
+ adbMultiply: string | null;
483
+ adbAdditive: string | null;
484
+ disabilityMultiply: string | null;
485
+ disabilityAdditive: string | null;
486
+ amount?: number | null;
487
+ premium?: number | null;
488
+ riskGroup?: string | number | null;
489
+ };
490
+ const recalculationData: recalculationInfo = (({ lifeMultiply, lifeAdditive, adbMultiply, adbAdditive, disabilityMultiply, disabilityAdditive }) => ({
491
+ lifeMultiply,
492
+ lifeAdditive,
493
+ adbMultiply,
494
+ adbAdditive,
495
+ disabilityMultiply,
496
+ disabilityAdditive,
497
+ }))(productConditionsForm);
498
+ Object.keys(recalculationData).forEach(key => {
499
+ // @ts-ignore
500
+ recalculationData[key] = formatProcents(recalculationData[key]);
501
+ });
502
+ recalculationData.amount = Number((productConditionsForm.requestedSumInsured as string)?.replace(/\s/g, ''));
503
+ recalculationData.premium = Number((productConditionsForm.insurancePremiumPerMonth as string)?.replace(/\s/g, ''));
504
+ recalculationData.riskGroup = productConditionsForm.riskGroup?.id ? productConditionsForm.riskGroup.id : 1;
505
+ isCalculating.value = true;
506
+ await dataStore.reCalculate(formStore.applicationData.processInstanceId, recalculationData, route.params.taskId, whichSum.value);
507
+ }
508
+ isCalculating.value = true;
509
+ if (props.isRecalculation) {
510
+ await dataStore.calculateWithoutApplication(true);
511
+ } else {
512
+ if (dataStore.isProcessEditable(formStore.applicationData.statusCode)) {
513
+ await dataStore.calculate(route.params.taskId);
514
+ }
515
+ }
516
+ isCalculating.value = false;
517
+ } else {
518
+ const errors = document.querySelector('.v-input--error');
519
+ if (errors) {
520
+ const errorText = errors.querySelector('.v-label.v-field-label');
521
+ if (errorText) {
522
+ dataStore.showToaster('error', dataStore.t('toaster.errorFormField', { text: errorText.innerHTML?.replace(/[-<>!//.]/g, '') }));
523
+ } else {
524
+ const errorFieldText = errors.querySelector('.v-input__control');
525
+ if (errorFieldText) {
526
+ dataStore.showToaster('error', dataStore.t('toaster.errorFormField', { text: errorFieldText.innerHTML?.replace(/[-<>!//.]/g, '') }));
527
+ }
528
+ }
529
+ errors.scrollIntoView({
530
+ behavior: 'smooth',
531
+ block: 'center',
532
+ inline: 'nearest',
533
+ });
534
+ }
535
+ }
536
+ });
537
+ };
538
+
539
+ onMounted(async () => {
540
+ if (props.isRecalculation === true) {
541
+ if (route.params.taskId === '0' && productConditionsForm.requestedSumInsured === null && productConditionsForm.insurancePremiumPerMonth === null) {
542
+ const defaultData = await dataStore.getDefaultCalculationData(true);
543
+ if (!defaultData) {
544
+ dataStore.showToaster('error', 'Отсутствуют базовые данные');
545
+ return;
546
+ }
547
+ formStore.additionalInsuranceTermsWithout = defaultData.addCovers;
548
+ productConditionsForm.requestedSumInsured = defaultData.amount;
549
+ productConditionsForm.insurancePremiumPerMonth = defaultData.premium;
550
+ const indexRate = dataStore.processIndexRate.find(i => i.id === defaultData.indexRateId);
551
+ if (indexRate) productConditionsForm.processIndexRate = indexRate;
552
+ const paymendPeriod = dataStore.processPaymentPeriod.find(i => i.id == defaultData.paymentPeriodId);
553
+ if (paymendPeriod) productConditionsForm.paymentPeriod = paymendPeriod;
554
+ productConditionsForm.signDate = reformatDate(defaultData.signDate);
555
+ }
556
+ }
557
+ additionalTerms.value = props.isRecalculation ? formStore.additionalInsuranceTermsWithout : formStore.additionalInsuranceTerms;
558
+ if (!!productConditionsForm.insurancePremiumPerMonth) {
559
+ whichSum.value = 'insurancePremiumPerMonth';
560
+ }
561
+ if (!!productConditionsForm.requestedSumInsured) {
562
+ whichSum.value = 'requestedSumInsured';
563
+ }
564
+ if (dataStore.isKazyna) {
565
+ const kazynaPaymentPeriod = dataStore.processPaymentPeriod.find(i => i.code === 'single');
566
+ if (kazynaPaymentPeriod) productConditionsForm.paymentPeriod = kazynaPaymentPeriod;
567
+ await dataStore.getCurrencies();
568
+ }
569
+ });
570
+
571
+ watch(
572
+ () => productConditionsForm.requestedSumInsured,
573
+ val => {
574
+ if (!val && whichSum.value == 'requestedSumInsured') whichSum.value = '';
575
+ if (val && whichSum.value != 'insurancePremiumPerMonth') {
576
+ whichSum.value = 'requestedSumInsured';
577
+ productConditionsForm.requestedSumInsured = dataStore.getNumberWithSpaces(val);
578
+ }
579
+ },
580
+ );
581
+ watch(
582
+ () => productConditionsForm.insurancePremiumPerMonth,
583
+ val => {
584
+ if (!val && whichSum.value == 'insurancePremiumPerMonth') whichSum.value = '';
585
+ if (val && whichSum.value != 'requestedSumInsured') {
586
+ whichSum.value = 'insurancePremiumPerMonth';
587
+ productConditionsForm.insurancePremiumPerMonth = dataStore.getNumberWithSpaces(val);
588
+ }
589
+ },
590
+ );
591
+ watch(
592
+ () => productConditionsForm.amountOfInsurancePremium,
593
+ val => {
594
+ if (val) productConditionsForm.amountOfInsurancePremium = dataStore.getNumberWithSpaces(val);
595
+ },
596
+ );
597
+
598
+ watch(
599
+ () => dataStore.panel.open,
600
+ () => {
601
+ if (dataStore.panel.open === false) {
602
+ isPanelOpen.value = false;
603
+ isTermsPanelOpen.value = false;
604
+ dataStore.panelAction = null;
605
+ }
606
+ },
607
+ { immediate: true },
608
+ );
609
+
610
+ return {
611
+ // State
612
+ formStore,
613
+ vForm,
614
+ productConditionsForm,
615
+ additionalTerms,
616
+ isCalculating,
617
+ isPanelLoading,
618
+ isPanelOpen,
619
+ isTermsPanelOpen,
620
+ panelValue,
621
+ termValue,
622
+ panelList,
623
+ searchQuery,
624
+ whichSum,
625
+ Value,
626
+
627
+ // Computed
628
+ isTask,
629
+ isDisabled,
630
+ isUnderwriterForm,
631
+ insurancePremiumPerMonth,
632
+ requestedSumInsured,
633
+ isRecalculationDisabled,
634
+ isUnderwriterRole,
635
+ hasProcessIndexRate,
636
+ hasPaymentPeriod,
637
+ hasRequestedSumInsuredInDollar,
638
+ hasInsurancePremiumPerMonthInDollar,
639
+ hasCurrency,
640
+
641
+ // Rules
642
+ coverPeriodRule,
643
+
644
+ // Functions
645
+ submitForm,
646
+ pickPanelValue,
647
+ pickTermValue,
648
+ openPanel,
649
+ openTermPanel,
650
+ pickCalculation,
651
+ underwriterCalculate,
652
+ onInputInsurancePremiumPerMonth,
653
+ onInputInsurancePremiumPerMonthInDollar,
654
+ onInputSum,
655
+ onInputSumDollar,
656
+ };
657
+ },
658
+ });
659
+ </script>