fix(analytics): 对齐质量维度布局与封号历史折叠

统一维度提示与表格间距,取消无数据时的局部滚动;风控封号历史复用运营看板折叠样式。开发环境浏览器回归、875 项单测、ESLint 和 Prettier 均通过。
This commit is contained in:
zhanjunhao
2026-11-20 16:03:20 +08:00
parent 72e7fe1072
commit 461f0c577a
4 changed files with 73 additions and 11 deletions
+36 -8
View File
@@ -1,6 +1,7 @@
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Select, Table, TabPane, Tabs, Tooltip } from '@/components/ui';
import { Layers } from 'lucide-react';
import { useIsMobile } from '@/hooks/common/useIsMobile';
import {
ORDER_OPTIONS,
ORG_DIMS,
@@ -27,6 +28,8 @@ export const RateBar = ({ value }) => (
/** 维度分布:每行可点击,把该维度值加入筛选(下钻) */
const QualityBreakdown = ({ quality, t }) => {
const { scope, get, params, setFilters } = quality;
const isPlatform = scope !== 'org';
const isMobile = useIsMobile();
const dims = scope === 'org' ? ORG_DIMS : PLATFORM_DIMS;
const [dim, setDim] = useState('model');
const [orderBy, setOrderBy] = useState('total');
@@ -171,6 +174,9 @@ const QualityBreakdown = ({ quality, t }) => {
setFilters({ [dimSpec.filterKey]: row.key });
};
const rows = data?.rows || [];
const isPlatformEmpty = isPlatform && rows.length === 0;
return (
<div className='quality-card'>
<div className='quality-card-head'>
@@ -189,7 +195,9 @@ const QualityBreakdown = ({ quality, t }) => {
onChange={setOrderBy}
/>
</div>
<div className='quality-card-body quality-nested-tabs'>
<div
className={`quality-card-body quality-nested-tabs${isPlatform ? ' quality-breakdown-body' : ''}`}
>
<Tabs type='button' size='small' activeKey={dim} onChange={setDim}>
{dims.map((d) => (
<TabPane key={d.value} itemKey={d.value} tab={t(d.label)} />
@@ -199,17 +207,37 @@ const QualityBreakdown = ({ quality, t }) => {
<QualityMetaNotice meta={data.meta} scope={scope} t={t} />
)}
{error ? (
<div className='quality-empty'>{qualityErrorText(t, error)}</div>
<div className={isPlatform ? 'quality-breakdown-result' : undefined}>
<div className='quality-empty'>{qualityErrorText(t, error)}</div>
</div>
) : (
<div className='overflow-x-auto app-scrollbar mt-2'>
<div
className={
isPlatform
? 'quality-breakdown-result'
: 'overflow-x-auto app-scrollbar mt-2'
}
>
<Table
className={
isPlatformEmpty ? 'quality-breakdown-empty' : undefined
}
size='small'
rowKey={(row) => `${row.key}|${row.key2 || ''}`}
loading={loading}
columns={columns}
dataSource={data?.rows || []}
columns={
isPlatformEmpty
? (isMobile ? columns.slice(0, 1) : columns).map(
(column) => ({
...column,
width: undefined,
}),
)
: columns
}
dataSource={rows}
pagination={false}
scroll={{ x: 960 }}
scroll={{ x: isPlatformEmpty ? undefined : 960 }}
onRow={(row) =>
canDrill(row)
? {
@@ -224,11 +252,11 @@ const QualityBreakdown = ({ quality, t }) => {
}
empty={<div className='quality-empty'>{t('暂无数据')}</div>}
/>
{data && data.total_rows > (data.rows || []).length && (
{data && data.total_rows > rows.length && (
<div className='mt-2 text-xs text-[var(--text-secondary)]'>
{t('共 {{total}} 项,仅展示排序后的前 {{shown}} 项', {
total: data.total_rows,
shown: (data.rows || []).length,
shown: rows.length,
})}
</div>
)}