v1.2.10 - 统计页筛选优化,全量数据筛选

This commit is contained in:
Admin 2026-03-22 23:39:03 +08:00
parent 51834f4498
commit ad1adfb811
2 changed files with 15 additions and 2 deletions

View File

@ -15,6 +15,7 @@ export default function List() {
const [key, setKey] = useState(0)
const [search, setSearch] = useState('')
const [isAdmin, setIsAdmin] = useState(false)
const [page, setPage] = useState(1)
useEffect(() => {
//
@ -63,7 +64,16 @@ export default function List() {
setLoading(true)
const token = localStorage.getItem('token')
try {
const res = await fetch('/api/collections?limit=100', {
// URL
const params = new URLSearchParams(window.location.hash.split('?')[1] || '')
const urlFilterType = params.get('filter') || ''
const urlFilterValue = params.get('value') ? decodeURIComponent(params.get('value')) : ''
let api = '/api/collections?page=' + page + '&limit=50&sortBy=' + sortField + '&sortOrder=' + sortOrder
if (urlFilterType && urlFilterValue) {
api += '&' + urlFilterType + '=' + encodeURIComponent(urlFilterValue)
}
const res = await fetch(api, {
headers: token ? { 'Authorization': 'Bearer ' + token } : {}
})

View File

@ -88,6 +88,9 @@ export default function Stats() {
gradingCompany: 'gradingCompany',
gradingScore: 'gradingScore',
specialMark: 'specialMark',
numberCategory: 'numberCategory',
gradingCompany: 'gradingCompany',
gradingScore: 'gradingScore',
profitLoss: 'profitLoss'
}
return map[type] || type
@ -159,7 +162,7 @@ export default function Stats() {
<div style={{ background: 'rgba(255,255,255,0.03)', borderRadius: '12px', padding: '16px', marginBottom: '12px' }}>
<div style={{ color: '#fbbf24', fontSize: '14px', fontWeight: 'bold', marginBottom: '12px' }}>{title}</div>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '8px' }}>
{getSortedData(data, type).slice(0, 6).map((item, index) => {
{getSortedData(data, type).map((item, index) => {
const value = item[valueKey]
const label = getLabel(type, item[labelKey] || value)
const color = getColor(type, value)