diff --git a/src/module/site-yonetimi/views/PopupListe.vue b/src/module/site-yonetimi/views/PopupListe.vue index c5a2c39..15fb7a1 100644 --- a/src/module/site-yonetimi/views/PopupListe.vue +++ b/src/module/site-yonetimi/views/PopupListe.vue @@ -9,7 +9,7 @@ icon="sitemanagement" title="Popup Listesi" listText="Popup" - :tableData="popups" + :tableData="[]" apiText="Popup Listesi" apiList="Popup" v-model:refresh="refresh" @@ -54,11 +54,8 @@ import { ref, computed } from 'vue' import AdminLayout from '@/layouts/AdminLayout.vue' import { Breadcrumb } from '@/components/global' - import router from '@/router' import { useDataStore } from '@/stores/dataStore' import PanelWrapper from '@/components/PanelWrapper.vue' - import { useGlobalStore } from '@/stores/globalStore' - const globalStore = useGlobalStore() import { useDialogStore } from '@/components/global/dialogStore' const dialogStore = useDialogStore() @@ -74,32 +71,43 @@ const refresh = ref(false) const panelPopup = ref>({}) - const popups = ref[]>([]) + + const rowToPanelPopup = (row: Record) => ({ + id: row.id ?? row.Id, + baslik: row.baslik ?? row.Baslik ?? '', + resimUrl: row.resimUrl ?? row.ResimUrl ?? '', + url: row.url ?? row.Url ?? '', + durum: row.durum ?? row.Durum ?? false + }) const tableHeader = ref[]>([ { name: 'baslik', title: 'Başlık', - sort: true + sort: true, + compute: (v: Record) => v.baslik ?? v.Baslik }, { name: 'resimUrl', title: 'Resim Url', computeHtml: (v: Record) => { - if (v.resimUrl !== null && v.resimUrl !== undefined) { - return `` + const src = v.resimUrl ?? v.ResimUrl + if (src !== null && src !== undefined && src !== '') { + return `` } } }, { name: 'url', - title: 'Url' + title: 'Url', + compute: (v: Record) => v.url ?? v.Url }, { name: 'durum', title: 'Durum', computeHtml: (v: Record): string => { - if (v.durum) { + const durum = v.durum ?? v.Durum + if (durum) { return ` Aktif ` @@ -111,6 +119,7 @@ ]) const DeleteRowPop = (data: Record, i: number) => { + const id = data.id ?? data.Id dialogStore.CreateDialog({ title: 'Popup Sil', id: 'deletepop', @@ -120,7 +129,7 @@ { label: 'Popup Sil', type: 'alert', - function: () => DeleteRow(data.id) + function: () => DeleteRow(id) } ] }) @@ -154,9 +163,6 @@ return URL.createObjectURL(panelPopup.value.resimUrl) }) - const OpenMenu = (row: any) => { - router.push('slider-yonetimi/' + row.id) - } const addAction = async () => { isUpdate.value = false panelPopup.value = { @@ -168,24 +174,24 @@ panel.value = true } const updateAction = (row: any) => { - Object.assign(panelPopup.value,row) + panelPopup.value = rowToPanelPopup(row) panel.value = true isUpdate.value = true } const save = async () => { if (isUpdate.value) { + const id = panelPopup.value.id ?? panelPopup.value.Id const formData = new FormData() - formData.append('Baslik', panelPopup.value.baslik) - formData.append('Durum', panelPopup.value.durum) - formData.append('Url', panelPopup.value.url) + formData.append('Baslik', panelPopup.value.baslik ?? '') + formData.append('Durum', String(panelPopup.value.durum ?? panelPopup.value.Durum ?? false)) + formData.append('Url', panelPopup.value.url ?? '') if (panelPopup.value.resimUrl instanceof File) { formData.append('ResimUrl', panelPopup.value.resimUrl) } - let update: any = dataStore.dataPut('Popup/' + panelPopup.value.id, { - data: formData, - headers: { 'Content-Type': 'multipart/form-data' } + let update: any = await dataStore.dataPut('Popup/' + id, { + data: formData }) if (update !== 'errorfalse') { panel.value = false @@ -194,8 +200,7 @@ } } else { let add = await dataStore.dataPost('Popup', { - data: panelPopup.value, - headers: { 'Content-Type': 'multipart/form-data' } + data: panelPopup.value }) if (add !== 'errorfalse') { panel.value = false