From dfad5a41c8690349377c708cf3dd1a9b574316bb Mon Sep 17 00:00:00 2001 From: burakovec Date: Mon, 20 Jul 2026 09:56:54 +0300 Subject: [PATCH] =?UTF-8?q?Refactor=20TabPiyangoTalihliListesi.vue=20to=20?= =?UTF-8?q?improve=20file=20upload=20handling=20and=20validation.=20Remove?= =?UTF-8?q?=20unused=20SignalR=20imports,=20enhance=20error=20handling=20f?= =?UTF-8?q?or=20file=20uploads,=20and=20integrate=20dialog=20and=20toast?= =?UTF-8?q?=20notifications=20for=20user=20feedback=20on=20upload=20result?= =?UTF-8?q?s.=20Update=20table=20header=20to=20include=20sorting=20for=20'?= =?UTF-8?q?=C4=B0kramiyesi'.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/TabPiyangoTalihliListesi.vue | 119 ++++++++++++++---- 1 file changed, 92 insertions(+), 27 deletions(-) diff --git a/src/module/cekilisler/components/TabPiyangoTalihliListesi.vue b/src/module/cekilisler/components/TabPiyangoTalihliListesi.vue index f0760df..5ae4e22 100644 --- a/src/module/cekilisler/components/TabPiyangoTalihliListesi.vue +++ b/src/module/cekilisler/components/TabPiyangoTalihliListesi.vue @@ -71,7 +71,6 @@ import { useUsersStore } from '@/stores/usersStore' import PanelWrapper from '@/components/PanelWrapper.vue' import PanelTalihliDocument from '@/module/cekilisler/components/panel/PanelTalihliDocument.vue' - import { connectToHub, onCompleted, onProgress } from '@/module/cekilisler/service/signalrService' const usersStore = useUsersStore() const tableHeader = ref>([ { @@ -111,7 +110,8 @@ style: { width: '20%' } },{ name: 'ikramiye', - title: 'İkramiyesi' + title: 'İkramiyesi', + sort: true },{ name: '', title: 'Talihli', @@ -191,53 +191,118 @@ import { usePiyangoTalihliStore } from '../stores/piyangoTalihliStore' const piyangoTalihliStore = usePiyangoTalihliStore() - import { usePiyangoKatilimciValidationStore } from '../validation/piyangoKatilimciValidationStore' + import { usePiyangoTalihliValidationStore } from '../validation/piyangoTalihliValidationStore' + import { useToastStore } from '@/components/global/toastStore' + import { useDialogStore } from '@/components/global/dialogStore' + + const piyangoTalihliValidationStore = usePiyangoTalihliValidationStore() + const toastStore = useToastStore() + const dialogStore = useDialogStore() + + const escapeHtml = (value: string) => + String(value) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + + const showTalihliUploadDialog = ( + title: string, + mesaj: string, + detaylar: string[] = [] + ) => { + const details = (Array.isArray(detaylar) ? detaylar : []).filter((x) => !!x) + const items = details + .map((x) => `
  • ${escapeHtml(String(x))}
  • `) + .join('') + + // Detay listesi varsa özet içinde aynı satırları tekrar gösterme + let summary = mesaj || '' + if (details.length > 0) { + for (const d of details) { + summary = summary.split(String(d)).join(' ').replace(/\s+/g, ' ').trim() + } + summary = summary.replace(/\.\s*\./g, '.').trim() + if (!summary) { + summary = 'Talihli listesi yüklenemedi. Aşağıdaki satır hatalarını kontrol ediniz.' + } + } + + const contentHtml = ` +

    ${escapeHtml(summary)}

    + ${ + items + ? `` + : '' + } + ` + + dialogStore.CreateDialog({ + id: 'talihli-upload-result', + title, + contentHtml, + closeText: 'Tamam', + showClose: true + }) + } - const piyangoKatilimciValidationStore = usePiyangoKatilimciValidationStore() const AddNewDocument = () => { dataStore.panelData = { title: '', file: '' } + piyangoTalihliStore.RestoreFileFormData() talihliFilePanel.value = true } const FileUpload = async () => { - // const connectionId = await connectToHub() + if (!piyangoTalihliValidationStore.FileFormCheck()) { + return + } - // Progress modal'ı aç uploadProgressValue.value = 0 uploadProgressPanel.value = true - // onProgress((data) => { - // uploadProgressValue.value = data.Percent - // console.log('Progress:', data.Percent) - // }) - // - // onCompleted((data) => { - // console.log('Tamamlandı:', data) - // uploadProgressPanel.value = false - // refreshList.value = true - // talihliFilePanel.value = false - // }) - const formData = new FormData() formData.append('file', piyangoTalihliStore.piyangoTalihliFileFormData.excelFile) - console.log( dataStore.panelData) const response = await dataStore.dataPost( `Katilimci/talihli-yukle/${piyangoStore.selectedLottery}`, { data: formData, - headers: { 'Content-Type': 'multipart/form-data' } + headers: { 'Content-Type': 'multipart/form-data' }, + skipErrorForStatuses: [400] } ) - if (response.data !== 'errorfalse') { - uploadProgressPanel.value = false - refreshList.value = true - talihliFilePanel.value = false - } else { - // Hata olursa paneli kapat - uploadProgressPanel.value = false + uploadProgressPanel.value = false + + if (response?._error && response.status === 400) { + const errData = response.data || {} + const hata = + typeof errData === 'string' + ? errData + : errData.hata || errData.Hata || 'Talihli listesi yüklenemedi.' + const detaylar = errData.detaylar || errData.Detaylar || [] + showTalihliUploadDialog('Talihli Yükleme Hatası', hata, detaylar) + return } + + if (response === 'errorfalse') { + showTalihliUploadDialog( + 'Talihli Yükleme Hatası', + 'Talihli listesi yüklenirken bir hata oluştu. Lütfen dosyayı kontrol edip tekrar deneyiniz.' + ) + return + } + + const mesaj = response?.Mesaj || response?.mesaj || 'Talihli listesi yüklendi.' + const detaylar = response?.Detaylar || response?.detaylar || [] + if (Array.isArray(detaylar) && detaylar.length > 0) { + showTalihliUploadDialog('Talihli Yükleme Uyarıları', mesaj, detaylar) + } else { + toastStore.AddToast(mesaj, 'ok', 5000) + } + + refreshList.value = true + talihliFilePanel.value = false }