fix(analytics): 对齐质量维度布局与封号历史折叠
统一维度提示与表格间距,取消无数据时的局部滚动;风控封号历史复用运营看板折叠样式。开发环境浏览器回归、875 项单测、ESLint 和 Prettier 均通过。
This commit is contained in:
@@ -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>
|
||||
)}
|
||||
|
||||
@@ -63,6 +63,32 @@
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.quality-breakdown-body {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
padding-block-start: 12px;
|
||||
}
|
||||
|
||||
.quality-breakdown-body .ant-tabs > .ant-tabs-nav {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.quality-breakdown-result {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.quality-breakdown-empty .ant-table-thead > tr > th {
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
.quality-breakdown-body .ant-tabs .ant-tabs-tab + .ant-tabs-tab {
|
||||
margin-inline-start: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 筛选栏 */
|
||||
.quality-filter-grid {
|
||||
display: grid;
|
||||
|
||||
Reference in New Issue
Block a user