Fix product performance grouped JSON build

This commit is contained in:
M_Kececi
2026-08-19 01:00:03 +03:00
parent 322bed753f
commit 82ad3783b3
@@ -2836,10 +2836,16 @@ function recalculateDetailRow (row, options = {}) {
} }
function recalculateAllDetailRows () { function recalculateAllDetailRows () {
detailGroups.value = detailGroups.value.map(grp => ({ // Preserve row identity. QTable editors and the computed group totals must
...grp, // observe the exact same reactive row objects. Replacing rows with
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => recalculateDetailRow({ ...row }, { preserveInputs: true })) // `{ ...row }` after the async exchange-rate request left QTable editing an
})) // older object while totals watched the replacement object.
detailGroups.value.forEach(grp => {
const items = Array.isArray(grp?.items) ? grp.items : []
items.forEach(row => {
recalculateDetailRow(row, { preserveInputs: true })
})
})
} }
function resolveRowTRYTutar (row) { function resolveRowTRYTutar (row) {
@@ -3420,25 +3426,23 @@ async function fetchBulkItemPrices () {
} }
let appliedCount = 0 let appliedCount = 0
detailGroups.value = detailGroups.value.map(grp => ({ detailGroups.value.forEach(grp => {
...grp, const items = Array.isArray(grp?.items) ? grp.items : []
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => { items.forEach(row => {
const match = updates.find(update => rowMatchesBulkUpdate(row, update)) const match = updates.find(update => rowMatchesBulkUpdate(row, update))
if (!match) return row if (!match) return
appliedCount += 1 appliedCount += 1
return recalculateDetailRow({ row.inputPrice = match.inputPrice
...row, row.fiyat_girilen = match.fiyat_girilen
inputPrice: match.inputPrice, row.inputPricePrBr = match.inputPricePrBr
fiyat_girilen: match.fiyat_girilen, row.fiyat_doviz = match.fiyat_doviz
inputPricePrBr: match.inputPricePrBr, recalculateDetailRow(row, {
fiyat_doviz: match.fiyat_doviz
}, {
priceType: match.priceType || 'SAF', priceType: match.priceType || 'SAF',
updateState: 'bulk', updateState: 'bulk',
markChanged: true markChanged: true
}) })
}) })
})) })
// Update sub-headers immediately after the bulk response is applied. Do // Update sub-headers immediately after the bulk response is applied. Do
// not wait for the optional previous-cost autofill request below. // not wait for the optional previous-cost autofill request below.
triggerUIUpdate() triggerUIUpdate()
@@ -3481,14 +3485,14 @@ async function fetchBulkItemPrices () {
}) })
let filled = 0 let filled = 0
detailGroups.value = detailGroups.value.map(grp => ({ detailGroups.value.forEach(grp => {
...grp, const items = Array.isArray(grp?.items) ? grp.items : []
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => { items.forEach(row => {
if (!row?.requiredPlaceholder) return row if (!row?.requiredPlaceholder) return
if (isCMGroupName(row?.sAciklama3) || normalizeGroupName(row?.sAciklama3) === 'FABRIC') return row if (isCMGroupName(row?.sAciklama3) || normalizeGroupName(row?.sAciklama3) === 'FABRIC') return
const no = parseInt(String(row?.nHammaddeTuruNo || '').trim() || '0', 10) || 0 const no = parseInt(String(row?.nHammaddeTuruNo || '').trim() || '0', 10) || 0
const hit = byNo[no] const hit = byNo[no]
if (!hit) return row if (!hit) return
const next = { ...row } const next = { ...row }
const hasCode = String(next.sKodu || '').trim() !== '' const hasCode = String(next.sKodu || '').trim() !== ''
@@ -3508,20 +3512,19 @@ async function fetchBulkItemPrices () {
// Only mark if something changed // Only mark if something changed
const changed = (next.sKodu !== row.sKodu) || (next.sAciklama !== row.sAciklama) || (next.inputPrice !== row.inputPrice) || (next.inputPricePrBr !== row.inputPricePrBr) const changed = (next.sKodu !== row.sKodu) || (next.sAciklama !== row.sAciklama) || (next.inputPrice !== row.inputPrice) || (next.inputPricePrBr !== row.inputPricePrBr)
if (!changed) return row if (!changed) return
filled += 1 filled += 1
return recalculateDetailRow({ Object.assign(row, next, {
...next, __autoFilledFromPrev: true,
__autoFilledFromPrev: true
,
__autoFilledFromPrevSameFirma: Boolean(hit?.is_same_firma || hit?.isSameFirma) __autoFilledFromPrevSameFirma: Boolean(hit?.is_same_firma || hit?.isSameFirma)
}, { })
recalculateDetailRow(row, {
priceType: 'PREV', priceType: 'PREV',
updateState: 'autofill', updateState: 'autofill',
markChanged: true markChanged: true
}) })
}) })
})) })
triggerUIUpdate() triggerUIUpdate()
if (filled > 0) { if (filled > 0) {