全局统计、按价格排序

This commit is contained in:
甲辰生产 2026-04-11 20:47:15 +08:00
parent 615be9805b
commit 36527d033f
1 changed files with 21 additions and 9 deletions

View File

@ -496,10 +496,6 @@ export default function News() {
else if (serial.startsWith('J1')) version = '马钞'
else if (serial.startsWith('J3')) version = '蛇钞'
if (version !== dealVersion) return false
if (dealDate) {
const itemDate = item.deal_date || ''
if (!itemDate.startsWith(dealDate)) return false
}
return true
})
@ -552,10 +548,25 @@ export default function News() {
</tr>
</thead>
<tbody>
{categories.map(cat => {
const rowData = packagings.map(pkg => calcAvg(pkg, cat))
const hasData = rowData.some(d => d !== null)
if (!hasData) return null
{(() => {
//
const catAvg = categories.map(cat => {
const prices = []
packagings.forEach(pkg => {
const d = calcAvg(pkg, cat)
if (d) prices.push(d.avg)
})
const avg = prices.length > 0 ? Math.round(prices.reduce((a,b) => a+b, 0) / prices.length) : 0
return { cat, avg }
}).filter(c => c.avg > 0)
//
catAvg.sort((a, b) => a.avg - b.avg)
const sortedCats = catAvg.map(c => c.cat)
return sortedCats.map(cat => {
const rowData = packagings.map(pkg => calcAvg(pkg, cat))
const hasData = rowData.some(d => d !== null)
if (!hasData) return null
return (
<tr key={cat}>
<td style={{ padding: '8px', color: '#fbbf24', fontWeight: '500', borderBottom: '1px solid rgba(255,255,255,0.05)' }}>{cat}</td>
@ -572,7 +583,8 @@ export default function News() {
))}
</tr>
)
})}
})
})()}
</tbody>
</table>
</div>