hl-core 0.0.8-beta.2 → 0.0.8-beta.4

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.
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="pt-3 rounded-lg border-[1px]" :class="[$libStyles.whiteBg]">
2
+ <div class="pt-3 rounded-lg border-[1px]" :class="[$libStyles.whiteBg, disabled && $libStyles.disabled]">
3
3
  <div class="ml-5">
4
4
  <p :class="[$libStyles.textTitle, $libStyles.greenText]">{{ title }}</p>
5
5
  <p v-if="!!subtitle" :class="[$libStyles.greyText, $libStyles.textSimple]">{{ subtitle }}</p>
@@ -21,9 +21,9 @@
21
21
  <span :class="[getMemberInfo(each).birthPlace === null && $libStyles.emptyBlockCol]" class="hidden lg:block"> {{ getMemberInfo(each).birthPlace }} </span>
22
22
  <span :class="[getMemberInfo(each).sectorCode === null && $libStyles.emptyBlockCol]" class="hidden lg:block"> {{ getMemberInfo(each).sectorCode }} </span>
23
23
  <div
24
- class="rounded-br-lg transition-all h-[70px] w-[60px] place-self-end cursor-pointer"
25
- :class="[$libStyles.blueBgLight, $libStyles.blueBgLightHover]"
26
- @click="$emit('onMore', { whichForm, index })"
24
+ class="rounded-br-lg transition-all h-[70px] w-[60px] place-self-end"
25
+ :class="[$libStyles.blueBgLight, $libStyles.blueBgLightHover, disabled ? $libStyles.disabled : 'cursor-pointer']"
26
+ @click="!disabled && $emit('onMore', { whichForm, index })"
27
27
  >
28
28
  <i class="mdi mdi-dots-vertical text-xl absolute top-[20px] right-[20px]"> </i>
29
29
  </div>
@@ -37,18 +37,18 @@
37
37
  <span :class="[getMemberInfo(member).birthPlace === null && $libStyles.emptyBlockCol]" class="hidden lg:block"> {{ getMemberInfo(member).birthPlace }} </span>
38
38
  <span :class="[getMemberInfo(member).sectorCode === null && $libStyles.emptyBlockCol]" class="hidden lg:block"> {{ getMemberInfo(member).sectorCode }} </span>
39
39
  <div
40
- class="rounded-br-lg transition-all h-[70px] w-[60px] place-self-end cursor-pointer"
41
- :class="[$libStyles.blueBgLight, $libStyles.blueBgLightHover]"
42
- @click="$emit('onMore', { whichForm })"
40
+ class="rounded-br-lg transition-all h-[70px] w-[60px] place-self-end"
41
+ :class="[$libStyles.blueBgLight, $libStyles.blueBgLightHover, disabled ? $libStyles.disabled : 'cursor-pointer']"
42
+ @click="!disabled && $emit('onMore', { whichForm })"
43
43
  >
44
44
  <i class="mdi mdi-dots-vertical text-xl absolute top-[20px] right-[20px]"> </i>
45
45
  </div>
46
46
  </div>
47
47
  <div
48
48
  v-if="isMultiple && more"
49
- :class="[$libStyles.blueBg, $libStyles.whiteText, $libStyles.textSimple]"
50
- class="cursor-pointer rounded-b-lg h-[36px] flex items-center font-medium justify-center"
51
- @click="memberStore.addMember(whichForm)"
49
+ :class="[$libStyles.blueBg, $libStyles.whiteText, $libStyles.textSimple, disabled ? $libStyles.disabled : 'cursor-pointer']"
50
+ class="rounded-b-lg h-[36px] flex items-center font-medium justify-center"
51
+ @click="!disabled && memberStore.addMember(whichForm)"
52
52
  >
53
53
  {{ $t('buttons.add') }}
54
54
  </div>
@@ -76,6 +76,10 @@ export default defineComponent({
76
76
  type: Boolean,
77
77
  default: false,
78
78
  },
79
+ disabled: {
80
+ type: Boolean,
81
+ default: false,
82
+ },
79
83
  },
80
84
  emits: ['onMore', 'addMember'],
81
85
  setup(props) {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="pt-3 pl-5 rounded-lg border-[1px]" :class="[$libStyles.whiteBg]">
2
+ <div class="pt-3 pl-5 rounded-lg border-[1px]" :class="[$libStyles.whiteBg, disabled && $libStyles.disabled]">
3
3
  <div>
4
4
  <p :class="[$libStyles.textTitle, $libStyles.greenText]">
5
5
  {{ $t('productConditions') }}
@@ -20,9 +20,9 @@
20
20
  {{ paymentPeriod }}
21
21
  </span>
22
22
  <div
23
- class="rounded-br-lg transition-all h-[70px] w-[60px] relative place-self-end cursor-pointer"
24
- :class="[$libStyles.blueBgLight, $libStyles.blueBgLightHover]"
25
- @click="$emit('onMore', { whichForm: 'productConditions' })"
23
+ class="rounded-br-lg transition-all h-[70px] w-[60px] relative place-self-end"
24
+ :class="[$libStyles.blueBgLight, $libStyles.blueBgLightHover, disabled ? $libStyles.disabled : 'cursor-pointer']"
25
+ @click="!disabled && $emit('onMore', { whichForm: 'productConditions' })"
26
26
  >
27
27
  <i class="mdi mdi-dots-vertical text-xl absolute top-[20px] right-[20px]"> </i>
28
28
  </div>
@@ -37,6 +37,10 @@ export default defineComponent({
37
37
  type: String,
38
38
  default: '',
39
39
  },
40
+ disabled: {
41
+ type: Boolean,
42
+ default: false,
43
+ },
40
44
  },
41
45
  setup() {
42
46
  const formStore = useFormStore();
@@ -23,12 +23,11 @@
23
23
  @keyup.enter.prevent="submitted"
24
24
  @click:append="!props.readonly && $emit('append-out')"
25
25
  @click:prepend="!props.readonly && $emit('prepend-out')"
26
- @click:append-inner="!props.readonly && $emit('append')"
27
26
  @click:prepend-inner="!props.readonly && $emit('prepend')"
28
27
  @update:modelValue="$emit('update:modelValue', $event)"
29
28
  >
30
29
  <template v-if="appendInnerIcon && appendInnerIcon.length" v-slot:append-inner>
31
- <v-icon v-if="appendInnerIcon !== 'mdi mdi-calendar-blank-outline'" icon="appendInnerIcon"></v-icon>
30
+ <v-icon v-if="appendInnerIcon !== 'mdi mdi-calendar-blank-outline'" :icon="appendInnerIcon" @click="!props.readonly && $emit('append')"></v-icon>
32
31
  <base-datepicker v-else :model-value="modelValue" @update:modelValue="$emit('update:modelValue', $event)"></base-datepicker>
33
32
  </template>
34
33
  <template v-if="loading" #loader>
@@ -35,7 +35,7 @@
35
35
  <div v-if="$dataStore.buttons && $dataStore.buttons.length" class="flex flex-col gap-[10px] justify-self-end absolute bottom-5 lg:bottom-[30%] w-full pr-4">
36
36
  <div v-for="(item, index) of $dataStore.buttons" :key="index">
37
37
  <transition enter-active-class="animate__animated animate__fadeIn animate__faster" leave-active-class="animate__animated animate__fadeOut animate__faster">
38
- <base-btn v-if="typeof item.show === 'boolean' ? item.show : true" :text="item.title!" :btn="item.color" :disabled="item.disabled" @click="item.action"> </base-btn>
38
+ <base-btn v-if="typeof item.show === 'boolean' ? item.show : true" :text="item.title!" :btn="item.color" :disabled="item.disabled" :loading="$dataStore.isButtonsLoading" @click="item.action"> </base-btn>
39
39
  </transition>
40
40
  </div></div
41
41
  ></base-fade-transition>
@@ -108,8 +108,8 @@
108
108
  :maska="$maska.numbers"
109
109
  :readonly="isDisabled"
110
110
  :clearable="!isDisabled"
111
- :rules="$rules.required.concat($rules.numbers, $rules.coverPeriodFrom3to20)"
112
- :label="$t('productConditionsForm.coverPeriodFrom3to20')"
111
+ :rules="coverPeriodRule"
112
+ :label="$t($dataStore.isGons ? 'productConditionsForm.coverPeriodFrom3to20' : 'productConditionsForm.coverPeriod')"
113
113
  ></base-form-input>
114
114
  <base-panel-input
115
115
  v-model="productConditionsForm.paymentPeriod"
@@ -121,6 +121,17 @@
121
121
  append-inner-icon="mdi mdi-chevron-right"
122
122
  @append="openPanel($t('productConditionsForm.processPaymentPeriod'), $dataStore.processPaymentPeriod, 'paymentPeriod', $dataStore.getProcessPaymentPeriod)"
123
123
  ></base-panel-input>
124
+ <base-panel-input
125
+ v-if="hasBaseProductConditions"
126
+ v-model="productConditionsForm.processIndexRate"
127
+ :value="productConditionsForm.processIndexRate.nameRu"
128
+ :readonly="isDisabled"
129
+ :clearable="!isDisabled"
130
+ :rules="$rules.objectRequired"
131
+ :label="$t('productConditionsForm.processIndexRate')"
132
+ append-inner-icon="mdi mdi-chevron-right"
133
+ @append="openPanel($t('productConditionsForm.processIndexRate'), $dataStore.processIndexRate, 'processIndexRate', $dataStore.getProcessIndexRate)"
134
+ ></base-panel-input>
124
135
  <base-form-input
125
136
  v-model="productConditionsForm.requestedSumInsured"
126
137
  :readonly="isDisabled"
@@ -136,6 +147,19 @@
136
147
  :label="$t('productConditionsForm.insurancePremiumAmount')"
137
148
  ></base-form-input>
138
149
  </base-form-section>
150
+ <base-form-section v-if="additionalTerms && additionalTerms.length" :title="$t('productConditionsForm.additional')">
151
+ <div v-for="(term, index) of additionalTerms" :key="index">
152
+ <base-panel-input
153
+ v-model="additionalTerms[index]"
154
+ :value="term.coverSumName"
155
+ :readonly="isDisabled"
156
+ :clearable="!isDisabled"
157
+ :label="term.coverTypeName"
158
+ append-inner-icon="mdi mdi-chevron-right"
159
+ @append="openTermPanel(term.coverTypeName, $dataStore.getAdditionalInsuranceTermsAnswers, term.coverTypeId, index)"
160
+ ></base-panel-input>
161
+ </div>
162
+ </base-form-section>
139
163
  </v-form>
140
164
  <base-btn
141
165
  v-if="!isDisabled && isTask && ($dataStore.isInitiator() || $dataStore.isUnderwriter())"
@@ -163,6 +187,21 @@
163
187
  <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50"></base-loader>
164
188
  </div>
165
189
  </Teleport>
190
+ <Teleport v-if="isTermsPanelOpen" to="#panel-actions">
191
+ <div :class="[$libStyles.scrollPage]" class="flex flex-col items-center">
192
+ <base-rounded-input v-model="searchQuery" :label="$t('labels.search')" class="w-full p-2" :hide-details="true"></base-rounded-input>
193
+ <div v-if="panelList && isPanelLoading === false" class="w-full flex flex-col gap-2 p-2">
194
+ <base-panel-select-item
195
+ v-for="(item, index) of panelList.filter(i => i.nameRu && (i.nameRu as string).match(new RegExp(searchQuery, 'i')))"
196
+ :key="index"
197
+ :text="(item.nameRu as string)"
198
+ :selected="item.nameRu === termValue?.coverSumName"
199
+ @click="pickTermValue(item)"
200
+ ></base-panel-select-item>
201
+ </div>
202
+ <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50"></base-loader>
203
+ </div>
204
+ </Teleport>
166
205
  </section>
167
206
  </template>
168
207
 
@@ -187,13 +226,17 @@ export default defineComponent({
187
226
  const isCalculating = ref<boolean>(false);
188
227
  const isPanelLoading = ref<boolean>(false);
189
228
  const isPanelOpen = ref<boolean>(false);
229
+ const isTermsPanelOpen = ref<boolean>(false);
190
230
  const panelValue = ref<Value>(new Value());
231
+ const termValue = ref<AddCover>();
191
232
  const panelList = ref<Value[]>([]);
192
233
  const productConditionsForm = formStore.productConditionsForm;
193
234
  const currentPanel = ref<keyof typeof productConditionsForm>();
235
+ const currentIndex = ref<number>();
194
236
  const searchQuery = ref<string>('');
195
237
  const whichSum = ref<'insurancePremiumPerMonth' | 'requestedSumInsured' | ''>('');
196
238
 
239
+ const additionalTerms = ref<AddCover[]>([]);
197
240
  const isUnderwriterForm = computed(() => {
198
241
  if (route.params.taskId === '0 ' || props.isRecalculation === true) {
199
242
  return false;
@@ -207,19 +250,42 @@ export default defineComponent({
207
250
  const isUnderwriterRole = computed(() => dataStore.isUnderwriter() || dataStore.isAdmin() || dataStore.isSupport());
208
251
  const insurancePremiumPerMonth = computed(() => (!!productConditionsForm.insurancePremiumPerMonth ? dataStore.rules.required.concat(dataStore.rules.sums) : []));
209
252
  const requestedSumInsured = computed(() => (!!productConditionsForm.requestedSumInsured ? dataStore.rules.required.concat(dataStore.rules.sums) : []));
253
+ const hasBaseProductConditions = computed(() => {
254
+ if (dataStore.isGons) {
255
+ return false;
256
+ }
257
+ return true;
258
+ });
259
+ const coverPeriodRule = computed(() => {
260
+ const baseCondition = dataStore.rules.required.concat(dataStore.rules.numbers);
261
+ if (dataStore.isGons) {
262
+ return baseCondition.concat(dataStore.rules.coverPeriodFrom3to20);
263
+ }
264
+ return baseCondition;
265
+ });
210
266
 
211
267
  const pickPanelValue = (item: Value) => {
212
268
  dataStore.panel.open = false;
213
269
  isPanelOpen.value = false;
270
+ if (!currentPanel.value) return;
214
271
  // @ts-ignore
215
272
  productConditionsForm[currentPanel.value] = item.nameRu === null ? new Value() : item;
216
273
  };
217
274
 
275
+ const pickTermValue = (item: Value) => {
276
+ dataStore.panel.open = false;
277
+ isTermsPanelOpen.value = false;
278
+ if (typeof currentIndex.value !== 'number') return;
279
+ additionalTerms.value[currentIndex.value].coverSumId = item.id as string;
280
+ additionalTerms.value[currentIndex.value].coverSumName = item.nameRu as string;
281
+ };
282
+
218
283
  const openPanel = async (title: string, list: Value[], key: string, asyncFunction?: Function, filterKey?: string) => {
219
284
  if (!isDisabled.value || (key === 'riskGroup' && !isRecalculationDisabled.value)) {
220
285
  searchQuery.value = '';
221
286
  currentPanel.value = key as keyof typeof productConditionsForm;
222
287
  isPanelOpen.value = true;
288
+ isTermsPanelOpen.value = false;
223
289
  dataStore.panelAction = null;
224
290
  dataStore.panel.open = true;
225
291
  dataStore.panel.title = title;
@@ -238,6 +304,30 @@ export default defineComponent({
238
304
  }
239
305
  };
240
306
 
307
+ const openTermPanel = async (title: string, asyncFunction: Function, questionId: string, index: number) => {
308
+ if (!isDisabled.value) {
309
+ searchQuery.value = '';
310
+ currentIndex.value = index;
311
+ isPanelOpen.value = false;
312
+ isTermsPanelOpen.value = true;
313
+ dataStore.panelAction = null;
314
+ dataStore.panel.open = true;
315
+ dataStore.panel.title = title;
316
+
317
+ let newList;
318
+ if (asyncFunction) {
319
+ isPanelLoading.value = true;
320
+ newList = await asyncFunction(questionId);
321
+ }
322
+ panelList.value = newList;
323
+ // @ts-ignore
324
+ termValue.value = additionalTerms.value[index];
325
+ isPanelLoading.value = false;
326
+ } else {
327
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
328
+ }
329
+ };
330
+
241
331
  const underwriterCalculate = async (type: 'sum' | 'premium') => {
242
332
  if (!type) return;
243
333
  if (type === 'sum') {
@@ -355,6 +445,7 @@ export default defineComponent({
355
445
  productConditionsForm.signDate = reformatDate(defaultData.signDate);
356
446
  }
357
447
  }
448
+ additionalTerms.value = props.isRecalculation ? formStore.additionalInsuranceTermsWithout : formStore.additionalInsuranceTerms;
358
449
  if (!!productConditionsForm.insurancePremiumPerMonth) {
359
450
  whichSum.value = 'insurancePremiumPerMonth';
360
451
  }
@@ -395,6 +486,7 @@ export default defineComponent({
395
486
  () => {
396
487
  if (dataStore.panel.open === false) {
397
488
  isPanelOpen.value = false;
489
+ isTermsPanelOpen.value = false;
398
490
  dataStore.panelAction = null;
399
491
  }
400
492
  },
@@ -406,10 +498,13 @@ export default defineComponent({
406
498
  formStore,
407
499
  vForm,
408
500
  productConditionsForm,
501
+ additionalTerms,
409
502
  isCalculating,
410
503
  isPanelLoading,
411
504
  isPanelOpen,
505
+ isTermsPanelOpen,
412
506
  panelValue,
507
+ termValue,
413
508
  panelList,
414
509
  searchQuery,
415
510
  whichSum,
@@ -423,11 +518,17 @@ export default defineComponent({
423
518
  requestedSumInsured,
424
519
  isRecalculationDisabled,
425
520
  isUnderwriterRole,
521
+ hasBaseProductConditions,
522
+
523
+ // Rules
524
+ coverPeriodRule,
426
525
 
427
526
  // Functions
428
527
  submitForm,
429
528
  pickPanelValue,
529
+ pickTermValue,
430
530
  openPanel,
531
+ openTermPanel,
431
532
  pickCalculation,
432
533
  underwriterCalculate,
433
534
  };
@@ -801,6 +801,7 @@ export class DataStoreClass {
801
801
  items: MenuItem[];
802
802
  };
803
803
  buttons: MenuItem[];
804
+ isButtonsLoading: boolean;
804
805
  panelAction: string | null;
805
806
  panel: {
806
807
  open: boolean;
@@ -891,6 +892,7 @@ export class DataStoreClass {
891
892
  items: [],
892
893
  };
893
894
  this.buttons = [];
895
+ this.isButtonsLoading = false;
894
896
  this.panel = {
895
897
  open: false,
896
898
  overlay: false,
@@ -69,6 +69,7 @@ export class Styles {
69
69
 
70
70
  // Muted or disabled
71
71
  mutedText: string = 'text-[#99A3B3]';
72
+ disabled: string = 'cursor-not-allowed opacity-50';
72
73
 
73
74
  constructor() {
74
75
  // Button
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hl-core",
3
- "version": "0.0.8-beta.2",
3
+ "version": "0.0.8-beta.4",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "nuxt.config.ts",
@@ -45,6 +45,6 @@
45
45
  "v-idle-3": "^0.3.14",
46
46
  "vue-toastification": "^2.0.0-rc.5",
47
47
  "vue-uuid": "^3.0.0",
48
- "vuetify": "^3.2.1"
48
+ "vuetify": "^3.2.2"
49
49
  }
50
50
  }
@@ -1716,6 +1716,7 @@ export const useDataStore = defineStore('data', {
1716
1716
  },
1717
1717
  async handleTask(action, taskId, comment) {
1718
1718
  if (action && Object.keys(constants.actions).includes(action)) {
1719
+ this.isButtonsLoading = true;
1719
1720
  switch (action) {
1720
1721
  case constants.actions.claim: {
1721
1722
  try {
@@ -1745,6 +1746,7 @@ export const useDataStore = defineStore('data', {
1745
1746
  }
1746
1747
  }
1747
1748
  }
1749
+ this.isButtonsLoading = false;
1748
1750
  } else {
1749
1751
  console.error('No handleTask action');
1750
1752
  }