excel pdf
This commit is contained in:
@ -297,18 +297,47 @@
|
||||
GetLocalData()
|
||||
}
|
||||
const GetLocalData = async () => {
|
||||
console.log("GetLocalData",selectedExport.value)
|
||||
if (selectedExport.value !== null) {
|
||||
const exportUrl =
|
||||
axios.defaults.baseURL + dataStore.apiBase + props.apiList + '?isPdf=true'
|
||||
|
||||
const link = document.createElement('a')
|
||||
link.href = exportUrl
|
||||
document.body.appendChild(link)
|
||||
link.dispatchEvent(
|
||||
new MouseEvent('click', { bubbles: true, cancelable: true, view: window })
|
||||
)
|
||||
link.remove()
|
||||
window.URL.revokeObjectURL(link.href)
|
||||
let exportUrl = ''
|
||||
let fileType = ''
|
||||
let fileName = ''
|
||||
|
||||
// Export tipine göre URL ve dosya ayarları
|
||||
if (selectedExport.value === 1) {
|
||||
// PDF
|
||||
exportUrl = axios.defaults.baseURL + dataStore.apiBase + props.apiList + '/Pdf'
|
||||
fileType = 'application/pdf'
|
||||
fileName = 'export.pdf'
|
||||
} else if (selectedExport.value === 2) {
|
||||
// Excel
|
||||
exportUrl = axios.defaults.baseURL + dataStore.apiBase + props.apiList + '/Excel'
|
||||
fileType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
fileName = 'export.xlsx'
|
||||
}
|
||||
|
||||
console.log("dataStore",dataStore)
|
||||
|
||||
// Axios ile dosya indirme - interceptor otomatik olarak token ekleyecek
|
||||
try {
|
||||
const response = await axios.get(exportUrl, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
|
||||
const blob = new Blob([response.data], { type: fileType })
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = fileName
|
||||
document.body.appendChild(link)
|
||||
link.dispatchEvent(
|
||||
new MouseEvent('click', { bubbles: true, cancelable: true, view: window })
|
||||
)
|
||||
link.remove()
|
||||
window.URL.revokeObjectURL(url)
|
||||
} catch (error) {
|
||||
console.error('Export error:', error)
|
||||
}
|
||||
|
||||
selectedExport.value = null
|
||||
exportPanel.value = false
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-content-item" v-if="showExport">
|
||||
<!-- <div class="panel-content-item" v-if="showExport">
|
||||
<div class="button-c button-icon button-export" @click="SelectExport(3)">
|
||||
<i class="ico-c">
|
||||
<svg>
|
||||
@ -31,7 +31,7 @@
|
||||
</i>
|
||||
<span class="panel-date">CSV</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@ -45,7 +45,7 @@
|
||||
const emit = defineEmits(['update:selectedExport'])
|
||||
|
||||
const selected = ref<number>(0)
|
||||
const showExport = ref<boolean>(false)
|
||||
const showExport = ref<boolean>(true)
|
||||
|
||||
const SelectExport = (exp: number) => {
|
||||
selected.value = exp
|
||||
|
||||
Reference in New Issue
Block a user