hl-core 0.0.10-beta.76 → 0.0.10-beta.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/base.api.ts CHANGED
@@ -994,6 +994,15 @@ export class ApiClass {
994
994
  });
995
995
  }
996
996
 
997
+ async generateDocDocument(data: any) {
998
+ return await this.axiosCall<any>({
999
+ method: Methods.POST,
1000
+ url: `/Arm/api/Bpm/generateDocDocument`,
1001
+ data: data,
1002
+ responseType: 'arraybuffer',
1003
+ });
1004
+ }
1005
+
997
1006
  async getVariableData(type: number, processCode: number) {
998
1007
  return await this.axiosCall<any>({
999
1008
  method: Methods.GET,
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div
3
3
  :class="[
4
- selected ? $styles.blueBg : $styles.blueBgLight,
5
- selected ? $styles.whiteText : $styles.blackText,
4
+ selected ? $styles.blueBg : menuItem.color ?? $styles.blueBgLight,
5
+ selected || menuItem.color ? $styles.whiteText : $styles.blackText,
6
6
  $styles.rounded,
7
7
  $styles.textSimple,
8
8
  disabled ? 'cursor-not-allowed opacity-50' : '',
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
  <div class="flex items-center">
17
17
  <base-chip :chip="menuItem.chip" />
18
- <i v-if="typeof menuItem.link == 'object' || menuItem.chip" class="mdi mdi-folder-outline text-xl pl-4 pr-4"></i>
18
+ <i v-if="typeof menuItem.link == 'object' || menuItem.chip" class="mdi mdi-folder-outline text-xl pl-4 pr-4"></i>
19
19
  </div>
20
20
  <v-tooltip v-if="menuItem.description" activator="parent" location="bottom">{{ menuItem.description }}</v-tooltip>
21
21
  </div>
@@ -1,5 +1,8 @@
1
1
  <template>
2
2
  <section :class="[$styles.scrollPage]">
3
+ <section v-if="isSupportAttachmentSection" class="w-full px-[10px] pt-[14px]">
4
+ <base-btn :disabled="documentLoading" :loading="documentLoading" text="Открыть панель вложения для Техподдержки" size="sm" @click="openSupportAttachPanel" />
5
+ </section>
3
6
  <base-form-section v-if="isUnderwriterDocuments" title="Загрузить документы для Андеррайтинга" class="mx-[10px] mt-[14px]">
4
7
  <base-file-input :readonly="isDisabled || documentLoading" @input.prevent="onUnderFiles($event)" @onClear="onClearUnderFiles()" />
5
8
  <base-animation>
@@ -29,7 +32,13 @@
29
32
  <i
30
33
  class="transition-all cursor-pointer mdi mdi-tray-arrow-down pl-2 mr-3 border-l-[1px] text-xl absolute right-0"
31
34
  :class="[$styles.greenTextHover]"
32
- @click="$dataStore.generatePDFDocument(processCode === 19 ? 'PA_Statement' : processCode === 25 ? 'PAJ_Statement' : 'PA_RefundStatement', '37')"
35
+ @click="
36
+ openDownloadFormatPanel(
37
+ processCode === 19 ? 'PA_Statement' : processCode === 25 ? 'PAJ_Statement' : 'PA_RefundStatement',
38
+ '37',
39
+ `Заявления на ${processCode === 19 || processCode === 25 ? 'страхование' : 'возврат'}`,
40
+ )
41
+ "
33
42
  ></i>
34
43
  </div>
35
44
  </base-content-block>
@@ -40,7 +49,13 @@
40
49
  <i
41
50
  class="transition-all cursor-pointer mdi mdi-tray-arrow-down pl-2 mr-3 border-l-[1px] text-xl absolute right-0"
42
51
  :class="[$styles.greenTextHover]"
43
- @click="$dataStore.generatePDFDocument(processCode === 19 ? 'PA_Contract' : processCode === 25 ? 'PAJ_Contract' : 'PA_RefundAgreement', '38')"
52
+ @click="
53
+ openDownloadFormatPanel(
54
+ processCode === 19 ? 'PA_Contract' : processCode === 25 ? 'PAJ_Contract' : 'PA_RefundAgreement',
55
+ '38',
56
+ `Договор ${processCode === 19 || processCode === 25 ? 'страхования' : 'возврата'}`,
57
+ )
58
+ "
44
59
  ></i>
45
60
  </div>
46
61
  </base-content-block>
@@ -51,7 +66,7 @@
51
66
  <i
52
67
  class="transition-all cursor-pointer mdi mdi-tray-arrow-down pl-2 mr-3 border-l-[1px] text-xl absolute right-0"
53
68
  :class="[$styles.greenTextHover]"
54
- @click="$dataStore.generatePDFDocument('Compliance_FinMonitoring', '39')"
69
+ @click="openDownloadFormatPanel('Compliance_FinMonitoring', '39', $appContextStore.t('pension.complianceFinMonitoring'))"
55
70
  ></i>
56
71
  </div>
57
72
  </base-content-block>
@@ -62,7 +77,7 @@
62
77
  <i
63
78
  class="transition-all cursor-pointer mdi mdi-tray-arrow-down pl-2 mr-3 border-l-[1px] text-xl absolute right-0"
64
79
  :class="[$styles.greenTextHover]"
65
- @click="$dataStore.generatePDFDocument('PA_Dossier', '40', 'doc')"
80
+ @click="openDownloadFormatPanel('PA_Dossier', '40', $appContextStore.t('pension.dossierPA'))"
66
81
  ></i>
67
82
  </div>
68
83
  </base-content-block>
@@ -241,13 +256,55 @@
241
256
  @click="getDoc('view')"
242
257
  />
243
258
  </base-animation>
244
- <base-btn :disabled="documentLoading" :loading="documentLoading" text="Скачать" @click="getDoc('download')" />
259
+ <base-btn :disabled="documentLoading" :loading="documentLoading" text="Скачать" @click="getDoc('download', $dataStore.isSupport() ? downloadType : undefined)" />
245
260
  <base-animation>
246
261
  <base-btn v-if="canDeleteFiles" :disabled="documentLoading" :loading="documentLoading" text="Удалить" @click="deletionDialog = true" />
247
262
  </base-animation>
248
263
  </div>
249
264
  </base-fade-transition>
250
265
  </Teleport>
266
+ <Teleport v-if="isSupportAttachOpen" to="#right-panel-actions">
267
+ <base-fade-transition>
268
+ <div :class="[$styles.flexColNav]">
269
+ <base-form-section class="!mt-0">
270
+ <div class="flex flex-col gap-2">
271
+ <base-rounded-input v-model="supportTypeSearch" :label="$appContextStore.t('labels.search')" class="w-full" :hide-details="true" />
272
+ <div class="px-1 text-xs" :class="[$styles.mutedText]">Найдено: {{ filteredSupportFileTypeItems.length }}</div>
273
+ <div class="w-full flex flex-col gap-2 p-2 max-h-[220px] overflow-y-auto" :class="[$styles.blueBgLight, $styles.rounded]">
274
+ <base-panel-select-item :text="$appContextStore.t('form.notChosen')" :selected="supportSelectedFileTypeCode === null" @click="pickSupportFileType(null)" />
275
+ <base-panel-select-item
276
+ v-for="item in filteredSupportFileTypeItems"
277
+ :key="item.value"
278
+ :text="String(item.title)"
279
+ :selected="item.value === supportSelectedFileTypeCode"
280
+ @click="pickSupportFileType(item.value)"
281
+ />
282
+ <div v-if="supportTypeSearch && filteredSupportFileTypeItems.length === 0" class="px-2 py-1 text-sm" :class="[$styles.mutedText]">Ничего не найдено</div>
283
+ </div>
284
+ <base-file-input :readonly="documentLoading" @input.prevent="onSupportFiles($event)" @onClear="onClearSupportFiles()" />
285
+ <base-animation>
286
+ <base-btn
287
+ :disabled="!supportSelectedFileTypeCode || !supportDocumentsList.length || documentLoading"
288
+ :loading="documentLoading"
289
+ text="Вложить"
290
+ size="sm"
291
+ @click="uploadSupportFiles"
292
+ />
293
+ </base-animation>
294
+ </div>
295
+ </base-form-section>
296
+ </div>
297
+ </base-fade-transition>
298
+ </Teleport>
299
+ <Teleport v-if="isDownloadFormatOpen" to="#right-panel-actions">
300
+ <base-fade-transition>
301
+ <div :class="[$styles.flexColNav]">
302
+ <div class="px-2 py-2 text-sm" :class="[$styles.mutedText]">{{ downloadingDocData.docName }}</div>
303
+ <base-btn text="PDF" @click="downloadFile('pdf')" />
304
+ <base-btn text="DOCX" @click="downloadFile('docx')" />
305
+ </div>
306
+ </base-fade-transition>
307
+ </Teleport>
251
308
  <Teleport v-if="isDigitalDocOpen" to="#right-panel-actions">
252
309
  <div :class="[$styles.flexColNav]">
253
310
  <base-form-section class="!mt-0">
@@ -323,6 +380,7 @@ export default defineComponent({
323
380
  const deletionDialog = ref<boolean>(false);
324
381
  const isPanelOpen = ref<boolean>(false);
325
382
  const isDigitalDocOpen = ref<boolean>(false);
383
+ const isSupportAttachOpen = ref<boolean>(false);
326
384
  const isDisabled = computed(() => !dataStore.isTask());
327
385
  const contractDict = computed(() => dictionariesStore.dicFileTypeList.find(i => i.nameRu === 'Договор страхования' || i.nameRu === 'Договор'));
328
386
  const processCode = formStore.applicationData.processCode;
@@ -339,9 +397,29 @@ export default defineComponent({
339
397
  const isDigitalDocDisabled = computed(
340
398
  () => !dataStore.isTask() || route.params.taskId === '0' || !dataStore.isInitiator() || !dataStore.isProcessEditable(formStore.applicationData.statusCode),
341
399
  );
400
+ const isSupportAttachmentSection = computed(() => dataStore.isSupport() && route.params.taskId !== '0' && !!formStore.applicationData.processInstanceId);
342
401
  const documentType = ref<DigitalDocNames | null>(null);
343
402
  const otpCode = ref<string>('');
344
403
  const currentIin = ref<string>('');
404
+ const downloadType = ref<'pdf' | 'docx'>('pdf');
405
+ const downloadTypes: Array<{ title: string; value: 'pdf' | 'docx' }> = [
406
+ { title: 'PDF', value: 'pdf' },
407
+ { title: 'DOCX', value: 'docx' },
408
+ ];
409
+ const supportSelectedFileTypeCode = ref<string | null>(null);
410
+ const supportTypeSearch = ref<string>('');
411
+ const supportDocumentsList = ref<File[]>([]);
412
+ const supportFileTypeItems = computed(() =>
413
+ dictionariesStore.dicFileTypeList.map(i => ({
414
+ title: i.nameRu || i.nameKz || String(i.code),
415
+ value: String(i.code),
416
+ })),
417
+ );
418
+ const filteredSupportFileTypeItems = computed(() => {
419
+ const query = supportTypeSearch.value.trim().toLowerCase();
420
+ if (!query) return supportFileTypeItems.value;
421
+ return supportFileTypeItems.value.filter(i => i.title.toLowerCase().includes(query) || i.value.toLowerCase().includes(query));
422
+ });
345
423
  const deleteFilesId = ['1', '2', '3', '4', '46'];
346
424
  const documentItems: Array<{ title: DigitalDocNames; value: DigitalDocTypes }> = [
347
425
  { title: 'Удостоверение личности', value: 'IdentityCard' },
@@ -374,6 +452,8 @@ export default defineComponent({
374
452
  processInstanceId: string;
375
453
  }[]
376
454
  >([]);
455
+ const isDownloadFormatOpen = ref<boolean>(false);
456
+ const downloadingDocData = ref<{ docType: string; fileCode: string; docName: string }>({ docType: '', fileCode: '', docName: '' });
377
457
 
378
458
  const object_list = computed(() => Object.values(formStore.signedDocumentList));
379
459
  const unSignedList = computed(() => document_list.value.filter((doc: DocumentItem) => doc.signed === false || doc.signed === null));
@@ -405,6 +485,7 @@ export default defineComponent({
405
485
  (formStore.applicationData.statusCode === 'StartForm' || formStore.applicationData.statusCode === 'EditForm'),
406
486
  );
407
487
  const canDeleteFiles = computed(() => {
488
+ if (dataStore.isSupport()) return true;
408
489
  const baseCondition = dataStore.isTask() && dataStore.isInitiator() && dataStore.isProcessEditable(formStore.applicationData.statusCode);
409
490
  if (
410
491
  appContextStore.isBaiterek ||
@@ -439,12 +520,120 @@ export default defineComponent({
439
520
  const openPanel = async (document: DocumentItem) => {
440
521
  dataStore.rightPanel.title = document.fileTypeName!;
441
522
  currentDocument.value = document;
523
+ const extension = String(document.fileName ?? '')
524
+ .split('.')
525
+ .pop()
526
+ ?.toLowerCase();
527
+ downloadType.value = extension === 'docx' ? 'docx' : 'pdf';
442
528
  dataStore.rightPanel.open = true;
529
+ isDownloadFormatOpen.value = false;
530
+ isSupportAttachOpen.value = false;
443
531
  isDigitalDocOpen.value = false;
444
532
  isPanelOpen.value = true;
445
533
  dataStore.panelAction = null;
446
534
  };
447
535
 
536
+ const openSupportAttachPanel = () => {
537
+ dataStore.panelAction = null;
538
+ dataStore.rightPanel.title = 'Вложение документов';
539
+ dataStore.rightPanel.open = true;
540
+ isPanelOpen.value = false;
541
+ isDigitalDocOpen.value = false;
542
+ isDownloadFormatOpen.value = false;
543
+ isSupportAttachOpen.value = true;
544
+ supportTypeSearch.value = '';
545
+ supportSelectedFileTypeCode.value = null;
546
+ supportDocumentsList.value = [];
547
+ };
548
+
549
+ const openDownloadFormatPanel = (docType: string, fileCode: string, docName: string) => {
550
+ downloadingDocData.value = { docType, fileCode, docName };
551
+ dataStore.panelAction = null;
552
+ dataStore.rightPanel.title = 'Выберите формат';
553
+ dataStore.rightPanel.open = true;
554
+ isPanelOpen.value = false;
555
+ isDigitalDocOpen.value = false;
556
+ isSupportAttachOpen.value = false;
557
+ isDownloadFormatOpen.value = true;
558
+ };
559
+
560
+ const downloadFile = (format: 'pdf' | 'docx') => {
561
+ const { docType, fileCode } = downloadingDocData.value;
562
+ dataStore.generatePDFDocument(docType, fileCode, format);
563
+ isDownloadFormatOpen.value = false;
564
+ dataStore.rightPanel.open = false;
565
+ };
566
+
567
+ const onSupportFiles = (event: InputEvent) => {
568
+ if (!(event.target || event.dataTransfer)) return;
569
+ const files = event.target ? (event.target as HTMLInputElement).files : (event.dataTransfer as DataTransfer).files;
570
+ if (files !== null) {
571
+ supportDocumentsList.value = Object.values(files);
572
+ }
573
+ };
574
+
575
+ const onClearSupportFiles = () => {
576
+ supportDocumentsList.value = [];
577
+ };
578
+
579
+ const pickSupportFileType = (code: string | null) => {
580
+ supportSelectedFileTypeCode.value = code;
581
+ };
582
+
583
+ const uploadSupportFiles = async () => {
584
+ if (!supportSelectedFileTypeCode.value) {
585
+ showToaster('error', appContextStore.t('toaster.chooseDocumentType') || 'Выберите тип документа', 3000);
586
+ return;
587
+ }
588
+ if (!supportDocumentsList.value.length) {
589
+ showToaster('error', appContextStore.t('toaster.noFileSelected') || 'Выберите файл', 3000);
590
+ return;
591
+ }
592
+ const selectedDocument = dictionariesStore.dicFileTypeList.find((i: Value) => String(i.code) === supportSelectedFileTypeCode.value);
593
+ if (!selectedDocument) {
594
+ showToaster('error', appContextStore.t('toaster.chooseDocumentType') || 'Выберите тип документа', 3000);
595
+ return;
596
+ }
597
+
598
+ documentLoading.value = true;
599
+ try {
600
+ await Promise.allSettled(
601
+ supportDocumentsList.value.map(async file => {
602
+ if (file.type !== constants.fileTypes.pdf && file.type !== constants.fileTypes.docx && file.type !== constants.fileTypes.doc) {
603
+ showToaster('error', appContextStore.t('toaster.onlyWithFormat', { format: 'PDF, Word' }), 6000);
604
+ return;
605
+ }
606
+ if (file.size >= 20_000_000) {
607
+ showToaster('error', appContextStore.t('toaster.fileOnlyBelow20mb'), 6000);
608
+ return;
609
+ }
610
+
611
+ const formData = new FormData();
612
+ const ext = file.name.substring(file.name.lastIndexOf('.'));
613
+ const uuidV4 = uuid.v4();
614
+ formData.append('file', file);
615
+ formData.append(
616
+ 'fileData',
617
+ JSON.stringify([
618
+ {
619
+ identifier: `${uuidV4}${ext}`,
620
+ processInstanceId: formStore.applicationData.processInstanceId,
621
+ fileTypeCode: selectedDocument.code,
622
+ fileTypeId: selectedDocument.id,
623
+ fileName: file.name,
624
+ },
625
+ ]),
626
+ );
627
+ await formStore.uploadFiles(formData, false);
628
+ }),
629
+ );
630
+ onClearSupportFiles();
631
+ await dataStore.getSignedDocList(formStore.applicationData.processInstanceId);
632
+ } finally {
633
+ documentLoading.value = false;
634
+ }
635
+ };
636
+
448
637
  const onFileChange = async (event: InputEvent) => {
449
638
  if (event.target) {
450
639
  const files = (event.target as HTMLInputElement).files;
@@ -509,6 +698,7 @@ export default defineComponent({
509
698
 
510
699
  const openDigitalDocPanel = async (iin: string, title: string) => {
511
700
  isPanelOpen.value = false;
701
+ isSupportAttachOpen.value = false;
512
702
  isDigitalDocOpen.value = true;
513
703
  dataStore.panelAction = null;
514
704
  dataStore.rightPanel.open = true;
@@ -534,10 +724,10 @@ export default defineComponent({
534
724
  },
535
725
  );
536
726
 
537
- const getDoc = async (type: FileActions) => {
727
+ const getDoc = async (type: FileActions, selectedType?: 'pdf' | 'docx') => {
538
728
  if (currentDocument.value) {
539
729
  documentLoading.value = true;
540
- const fileExtension = currentDocument.value.fileName!.match(/\.([0-9a-z]+)(?:[\?#]|$)/i)![1];
730
+ const fileExtension = selectedType || currentDocument.value.fileName?.match(/\.([0-9a-z]+)(?:[\?#]|$)/i)?.[1]?.toLowerCase() || 'pdf';
541
731
  await formStore.getDoc(currentDocument.value, type, fileExtension);
542
732
  documentLoading.value = false;
543
733
  }
@@ -712,8 +902,13 @@ export default defineComponent({
712
902
  memberStore,
713
903
  processCode,
714
904
  isPanelOpen,
905
+ isSupportAttachOpen,
906
+ isDownloadFormatOpen,
907
+ downloadingDocData,
715
908
  jointMembers,
716
909
  DocumentItem,
910
+ downloadType,
911
+ downloadTypes,
717
912
  documentType,
718
913
  documentItems,
719
914
  signedContract,
@@ -722,6 +917,11 @@ export default defineComponent({
722
917
  documentLoading,
723
918
  isDigitalDocOpen,
724
919
  underDocumentsList,
920
+ supportDocumentsList,
921
+ supportTypeSearch,
922
+ supportFileTypeItems,
923
+ filteredSupportFileTypeItems,
924
+ supportSelectedFileTypeCode,
725
925
 
726
926
  // Computed
727
927
  isDisabled,
@@ -729,6 +929,7 @@ export default defineComponent({
729
929
  showContract,
730
930
  noDocuments,
731
931
  canDeleteFiles,
932
+ isSupportAttachmentSection,
732
933
  insuredFiltered,
733
934
  policyholderForm,
734
935
  slaveInsuredForm,
@@ -742,26 +943,28 @@ export default defineComponent({
742
943
  getCode,
743
944
  getDoc,
744
945
  openPanel,
946
+ openSupportAttachPanel,
947
+ openDownloadFormatPanel,
948
+ downloadFile,
745
949
  deleteFile,
746
950
  getDigitalDocument,
747
951
  onFileChange,
748
952
  onUnderFiles,
953
+ onSupportFiles,
749
954
  openDigitalDocPanel,
750
955
  uploadUnderFiles,
751
956
  onClearUnderFiles,
957
+ onClearSupportFiles,
958
+ uploadSupportFiles,
752
959
  uploadAdditionalFile,
753
960
  memberHasDocumentsToSign,
961
+ pickSupportFileType,
754
962
  };
755
963
  },
756
964
  });
757
965
  </script>
758
966
 
759
967
  <style>
760
- .document-type-select .v-field {
761
- border: none !important;
762
- border-radius: 4px;
763
- height: 56px;
764
- }
765
968
  .digital-document-otp .base-otp-input .v-otp-input__content {
766
969
  gap: 8px;
767
970
  padding-right: 0px !important;
@@ -318,23 +318,95 @@ export const ESBDMessage = (ESBDObject: any, initialPoint: any) => {
318
318
  };
319
319
 
320
320
  export const ErrorHandler = (err: unknown, errorText?: string) => {
321
- console.log(err);
322
- if (useDataStore) {
323
- const dataStore = useDataStore();
324
- if (typeof err === 'string') showToaster('error', err);
321
+ console.error('[ErrorHandler]', err);
322
+
323
+ try {
324
+ if (typeof err === 'string') {
325
+ showToaster('error', err, 6000);
326
+ return false;
327
+ }
328
+
325
329
  if (err instanceof AxiosError) {
326
- if ('response' in err && err.response && err.response.data) {
327
- if (err.response.data === Object(err.response.data) && 'errors' in err.response.data && 'title' in err.response.data && 'traceId' in err.response.data) {
328
- Object.entries(err.response.data.errors).forEach(([field, errors]) => {
329
- showToaster('error', `Поле: ${field}. Ошибка: ${Array.isArray(errors) ? errors.join(', ') : errors}`, 10000);
330
- });
331
- } else {
332
- showToaster('error', errorText ? errorText : err.response.data, 10000);
330
+ const response = err.response;
331
+ if (!response) {
332
+ const message =
333
+ err.code === 'ECONNABORTED'
334
+ ? 'Время ожидания истекло'
335
+ : err.code === 'ENOTFOUND'
336
+ ? 'Сервер недоступен'
337
+ : err.code === 'ERR_NETWORK'
338
+ ? 'Ошибка сети'
339
+ : errorText || err.message || 'Произошла ошибка при выполнении запроса';
340
+ showToaster('error', message, 6000);
341
+ return false;
342
+ }
343
+
344
+ const responseData = response.data as unknown;
345
+
346
+ if (responseData instanceof ArrayBuffer) {
347
+ const decoded = new TextDecoder('utf-8').decode(new Uint8Array(responseData)).trim();
348
+ showToaster('error', decoded || errorText || `Ошибка: ${response.status} ${response.statusText}`, 10000);
349
+ return false;
350
+ }
351
+
352
+ if (typeof responseData === 'string') {
353
+ showToaster('error', responseData || errorText || `Ошибка: ${response.status} ${response.statusText}`, 10000);
354
+ return false;
355
+ }
356
+
357
+ if (
358
+ typeof responseData === 'object' &&
359
+ responseData !== null &&
360
+ 'errors' in responseData &&
361
+ 'title' in responseData &&
362
+ 'traceId' in responseData &&
363
+ typeof (responseData as { errors?: unknown }).errors === 'object'
364
+ ) {
365
+ Object.entries((responseData as { errors: Record<string, unknown> }).errors).forEach(([field, errors]) => {
366
+ const errorMessage = Array.isArray(errors) ? errors.join(', ') : String(errors);
367
+ showToaster('error', `Поле: ${field}. Ошибка: ${errorMessage}`, 10000);
368
+ });
369
+ return false;
370
+ }
371
+
372
+ if (typeof responseData === 'object' && responseData !== null && 'message' in responseData) {
373
+ const message = String((responseData as { message?: unknown }).message || '').trim();
374
+ if (message) {
375
+ showToaster('error', message, 6000);
376
+ return false;
333
377
  }
334
378
  }
379
+
380
+ if (
381
+ typeof responseData === 'object' &&
382
+ responseData !== null &&
383
+ 'error' in responseData &&
384
+ typeof (responseData as { error?: unknown }).error === 'object' &&
385
+ (responseData as { error?: unknown }).error !== null
386
+ ) {
387
+ const error = (responseData as { error: { message?: unknown } }).error;
388
+ if ('message' in error && typeof error.message === 'string') {
389
+ showToaster('error', error.message, 6000);
390
+ return false;
391
+ }
392
+ }
393
+
394
+ showToaster('error', errorText || `Ошибка: ${response.status} ${response.statusText}`, 6000);
395
+ return false;
396
+ }
397
+
398
+ if (err instanceof Error) {
399
+ showToaster('error', errorText || err.message, 6000);
400
+ return false;
335
401
  }
402
+
403
+ showToaster('error', errorText || 'Произошла неизвестная ошибка', 6000);
404
+ return false;
405
+ } catch (handlerErr) {
406
+ console.error('[ErrorHandler] Ошибка при обработке ошибки:', handlerErr);
407
+ showToaster('error', 'Ошибка при обработке запроса', 6000);
408
+ return false;
336
409
  }
337
- return false;
338
410
  };
339
411
 
340
412
  export const policyholderToBeneficialOwner = (isPolicyholderBeneficialOwner: boolean, policyholder?: PolicyholderClass) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hl-core",
3
- "version": "0.0.10-beta.76",
3
+ "version": "0.0.10-beta.78",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "nuxt.config.ts",
@@ -1078,7 +1078,7 @@ export const useDataStore = defineStore('data', {
1078
1078
  }
1079
1079
  this.isButtonsLoading = false;
1080
1080
  },
1081
- async generatePDFDocument(name: string, code: string, format: 'pdf' | 'doc' = 'pdf', open: boolean = false) {
1081
+ async generatePDFDocument(name: string, code: string, format: 'pdf' | 'docx' = 'pdf', open: boolean = false) {
1082
1082
  const dictionariesStore = useDictionariesStore();
1083
1083
  try {
1084
1084
  this.isButtonsLoading = true;
@@ -1088,7 +1088,13 @@ export const useDataStore = defineStore('data', {
1088
1088
  name: name,
1089
1089
  format: format,
1090
1090
  };
1091
- const response: any = await this.api.generatePdfDocument(data);
1091
+ let response: any;
1092
+ if (format === 'pdf') {
1093
+ response = await this.api.generatePdfDocument(data);
1094
+ } else {
1095
+ response = await this.api.generateDocDocument(data);
1096
+ }
1097
+
1092
1098
  const blob = new Blob([response], {
1093
1099
  type: format === 'pdf' ? `application/pdf` : `application/vnd.openxmlformats-officedocument.wordprocessingml.document`,
1094
1100
  });
@@ -72,7 +72,7 @@ export const useFormStore = defineStore('forms', {
72
72
  }
73
73
  });
74
74
  } else {
75
- await this.api.file.getDoc(file.id).then((response: any) => {
75
+ await this.api.file.getDoc(file.id).then((response: any) => {
76
76
  if (!['pdf', 'docx'].includes(fileType)) {
77
77
  const blob = new Blob([response], { type: `image/${fileType}` });
78
78
  const url = window.URL.createObjectURL(blob);