From d0fee1544a36c56d3bfea2977cdf40feaa6c8550 Mon Sep 17 00:00:00 2001 From: lyun Date: Sun, 1 Nov 2026 17:01:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E7=AD=9B=E9=80=89=E5=B0=BA=E5=AF=B8=E5=B9=B6?= =?UTF-8?q?=E5=B9=B3=E6=BB=91=E6=9B=B4=E6=96=B0=E9=92=BB=E5=8F=96=E8=B6=8B?= =?UTF-8?q?=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DESIGN.md | 7 +++++++ web/src/QueryPage.tsx | 29 +++++++++++++++++++++-------- web/src/StageProductPage.tsx | 6 +++--- web/src/stage-product.css | 3 --- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 026de4a..aefef76 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -102,3 +102,10 @@ - 六个查询页桌面端指标卡统一最小高度 96px,避免黑片与亮片页因没有辅助说明而矮一截;保留手机端原有 84px 最小高度。 - 六个查询页和六种主题的卡片高度已实测一致;数据、字号、卡片排列与口径切换保持原有行为。 + +## 2026-11-01:筛选框统一与钻取趋势过渡(本地) + +- 黑片、亮片取消独立的筛选框最小宽度与间距,年份、月份、季度复用其他查询页的尺寸规则;月份统一为两位显示,原查询方式保留。 +- 钻取时保留上次成功的趋势及目标线,新数据返回后使用同一图表实例进行 520ms 更新动画;减少动态效果时直接更新。 +- 旧范围图表在更新或失败时禁止交互;加载失败保留原图并允许重试。已取消的请求不能覆盖后续相同范围的新请求。 +- 本地复现原钻取存在 23 帧空白,修复后三级钻取与六主题均为零空白帧;快速返回重入、失败保留、实际筛选框尺寸及相关检查通过,未发布。 diff --git a/web/src/QueryPage.tsx b/web/src/QueryPage.tsx index 1a8459a..c2c8d7a 100644 --- a/web/src/QueryPage.tsx +++ b/web/src/QueryPage.tsx @@ -321,6 +321,7 @@ export default function QueryPage({ page, onUnauthorized }: { const [dataKey, setDataKey] = useState(''); const [trendData, setTrendData] = useState([]); const [trendDataKey, setTrendDataKey] = useState(''); + const [trendFailure, setTrendFailure] = useState<{ key: string; message: string } | null>(null); const [trendTarget, setTrendTarget] = useState(null); const [trendTargetKey, setTrendTargetKey] = useState(''); const [trendObject, setTrendObject] = useState(''); @@ -491,6 +492,7 @@ export default function QueryPage({ page, onUnauthorized }: { useEffect(() => { if (optionsLoading) return; + setTrendFailure(null); if (useSummaryTrend) { setTrendLoading(false); return; @@ -498,15 +500,15 @@ export default function QueryPage({ page, onUnauthorized }: { const controller = new AbortController(); setTrendLoading(true); api.metrics(trendParams, controller.signal).then(result => { - if (trendKeyRef.current !== trendKey) return; + if (controller.signal.aborted || trendKeyRef.current !== trendKey) return; setTrendData(Array.isArray(result.trend) ? result.trend : []); setTrendDataKey(trendKey); }) .catch(errorValue => { - if (!controller.signal.aborted && !onUnauthorized(errorValue)) message.error(`趋势加载失败:${chooseError(errorValue)}`); + if (!controller.signal.aborted && !onUnauthorized(errorValue)) setTrendFailure({ key: trendKey, message: chooseError(errorValue) }); }).finally(() => { if (!controller.signal.aborted) setTrendLoading(false); }); return () => controller.abort(); - }, [trendKey, useSummaryTrend, queryRevision, onUnauthorized, message, optionsLoading]); + }, [trendKey, useSummaryTrend, queryRevision, onUnauthorized, optionsLoading]); useEffect(() => { let alive = true; @@ -531,6 +533,12 @@ export default function QueryPage({ page, onUnauthorized }: { const currentTrendTarget = trendTargetKey === trendKey ? trendTarget : null; const visibleTrendData = useMemo(() => fullYearTrend(trendDataKey === trendKey ? trendData : [], year, trendGranularity), [trendData, trendDataKey, trendKey, year, trendGranularity]); + const currentTrendError = trendFailure?.key === trendKey ? trendFailure.message : ''; + const trendRefreshing = trendLoading || (useSummaryTrend && queryBusy) || (trendDataKey !== trendKey && !(useSummaryTrend ? currentMetricsError : currentTrendError)); + // 只在当前查询返回后替换画面;钻取等待期间保留上一次趋势和目标线。 + const retainedTrend = useRetainedResult(trendDataKey === trendKey ? { rows: visibleTrendData, target: currentTrendTarget } : null); + const renderedTrendData = retainedTrend?.rows || visibleTrendData; + const renderedTrendTarget = retainedTrend ? retainedTrend.target : currentTrendTarget; const drilledTrendData = useMemo( () => trendDataKey === trendKey ? visibleTrendData : fullYearTrend([], year, 'month'), [trendDataKey, trendKey, visibleTrendData, year], @@ -798,11 +806,12 @@ export default function QueryPage({ page, onUnauthorized }: { {trendMode !== 'data' && setTrendStage(value as Stage)} aria-label="趋势阶段" />} -
+ {currentTrendError && setQueryRevision(value => value + 1)}>重试} />} +
{trendMode === 'data' - ? - : } - {(trendLoading || (useSummaryTrend && queryBusy)) && 正在更新趋势} + ? + : } + {trendRefreshing && 正在更新趋势}
点击期间筛选,再次点击可取消
@@ -1304,6 +1313,7 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP const surface = css.getPropertyValue('--surface').trim() || '#ffffff'; const labels = rows.map(row => row.periodLabel || String(row.month)); const barData = (field: 'qualifiedWeight' | 'scrapWeight') => rows.map(row => ({ + id: String(row.period ?? row.month), value: hasStageRows(row, stage) ? stageValue(row, stage, field, rateBasis) : null, itemStyle: { color: field === 'qualifiedWeight' ? (String(row.period ?? row.month) === selectedPeriod ? bars.selectedQualified : bars.qualified) @@ -1319,7 +1329,10 @@ export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedP })].join('
'); }; const base: echarts.EChartsCoreOption = { - animation: false, + animation: !window.matchMedia('(prefers-reduced-motion: reduce)').matches, + animationDuration: 0, + animationDurationUpdate: 520, + animationEasingUpdate: 'cubicOut', textStyle: { fontFamily, color: ink, fontSize }, grid: { left: 65, right: mode === 'production' ? 67 : 32, top: 70, bottom: 38 }, legend: { type: 'scroll', top: 0, left: 9, right: 9, itemWidth: 14, itemHeight: 7, itemGap: 20, textStyle: { color: ink, fontFamily, fontSize, fontWeight: 500 } }, diff --git a/web/src/StageProductPage.tsx b/web/src/StageProductPage.tsx index 20a5acd..c334629 100644 --- a/web/src/StageProductPage.tsx +++ b/web/src/StageProductPage.tsx @@ -77,9 +77,9 @@ export default function StageProductPage({stage,onUnauthorized}:{stage:Stage;onU {supportError&&void loadSupport()}>重试}/>}
{automaticPeriod.current=false;setPeriod(v as PeriodKind);}}/> - } - {period==='quarter'&& + {period==='month'&&} {select('产业部',department,options?.departments||[],values=>{setDepartment(values);setGroup([]);setProduct([]);})} {select('业务分组',group,groups,values=>{setGroup(values);setProduct([]);})} {select('产品',product,products,setProduct)} diff --git a/web/src/stage-product.css b/web/src/stage-product.css index 31a6923..5534c6b 100644 --- a/web/src/stage-product.css +++ b/web/src/stage-product.css @@ -1,12 +1,9 @@ -.stage-product-page .query-toolbar { gap: 10px; } .stage-source-filters { display: contents; } .stage-source-filters > .ant-select { width: 220px; } .stage-source-filter-row { flex: 1 0 100%; display: grid; grid-template-columns: minmax(120px,180px) 150px minmax(240px,1fr) 32px; align-items: center; gap: 10px; } .stage-source-filter-row > strong { overflow-wrap: anywhere; font-size: var(--font-body); } .stage-source-filter-row > .ant-select { width: 100%; min-width: 0; } .stage-query-pending { flex-basis: 100%; color: var(--muted-ink); font-size: var(--font-control); } -.stage-product-page .query-field > .ant-select { min-width: 110px; } -.stage-product-page .query-primary-field > .ant-select { min-width: 0; } @media(max-width:760px) { .stage-source-filter-row { grid-template-columns: minmax(0,1fr) 140px 32px; } .stage-source-filter-row > .ant-select:nth-of-type(2) { grid-column: 1 / 3; grid-row: 2; }