hl-core 0.0.7-beta.20 → 0.0.7-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,333 @@
1
+ <template>
2
+ <base-fade-transition>
3
+ <section v-if="firstQuestionList && firstQuestionList.length && !firstPanel && !secondPanel" class="flex flex-col">
4
+ <section :class="[$libStyles.blueBgLight, $libStyles.rounded]" class="mx-[10px] my-[14px] p-4 flex flex-col gap-4">
5
+ <base-form-toggle v-model="answerToAll" :title="$t('questionnaireType.answerAllNo')" :disabled="formStore.isDisabled[whichSurvey] || !$dataStore.isTask()" :has-border="false" @clicked="handleToggler"></base-form-toggle>
6
+ </section>
7
+ <v-form ref="vForm" class="max-h-[70vh] overflow-y-scroll" @submit="submitForm">
8
+ <section
9
+ v-if="firstQuestionList.filter(i => i.first.definedAnswers === 'N').length"
10
+ :class="[$libStyles.blueBgLight, $libStyles.rounded]"
11
+ class="mx-[10px] p-4 flex flex-col gap-4"
12
+ >
13
+ <base-form-input
14
+ v-for="(question, index) in firstQuestionList.filter(i => i.first.definedAnswers === 'N')"
15
+ :key="index"
16
+ v-model="question.first.answerText"
17
+ :label="question.first.name"
18
+ :maska="$maska.threeDigit"
19
+ :readonly="formStore.isDisabled[whichSurvey] || !$dataStore.isTask()"
20
+ :rules="$rules.required"
21
+ ></base-form-input>
22
+ </section>
23
+ <section
24
+ v-if="firstQuestionList.filter(i => i.first.definedAnswers === 'Y').length"
25
+ :class="[$libStyles.blueBgLight, $libStyles.rounded]"
26
+ class="mx-[10px] mt-[14px] p-4 flex flex-col gap-4"
27
+ >
28
+ <base-form-text-section v-for="(question, index) in firstQuestionList.filter(i => i.first.definedAnswers === 'Y')" :key="index">
29
+ <base-fade-transition>
30
+ <div
31
+ v-if="question.first.answerName === 'Да' && secondQuestionList"
32
+ :class="[$libStyles.greenBg, $libStyles.whiteText, $libStyles.textSimple]"
33
+ class="rounded-t-lg pl-6 py-1 cursor-pointer"
34
+ @click="openFirstPanel(question)"
35
+ >
36
+ {{ $t('questionnaireType.pleaseAnswer').replace('{text}', `${secondQuestionList.length}`) }}
37
+ </div>
38
+ </base-fade-transition>
39
+ <span :class="[$libStyles.textTitle]" class="border-b-[1px] border-b-[#F3F6FC] p-6 flex items-center justify-between">
40
+ {{ question.first.name }}
41
+ <base-fade-transition>
42
+ <i v-if="question.first.answerName === 'Да' && secondQuestionList" class="mdi mdi-chevron-right text-2xl cursor-pointer" @click="openFirstPanel(question)"></i>
43
+ </base-fade-transition>
44
+ </span>
45
+ <div class="flex items-center justify-start gap-5 px-4 pt-4" :class="[$libStyles.textSimple]">
46
+ <v-radio-group
47
+ v-model="question.first.answerName"
48
+ class="anketa-radio"
49
+ :true-icon="`mdi-radiobox-marked ${$libStyles.greenText}`"
50
+ false-icon="mdi-radiobox-blank text-[#636363]"
51
+ :rules="$rules.required"
52
+ :readonly="formStore.isDisabled[whichSurvey] || !$dataStore.isTask()"
53
+ inline
54
+ >
55
+ <v-radio label="Да" value="Да"></v-radio>
56
+ <v-radio label="Нет" value="Нет"></v-radio>
57
+ </v-radio-group>
58
+ </div>
59
+ </base-form-text-section>
60
+ </section>
61
+ </v-form>
62
+ <base-btn class="my-[14px] self-center" :loading="isButtonLoading" :disabled="formStore.isDisabled[whichSurvey]" @click="submitForm" :text="$t('buttons.save')"></base-btn>
63
+ </section>
64
+ <section
65
+ ref="firstPanelSection"
66
+ v-if="secondQuestionList && secondQuestionList.length && firstPanel"
67
+ class="flex flex-col px-[10px] py-[14px]"
68
+ :class="[$libStyles.scrollPage]"
69
+ >
70
+ <v-btn
71
+ icon="mdi mdi-close"
72
+ variant="text"
73
+ size="large"
74
+ @click="
75
+ firstPanel = false;
76
+ secondPanel = false;
77
+ "
78
+ ></v-btn>
79
+ <section v-if="currentQuestion" :class="[$libStyles.blueBgLight, $libStyles.rounded]" class="mx-[10px] my-[14px] p-4 flex flex-col gap-4">
80
+ <base-form-text-section v-for="question in currentQuestion.second" :title="question.name" :key="question.name">
81
+ <base-form-input
82
+ v-if="question.definedAnswers === 'N'"
83
+ v-model="question.answerText"
84
+ class="border-t-[1px] border-t-[#F3F6FC]"
85
+ placeholder="Введите текст"
86
+ ></base-form-input>
87
+ <span v-else class="flex items-center justify-between p-4 cursor-pointer" :class="[$libStyles.textTitle, $libStyles.greenText]" @click="openSecondPanel(question)">
88
+ {{ question.answerName ? question.answerName : 'Выбрать вариант ответа' }}
89
+ <i class="mdi mdi-chevron-right text-[28px]"></i>
90
+ </span>
91
+ </base-form-text-section>
92
+ </section>
93
+ </section>
94
+ </base-fade-transition>
95
+ <Teleport v-if="secondPanel" to="#panel-actions">
96
+ <div :class="[$libStyles.scrollPage]" class="flex flex-col items-center">
97
+ <base-rounded-input v-model="searchQuery" :label="$t('labels.search')" class="w-full p-2" :hide-details="true"></base-rounded-input>
98
+ <div v-if="$dataStore.questionRefs && $dataStore.questionRefs.length && isPanelLoading === false" class="w-full flex flex-col gap-2 p-2">
99
+ <base-panel-select-item
100
+ v-for="(item, index) of $dataStore.questionRefs.filter(i => i.nameRu && (i.nameRu as string).match(new RegExp(searchQuery, 'i')))"
101
+ :key="index"
102
+ :text="`${item.nameRu}`"
103
+ :selected="currentSecond!.answerId === item.ids"
104
+ @click="closeSecondPanel(item)"
105
+ ></base-panel-select-item>
106
+ </div>
107
+ <base-loader v-if="isPanelLoading" class="absolute mt-10" :size="50"></base-loader>
108
+ </div>
109
+ </Teleport>
110
+ <base-scroll-buttons @up="scrollForm('up')" @down="scrollForm('down')" />
111
+ </template>
112
+
113
+ <script lang="ts">
114
+ import { Value } from '@/composables/classes';
115
+
116
+ export default defineComponent({
117
+ setup() {
118
+ const route = useRoute();
119
+ const router = useRouter();
120
+ const formStore = useFormStore();
121
+ const dataStore = useDataStore();
122
+ const vForm = ref<any>();
123
+ const firstPanelSection = ref<any>();
124
+ const isButtonLoading = ref<boolean>(false);
125
+ const answerToAll = ref<boolean>(false);
126
+ const firstPanel = ref<boolean>(false);
127
+ const secondPanel = ref<boolean>(false);
128
+ const surveyType = ref<'health' | 'critical'>('tab' in route.query && route.query.tab === 'criticalBase' ? 'critical' : 'health');
129
+ const whichSurvey = computed(() => (surveyType.value === 'health' ? 'surveyByHealthBase' : 'surveyByCriticalBase'));
130
+ const firstQuestionList = ref<AnketaBody[]>();
131
+ const secondQuestionList = ref<AnketaSecond[]>([]);
132
+ const currentQuestion = ref<AnketaBody>();
133
+ const currentSecond = ref<AnketaSecond>();
134
+ const isPanelLoading = ref<boolean>(false);
135
+ const searchQuery = ref<string>('');
136
+
137
+ const scrollForm = (direction: 'up' | 'down') => {
138
+ const scrollObject = { top: direction === 'up' ? 0 : screen.height * 10, behavior: 'smooth' };
139
+ if (firstPanel.value) {
140
+ firstPanelSection.value.scrollTo(scrollObject);
141
+ } else {
142
+ vForm.value.scrollTo(scrollObject);
143
+ }
144
+ };
145
+
146
+ const submitForm = async () => {
147
+ await vForm.value.validate().then(async (v: { valid: Boolean; errors: any }) => {
148
+ if (v.valid) {
149
+ isButtonLoading.value = true;
150
+ formStore[whichSurvey.value]!.body.forEach((survey: AnketaBody) => {
151
+ if (survey.first.answerText === 'Нет') {
152
+ survey.second = [];
153
+ }
154
+ });
155
+ formStore[whichSurvey.value]!.type = surveyType.value;
156
+ const anketaToken = await dataStore.setSurvey(formStore[whichSurvey.value]);
157
+ formStore[whichSurvey.value]!.id = anketaToken;
158
+ isButtonLoading.value = false;
159
+ } else {
160
+ const errors = document.querySelector('.v-input--error');
161
+ if (errors) {
162
+ const errorText = errors.querySelector('.v-label.v-field-label');
163
+ if (errorText) {
164
+ dataStore.showToaster('error', dataStore.t('toaster.errorFormField').replace('{text}', errorText.innerHTML?.replace(/[-<>!//.]/g, '')));
165
+ } else {
166
+ const errorFieldText = errors.parentElement?.parentElement?.children[0].innerHTML;
167
+ if (errorFieldText) {
168
+ dataStore.showToaster('error', dataStore.t('toaster.errorFormField').replace('{text}', errorFieldText));
169
+ }
170
+ }
171
+ errors.scrollIntoView({
172
+ behavior: 'smooth',
173
+ block: 'center',
174
+ inline: 'nearest',
175
+ });
176
+ }
177
+ }
178
+ });
179
+ };
180
+
181
+ const openFirstPanel = async (question: AnketaBody) => {
182
+ currentQuestion.value = question;
183
+ formStore[whichSurvey.value]!.body.forEach((question_object: AnketaBody) => {
184
+ if ((question_object.first.id === question.first.id && question_object.second && !question_object.second.length) || question_object.second == null) {
185
+ question_object.second = JSON.parse(JSON.stringify(formStore[surveyType.value === 'health' ? 'surveyByHealthSecond' : 'surveyByCriticalSecond']));
186
+ }
187
+ });
188
+ firstPanel.value = true;
189
+ secondPanel.value = false;
190
+ };
191
+
192
+ const openSecondPanel = async (question: AnketaSecond) => {
193
+ dataStore.questionRefs = [];
194
+ currentSecond.value = question;
195
+ isPanelLoading.value = true;
196
+ await dataStore.getQuestionRefs(question.id);
197
+ secondPanel.value = true;
198
+ dataStore.panelAction = null;
199
+ dataStore.panel.open = true;
200
+ dataStore.panel.title = question.name;
201
+ isPanelLoading.value = false;
202
+ };
203
+
204
+ const closeSecondPanel = (selectedAnswer: Value) => {
205
+ if (selectedAnswer.ids && currentSecond.value) {
206
+ currentSecond.value.answerId = selectedAnswer.ids as string;
207
+ currentSecond.value.answerName = selectedAnswer.nameRu as string;
208
+ }
209
+ secondPanel.value = false;
210
+ dataStore.panelAction = null;
211
+ dataStore.panel.open = false;
212
+ dataStore.questionRefs = [];
213
+ };
214
+
215
+ const getDefinedAnswerId = async (id: string, value: any, index: number) => {
216
+ // @ts-ignore
217
+ await dataStore.definedAnswers(id, whichSurvey.value, value, index);
218
+ };
219
+
220
+ const handleToggler = async () => {
221
+ if (firstQuestionList.value) {
222
+ if (answerToAll.value) {
223
+ firstQuestionList.value.forEach((question: AnketaBody, index: number) => {
224
+ if (question.first.answerType === 'T') {
225
+ firstQuestionList.value![index].first.answerName = 'Нет' as AnswerName;
226
+ }
227
+ });
228
+ for (const question of firstQuestionList.value) {
229
+ const index = firstQuestionList.value.indexOf(question);
230
+ await getDefinedAnswerId(question.first.id, 'Нет', index);
231
+ }
232
+ } else {
233
+ firstQuestionList.value.forEach((question: AnketaBody, index: number) => {
234
+ if (question.first.answerType === 'T') {
235
+ firstQuestionList.value![index].first.answerName = null;
236
+ }
237
+ });
238
+ }
239
+ }
240
+ };
241
+
242
+ const onInit = async () => {
243
+ if (route.params.taskId === '0' || formStore.applicationData.processInstanceId === 0) {
244
+ await router.push({ name: 'taskId', params: route.params });
245
+ return;
246
+ }
247
+ await dataStore.getQuestionList(
248
+ surveyType.value,
249
+ formStore.applicationData.processInstanceId,
250
+ formStore.applicationData.insuredApp[0].id,
251
+ whichSurvey.value,
252
+ surveyType.value === 'health' ? 'surveyByHealthSecond' : 'surveyByCriticalSecond',
253
+ );
254
+ firstQuestionList.value = formStore[whichSurvey.value]!.body;
255
+ secondQuestionList.value = formStore[surveyType.value === 'health' ? 'surveyByHealthSecond' : 'surveyByCriticalSecond']!;
256
+ formStore[whichSurvey.value]!.type = surveyType.value;
257
+ const negativeAnswer = firstQuestionList.value.every(i => i.first.answerName === 'Нет');
258
+ if (negativeAnswer) {
259
+ answerToAll.value = true;
260
+ }
261
+ await Promise.allSettled(
262
+ firstQuestionList.value.map(async (question: any) => {
263
+ await dataStore.definedAnswers(question.first.id, whichSurvey.value);
264
+ }),
265
+ );
266
+ if (formStore.isDisabled.surveyByHealthBase) {
267
+ dataStore.showToaster('error', dataStore.t('toaster.viewErrorText'));
268
+ }
269
+ };
270
+
271
+ onMounted(async () => {
272
+ await onInit();
273
+ });
274
+
275
+ watch(
276
+ () => dataStore.panel.open,
277
+ () => {
278
+ if (dataStore.panel.open === false) {
279
+ secondPanel.value = false;
280
+ dataStore.panelAction = null;
281
+ }
282
+ },
283
+ { immediate: true },
284
+ );
285
+
286
+ watch(
287
+ () => firstQuestionList.value,
288
+ value => {
289
+ if (value) {
290
+ const hasPositiveAnswer = value.some(i => i.first.definedAnswers === 'Y' && i.first.answerName !== 'Нет');
291
+ answerToAll.value = !hasPositiveAnswer;
292
+ }
293
+ },
294
+ {
295
+ deep: true,
296
+ },
297
+ );
298
+
299
+ return {
300
+ // State
301
+ vForm,
302
+ formStore,
303
+ answerToAll,
304
+ firstQuestionList,
305
+ secondQuestionList,
306
+ whichSurvey,
307
+ isButtonLoading,
308
+ firstPanel,
309
+ secondPanel,
310
+ currentQuestion,
311
+ currentSecond,
312
+ isPanelLoading,
313
+ searchQuery,
314
+ firstPanelSection,
315
+
316
+ // Functions
317
+ submitForm,
318
+ getDefinedAnswerId,
319
+ scrollForm,
320
+ handleToggler,
321
+ openFirstPanel,
322
+ openSecondPanel,
323
+ closeSecondPanel,
324
+ };
325
+ },
326
+ });
327
+ </script>
328
+
329
+ <style>
330
+ .anketa-radio .v-selection-control-group {
331
+ gap: 40px;
332
+ }
333
+ </style>
@@ -0,0 +1,91 @@
1
+ <template>
2
+ <section class="flex flex-col justify-evenly">
3
+ <img draggable="false" class="w-2/3 lg:w-[25vw] self-center" src="~/assets/auth-logo.svg" />
4
+ <v-form ref="vForm" class="w-2/3 lg:w-[35vw] self-center">
5
+ <base-rounded-input
6
+ class="mb-1"
7
+ v-model="login"
8
+ :rules="$dataStore.rules.required"
9
+ :loading="authLoading"
10
+ :placeholder="$t('buttons.userLogin')"
11
+ type="text"
12
+ @submitted="submitAuthForm"
13
+ ></base-rounded-input>
14
+ <base-rounded-input
15
+ class="mb-1"
16
+ v-model="password"
17
+ :rules="$dataStore.rules.required"
18
+ :loading="authLoading"
19
+ :placeholder="$t('buttons.password')"
20
+ type="password"
21
+ @submitted="submitAuthForm"
22
+ ></base-rounded-input>
23
+ <base-btn :text="$t('buttons.login')" :disabled="authLoading" :btn="$libStyles.greenBtn" @click="submitAuthForm"></base-btn>
24
+ </v-form>
25
+ </section>
26
+ </template>
27
+
28
+ <script lang="ts">
29
+ export default defineComponent({
30
+ setup() {
31
+ const route = useRoute();
32
+ const router = useRouter();
33
+ const dataStore = useDataStore();
34
+
35
+ const vForm = ref<any>(null);
36
+
37
+ const credentials = {
38
+ production: { login: '', password: '' },
39
+ test: { login: '', password: '' },
40
+ development: { login: 'manager', password: 'asdqwe123' },
41
+ vercel: { login: '', password: 'asdqwe123' },
42
+ };
43
+
44
+ const useEnv = {
45
+ envMode: import.meta.env.VITE_MODE,
46
+ isDev: import.meta.env.VITE_MODE === 'development',
47
+ isTest: import.meta.env.VITE_MODE === 'test',
48
+ isVercel: import.meta.env.VITE_MODE === 'vercel',
49
+ isProduction: import.meta.env.VITE_MODE === 'production',
50
+ };
51
+
52
+ const login = ref<string>(credentials[useEnv.envMode as keyof typeof credentials].login);
53
+ const password = ref<string>(credentials[useEnv.envMode as keyof typeof credentials].password);
54
+
55
+ const numAttempts = ref(0);
56
+
57
+ const authLoading = ref(false);
58
+
59
+ onMounted(() => {
60
+ if (route.query && route.query.error) {
61
+ const authError = route.query.error;
62
+ if (authError === '401') {
63
+ dataStore.showToaster('error', dataStore.t('toaster.tokenExpire'), 3000);
64
+ }
65
+ }
66
+ });
67
+
68
+ const submitAuthForm = async () => {
69
+ await vForm.value.validate().then(async (v: { valid: Boolean; errors: any }) => {
70
+ if (v.valid) {
71
+ authLoading.value = true;
72
+ await dataStore.loginUser(login.value, password.value, numAttempts.value);
73
+ numAttempts.value++;
74
+ authLoading.value = false;
75
+ if (!!dataStore.user.id) {
76
+ router.push({ name: 'index' });
77
+ }
78
+ }
79
+ });
80
+ };
81
+
82
+ return {
83
+ login,
84
+ password,
85
+ vForm,
86
+ authLoading,
87
+ submitAuthForm,
88
+ };
89
+ },
90
+ });
91
+ </script>
@@ -1,6 +1,6 @@
1
1
  <template>
2
- <section class="w-full px-[10px] pt-[14px] flex flex-col gap-2" :class="[$libStyles.scrollPage]" v-if="$dataStore.signedDocumentList && $dataStore.signedDocumentList.length">
3
- <base-content-block v-for="document of $dataStore.signedDocumentList as DocumentItem[]" :key="document.id" :class="[$libStyles.textSimple]">
2
+ <section class="w-full px-[10px] pt-[14px] flex flex-col gap-2" :class="[$libStyles.scrollPage]" v-if="formStore.signedDocumentList && formStore.signedDocumentList.length">
3
+ <base-content-block v-for="document of formStore.signedDocumentList as DocumentItem[]" :key="document.id" :class="[$libStyles.textSimple]">
4
4
  <h5 class="text-center font-medium mb-4">
5
5
  {{ document.fileTypeName }}
6
6
  </h5>
@@ -39,7 +39,7 @@ export default defineComponent({
39
39
  action: '',
40
40
  text: '',
41
41
  });
42
- const object_list = computed(() => Object.values(dataStore.signedDocumentList));
42
+ const object_list = computed(() => Object.values(formStore.signedDocumentList));
43
43
  const unSignedList = computed(() => document_list.value.filter(doc => doc.signed === false || doc.signed === null));
44
44
  const document_list = computed(() =>
45
45
  object_list.value.filter(obj => {
@@ -95,6 +95,7 @@ export default defineComponent({
95
95
 
96
96
  return {
97
97
  // State
98
+ formStore,
98
99
  documentLoading,
99
100
  DocumentItem,
100
101
 
@@ -486,6 +486,7 @@
486
486
  </template>
487
487
  </base-dialog>
488
488
  </section>
489
+ <base-scroll-buttons @up="scrollForm('up')" @down="scrollForm('down')"></base-scroll-buttons>
489
490
  </template>
490
491
 
491
492
  <script lang="ts">
@@ -637,6 +638,10 @@ export default {
637
638
  }
638
639
  };
639
640
 
641
+ const scrollForm = (direction: 'up' | 'down') => {
642
+ vForm.value.scrollTo({ top: direction === 'up' ? 0 : screen.height * 10, behavior: 'smooth' });
643
+ };
644
+
640
645
  const openCustomPanel = (type: 'document' = 'document') => {
641
646
  dataStore.panelAction = null;
642
647
  if (type === 'document' && memberDocument.value) {
@@ -849,7 +854,7 @@ export default {
849
854
  await dataStore.getApplicationData(taskId, false, false, false, false);
850
855
  await router.replace({
851
856
  name: route.name!,
852
- params: { taskId },
857
+ params: { taskId: taskId as string },
853
858
  query: { ...route.query },
854
859
  });
855
860
  dataStore.showToaster('success', dataStore.t('toaster.successStatementCreation'));
@@ -886,9 +891,9 @@ export default {
886
891
  });
887
892
  await dataStore.getApplicationData(route.params.taskId, false, false, false, false);
888
893
  if (dataStore.controls.hasCalculator) {
889
- if (dataStore.additionalInsuranceTermsWithout && dataStore.additionalInsuranceTermsWithout.length !== 0) {
890
- dataStore.additionalInsuranceTerms.forEach((term: any) => {
891
- const defaultTerm = dataStore.additionalInsuranceTermsWithout.find((i: any) => i.coverTypeId === term.coverTypeId);
894
+ if (formStore.additionalInsuranceTermsWithout && formStore.additionalInsuranceTermsWithout.length !== 0) {
895
+ formStore.additionalInsuranceTerms.forEach((term: any) => {
896
+ const defaultTerm = formStore.additionalInsuranceTermsWithout.find((i: any) => i.coverTypeId === term.coverTypeId);
892
897
  if (defaultTerm) {
893
898
  term.coverSumName = defaultTerm.coverSumName;
894
899
  term.coverSumId = defaultTerm.coverSumId;
@@ -1126,6 +1131,7 @@ export default {
1126
1131
  getFile,
1127
1132
  selectFamilyMember,
1128
1133
  closeFamilyDialog,
1134
+ scrollForm,
1129
1135
  };
1130
1136
  },
1131
1137
  };
@@ -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>