Fix product performance grouped JSON build
This commit is contained in:
@@ -40,6 +40,14 @@
|
|||||||
:loading="loading"
|
:loading="loading"
|
||||||
@click="fetchRows"
|
@click="fetchRows"
|
||||||
/>
|
/>
|
||||||
|
<q-btn
|
||||||
|
label="Excel'e Aktar"
|
||||||
|
icon="download"
|
||||||
|
color="primary"
|
||||||
|
outline
|
||||||
|
:disable="loading || rows.length === 0"
|
||||||
|
@click="exportVisibleRows"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -374,6 +382,38 @@ function clearFilters () {
|
|||||||
fetchRows()
|
fetchRows()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeExcelCsvCell (value) {
|
||||||
|
let text = String(value ?? '')
|
||||||
|
// Prevent spreadsheet applications from evaluating data as a formula.
|
||||||
|
if (/^[=+\-@]/.test(text)) text = `'${text}`
|
||||||
|
return `"${text.replace(/"/g, '""')}"`
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportVisibleRows () {
|
||||||
|
const visibleRows = Array.isArray(rows.value) ? rows.value : []
|
||||||
|
if (visibleRows.length === 0) return
|
||||||
|
|
||||||
|
const exportColumns = columns.filter(col => col.name !== 'open')
|
||||||
|
const csvLines = [
|
||||||
|
exportColumns.map(col => escapeExcelCsvCell(col.label)).join(';'),
|
||||||
|
...visibleRows.map(row => exportColumns.map(col => {
|
||||||
|
const rawValue = typeof col.field === 'function' ? col.field(row) : row?.[col.field]
|
||||||
|
const displayValue = typeof col.format === 'function' ? col.format(rawValue, row) : rawValue
|
||||||
|
return escapeExcelCsvCell(displayValue)
|
||||||
|
}).join(';'))
|
||||||
|
]
|
||||||
|
|
||||||
|
const blob = new Blob([`\uFEFF${csvLines.join('\r\n')}`], { type: 'text/csv;charset=utf-8;' })
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = `mevcut_maliyetli_urunler_${new Date().toISOString().slice(0, 10)}.csv`
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
link.remove()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
}
|
||||||
|
|
||||||
function openRow (row) {
|
function openRow (row) {
|
||||||
const urunKodu = String(row?.UrunKodu || '').trim()
|
const urunKodu = String(row?.UrunKodu || '').trim()
|
||||||
if (!urunKodu) return
|
if (!urunKodu) return
|
||||||
|
|||||||
@@ -49,6 +49,14 @@
|
|||||||
:loading="loading"
|
:loading="loading"
|
||||||
@click="fetchRows"
|
@click="fetchRows"
|
||||||
/>
|
/>
|
||||||
|
<q-btn
|
||||||
|
label="Excel'e Aktar"
|
||||||
|
icon="download"
|
||||||
|
color="primary"
|
||||||
|
outline
|
||||||
|
:disable="loading || rows.length === 0"
|
||||||
|
@click="exportVisibleRows"
|
||||||
|
/>
|
||||||
<div class="npc-missing-count text-caption text-grey-7">
|
<div class="npc-missing-count text-caption text-grey-7">
|
||||||
Maliyeti Girilmemis Satir Sayisi: <b>{{ missingCostRowCount }}</b>
|
Maliyeti Girilmemis Satir Sayisi: <b>{{ missingCostRowCount }}</b>
|
||||||
</div>
|
</div>
|
||||||
@@ -461,6 +469,41 @@ function clearFilters () {
|
|||||||
fetchRows()
|
fetchRows()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeExcelCsvCell (value) {
|
||||||
|
let text = String(value ?? '')
|
||||||
|
// Prevent spreadsheet applications from evaluating data as a formula.
|
||||||
|
if (/^[=+\-@]/.test(text)) text = `'${text}`
|
||||||
|
return `"${text.replace(/"/g, '""')}"`
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportVisibleRows () {
|
||||||
|
const visibleRows = Array.isArray(rows.value) ? rows.value : []
|
||||||
|
if (visibleRows.length === 0) {
|
||||||
|
$q.notify({ type: 'warning', message: 'Excel aktarimi icin ekranda satir bulunamadi.', position: 'top-right' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const exportColumns = columns.filter(col => col.name !== 'open')
|
||||||
|
const csvLines = [
|
||||||
|
exportColumns.map(col => escapeExcelCsvCell(col.label)).join(';'),
|
||||||
|
...visibleRows.map(row => exportColumns.map(col => {
|
||||||
|
const rawValue = typeof col.field === 'function' ? col.field(row) : row?.[col.field]
|
||||||
|
const displayValue = typeof col.format === 'function' ? col.format(rawValue, row) : rawValue
|
||||||
|
return escapeExcelCsvCell(displayValue)
|
||||||
|
}).join(';'))
|
||||||
|
]
|
||||||
|
|
||||||
|
const blob = new Blob([`\uFEFF${csvLines.join('\r\n')}`], { type: 'text/csv;charset=utf-8;' })
|
||||||
|
const url = URL.createObjectURL(blob)
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.download = `maliyeti_olmayan_urunler_${new Date().toISOString().slice(0, 10)}.csv`
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
link.remove()
|
||||||
|
URL.revokeObjectURL(url)
|
||||||
|
}
|
||||||
|
|
||||||
function openRow (row) {
|
function openRow (row) {
|
||||||
const productCode = String(row?.sMModelKodu || '').trim()
|
const productCode = String(row?.sMModelKodu || '').trim()
|
||||||
const recipeCode = String(row?.sKodu || '').trim()
|
const recipeCode = String(row?.sKodu || '').trim()
|
||||||
|
|||||||
Reference in New Issue
Block a user