Fix product performance grouped JSON build
This commit is contained in:
@@ -465,19 +465,19 @@
|
||||
<div class="sub-left">
|
||||
<span class="pcd-sub-title">{{ grp.sAciklama3 || 'TANIMSIZ' }}</span>
|
||||
<span v-if="normalizeGroupName(grp.sAciklama3) === 'FABRIC'" class="pcd-sub-mt-qty">
|
||||
Toplam Miktar: {{ formatBarQuantity(resolveGroupQuantity(grp, gi)) }} MT
|
||||
Toplam Miktar: {{ formatBarQuantity(resolveGroupQuantity(grp)) }} MT
|
||||
</span>
|
||||
</div>
|
||||
<div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)">
|
||||
<span class="pcd-group-total-text">
|
||||
Grup Toplamı TRY: {{ formatBarMoney(resolveGroupTRYTutar(grp, gi, groupTotalsRevision)) }}
|
||||
Grup Toplamı TRY: {{ formatBarMoney(resolveGroupTRYTutar(gi, groupTotalsRevision)) }}
|
||||
<span class="pcd-group-total-divider">|</span>
|
||||
USD: {{ formatBarMoney(resolveGroupUSDTutar(grp, gi, groupTotalsRevision)) }}
|
||||
USD: {{ formatBarMoney(resolveGroupUSDTutar(gi, groupTotalsRevision)) }}
|
||||
</span>
|
||||
<span class="pcd-group-debug">
|
||||
Tanı: {{ resolveGroupIncludedCount(grp, gi) }}/{{ rowsForGroupTotal(grp, gi).length }} kalem
|
||||
Tanı: {{ resolveRenderedGroupIncludedCount(gi) }}/{{ resolveRenderedGroupRowCount(gi) }} kalem
|
||||
<span>|</span>
|
||||
Ham TRY: {{ formatBarMoney(resolveGroupRawTRYTutar(grp, gi)) }}
|
||||
Ham TRY: {{ formatBarMoney(resolveGroupTRYTutar(gi, groupTotalsRevision)) }}
|
||||
</span>
|
||||
<q-icon
|
||||
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
|
||||
@@ -489,7 +489,6 @@
|
||||
|
||||
<q-table
|
||||
v-if="isGroupOpen(grp, gi)"
|
||||
:ref="el => setGroupTableRef(gi, el)"
|
||||
class="pcd-detail-table"
|
||||
dense
|
||||
flat
|
||||
@@ -680,6 +679,20 @@
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
<template #body-cell-lTutar="props">
|
||||
<q-td :props="props">
|
||||
{{ formatMoney(props.value) }}
|
||||
<span class="hidden">{{ captureRenderedGroupAmount(gi, grp, props.row, 'try', props.value) }}</span>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
<template #body-cell-usdTutar="props">
|
||||
<q-td :props="props">
|
||||
{{ formatMoney(props.value) }}
|
||||
<span class="hidden">{{ captureRenderedGroupAmount(gi, grp, props.row, 'usd', props.value) }}</span>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
<template #body-cell-sBirim="props">
|
||||
<q-td :props="props">
|
||||
<span>{{ props.value }}</span>
|
||||
@@ -1127,7 +1140,7 @@ const detailLoading = ref(false)
|
||||
const detailError = ref('')
|
||||
const detailGroups = ref([])
|
||||
const groupTotalsRevision = ref(0)
|
||||
const groupTableRefs = ref([])
|
||||
const renderedGroupAmounts = ref({})
|
||||
const detailHeader = ref(null)
|
||||
const costDate = ref('')
|
||||
const exchangeRates = ref(createEmptyExchangeRates())
|
||||
@@ -2911,55 +2924,68 @@ function shouldIncludeRowInGroupTotal (grp, row) {
|
||||
return normalizedValue !== '0' && normalizedValue !== 'false' && normalizedValue !== 'hayir'
|
||||
}
|
||||
|
||||
function setGroupTableRef (groupIndex, tableRef) {
|
||||
groupTableRefs.value[groupIndex] = tableRef || null
|
||||
const pendingRenderedAmounts = new Map()
|
||||
let renderedAmountFlushScheduled = false
|
||||
|
||||
function captureRenderedGroupAmount (groupIndex, grp, row, currency, value) {
|
||||
const rowKey = String(row?.__rowKey || row?.nOnMLDetNo || row?.sKodu || '').trim()
|
||||
const cacheKey = `${groupIndex}:${rowKey}`
|
||||
const previousPending = pendingRenderedAmounts.get(cacheKey) || {}
|
||||
pendingRenderedAmounts.set(cacheKey, {
|
||||
...previousPending,
|
||||
groupIndex,
|
||||
rowKey,
|
||||
included: shouldIncludeRowInGroupTotal(grp, row),
|
||||
[currency]: parseMoneyInput(value)
|
||||
})
|
||||
|
||||
if (!renderedAmountFlushScheduled) {
|
||||
renderedAmountFlushScheduled = true
|
||||
Promise.resolve().then(() => {
|
||||
const next = { ...renderedGroupAmounts.value }
|
||||
let changed = false
|
||||
pendingRenderedAmounts.forEach(entry => {
|
||||
const groupRows = { ...(next[entry.groupIndex] || {}) }
|
||||
const previous = groupRows[entry.rowKey] || {}
|
||||
if (previous.try !== entry.try || previous.usd !== entry.usd || previous.included !== entry.included) {
|
||||
groupRows[entry.rowKey] = { ...previous, ...entry }
|
||||
changed = true
|
||||
}
|
||||
next[entry.groupIndex] = groupRows
|
||||
})
|
||||
pendingRenderedAmounts.clear()
|
||||
renderedAmountFlushScheduled = false
|
||||
if (changed) {
|
||||
renderedGroupAmounts.value = next
|
||||
groupTotalsRevision.value += 1
|
||||
}
|
||||
})
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function rowsForGroupTotal (grp, groupIndex) {
|
||||
const tableRef = groupTableRefs.value[groupIndex]
|
||||
if (tableRef && typeof tableRef.getFilteredSortedRows === 'function') {
|
||||
const renderedRows = tableRef.getFilteredSortedRows()
|
||||
if (Array.isArray(renderedRows)) return renderedRows
|
||||
}
|
||||
return Array.isArray(grp?.items) ? grp.items : []
|
||||
function renderedRowsForGroup (groupIndex) {
|
||||
return Object.values(renderedGroupAmounts.value[groupIndex] || {})
|
||||
}
|
||||
|
||||
function resolveGroupIncludedCount (grp, groupIndex) {
|
||||
return rowsForGroupTotal(grp, groupIndex).filter(row => shouldIncludeRowInGroupTotal(grp, row)).length
|
||||
function resolveRenderedGroupIncludedCount (groupIndex) {
|
||||
return renderedRowsForGroup(groupIndex).filter(row => row.included).length
|
||||
}
|
||||
|
||||
function resolveGroupRawTRYTutar (grp, groupIndex) {
|
||||
return rowsForGroupTotal(grp, groupIndex).reduce((total, row) => total + parseMoneyInput(row?.lTutar), 0)
|
||||
function resolveRenderedGroupRowCount (groupIndex) {
|
||||
return renderedRowsForGroup(groupIndex).length
|
||||
}
|
||||
|
||||
function resolveGroupRowTRYAmount (row) {
|
||||
const storedAmount = parseMoneyInput(row?.lTutar)
|
||||
if (storedAmount !== 0) return storedAmount
|
||||
const lastValidAmount = parseMoneyInput(row?.__lastValidTRYAmount)
|
||||
return lastValidAmount !== 0 ? lastValidAmount : resolveRowTRYTutar(row)
|
||||
function resolveGroupTRYTutar (groupIndex, _revision) {
|
||||
return renderedRowsForGroup(groupIndex).reduce((total, row) => total + (row.included ? parseMoneyInput(row.try) : 0), 0)
|
||||
}
|
||||
|
||||
function resolveGroupRowUSDAmount (row) {
|
||||
const storedAmount = parseMoneyInput(row?.usdTutar ?? row?.lTutarUSD)
|
||||
if (storedAmount !== 0) return storedAmount
|
||||
const lastValidAmount = parseMoneyInput(row?.__lastValidUSDAmount)
|
||||
return lastValidAmount !== 0 ? lastValidAmount : resolveRowUSDTutar(row)
|
||||
function resolveGroupUSDTutar (groupIndex, _revision) {
|
||||
return renderedRowsForGroup(groupIndex).reduce((total, row) => total + (row.included ? parseMoneyInput(row.usd) : 0), 0)
|
||||
}
|
||||
|
||||
function resolveGroupTRYTutar (grp, groupIndex, _revision) {
|
||||
return rowsForGroupTotal(grp, groupIndex).reduce((total, row) => (
|
||||
total + (shouldIncludeRowInGroupTotal(grp, row) ? resolveGroupRowTRYAmount(row) : 0)
|
||||
), 0)
|
||||
}
|
||||
|
||||
function resolveGroupUSDTutar (grp, groupIndex, _revision) {
|
||||
return rowsForGroupTotal(grp, groupIndex).reduce((total, row) => (
|
||||
total + (shouldIncludeRowInGroupTotal(grp, row) ? resolveGroupRowUSDAmount(row) : 0)
|
||||
), 0)
|
||||
}
|
||||
|
||||
function resolveGroupQuantity (grp, groupIndex) {
|
||||
return rowsForGroupTotal(grp, groupIndex).reduce((total, row) => (
|
||||
function resolveGroupQuantity (grp) {
|
||||
return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => (
|
||||
total + resolveNumericRowQuantity(row)
|
||||
), 0)
|
||||
}
|
||||
@@ -3080,6 +3106,8 @@ async function fetchDetail (options = {}) {
|
||||
detailLoading.value = true
|
||||
detailError.value = ''
|
||||
detailGroups.value = []
|
||||
renderedGroupAmounts.value = {}
|
||||
pendingRenderedAmounts.clear()
|
||||
detailHeader.value = null
|
||||
costDate.value = ''
|
||||
exchangeRates.value = createEmptyExchangeRates()
|
||||
|
||||
Reference in New Issue
Block a user