feat(platform-web): summarize vehicle list results
This commit is contained in:
@@ -33,6 +33,17 @@ export function Vehicles({ onOpenVehicle, initialFilters = {} }: { onOpenVehicle
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [filters, setFilters] = useState<Record<string, string>>(initialFilters);
|
||||
const [pagination, setPagination] = useState({ currentPage: 1, pageSize: 20, total: 0 });
|
||||
const resultSummary = useMemo(() => {
|
||||
const onlineRows = rows.filter((row) => row.online).length;
|
||||
const multiSourceRows = rows.filter((row) => row.sourceCount > 1).length;
|
||||
const unboundRows = rows.filter((row) => row.bindingStatus !== 'bound').length;
|
||||
return [
|
||||
{ label: '过滤车辆', value: pagination.total.toLocaleString() },
|
||||
{ label: '本页在线', value: onlineRows.toLocaleString() },
|
||||
{ label: '本页多源', value: multiSourceRows.toLocaleString() },
|
||||
{ label: '本页待绑定', value: unboundRows.toLocaleString() }
|
||||
];
|
||||
}, [pagination.total, rows]);
|
||||
|
||||
const load = (values: Record<string, string> = filters, page = pagination.currentPage, pageSize = pagination.pageSize) => {
|
||||
setLoading(true);
|
||||
@@ -131,6 +142,16 @@ export function Vehicles({ onOpenVehicle, initialFilters = {} }: { onOpenVehicle
|
||||
</Space>
|
||||
</Form>
|
||||
</Card>
|
||||
<Card bordered title="当前车辆结果" style={{ marginTop: 16 }}>
|
||||
<div className="vp-result-summary-grid">
|
||||
{resultSummary.map((item) => (
|
||||
<div key={item.label} className="vp-result-summary-item">
|
||||
<div className="vp-result-summary-value">{item.value}</div>
|
||||
<div className="vp-result-summary-label">{item.label}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
<Card bordered style={{ marginTop: 16 }}>
|
||||
{rows.length === 0 && !loading ? (
|
||||
<DataEmpty />
|
||||
|
||||
Reference in New Issue
Block a user