hl-core 0.0.9-beta.16 → 0.0.9-beta.17

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.
@@ -116,7 +116,7 @@
116
116
  @append="openPanel($dataStore.t('productConditionsForm.riskGroup'), $dataStore.riskGroup, 'riskGroup')"
117
117
  />
118
118
  </base-form-section>
119
- <base-form-section :title="$dataStore.t('generalConditions')">
119
+ <base-form-section v-if="hasDefault" :title="$dataStore.t('generalConditions')">
120
120
  <div v-if="isCalculator && ($route.params.taskId === '0' || $dataStore.isCalculator)">
121
121
  <base-form-input
122
122
  v-model="productConditionsForm.signDate"
@@ -255,8 +255,19 @@
255
255
  :label="$dataStore.t('productConditionsForm.statePremium7')"
256
256
  :suffix="$constants.currencySymbols.kzt"
257
257
  />
258
+ <base-panel-input
259
+ v-if="hasAgencyPart"
260
+ v-model="productConditionsForm.processTariff"
261
+ :value="productConditionsForm.processTariff?.nameRu"
262
+ :readonly="isDisabled"
263
+ :clearable="!isDisabled"
264
+ :rules="$rules.objectRequired"
265
+ :label="$dataStore.t('productConditionsForm.agencyPart')"
266
+ append-inner-icon="mdi mdi-chevron-right"
267
+ @append="openPanel($dataStore.t('productConditionsForm.agencyPart'), $dataStore.processTariff, 'processTariff', $dataStore.getProcessTariff)"
268
+ />
258
269
  </base-form-section>
259
- <base-form-section :title="$dataStore.t('calculationAnnuityPayments')" v-if="hasAnnuityPayments">
270
+ <base-form-section v-if="hasAnnuityPayments" :title="$dataStore.t('calculationAnnuityPayments')">
260
271
  <base-form-toggle
261
272
  v-model="productConditionsForm.additionalConditionAnnuityPayments"
262
273
  :title="$dataStore.t('productConditionsForm.guaranteedTermAnnuityPayments')"
@@ -318,6 +329,128 @@
318
329
  :label="$dataStore.t('productConditionsForm.amountAnnuityPayments')"
319
330
  />
320
331
  </base-form-section>
332
+ <base-form-section v-if="whichProduct === 'lifetrip'" :title="$dataStore.t('generalConditions')">
333
+ <base-panel-input
334
+ v-model="calculatorForm.type"
335
+ :value="calculatorForm.type.nameRu ?? $dataStore.t('form.notChosen')"
336
+ :readonly="isDisabled"
337
+ :clearable="!isDisabled"
338
+ :rules="$rules.objectRequired"
339
+ :label="$dataStore.t('calculatorForm.type')"
340
+ append-inner-icon="mdi mdi-chevron-right"
341
+ @append="openPanel($dataStore.t('calculatorForm.type'), [], 'type', $dataStore.getDicTripType)"
342
+ />
343
+ <base-panel-input
344
+ v-model="calculatorForm.countries"
345
+ :value="calculatorForm?.countries![0]?.nameRu && calculatorForm.countries.length ? countriesComputed : $dataStore.t('form.notChosen')"
346
+ :readonly="isDisabled"
347
+ :clearable="!isDisabled"
348
+ :clear-value="[]"
349
+ :label="$dataStore.t('calculatorForm.countries')"
350
+ append-inner-icon="mdi mdi-chevron-right"
351
+ @append="openMultiplePanel($dataStore.t('calculatorForm.countries'), $dataStore.dicAllCountries, 'countries', $dataStore.getDicCountries)"
352
+ />
353
+ <base-panel-input
354
+ v-model="calculatorForm.amount"
355
+ :value="calculatorForm.amount.nameRu ? calculatorForm.amount.nameRu + $dataStore.currency : $dataStore.t('form.notChosen')"
356
+ :readonly="isDisabled"
357
+ :clearable="!isDisabled"
358
+ :rules="$rules.objectRequired"
359
+ :label="$dataStore.t('calculatorForm.amount')"
360
+ append-inner-icon="mdi mdi-chevron-right"
361
+ @append="openPanel($dataStore.t('calculatorForm.amount'), $dataStore.amountArray, 'amount')"
362
+ />
363
+ <base-panel-input
364
+ v-model="calculatorForm.purpose"
365
+ :value="calculatorForm.purpose.nameRu ?? $dataStore.t('form.notChosen')"
366
+ :readonly="isDisabled"
367
+ :clearable="!isDisabled"
368
+ :rules="$rules.objectRequired"
369
+ :label="$dataStore.t('calculatorForm.purpose')"
370
+ append-inner-icon="mdi mdi-chevron-right"
371
+ @append="openPanel($dataStore.t('calculatorForm.purpose'), [], 'purpose', $dataStore.getDicTripPurpose)"
372
+ />
373
+ <base-panel-input
374
+ v-if="calculatorForm.purpose.code === 'WorkStudy'"
375
+ v-model="calculatorForm.workType"
376
+ :value="calculatorForm.workType.nameRu ?? $dataStore.t('form.notChosen')"
377
+ :readonly="isDisabled"
378
+ :clearable="!isDisabled"
379
+ :rules="$rules.objectRequired"
380
+ :label="$dataStore.t('calculatorForm.workType')"
381
+ append-inner-icon="mdi mdi-chevron-right"
382
+ @append="openPanel($dataStore.t('calculatorForm.workType'), [], 'workType', $dataStore.getDicTripWorkType)"
383
+ />
384
+ <base-panel-input
385
+ v-if="calculatorForm.purpose.code === 'Sport'"
386
+ v-model="calculatorForm.sportsType"
387
+ :value="calculatorForm.sportsType.nameRu ?? $dataStore.t('form.notChosen')"
388
+ :readonly="isDisabled"
389
+ :clearable="!isDisabled"
390
+ :rules="$rules.objectRequired"
391
+ :label="$dataStore.t('calculatorForm.sportsType')"
392
+ append-inner-icon="mdi mdi-chevron-right"
393
+ @append="openPanel($dataStore.t('calculatorForm.sportsType'), [], 'sportsType', $dataStore.getDicSportsType)"
394
+ />
395
+ <base-panel-input
396
+ v-if="calculatorForm.type.code === 'Multiple'"
397
+ v-model="calculatorForm.period"
398
+ :value="calculatorForm.period && calculatorForm.period.nameRu ? calculatorForm.period.nameRu : $dataStore.t('form.notChosen')"
399
+ :readonly="isDisabled"
400
+ :clearable="!isDisabled"
401
+ :rules="$rules.objectRequired"
402
+ :label="$dataStore.t('calculatorForm.period')"
403
+ append-inner-icon="mdi mdi-chevron-right"
404
+ @append="openPanel($dataStore.t('calculatorForm.period'), $dataStore.periodArray, 'period')"
405
+ />
406
+ <base-panel-input
407
+ v-if="calculatorForm.type.code === 'Multiple'"
408
+ v-model="calculatorForm.maxDays"
409
+ :value="calculatorForm.period && calculatorForm.maxDays.nameRu ? calculatorForm.maxDays.nameRu : $dataStore.t('form.notChosen')"
410
+ :readonly="isDisabled"
411
+ :clearable="!isDisabled"
412
+ :rules="$rules.objectRequired"
413
+ :label="$dataStore.t('calculatorForm.maxDays')"
414
+ append-inner-icon="mdi mdi-chevron-right"
415
+ @append="openPanel($dataStore.t('calculatorForm.maxDays'), $dataStore.maxDaysFiltered, 'maxDays')"
416
+ />
417
+ <base-form-input
418
+ v-if="calculatorForm.type.code === 'Single'"
419
+ v-model="calculatorForm.days"
420
+ :readonly="isDisabled || !isCalculator"
421
+ :label="$dataStore.t('calculatorForm.days')"
422
+ :rules="$rules.required"
423
+ />
424
+ <base-form-input
425
+ v-if="isCalculator && whichProduct === 'lifetrip'"
426
+ v-model="calculatorForm.age"
427
+ :rules="$rules.required"
428
+ :readonly="isDisabledSum"
429
+ :clearable="!isDisabled"
430
+ :label="$dataStore.t('calculatorForm.age')"
431
+ />
432
+ <base-form-input
433
+ v-if="!isCalculator && whichProduct === 'lifetrip'"
434
+ v-model="calculatorForm.startDate"
435
+ :readonly="isDisabled"
436
+ :clearable="!isDisabled"
437
+ :label="$dataStore.t('calculatorForm.startDate')"
438
+ :rules="$dataStore.rules.required.concat($dataStore.rules.planDate)"
439
+ :maska="$maska.date"
440
+ append-inner-icon="mdi mdi-calendar-blank-outline"
441
+ />
442
+ <base-form-input
443
+ v-if="!isCalculator && calculatorForm.type.code != 'Multiple'"
444
+ v-model="calculatorForm.endDate"
445
+ :readonly="isDisabled"
446
+ :clearable="!isDisabled"
447
+ :label="$dataStore.t('calculatorForm.endDate')"
448
+ :rules="$dataStore.rules.required"
449
+ :maska="$maska.date"
450
+ append-inner-icon="mdi mdi-calendar-blank-outline"
451
+ />
452
+ <base-form-input v-model="calculatorForm.price" :readonly="true" :label="isCalculator ? $dataStore.t('calculatorForm.premium') : $dataStore.t('calculatorForm.price')" />
453
+ </base-form-section>
321
454
  <base-form-section v-if="additionalTerms && additionalTerms.length" :title="$dataStore.t('productConditionsForm.additional')">
322
455
  <div v-for="(term, index) of additionalTerms" :key="index">
323
456
  <base-panel-input
@@ -361,6 +494,29 @@
361
494
  <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50" />
362
495
  </div>
363
496
  </Teleport>
497
+ <Teleport v-if="isMultiplePanelOpen && calculatorForm.countries !== null" to="#panel-actions">
498
+ <div :class="[$styles.scrollPage]" class="flex flex-col items-center">
499
+ <base-rounded-input v-model.trim="searchQuery" :label="$dataStore.t('labels.search')" class="w-full p-2" :hide-details="true" />
500
+ <v-fade-transition>
501
+ <base-form-section v-if="countriesComputed" class="w-[95%]" :title="$dataStore.t('calculatorForm.selectedCountries')">
502
+ <base-white-block class="text-center" :class="[$styles.textSimple]"> {{ countriesComputed }} </base-white-block>
503
+ </base-form-section>
504
+ </v-fade-transition>
505
+ <div v-if="multiplePanelList && isPanelLoading === false" class="w-full flex flex-col gap-2 p-2">
506
+ <base-panel-select-item :text="$dataStore.t('buttons.clearOrReset')" @click="calculatorForm.countries = []" false-icon="mdi-close-circle-outline" />
507
+ <base-panel-select-item
508
+ v-for="(item, index) of multiplePanelList.filter(i => i.nameRu && (i.nameRu as string).match(new RegExp(searchQuery, 'i')))"
509
+ :key="index"
510
+ :text="(item.nameRu as string)"
511
+ :selected="calculatorForm.countries && calculatorForm.countries.some(option => option.id === item.id)"
512
+ :disabled="calculatorForm.countries.length >= 3 && !calculatorForm.countries.some(option => option.id === item.id)"
513
+ true-icon="mdi-check-circle-outline"
514
+ @click="selectOption(item)"
515
+ />
516
+ </div>
517
+ <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50" />
518
+ </div>
519
+ </Teleport>
364
520
  <Teleport v-if="isTermsPanelOpen" to="#panel-actions">
365
521
  <div :class="[$styles.scrollPage]" class="flex flex-col items-center">
366
522
  <base-rounded-input v-model.trim="searchQuery" :label="$dataStore.t('labels.search')" class="w-full p-2" :hide-details="true" />
@@ -376,11 +532,25 @@
376
532
  <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50" />
377
533
  </div>
378
534
  </Teleport>
535
+ <Teleport v-if="isFixInsAmountPanelOpen" to="#panel-actions">
536
+ <div :class="[$styles.scrollPage]" class="flex flex-col items-center">
537
+ <base-rounded-input v-model.trim="searchQuery" :label="$dataStore.t('labels.search')" class="w-full p-2" :hide-details="true" />
538
+ <div class="w-full flex flex-col gap-2 p-2">
539
+ <base-panel-select-item
540
+ v-for="(item, index) of $constants.fixInsAmount.filter(i => i.nameRu && (i.nameRu as string).match(new RegExp(searchQuery, 'i')))"
541
+ :key="index"
542
+ :text="(item.nameRu as string)"
543
+ :selected="item.code === fixInsValue"
544
+ @click="pickfixInsValue(item)"
545
+ />
546
+ </div>
547
+ </div>
548
+ </Teleport>
379
549
  </section>
380
550
  </template>
381
551
 
382
552
  <script lang="ts">
383
- import { Member, Value } from '../../composables/classes';
553
+ import { Member, Value, CountryValue, CalculatorForm } from '../../composables/classes';
384
554
 
385
555
  export default defineComponent({
386
556
  props: {
@@ -406,6 +576,8 @@ export default defineComponent({
406
576
  const isPanelLoading = ref<boolean>(false);
407
577
  const isPanelOpen = ref<boolean>(false);
408
578
  const isTermsPanelOpen = ref<boolean>(false);
579
+ const isFixInsAmountPanelOpen = ref<boolean>(false);
580
+ const fixInsValue = ref<string | number>();
409
581
  const panelValue = ref<Value>(new Value());
410
582
  const termValue = ref<AddCover>();
411
583
  const panelList = ref<Value[]>([]);
@@ -416,6 +588,12 @@ export default defineComponent({
416
588
  const whichSum = ref<'insurancePremiumPerMonth' | 'requestedSumInsured' | ''>('');
417
589
 
418
590
  const additionalTerms = ref<AddCover[]>([]);
591
+ const isMultiplePanelOpen = ref<boolean>(false);
592
+
593
+ const multiplePanelValue = ref<CountryValue>(new CountryValue());
594
+ const multiplePanelList = ref<CountryValue[]>([]);
595
+ const calculatorForm = productConditionsForm.calculatorForm;
596
+
419
597
  const isUnderwriterForm = computed(() => {
420
598
  if (route.params.taskId === '0 ' || props.isCalculator === true) {
421
599
  return false;
@@ -527,6 +705,12 @@ export default defineComponent({
527
705
  }
528
706
  return true;
529
707
  });
708
+ const hasAgencyPart = computed(() => {
709
+ if (whichProduct.value === 'lifebusiness') {
710
+ return true;
711
+ }
712
+ return false;
713
+ });
530
714
  const coverPeriodRule = computed(() => {
531
715
  const baseCondition = dataStore.rules.required.concat(dataStore.rules.numbers);
532
716
  if (whichProduct.value === 'gons') {
@@ -585,22 +769,39 @@ export default defineComponent({
585
769
  }
586
770
  return isDisabled.value;
587
771
  });
772
+ const countriesComputed = computed(() => {
773
+ let message = '';
774
+ for (let country in calculatorForm.countries) {
775
+ message += calculatorForm.countries[country as any].nameRu + ', ';
776
+ }
777
+ return message.slice(0, -2);
778
+ });
588
779
  const isDisabledCoverPeriod = computed(() => {
589
780
  if (whichProduct.value === 'lifebusiness') {
590
781
  return true;
591
782
  }
592
783
  return isDisabled.value;
593
784
  });
594
-
785
+ const hasDefault = computed(() => {
786
+ if (whichProduct.value === 'lifetrip') {
787
+ return false;
788
+ }
789
+ return true;
790
+ });
595
791
  const formatTermValue = (term: number) => {
596
792
  if (term !== null) {
597
- return Number.isInteger(term) ? dataStore.getNumberWithSpaces(term) : dataStore.getNumberWithDot(term);
793
+ const termNumber = Number(term);
794
+ return Number.isInteger(termNumber) ? dataStore.getNumberWithSpaces(termNumber) : dataStore.getNumberWithDot(termNumber);
598
795
  }
599
796
  return null;
600
797
  };
601
798
 
602
799
  const toStatement = async () => {
603
800
  const statementItem = dataStore.menuItems.find(i => i.id === 'statement');
801
+ if (whichProduct.value === 'lifebusiness') {
802
+ await router.push({ name: 'taskId-NewApp', params: route.params, query: { tab: 'statement' } });
803
+ return;
804
+ }
604
805
  if (statementItem) {
605
806
  dataStore.menu.selectedItem = statementItem;
606
807
  await router.replace({
@@ -616,28 +817,80 @@ export default defineComponent({
616
817
  const pickPanelValue = (item: Value) => {
617
818
  dataStore.panel.open = false;
618
819
  isPanelOpen.value = false;
820
+ isMultiplePanelOpen.value = false;
821
+ if (item.id === null) {
822
+ calculatorForm.countries = [];
823
+ }
619
824
  if (!currentPanel.value) return;
620
- // @ts-ignore
621
- productConditionsForm[currentPanel.value] = item.nameRu === null ? new Value() : item;
825
+ if (whichProduct.value === 'lifetrip') {
826
+ // @ts-ignore
827
+ calculatorForm[currentPanel.value] = item.nameRu === null ? new Value() : item;
828
+ } else {
829
+ // @ts-ignore
830
+ productConditionsForm[currentPanel.value] = item.nameRu === null ? new Value() : item;
831
+ }
832
+ };
833
+ const selectOption = (value: CountryValue) => {
834
+ if (calculatorForm.countries !== null) {
835
+ if (value.id == 0) {
836
+ calculatorForm.countries = [];
837
+ return (dataStore.dicCountries = dataStore.dicAllCountries);
838
+ }
839
+ if (calculatorForm.countries.some((option: CountryValue) => option.id == value.id)) {
840
+ calculatorForm.countries = calculatorForm.countries.filter((obj: CountryValue) => obj.id !== value.id);
841
+ dataStore.dicCountries = dataStore.dicAllCountries;
842
+ } else {
843
+ dataStore.dicCountries = dataStore.dicAllCountries.filter(i =>
844
+ i.id == 0 || (value.countryTypeCode == '1' && i.countryTypeCode == value.countryTypeCode) || (value.countryTypeCode != '1' && i.countryTypeCode != '1') ? true : false,
845
+ );
846
+ if (value.countryTypeCode == 1) {
847
+ dataStore.showToaster('success', dataStore.t('toaster.shengenZoneCondition'), 3000);
848
+ formStore.insuredForm.length = 1;
849
+ }
850
+ if (calculatorForm.countries.length < 3) {
851
+ calculatorForm.countries.push(value);
852
+ } else if (calculatorForm.countries.length >= 3) {
853
+ closeMultiplePanel();
854
+ }
855
+ }
856
+ }
622
857
  };
623
-
624
858
  const pickTermValue = (item: Value) => {
625
859
  dataStore.panel.open = false;
626
860
  isTermsPanelOpen.value = false;
627
861
  if (typeof currentIndex.value !== 'number') return;
628
862
  additionalTerms.value[currentIndex.value].coverSumId = item.id as string;
629
863
  additionalTerms.value[currentIndex.value].coverSumName = item.nameRu as string;
864
+ if (whichProduct.value === 'lifebusiness') {
865
+ if (item.code === 'fixedinssum') {
866
+ openFixInsPanel(dataStore.t('insurers.selectInsSum'), additionalTerms.value[currentIndex.value].amount);
867
+ } else {
868
+ additionalTerms.value[currentIndex.value].amount = 0;
869
+ }
870
+ }
630
871
  };
631
872
 
632
873
  const openPanel = async (title: string, list: Value[], key: string, asyncFunction?: Function, filterKey?: string) => {
633
874
  if (!isDisabled.value || (key === 'riskGroup' && !isRecalculationDisabled.value)) {
875
+ if (key === 'amount') {
876
+ if (calculatorForm.type.nameRu === null || !calculatorForm.countries || (calculatorForm.countries && calculatorForm.countries.length === 0)) {
877
+ return dataStore.showToaster('error', dataStore.t('toaster.noAmountBeforeTypeAndCountries'), 2000);
878
+ }
879
+ }
880
+ if (key === 'maxDays') {
881
+ if (calculatorForm.period.code === null) {
882
+ return dataStore.showToaster('error', dataStore.t('toaster.noMaxDaysBeforePeriod'), 2000);
883
+ }
884
+ }
634
885
  searchQuery.value = '';
635
886
  currentPanel.value = key as keyof typeof productConditionsForm;
636
887
  isPanelOpen.value = true;
637
888
  isTermsPanelOpen.value = false;
889
+ isFixInsAmountPanelOpen.value = false;
638
890
  dataStore.panelAction = null;
639
891
  dataStore.panel.open = true;
640
892
  dataStore.panel.title = title;
893
+ isMultiplePanelOpen.value = false;
641
894
 
642
895
  let newList = list;
643
896
  if (asyncFunction) {
@@ -645,13 +898,54 @@ export default defineComponent({
645
898
  newList = await asyncFunction(filterKey, formStore.productConditionsFormKey);
646
899
  }
647
900
  panelList.value = filterList(newList, key);
648
- // @ts-ignore
649
- panelValue.value = productConditionsForm[currentPanel.value];
901
+ if (whichProduct.value === 'lifetrip') {
902
+ // @ts-ignore
903
+ panelValue.value = calculatorForm[currentPanel.value];
904
+ } else {
905
+ // @ts-ignore
906
+ panelValue.value = productConditionsForm[currentPanel.value];
907
+ }
650
908
  isPanelLoading.value = false;
651
909
  } else {
652
910
  dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
653
911
  }
654
912
  };
913
+ const openMultiplePanel = async (title: string, list: CountryValue[], key: string, asyncFunction?: Function, filterKey?: string) => {
914
+ if (!isDisabled.value || !isRecalculationDisabled.value) {
915
+ isPanelOpen.value = false;
916
+ isFixInsAmountPanelOpen.value = false;
917
+ isMultiplePanelOpen.value = true;
918
+ isPanelLoading.value = true;
919
+ let newList = list;
920
+ if (asyncFunction !== null) {
921
+ // @ts-ignore
922
+ newList = await asyncFunction(filterKey, formStore.productConditionsFormKey);
923
+ }
924
+ if (newList[0].nameRu !== null) {
925
+ // @ts-ignore
926
+ newList.unshift(new CountryValue(0, null));
927
+ }
928
+
929
+ dataStore.panelAction = null;
930
+ dataStore.panel.open = true;
931
+ dataStore.panel.title = title;
932
+
933
+ // @ts-ignore
934
+ multiplePanelList.value = filterList(newList, key);
935
+ // @ts-ignore
936
+ multiplePanelValue.value = calculatorForm[currentPanel.value];
937
+ isPanelLoading.value = false;
938
+ } else {
939
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'), 2000);
940
+ }
941
+ };
942
+ const closeMultiplePanel = (item?: CountryValue) => {
943
+ dataStore.panel.open = false;
944
+ isMultiplePanelOpen.value = false;
945
+ if (!currentPanel.value) return;
946
+ // @ts-ignore
947
+ calculatorForm[currentPanel.value] = item?.nameRu === null ? new Value() : item;
948
+ };
655
949
 
656
950
  const filterList = (list: Value[], key: string) => {
657
951
  if (whichProduct.value === 'baiterek') {
@@ -667,6 +961,8 @@ export default defineComponent({
667
961
  searchQuery.value = '';
668
962
  currentIndex.value = index;
669
963
  isPanelOpen.value = false;
964
+ isMultiplePanelOpen.value = false;
965
+ isFixInsAmountPanelOpen.value = false;
670
966
  isTermsPanelOpen.value = true;
671
967
  dataStore.panelAction = null;
672
968
  dataStore.panel.open = true;
@@ -686,6 +982,30 @@ export default defineComponent({
686
982
  }
687
983
  };
688
984
 
985
+ const openFixInsPanel = async (title: string, amount: number) => {
986
+ if (!isDisabled.value) {
987
+ searchQuery.value = '';
988
+ isPanelOpen.value = false;
989
+ isTermsPanelOpen.value = false;
990
+ isMultiplePanelOpen.value = false;
991
+ isFixInsAmountPanelOpen.value = true;
992
+ dataStore.panelAction = null;
993
+ dataStore.panel.open = true;
994
+ dataStore.panel.title = title;
995
+ panelList.value = constants.fixInsAmount;
996
+ fixInsValue.value = amount;
997
+ } else {
998
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
999
+ }
1000
+ };
1001
+
1002
+ const pickfixInsValue = (item: Value) => {
1003
+ dataStore.panel.open = false;
1004
+ isFixInsAmountPanelOpen.value = false;
1005
+ if (typeof currentIndex.value !== 'number') return;
1006
+ additionalTerms.value[currentIndex.value].amount = Number(item.code);
1007
+ };
1008
+
689
1009
  const underwriterCalculate = async (type: 'sum' | 'premium') => {
690
1010
  if (!type) return;
691
1011
  if (type === 'sum') {
@@ -785,6 +1105,12 @@ export default defineComponent({
785
1105
  productConditionsForm.requestedSumInsuredInDollar = null;
786
1106
  productConditionsForm.insurancePremiumPerMonth = null;
787
1107
  productConditionsForm.insurancePremiumPerMonthInDollar = null;
1108
+ if (whichProduct.value === 'lifetrip') {
1109
+ Object.keys(calculatorForm).forEach(key => {
1110
+ //@ts-ignore
1111
+ calculatorForm[key] = new CalculatorForm()[key];
1112
+ });
1113
+ }
788
1114
  };
789
1115
 
790
1116
  const filterTermConditions = (term: AddCover) => {
@@ -793,96 +1119,111 @@ export default defineComponent({
793
1119
  }
794
1120
  return true;
795
1121
  };
796
-
797
1122
  const submitForm = async () => {
798
1123
  vForm.value.validate().then(async (v: { valid: Boolean; errors: any }) => {
799
1124
  if (v.valid) {
800
- if (whichSum.value === 'requestedSumInsured') {
801
- productConditionsForm.insurancePremiumPerMonth = null;
802
- if (whichProduct.value === 'halykkazyna') {
803
- productConditionsForm.insurancePremiumPerMonthInDollar = null;
1125
+ if (whichProduct.value === 'lifetrip') {
1126
+ if (calculatorForm.type.code === 'Single' && calculatorForm.startDate && calculatorForm.endDate) {
1127
+ const formattedStartDate = formatDate(calculatorForm.startDate);
1128
+ const formattedEndDate = formatDate(calculatorForm.endDate);
1129
+ if (formattedStartDate && formattedEndDate && formattedStartDate.getTime() > formattedEndDate.getTime()) {
1130
+ return dataStore.showToaster('error', dataStore.t('toaster.startMoreEnd'));
1131
+ }
804
1132
  }
805
- }
806
- if (whichSum.value === 'insurancePremiumPerMonth') {
807
- productConditionsForm.requestedSumInsured = null;
808
- if (whichProduct.value === 'halykkazyna') {
809
- productConditionsForm.requestedSumInsuredInDollar = null;
1133
+ if (dataStore.isTask()) {
1134
+ await dataStore.calculatePrice(route.params.taskId as string);
1135
+ } else {
1136
+ await dataStore.calculatePrice();
1137
+ }
1138
+ } else {
1139
+ if (whichSum.value === 'requestedSumInsured') {
1140
+ productConditionsForm.insurancePremiumPerMonth = null;
1141
+ if (whichProduct.value === 'halykkazyna') {
1142
+ productConditionsForm.insurancePremiumPerMonthInDollar = null;
1143
+ }
1144
+ }
1145
+ if (whichSum.value === 'insurancePremiumPerMonth') {
1146
+ productConditionsForm.requestedSumInsured = null;
1147
+ if (whichProduct.value === 'halykkazyna') {
1148
+ productConditionsForm.requestedSumInsuredInDollar = null;
1149
+ }
1150
+ }
1151
+ if (productConditionsForm.requestedSumInsured !== '' && productConditionsForm.requestedSumInsured != null) {
1152
+ productConditionsForm.insurancePremiumPerMonth = null;
1153
+ if (props.isCalculator) whichSum.value = 'requestedSumInsured';
1154
+ }
1155
+ if (productConditionsForm.insurancePremiumPerMonth !== '' && productConditionsForm.insurancePremiumPerMonth != null) {
1156
+ productConditionsForm.requestedSumInsured = null;
1157
+ if (props.isCalculator) whichSum.value = 'insurancePremiumPerMonth';
810
1158
  }
811
- }
812
- if (productConditionsForm.requestedSumInsured !== '' && productConditionsForm.requestedSumInsured != null) {
813
- productConditionsForm.insurancePremiumPerMonth = null;
814
- if (props.isCalculator) whichSum.value = 'requestedSumInsured';
815
- }
816
- if (productConditionsForm.insurancePremiumPerMonth !== '' && productConditionsForm.insurancePremiumPerMonth != null) {
817
- productConditionsForm.requestedSumInsured = null;
818
- if (props.isCalculator) whichSum.value = 'insurancePremiumPerMonth';
819
- }
820
1159
 
821
- if (!whichSum.value && isUnderwriterForm.value === false) {
822
- dataStore.showToaster('error', dataStore.t('toaster.emptyProductConditions'));
823
- return;
824
- }
1160
+ if (!whichSum.value && isUnderwriterForm.value === false) {
1161
+ dataStore.showToaster('error', dataStore.t('toaster.emptyProductConditions'));
1162
+ return;
1163
+ }
825
1164
 
826
- if (
827
- whichProduct.value === 'gons' &&
828
- (formStore.applicationData.statusCode === 'EditForm' || formStore.applicationData.statusCode === 'StartForm') &&
829
- getNumber(productConditionsForm.requestedSumInsured as string)! >= 10_000_000
830
- ) {
831
- dataStore.showToaster('info', dataStore.t('toaster.calcSumForUnder'), 6000);
832
- }
833
- if (isUnderwriterForm.value) {
834
- type recalculationInfo = {
835
- lifeMultiply: string | null | number;
836
- lifeAdditive: string | null | number;
837
- lifeMultiplyClient?: string | number | null;
838
- lifeAdditiveClient?: string | number | null;
839
- adbMultiply: string | null | number;
840
- adbAdditive: string | null | number;
841
- disabilityMultiply: string | null | number;
842
- disabilityAdditive: string | null | number;
843
- amount?: string | number | null;
844
- premium?: string | number | null;
845
- riskGroup?: string | string | number | null;
846
- };
847
- const recalculationData: recalculationInfo = (({ lifeMultiply, lifeAdditive, adbMultiply, adbAdditive, disabilityMultiply, disabilityAdditive }) => ({
848
- lifeMultiply,
849
- lifeAdditive,
850
- adbMultiply,
851
- adbAdditive,
852
- disabilityMultiply,
853
- disabilityAdditive,
854
- }))(productConditionsForm);
855
- Object.keys(recalculationData).forEach(key => {
856
- // @ts-ignore
857
- recalculationData[key] = formatProcents(recalculationData[key]);
858
- });
859
- recalculationData.lifeMultiplyClient = dataStore.isClientAnketaCondition
860
- ? formStore.productConditionsForm.lifeMultiplyClient === null
861
- ? null
862
- : formatProcents(formStore.productConditionsForm.lifeMultiplyClient)
863
- : null;
864
- recalculationData.lifeAdditiveClient = dataStore.isClientAnketaCondition
865
- ? formStore.productConditionsForm.lifeAdditiveClient === null
866
- ? null
867
- : formatProcents(formStore.productConditionsForm.lifeAdditiveClient)
868
- : null;
869
- recalculationData.amount = Number((productConditionsForm.requestedSumInsured as string)?.replace(/\s/g, ''));
870
- recalculationData.premium = Number((productConditionsForm.insurancePremiumPerMonth as string)?.replace(/\s/g, ''));
871
- recalculationData.riskGroup = productConditionsForm.riskGroup?.id ? productConditionsForm.riskGroup.id : 1;
1165
+ if (
1166
+ whichProduct.value === 'gons' &&
1167
+ (formStore.applicationData.statusCode === 'EditForm' || formStore.applicationData.statusCode === 'StartForm') &&
1168
+ getNumber(productConditionsForm.requestedSumInsured as string)! >= 10_000_000
1169
+ ) {
1170
+ dataStore.showToaster('info', dataStore.t('toaster.calcSumForUnder'), 6000);
1171
+ }
1172
+ if (isUnderwriterForm.value) {
1173
+ type recalculationInfo = {
1174
+ lifeMultiply: string | null | number;
1175
+ lifeAdditive: string | null | number;
1176
+ lifeMultiplyClient?: string | number | null;
1177
+ lifeAdditiveClient?: string | number | null;
1178
+ adbMultiply: string | null | number;
1179
+ adbAdditive: string | null | number;
1180
+ disabilityMultiply: string | null | number;
1181
+ disabilityAdditive: string | null | number;
1182
+ amount?: string | number | null;
1183
+ premium?: string | number | null;
1184
+ riskGroup?: string | string | number | null;
1185
+ };
1186
+ const recalculationData: recalculationInfo = (({ lifeMultiply, lifeAdditive, adbMultiply, adbAdditive, disabilityMultiply, disabilityAdditive }) => ({
1187
+ lifeMultiply,
1188
+ lifeAdditive,
1189
+ adbMultiply,
1190
+ adbAdditive,
1191
+ disabilityMultiply,
1192
+ disabilityAdditive,
1193
+ }))(productConditionsForm);
1194
+ Object.keys(recalculationData).forEach(key => {
1195
+ // @ts-ignore
1196
+ recalculationData[key] = formatProcents(recalculationData[key]);
1197
+ });
1198
+ recalculationData.lifeMultiplyClient = dataStore.isClientAnketaCondition
1199
+ ? formStore.productConditionsForm.lifeMultiplyClient === null
1200
+ ? null
1201
+ : formatProcents(formStore.productConditionsForm.lifeMultiplyClient)
1202
+ : null;
1203
+ recalculationData.lifeAdditiveClient = dataStore.isClientAnketaCondition
1204
+ ? formStore.productConditionsForm.lifeAdditiveClient === null
1205
+ ? null
1206
+ : formatProcents(formStore.productConditionsForm.lifeAdditiveClient)
1207
+ : null;
1208
+ recalculationData.amount = Number((productConditionsForm.requestedSumInsured as string)?.replace(/\s/g, ''));
1209
+ recalculationData.premium = Number((productConditionsForm.insurancePremiumPerMonth as string)?.replace(/\s/g, ''));
1210
+ recalculationData.riskGroup = productConditionsForm.riskGroup?.id ? productConditionsForm.riskGroup.id : 1;
1211
+ isCalculating.value = true;
1212
+ await dataStore.reCalculate(formStore.applicationData.processInstanceId, recalculationData, route.params.taskId as string, whichSum.value);
1213
+ }
872
1214
  isCalculating.value = true;
873
- await dataStore.reCalculate(formStore.applicationData.processInstanceId, recalculationData, route.params.taskId as string, whichSum.value);
874
- }
875
- isCalculating.value = true;
876
- if (props.isCalculator) {
877
- //@ts-ignore
878
- await dataStore.calculateWithoutApplication(true, whichProduct.value);
879
- additionalTerms.value = formStore.additionalInsuranceTermsWithout;
880
- } else {
881
- if (dataStore.isProcessEditable(formStore.applicationData.statusCode)) {
882
- await dataStore.calculate(route.params.taskId as string);
883
- additionalTerms.value = formStore.additionalInsuranceTerms;
1215
+ if (props.isCalculator) {
1216
+ //@ts-ignore
1217
+ await dataStore.calculateWithoutApplication(true, whichProduct.value);
1218
+ additionalTerms.value = formStore.additionalInsuranceTermsWithout;
1219
+ } else {
1220
+ if (dataStore.isProcessEditable(formStore.applicationData.statusCode)) {
1221
+ await dataStore.calculate(route.params.taskId as string);
1222
+ additionalTerms.value = formStore.additionalInsuranceTerms;
1223
+ }
884
1224
  }
885
1225
  }
1226
+
886
1227
  isCalculating.value = false;
887
1228
  } else {
888
1229
  const errors = document.querySelector('.v-input--error');
@@ -911,25 +1252,32 @@ export default defineComponent({
911
1252
  if (dataStore.isCalculator) {
912
1253
  clearFields();
913
1254
  }
914
- if (
915
- (dataStore.isCalculator || route.params.taskId === '0') &&
916
- productConditionsForm.requestedSumInsured === null &&
917
- productConditionsForm.insurancePremiumPerMonth === null
918
- ) {
919
- // @ts-ignore
920
- const defaultData = await dataStore.getDefaultCalculationData(true, whichProduct.value);
921
- if (!defaultData) {
922
- dataStore.showToaster('error', 'Отсутствуют базовые данные');
923
- return;
1255
+ if (whichProduct.value !== 'lifetrip') {
1256
+ if (
1257
+ (dataStore.isCalculator || route.params.taskId === '0') &&
1258
+ productConditionsForm.requestedSumInsured === null &&
1259
+ productConditionsForm.insurancePremiumPerMonth === null
1260
+ ) {
1261
+ // @ts-ignore
1262
+ const defaultData = await dataStore.getDefaultCalculationData(true, whichProduct.value);
1263
+ if (!defaultData) {
1264
+ dataStore.showToaster('error', 'Отсутствуют базовые данные');
1265
+ return;
1266
+ }
1267
+ formStore.additionalInsuranceTermsWithout = defaultData.addCovers;
1268
+ productConditionsForm.requestedSumInsured = defaultData.amount;
1269
+ productConditionsForm.insurancePremiumPerMonth = defaultData.premium;
1270
+ const indexRate = dataStore.processIndexRate.find(i => i.id === defaultData.indexRateId);
1271
+ if (indexRate) productConditionsForm.processIndexRate = indexRate;
1272
+ const paymendPeriod = dataStore.processPaymentPeriod.find(i => i.id === defaultData.paymentPeriodId);
1273
+ if (paymendPeriod) productConditionsForm.paymentPeriod = paymendPeriod;
1274
+ if (defaultData.signDate) {
1275
+ productConditionsForm.signDate = reformatDate(defaultData.signDate);
1276
+ }
1277
+ if (dataStore.isLifeBusiness) {
1278
+ productConditionsForm.coverPeriod = defaultData.insTermInMonth ?? null;
1279
+ }
924
1280
  }
925
- formStore.additionalInsuranceTermsWithout = defaultData.addCovers;
926
- productConditionsForm.requestedSumInsured = defaultData.amount;
927
- productConditionsForm.insurancePremiumPerMonth = defaultData.premium;
928
- const indexRate = dataStore.processIndexRate.find(i => i.id === defaultData.indexRateId);
929
- if (indexRate) productConditionsForm.processIndexRate = indexRate;
930
- const paymendPeriod = dataStore.processPaymentPeriod.find(i => i.id == defaultData.paymentPeriodId);
931
- if (paymendPeriod) productConditionsForm.paymentPeriod = paymendPeriod;
932
- productConditionsForm.signDate = reformatDate(defaultData.signDate);
933
1281
  }
934
1282
  }
935
1283
  additionalTerms.value = props.isCalculator ? formStore.additionalInsuranceTermsWithout : formStore.additionalInsuranceTerms;
@@ -980,6 +1328,57 @@ export default defineComponent({
980
1328
  { immediate: true },
981
1329
  );
982
1330
 
1331
+ if (whichProduct.value === 'lifetrip') {
1332
+ watch(
1333
+ () => calculatorForm.type,
1334
+ async val => {
1335
+ if (val.code === 'Multiple') {
1336
+ await dataStore.getPeriod();
1337
+ calculatorForm.period = new Value();
1338
+ calculatorForm.endDate = null;
1339
+ }
1340
+ if (calculatorForm.countries?.length != 0) {
1341
+ await dataStore.getTripInsuredAmount();
1342
+ }
1343
+ },
1344
+ );
1345
+ watch(
1346
+ () => calculatorForm.countries,
1347
+ async val => {
1348
+ if (val?.length && val.every(option => option.id != 0) && calculatorForm.type?.nameRu != null) {
1349
+ await dataStore.getTripInsuredAmount();
1350
+ }
1351
+ },
1352
+ { deep: true },
1353
+ );
1354
+
1355
+ watch(
1356
+ () => calculatorForm.period,
1357
+ val => {
1358
+ if (val) {
1359
+ dataStore.maxDaysFiltered = dataStore.maxDaysAllArray.filter(days => days.code == val.code);
1360
+ calculatorForm.maxDays = new Value();
1361
+ }
1362
+ },
1363
+ );
1364
+
1365
+ watch(
1366
+ () => calculatorForm.startDate,
1367
+ val => {
1368
+ if (val !== null && val.length === 10 && calculatorForm.endDate != null && calculatorForm.endDate.length === 10) {
1369
+ calculatorForm.days = productConditionsForm.getSingleTripDays();
1370
+ }
1371
+ },
1372
+ );
1373
+ watch(
1374
+ () => calculatorForm.endDate,
1375
+ val => {
1376
+ if (val !== null && val.length === 10 && calculatorForm.startDate != null && calculatorForm.startDate.length === 10) {
1377
+ calculatorForm.days = productConditionsForm.getSingleTripDays();
1378
+ }
1379
+ },
1380
+ );
1381
+ }
983
1382
  return {
984
1383
  // State
985
1384
  formStore,
@@ -990,13 +1389,19 @@ export default defineComponent({
990
1389
  isCalculating,
991
1390
  isPanelLoading,
992
1391
  isPanelOpen,
1392
+ isMultiplePanelOpen,
993
1393
  isTermsPanelOpen,
994
1394
  panelValue,
995
1395
  termValue,
996
1396
  panelList,
1397
+ multiplePanelList,
1398
+ multiplePanelValue,
997
1399
  searchQuery,
998
1400
  whichSum,
999
1401
  Value,
1402
+ calculatorForm,
1403
+ isFixInsAmountPanelOpen,
1404
+ fixInsValue,
1000
1405
 
1001
1406
  // Computed
1002
1407
  isTask,
@@ -1021,16 +1426,19 @@ export default defineComponent({
1021
1426
  hasRiskGroup,
1022
1427
  hasCalculated,
1023
1428
  hasAnnuityPayments,
1429
+ hasAgencyPart,
1024
1430
  currencySymbolsAddTerm,
1025
1431
  amountAnnuityPayments,
1026
1432
  requestedSumInsuredLabel,
1027
1433
  isDisabledSum,
1028
1434
  isDisabledSumDollar,
1435
+ countriesComputed,
1029
1436
  hasBirthDate,
1030
1437
  hasGender,
1031
1438
  coverPeriodLabel,
1032
1439
  insurancePremiumPerMonthLabel,
1033
1440
  isDisabledCoverPeriod,
1441
+ hasDefault,
1034
1442
 
1035
1443
  // Rules
1036
1444
  coverPeriodRule,
@@ -1040,6 +1448,7 @@ export default defineComponent({
1040
1448
  pickPanelValue,
1041
1449
  pickTermValue,
1042
1450
  openPanel,
1451
+ openMultiplePanel,
1043
1452
  openTermPanel,
1044
1453
  pickCalculation,
1045
1454
  underwriterCalculate,
@@ -1055,6 +1464,9 @@ export default defineComponent({
1055
1464
  clearFields,
1056
1465
  formatTermValue,
1057
1466
  filterTermConditions,
1467
+ selectOption,
1468
+ pickfixInsValue,
1469
+ openFixInsPanel,
1058
1470
  };
1059
1471
  },
1060
1472
  });