Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -274,45 +274,57 @@
|
||||
</div>
|
||||
</q-expansion-item>
|
||||
|
||||
<q-dialog v-model="last10WarningDialogOpen" persistent>
|
||||
<q-card style="min-width: 860px; max-width: 92vw;">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Son 10 Ort. Fiyat Sapmalari</div>
|
||||
<q-space />
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
<q-card-section style="max-height: 70vh; overflow: auto;">
|
||||
<q-markup-table dense flat bordered>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">Kod</th>
|
||||
<th class="text-left">Doviz</th>
|
||||
<th class="text-right">Giris</th>
|
||||
<th class="text-right">Ort10</th>
|
||||
<th class="text-right">Sapma %</th>
|
||||
<th class="text-right">Sample</th>
|
||||
<th class="text-left">Tarih Araligi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="w in last10Warnings" :key="w.item_code + '|' + w.currency_code">
|
||||
<td class="text-left">{{ w.item_code }}</td>
|
||||
<td class="text-left">{{ w.currency_code }}</td>
|
||||
<td class="text-right">{{ formatMoney(w.input_price) }}</td>
|
||||
<td class="text-right">{{ formatMoney(w.avg_doc_price) }}</td>
|
||||
<td class="text-right">{{ formatPercent(w.diff_ratio) }}</td>
|
||||
<td class="text-right">{{ w.sample_count }}</td>
|
||||
<td class="text-left">{{ (w.min_invoice_date || '-') + ' / ' + (w.max_invoice_date || '-') }}</td>
|
||||
</tr>
|
||||
<tr v-if="last10Warnings.length === 0">
|
||||
<td colspan="7" class="text-center text-grey-7">Kayit yok</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</q-markup-table>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="last10WarningDialogOpen" persistent>
|
||||
<q-card style="min-width: 860px; max-width: 92vw;">
|
||||
<q-card-section class="row items-center">
|
||||
<div class="text-h6">Son 10 Ort. Fiyat Sapmalari</div>
|
||||
<q-space />
|
||||
<q-btn
|
||||
dense
|
||||
outline
|
||||
color="secondary"
|
||||
icon="download"
|
||||
label="Excel"
|
||||
class="q-mr-sm"
|
||||
:disable="!last10Warnings || last10Warnings.length === 0"
|
||||
@click="downloadLast10WarningsExcel"
|
||||
/>
|
||||
<q-btn icon="close" flat round dense v-close-popup />
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
<q-card-section style="max-height: 70vh; overflow: auto;">
|
||||
<q-markup-table dense flat bordered>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">Kod</th>
|
||||
<th class="text-left">Aciklama</th>
|
||||
<th class="text-left">Doviz</th>
|
||||
<th class="text-right">Giris</th>
|
||||
<th class="text-right">Ort10</th>
|
||||
<th class="text-right">Sapma %</th>
|
||||
<th class="text-right">Sample</th>
|
||||
<th class="text-left">Tarih Araligi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="w in last10Warnings" :key="w.item_code + '|' + w.currency_code">
|
||||
<td class="text-left">{{ w.item_code }}</td>
|
||||
<td class="text-left">{{ w.item_description || '' }}</td>
|
||||
<td class="text-left">{{ w.currency_code }}</td>
|
||||
<td class="text-right">{{ formatMoney(w.input_price) }}</td>
|
||||
<td class="text-right">{{ formatMoney(w.avg_doc_price) }}</td>
|
||||
<td class="text-right">{{ formatPercent(w.diff_ratio) }}</td>
|
||||
<td class="text-right">{{ w.sample_count }}</td>
|
||||
<td class="text-left">{{ (w.min_invoice_date || '-') + ' / ' + (w.max_invoice_date || '-') }}</td>
|
||||
</tr>
|
||||
<tr v-if="last10Warnings.length === 0">
|
||||
<td colspan="8" class="text-center text-grey-7">Kayit yok</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</q-markup-table>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<div v-if="detailHeader && !detailLoading && !headerInfoCollapsed" class="filter-bar pcd-detail-header-bar q-mx-md q-mb-md">
|
||||
<div class="row q-col-gutter-sm">
|
||||
@@ -1149,11 +1161,76 @@ async function refreshTbStokMissingCodes () {
|
||||
missingTbStokCodesMap.value = {}
|
||||
}
|
||||
|
||||
function formatPercent (ratio) {
|
||||
const n = Number(ratio)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return `${(n * 100).toFixed(0)}%`
|
||||
}
|
||||
function formatPercent (ratio) {
|
||||
const n = Number(ratio)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return `${(n * 100).toFixed(0)}%`
|
||||
}
|
||||
|
||||
function downloadLast10WarningsExcel () {
|
||||
const rows = Array.isArray(last10Warnings.value) ? last10Warnings.value : []
|
||||
if (rows.length === 0) return
|
||||
|
||||
// Excel-friendly CSV (UTF-8 with BOM).
|
||||
const header = [
|
||||
'Kod',
|
||||
'Aciklama',
|
||||
'Doviz',
|
||||
'Giris',
|
||||
'Ort10',
|
||||
'SapmaOran',
|
||||
'SapmaYuzde',
|
||||
'Sample',
|
||||
'MinTarih',
|
||||
'MaxTarih'
|
||||
]
|
||||
const lines = [header.join(';')]
|
||||
for (const w of rows) {
|
||||
const code = String(w?.item_code || '').trim()
|
||||
const desc = String(w?.item_description || '').replaceAll('\n', ' ').replaceAll('\r', ' ').trim()
|
||||
const cur = String(w?.currency_code || '').trim()
|
||||
const inP = Number(w?.input_price || 0)
|
||||
const avgP = Number(w?.avg_doc_price || 0)
|
||||
const diff = Number(w?.diff_ratio || 0)
|
||||
const sample = Number(w?.sample_count || 0)
|
||||
const minD = String(w?.min_invoice_date || '').trim()
|
||||
const maxD = String(w?.max_invoice_date || '').trim()
|
||||
|
||||
const safe = (s) => {
|
||||
s = String(s ?? '')
|
||||
if (s.includes(';') || s.includes('\"')) {
|
||||
s = '\"' + s.replaceAll('\"', '\"\"') + '\"'
|
||||
}
|
||||
return s
|
||||
}
|
||||
lines.push([
|
||||
safe(code),
|
||||
safe(desc),
|
||||
safe(cur),
|
||||
String(Number.isFinite(inP) ? inP : 0),
|
||||
String(Number.isFinite(avgP) ? avgP : 0),
|
||||
String(Number.isFinite(diff) ? diff : 0),
|
||||
`${Number.isFinite(diff) ? (diff * 100).toFixed(0) : '0'}%`,
|
||||
String(Number.isFinite(sample) ? sample : 0),
|
||||
safe(minD),
|
||||
safe(maxD)
|
||||
].join(';'))
|
||||
}
|
||||
|
||||
const bom = '\uFEFF'
|
||||
const blob = new Blob([bom + lines.join('\n')], { type: 'text/csv;charset=utf-8;' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
const urun = String(detailHeader.value?.UrunKodu || productCode.value || '').trim()
|
||||
const onml = String(onMLNo.value || '').trim()
|
||||
const date = String(costDate.value || '').trim()
|
||||
a.href = url
|
||||
a.download = `fiyat_uyari_${urun || 'urun'}_${onml || 'onml'}_${date || 'tarih'}.csv`
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
a.remove()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
async function refreshLast10Warnings () {
|
||||
if (!onMLNo.value) {
|
||||
|
||||
Reference in New Issue
Block a user