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