同步:完善质量分析工作台并更新主题字体
同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。 补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。 统一午夜黑及其他主题的控件细节、中文和业务数字字体。 排除本地业务数据、凭据、预览、发布与验收产物。 验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
+160
-102
@@ -1,5 +1,6 @@
|
||||
import { BusinessValue } from './BusinessValue';
|
||||
import { usePageCache } from './pageCache';
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||
import * as echarts from 'echarts/core';
|
||||
import { BarChart, LineChart } from 'echarts/charts';
|
||||
import { GraphicComponent, GridComponent, LegendComponent, MarkLineComponent, TooltipComponent } from 'echarts/components';
|
||||
@@ -21,7 +22,7 @@ import {
|
||||
Tooltip,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { DownloadOutlined, InfoCircleOutlined, ReloadOutlined, SearchOutlined } from '@ant-design/icons';
|
||||
import { DownloadOutlined, ReloadOutlined, SearchOutlined } from '@ant-design/icons';
|
||||
import { ApiError, api, decodeQueryValueList, encodeQueryValueList } from './api';
|
||||
import type {
|
||||
DefectMetric,
|
||||
@@ -45,10 +46,13 @@ import { previousCompleteMonth, previousCompleteQuarter } from './periodDefaults
|
||||
import { defectWeightRate } from './trendMetrics';
|
||||
import './query-motion.css';
|
||||
import { ExtraQueryFilters } from './ExtraQueryFilters';
|
||||
import { freezeSourceRecordsQuery } from './sourceRecordsContext';
|
||||
import { downloadMetricWorkbook } from './metricWorkbook';
|
||||
|
||||
echarts.use([BarChart, LineChart, GraphicComponent, GridComponent, LegendComponent, MarkLineComponent, TooltipComponent, SVGRenderer]);
|
||||
|
||||
const MONTHS = Array.from({ length: 12 }, (_, index) => `${String(index + 1).padStart(2, '0')}月`);
|
||||
const CHART_FONT_SIZE = 12;
|
||||
const TABLE_PAGE_SIZE = 20;
|
||||
const SUMMARY_PAGE_SIZE = 15;
|
||||
const SUMMARY_PAGE_SIZE_OPTIONS = ['10', '15', '20', '50', '100'];
|
||||
@@ -69,6 +73,10 @@ function rateText(value: number | null | undefined): string {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? `${(value * 100).toFixed(2)}%` : '—';
|
||||
}
|
||||
|
||||
function defectRateLabel(label: string): string {
|
||||
return `${label.replace(/(?:总重量|重量)(?:合计)?$/, '').replace(/率$/, '')}率`;
|
||||
}
|
||||
|
||||
function rateNumber(value: number | null | undefined): number | null {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value * 100 : null;
|
||||
}
|
||||
@@ -203,7 +211,7 @@ function escapeTooltipText(value: string): string {
|
||||
return value.replace(/[&<>"']/g, character => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[character]!);
|
||||
}
|
||||
|
||||
function queryFromLocation(search = window.location.search): Partial<QueryParams> {
|
||||
export function queryFromLocation(search = window.location.search): Partial<QueryParams> {
|
||||
const context = new URLSearchParams(search).get('context');
|
||||
if (!context) return {};
|
||||
try {
|
||||
@@ -294,6 +302,7 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
const [search, setSearch] = useState(initialQuery.productSearch || '');
|
||||
const [appliedSearch, setAppliedSearch] = useState(initialQuery.productSearch || '');
|
||||
const [fullFields, setFullFields] = useState(false);
|
||||
const [defectDisplay, setDefectDisplay] = useState<'weight' | 'rate'>('weight');
|
||||
const [data, setData] = useState<MetricsResponse | null>(null);
|
||||
const [dataKey, setDataKey] = useState('');
|
||||
const [trendData, setTrendData] = useState<TrendMetricRow[]>([]);
|
||||
@@ -317,9 +326,12 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
const [recordsOpen, setRecordsOpen] = useState(false);
|
||||
const [recordStage, setRecordStage] = useState<Stage>('black');
|
||||
const [recordMonth, setRecordMonth] = useState<number>();
|
||||
const [recordQuerySnapshot, setRecordQuerySnapshot] = useState<QueryParams | null>(null);
|
||||
const [basisOpen, setBasisOpen] = useState(false);
|
||||
const trendAnchorTop = useRef<number | null>(null);
|
||||
const tableContent = useRef<HTMLDivElement>(null);
|
||||
const summaryExport = useRef<{ exportExcel: () => Promise<void> }>(null);
|
||||
const [summaryExporting, setSummaryExporting] = useState(false);
|
||||
const trendSection = useRef<HTMLElement>(null);
|
||||
const refreshSeen = useRef(refreshKey);
|
||||
useEffect(() => {
|
||||
@@ -540,12 +552,6 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
return orderedRows.filter(row => [row.label, row.department, row.group, row.product, row.projectGroup].filter(Boolean).join(' ').toLocaleLowerCase().includes(term));
|
||||
}, [page, period, currentMetricsData, appliedSearch, year, view, department, allowedGroupSet]);
|
||||
|
||||
const openRecords = useCallback((row: MetricRow | null, stage: Stage, selectedMonth?: number) => {
|
||||
setSelectedRecord(row);
|
||||
setRecordStage(stage);
|
||||
setRecordMonth(selectedMonth);
|
||||
setRecordsOpen(true);
|
||||
}, []);
|
||||
const captureTrendAnchor = useCallback(() => {
|
||||
trendAnchorTop.current = trendSection.current?.getBoundingClientRect().top ?? null;
|
||||
}, []);
|
||||
@@ -622,6 +628,12 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
: currentMetricsData;
|
||||
// 产品月度下钻复用当前对象的服务端指标,汇总表仍保留父层结果供返回。
|
||||
const summaryMetricsData = drilledProduct ? activeDefectData : currentMetricsData;
|
||||
const openRecords = useCallback((row: MetricRow | null, stage: Stage, selectedMonth?: number, sourceQuery?: QueryParams, sourceData?: MetricsResponse | null) => {
|
||||
const source = sourceData === undefined ? summaryMetricsData : sourceData;
|
||||
if (!source?.release?.id) { message.info('指标数据尚未就绪,请重新查询后打开来源明细。'); return; }
|
||||
setRecordQuerySnapshot(freezeSourceRecordsQuery(sourceQuery || (drilledProduct ? defectQueryParams : queryParams), source.release.id, view, row, selectedMonth));
|
||||
setSelectedRecord(row); setRecordStage(stage); setRecordMonth(selectedMonth); setRecordsOpen(true);
|
||||
}, [summaryMetricsData, drilledProduct, defectQueryParams, queryParams, view, message]);
|
||||
const summaryMetricsError = drilledProduct ? trendObjectMetricsError : currentMetricsError;
|
||||
const summaryBusy = drilledProduct ? trendObjectMetricsLoading || !summaryMetricsData && !summaryMetricsError : queryBusy;
|
||||
const rowForSummary = summaryMetricsData?.summary;
|
||||
@@ -727,7 +739,8 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
|
||||
<div className="query-quality-summary" aria-label="数据覆盖摘要">
|
||||
<span>{drilledProduct && <>{drilledProduct} · </>}{summaryMetricsData ? <>来源覆盖 {summaryMetricsData.coverage.sourceMonths.filter(item => item.blackRows > 0 || item.brightRows > 0).length} 个月 · 参与计算 {summaryMetricsData.coverage.includedRows.toLocaleString('zh-CN')} / 原始 {summaryMetricsData.coverage.rawRows.toLocaleString('zh-CN')} 行 · 未分类 {summaryMetricsData.coverage.excludedBlankRows.toLocaleString('zh-CN')} 行({includeUnassigned ? '已包含' : '本次排除'})</> : summaryBusy ? '正在更新来源覆盖…' : '来源覆盖暂不可用'}</span>
|
||||
<Button type="link" size="small" disabled={!summaryMetricsData} onClick={() => setBasisOpen(true)}>质量范围说明</Button>
|
||||
<Button type="link" size="small" disabled={!summaryMetricsData} onClick={() => setBasisOpen(true)}>计算口径</Button>
|
||||
|
||||
</div>
|
||||
|
||||
{['department', 'group', 'product'].includes(page) && <>
|
||||
@@ -742,15 +755,23 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
<Input allowClear={!drilledProduct} disabled={Boolean(drilledProduct)} maxLength={view === 'product' ? 256 : undefined} prefix={<SearchOutlined />} placeholder={view === 'product' ? '输入关键词或完整产品名称' : `搜索${view === 'group' ? '业务分组' : '汇总对象'}`} value={drilledProduct || search} onChange={event => setSearch(event.target.value)} aria-label={view === 'product' ? '搜索产品名称并同步筛选指标和趋势' : '搜索汇总对象'} />
|
||||
<Button type="primary" disabled={Boolean(drilledProduct)} onClick={() => applySearch()} aria-label="开始搜索">搜索</Button>
|
||||
<Segmented value={fullFields ? 'full' : 'key'} options={[{ label: '关键指标', value: 'key' }, { label: '完整字段', value: 'full' }]} onChange={value => setFullFields(value === 'full')} aria-label="字段显示" />
|
||||
<Tooltip title="点击综合合格率可查看计算依据"><Button type="text" icon={<InfoCircleOutlined />} aria-label="查看计算依据" onClick={() => setBasisOpen(true)} /></Tooltip>
|
||||
<Segmented value={defectDisplay} options={[{label:'不良重量',value:'weight'},{label:'不良率',value:'rate'}]} onChange={value=>setDefectDisplay(value as typeof defectDisplay)} aria-label="不良显示方式" />
|
||||
{!drilledProduct && (view === 'group' || view === 'product' && (group.length > 0 || department.length > 0)) && <Button onClick={() => { setSearch(''); setAppliedSearch(''); setTrendObject(''); if (view === 'product') { setProduct([]); setGroup([]); setViewOverride('group'); } else { setGroup([]); setDepartment([]); setViewOverride('department'); } }}>{view === 'product' ? '返回业务分组' : '返回产业部'}</Button>}
|
||||
{drilledProduct && <Button onClick={() => { setDrilledProduct(''); setTrendObject(''); setTrendMode('production'); }}>返回产品汇总</Button>}
|
||||
<Tooltip title="导出 Excel"><Button type="text" icon={<DownloadOutlined />} aria-label="导出 Excel" loading={summaryExporting} disabled={queryBusy || summaryBusy || !summaryMetricsData || Boolean(drilledProduct && trendLoading) || !(drilledProduct ? drilledTrendData : visibleRows).length} onClick={async () => {
|
||||
setSummaryExporting(true);
|
||||
try { await summaryExport.current?.exportExcel(); }
|
||||
catch (error) { message.error(`导出失败:${chooseError(error)}`); }
|
||||
finally { setSummaryExporting(false); }
|
||||
}} /></Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mobile-scroll-hint">横向滑动查看完整指标</div>
|
||||
<Spin spinning={queryBusy}><div ref={tableContent} className="query-table-content" style={{ minHeight: queryBusy ? tableHeight.current : undefined }} aria-busy={queryBusy} inert={!currentMetricsData}>
|
||||
{drilledProduct ? (
|
||||
<MetricTable
|
||||
ref={summaryExport}
|
||||
exportFilename={`${drilledProduct || scopeName}质量汇总-${year}${drilledProduct || period === 'year' ? '' : period === 'month' ? `-${String(month).padStart(2, '0')}` : `-Q${quarter}`}-${fullFields ? '完整字段' : '关键指标'}`}
|
||||
rows={drilledTrendData}
|
||||
view="overall"
|
||||
layoutView="product"
|
||||
@@ -759,6 +780,7 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
month={month}
|
||||
quarter={quarter}
|
||||
fullFields={fullFields}
|
||||
defectDisplay={defectDisplay}
|
||||
rateBasis={rateBasis}
|
||||
onDetail={openRecords}
|
||||
onBasis={() => setBasisOpen(true)}
|
||||
@@ -766,12 +788,15 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
/>
|
||||
) : (
|
||||
<MetricTable
|
||||
ref={summaryExport}
|
||||
exportFilename={`${drilledProduct || scopeName}质量汇总-${year}${drilledProduct || period === 'year' ? '' : period === 'month' ? `-${String(month).padStart(2, '0')}` : `-Q${quarter}`}-${fullFields ? '完整字段' : '关键指标'}`}
|
||||
rows={visibleRows}
|
||||
view={view}
|
||||
period={period}
|
||||
month={month}
|
||||
quarter={quarter}
|
||||
fullFields={fullFields}
|
||||
defectDisplay={defectDisplay}
|
||||
rateBasis={rateBasis}
|
||||
onDetail={openRecords}
|
||||
onBasis={() => setBasisOpen(true)}
|
||||
@@ -802,6 +827,7 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
<Segmented value={trendMode} options={[{ label: '合格率与产量', value: 'production' }, { label: '不良率', value: 'defects' }, { label: `${trendGranularity === 'quarter' ? '季度' : trendGranularity === 'year' ? '年度' : '月度'}数据`, value: 'data' }]} onChange={value => setTrendMode(value as typeof trendMode)} aria-label="趋势视图" />
|
||||
</div>
|
||||
<div className="trend-controls">
|
||||
{trendMode==='data'&&<Segmented value={defectDisplay} options={[{label:'不良重量',value:'weight'},{label:'不良率',value:'rate'}]} onChange={value=>setDefectDisplay(value as typeof defectDisplay)} aria-label="趋势不良显示方式"/>}
|
||||
<label className="query-field trend-granularity"><span>趋势粒度</span><Select {...readableSelectPopup} value={trendGranularity} options={[{ label: '按月', value: 'month' }, { label: '按季度', value: 'quarter' }, { label: '按年度', value: 'year' }]} onChange={value => setTrendGranularity(value)} aria-label="趋势粒度" /></label>
|
||||
<label className="query-field trend-object"><span>趋势对象</span><Select {...readableSelectPopup} allowClear placeholder={`当前${scopeName}筛选`} value={trendObject || undefined} options={trendOptions} onChange={setSynchronizedTrendObject} aria-label="趋势对象" />
|
||||
</label>
|
||||
@@ -809,7 +835,7 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
</div>
|
||||
<div className="trend-chart-shell" aria-busy={trendLoading}>
|
||||
{trendMode === 'data'
|
||||
? <TrendTable rows={visibleTrendData} rateBasis={rateBasis} onMonth={selectTrendPeriod} />
|
||||
? <TrendTable rows={visibleTrendData} defectDisplay={defectDisplay} rateBasis={rateBasis} onMonth={selectTrendPeriod} />
|
||||
: <TrendChart rows={visibleTrendData} mode={trendMode} stage={trendStage} rateBasis={rateBasis} targetRate={currentTrendTarget} selectedPeriod={selectedTrendPeriod} onMonth={selectTrendPeriod} />}
|
||||
{(trendLoading || (useSummaryTrend && queryBusy)) && <span className="trend-refresh-indicator"><Spin size="small" />正在更新趋势</span>}
|
||||
</div>
|
||||
@@ -818,7 +844,7 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
|
||||
<section className="panel section-panel defects-panel">
|
||||
<div className="section-heading-row">
|
||||
<SectionHeading title="不良具体构成" subtitle={`${year}年${period === 'month' ? MONTHS[month - 1] : period === 'quarter' ? `第${quarter}季度` : '全年'}${trendObject ? ` · ${trendObject}` : ''} · 占比为分类报废内占比;废率为该类重量 ÷ 同阶段适用总重量`} />
|
||||
<SectionHeading title="不良具体构成" subtitle={`${year}年${period === 'month' ? MONTHS[month - 1] : period === 'quarter' ? `第${quarter}季度` : '全年'}${trendObject ? ` · ${trendObject}` : ''} · 占比为分类报废内占比;废率为该类重量 ÷ 同阶段总重量`} />
|
||||
</div>
|
||||
{trendObjectMetricsLoading && <div className="defect-pareto-status"><Spin size="small" />正在更新当前趋势对象的不良数据</div>}
|
||||
{trendObjectMetricsError && <Alert showIcon type="warning" message="当前趋势对象的不良数据读取失败" description={trendObjectMetricsError} />}
|
||||
@@ -830,7 +856,7 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
{trendObjectMetricsLoading || trendObjectMetricsError
|
||||
? null
|
||||
: items.length
|
||||
? <DefectBreakdown items={items} stage={stage} totalWeight={activeDefectData?.summary?.[stage]?.totalWeight} maximum={Math.max(0, ...items.map(item => item.weight ?? 0))} onDetail={() => openRecords(null, stage)} />
|
||||
? <DefectBreakdown items={items} stage={stage} totalWeight={activeDefectData?.summary?.[stage]?.totalWeight} maximum={Math.max(0, ...items.map(item => item.weight ?? 0))} onDetail={() => openRecords(null, stage, undefined, defectQueryParams, activeDefectData)} />
|
||||
: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="当前条件下暂无不良分类数据" />}
|
||||
</section>;
|
||||
})}
|
||||
@@ -840,41 +866,41 @@ export default function QueryPage({ page, onUnauthorized }: {
|
||||
</div>
|
||||
</>
|
||||
|
||||
<div className="query-footer"><span>查询数据由服务端按当前数据返回</span><Button type="link" disabled={!currentMetricsData} onClick={() => setBasisOpen(true)}>计算口径</Button></div>
|
||||
|
||||
<Modal open={basisOpen} title={`${rateBasis === 'original' ? '综合合格率' : '综合调整率'}计算依据`} onCancel={() => setBasisOpen(false)} footer={<Button onClick={() => setBasisOpen(false)}>关闭</Button>} width={680}>
|
||||
<div className="basis-card"><span>当前服务返回的{rateBasis === 'original' ? '综合合格率' : '综合调整率'}</span><strong>{rateText(visibleCompositeRate(rowForSummary, rateBasis))}</strong><span>黑片 {rateText(visibleStageRate(rowForSummary, 'black'))} · {rateBasis === 'original' ? '亮片' : '亮片调整率'} {rateText(visibleStageRate(rowForSummary, 'bright', rateBasis))}</span></div>
|
||||
<p className="basis-copy">正式指标按当前数据绑定的规则与筛选条件计算。综合合格率是黑片合格率与亮片合格率相乘的业务指标。以下公式及空值处理说明来自指标服务;缺少阶段来源时不展示对应率。</p>
|
||||
|
||||
<Modal open={basisOpen} title={`${rateBasis === 'original' ? '综合合格率' : '综合调整率'}计算口径`} onCancel={() => setBasisOpen(false)} footer={<Button onClick={() => setBasisOpen(false)}>关闭</Button>} width={680}>
|
||||
<div className="basis-card"><span>当前{rateBasis === 'original' ? '综合合格率' : '综合调整率'}</span><strong>{rateText(visibleCompositeRate(rowForSummary, rateBasis))}</strong><span>黑片 {rateText(visibleStageRate(rowForSummary, 'black'))} · {rateBasis === 'original' ? '亮片' : '亮片调整率'} {rateText(visibleStageRate(rowForSummary, 'bright', rateBasis))}</span></div>
|
||||
<p className="basis-copy">以下为当前查询实际使用的公式、适用条件与空值处理规则。月、季、年先汇总计算分量,再按生效公式计算。</p>
|
||||
<dl className="basis-details">
|
||||
<dt>综合公式</dt><dd>{formulaText(compositeFormula)}</dd>
|
||||
<dt>黑片公式</dt><dd>{formulaText(formulaDescriptions.blackRate)}</dd>
|
||||
<dt>{rateBasis === 'original' ? '亮片公式' : '亮片调整公式'}</dt><dd>{formulaText(brightFormula)}</dd>
|
||||
<dt>统计范围</dt><dd>{year}年{period === 'month' ? ` ${MONTHS[month - 1]}` : period === 'quarter' ? ` 第${quarter}季度` : '度'} · {drilledProduct || scopeName}</dd>
|
||||
<dt>适用总重量</dt><dd>黑片 {numberText(rowForSummary?.black?.totalWeight)} kg · 亮片 {numberText(rowForSummary?.bright?.totalWeight)} kg</dd>
|
||||
<dt>总重量</dt><dd>黑片 {numberText(rowForSummary?.black?.totalWeight)} kg · 亮片 {numberText(rowForSummary?.bright?.totalWeight)} kg</dd>
|
||||
<dt>覆盖行数</dt><dd>黑片 {rowForSummary?.coverage.blackRows ?? '—'} · 亮片 {rowForSummary?.coverage.brightRows ?? '—'}</dd>
|
||||
<dt>来源行覆盖</dt><dd>原始 {summaryMetricsData?.coverage.rawRows ?? '—'} · 参与 {summaryMetricsData?.coverage.includedRows ?? '—'} · 未分类行 {includeUnassigned ? '(已选择包含)' : '(本次排除)'} {summaryMetricsData?.coverage.excludedBlankRows ?? '—'}</dd>
|
||||
<dt>业务分类映射</dt><dd>未映射 {summaryMetricsData?.coverage.unmappedRows ?? '—'} 行</dd>
|
||||
<dt>项目组维度</dt><dd>{summaryMetricsData?.coverage.projectGroupUnconfiguredRows ?? '—'} 行未配置项目组归属。该计数不等于排除行数;是否参与指标由当前筛选及规则决定。</dd>
|
||||
</dl>
|
||||
<details><summary>查看服务返回的公式原文</summary><pre>{JSON.stringify(formulaDescriptions, null, 2)}</pre></details>
|
||||
|
||||
</Modal>
|
||||
|
||||
<RecordsDrawer
|
||||
{recordsOpen && recordQuerySnapshot && <RecordsDrawer
|
||||
key={JSON.stringify({ query: recordQuerySnapshot, stage: recordStage })}
|
||||
open={recordsOpen}
|
||||
row={selectedRecord}
|
||||
stage={recordStage}
|
||||
onStage={setRecordStage}
|
||||
onClose={() => { setSelectedRecord(null); setRecordMonth(undefined); setRecordsOpen(false); }}
|
||||
query={drilledProduct ? defectQueryParams : queryParams}
|
||||
view={view}
|
||||
query={recordQuerySnapshot}
|
||||
month={recordMonth}
|
||||
onUnauthorized={onUnauthorized}
|
||||
/>
|
||||
/>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MetricCard({ primary, label, value, note, stage, onClick }: { primary?: boolean; label: string; value: string; note?: string; stage?: Stage; onClick: () => void }) {
|
||||
export function MetricCard({ primary, label, value, note, stage, onClick }: { primary?: boolean; label: string; value: string; note?: string; stage?: Stage; onClick: () => void }) {
|
||||
const parts = value.match(/^(.*?)(%| kg)$/);
|
||||
return <button className={`metric-card ${primary ? 'primary' : ''} ${stage || ''}`} onClick={onClick}>
|
||||
<span className="metric-label">{stage && <i className={`stage-dot ${stage}`} />}{label}</span>
|
||||
@@ -883,7 +909,7 @@ function MetricCard({ primary, label, value, note, stage, onClick }: { primary?:
|
||||
</button>;
|
||||
}
|
||||
|
||||
function DefectBreakdown({ items, stage, totalWeight, maximum, onDetail }: { items: DefectMetric[]; stage: Stage; totalWeight?: number | null; maximum: number; onDetail: () => void }) {
|
||||
export function DefectBreakdown({ items, stage, totalWeight, maximum, onDetail }: { items: DefectMetric[]; stage: Stage; totalWeight?: number | null; maximum: number; onDetail: () => void }) {
|
||||
return <div className="defect-list">
|
||||
<div className="defect-header"><span>不良分类</span><span aria-hidden="true" /><span>重量 / kg</span><span>占比</span><span>废率</span></div>
|
||||
{items.map(item => <button className="defect-row" key={item.name} onClick={onDetail}>
|
||||
@@ -898,8 +924,8 @@ function DefectBreakdown({ items, stage, totalWeight, maximum, onDetail }: { ite
|
||||
|
||||
const FINE_DEFECT_FIELD_COUNT = 33;
|
||||
|
||||
function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthorized }: {
|
||||
releaseId?: string; query: QueryParams; externalScrapWeight?: number | null; onUnauthorized: (error: unknown) => boolean;
|
||||
export function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthorized, onlyStage }: {
|
||||
releaseId?: string; query: QueryParams; externalScrapWeight?: number | null; onUnauthorized: (error: unknown) => boolean; onlyStage?: Stage;
|
||||
}) {
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
const chart = useRef<ReturnType<typeof echarts.init> | null>(null);
|
||||
@@ -911,6 +937,7 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
year: query.year,
|
||||
...(query.productSearch ? { productSearch: query.productSearch } : {}),
|
||||
...(query.extraFilters ? { extraFilters: query.extraFilters } : {}),
|
||||
...(query.columnFilters?.length ? { columnFilters: query.columnFilters } : {}),
|
||||
...(query.month != null ? { month: query.month } : {}),
|
||||
...(query.quarter != null ? { quarter: query.quarter } : {}),
|
||||
...(query.department ? { department: query.department } : {}),
|
||||
@@ -918,7 +945,7 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
...(query.product ? { product: query.product } : {}),
|
||||
...(query.projectGroup ? { projectGroup: query.projectGroup } : {}),
|
||||
...(query.includeUnassigned ? { includeUnassigned: true } : {}),
|
||||
}), [query.year, query.month, query.quarter, query.department, query.group, query.product, query.productSearch, query.projectGroup, query.extraFilters, query.includeUnassigned]);
|
||||
}), [query.year, query.month, query.quarter, query.department, query.group, query.product, query.productSearch, query.projectGroup, query.extraFilters, query.columnFilters, query.includeUnassigned]);
|
||||
const fineQueryKey = JSON.stringify(fineQuery);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -929,9 +956,9 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
setLoading(true);
|
||||
setError('');
|
||||
Promise.all([
|
||||
api.fineDefectTop({ ...base, stage: 'black' }, controller.signal),
|
||||
api.fineDefectTop({ ...base, stage: 'bright' }, controller.signal),
|
||||
]).then(([black, bright]) => setResponses({ black, bright }))
|
||||
onlyStage === 'bright' ? Promise.resolve({kind:'fine_defect_top' as const,releaseId,sourceRows:0,rows:[]}) : api.fineDefectTop({ ...base, stage: 'black' }, controller.signal),
|
||||
onlyStage === 'black' ? Promise.resolve({kind:'fine_defect_top' as const,releaseId,sourceRows:0,rows:[]}) : api.fineDefectTop({ ...base, stage: 'bright' }, controller.signal),
|
||||
]).then(([black, bright]) => { if (!controller.signal.aborted) setResponses({ black, bright }); })
|
||||
.catch(value => {
|
||||
if (controller.signal.aborted) return;
|
||||
if (onUnauthorized(value)) return;
|
||||
@@ -939,7 +966,7 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
})
|
||||
.finally(() => { if (!controller.signal.aborted) setLoading(false); });
|
||||
return () => controller.abort();
|
||||
}, [releaseId, fineQueryKey, onUnauthorized]);
|
||||
}, [releaseId, fineQueryKey, onUnauthorized, onlyStage]);
|
||||
|
||||
useEffect(() => {
|
||||
const observer = new MutationObserver(() => setThemeRevision(value => value + 1));
|
||||
@@ -966,12 +993,12 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
weight: row.weight,
|
||||
kind: 'source' as const,
|
||||
})));
|
||||
if (typeof externalScrapWeight === 'number' && Number.isFinite(externalScrapWeight) && externalScrapWeight > 0) {
|
||||
if (onlyStage !== 'bright' && typeof externalScrapWeight === 'number' && Number.isFinite(externalScrapWeight) && externalScrapWeight > 0) {
|
||||
raw.push({ key: 'black:externalScrap', label: '黑片·外废(仅大类重量)', category: '外废', weight: externalScrapWeight, kind: 'category' });
|
||||
}
|
||||
return raw.filter(item => typeof item.weight === 'number' && Number.isFinite(item.weight) && item.weight > 0)
|
||||
.sort((left, right) => right.weight! - left.weight! || left.label.localeCompare(right.label, 'zh-CN'));
|
||||
}, [responses, externalScrapWeight]);
|
||||
}, [responses, externalScrapWeight, onlyStage]);
|
||||
const totalWeight = items.reduce((total, item) => total + (item.weight || 0), 0);
|
||||
const visibleFieldCount = responses ? (responses.black.sourceFields?.length || 0) + (responses.bright.sourceFields?.length || 0) : 0;
|
||||
|
||||
@@ -994,7 +1021,7 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
animationDuration: 420,
|
||||
animationDurationUpdate: 520,
|
||||
grid: { left: 68, right: 72, top: 48, bottom: items.length > 12 ? 92 : 62, containLabel: true },
|
||||
legend: { top: 8, data: ['报废重量', '累计占比'], textStyle: { color: ink, fontSize: 11 } },
|
||||
legend: { top: 8, data: ['报废重量', '累计占比'], textStyle: { color: ink, fontSize: CHART_FONT_SIZE } },
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
@@ -1013,13 +1040,13 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: items.map(item => item.label),
|
||||
axisLabel: { color: ink, rotate: 35, interval: 0, hideOverlap: true, fontSize: 10 },
|
||||
axisLabel: { color: ink, rotate: 35, interval: 0, hideOverlap: true, fontSize: CHART_FONT_SIZE },
|
||||
axisLine: { lineStyle: { color: line } },
|
||||
axisTick: { alignWithLabel: true, lineStyle: { color: line } },
|
||||
},
|
||||
yAxis: [
|
||||
{ type: 'value', name: '报废重量 / kg', nameTextStyle: { color: ink, fontSize: 10 }, axisLabel: { color: ink, fontSize: 10 }, splitLine: { lineStyle: { color: line, type: 'dashed' } } },
|
||||
{ type: 'value', name: '累计占比', min: 0, max: 100, nameTextStyle: { color: ink, fontSize: 10 }, axisLabel: { color: ink, fontSize: 10, formatter: '{value}%' }, splitLine: { show: false } },
|
||||
{ type: 'value', name: '报废重量 / kg', nameTextStyle: { color: ink, fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, fontSize: CHART_FONT_SIZE }, splitLine: { lineStyle: { color: line, type: 'dashed' } } },
|
||||
{ type: 'value', name: '累计占比', min: 0, max: 100, nameTextStyle: { color: ink, fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, fontSize: CHART_FONT_SIZE, formatter: '{value}%' }, splitLine: { show: false } },
|
||||
],
|
||||
series: [
|
||||
{ name: '报废重量', type: 'bar', z: 1, barMaxWidth: 36, data: items.map(item => ({ value: item.weight, itemStyle: { color: item.kind === 'category' ? '#9aa4b2' : item.key.startsWith('black:') ? blue : teal } })) },
|
||||
@@ -1034,8 +1061,8 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
.filter(item => item.reconciliationStatus !== 'RECONCILED' && item.reconciliationStatus !== 'UNAVAILABLE').length
|
||||
: 0;
|
||||
|
||||
return <section className="defect-pareto-section" aria-label="综合报废重量柏拉图">
|
||||
<div className="defect-pareto-heading"><strong>黑片与亮片综合报废重量柏拉图</strong><span>{responses ? `细分源字段 ${visibleFieldCount} / ${FINE_DEFECT_FIELD_COUNT} 项${incompleteCategories ? ` · ${incompleteCategories} 类细分数据未与正式大类完全核对` : ''}` : '按当前筛选范围汇总全部可见细分报废重量'}</span></div>
|
||||
return <section className="defect-pareto-section" aria-label={onlyStage ? `${onlyStage === 'black' ? '黑片' : '亮片'}报废重量柏拉图` : '综合报废重量柏拉图'}>
|
||||
<div className="defect-pareto-heading"><strong>{onlyStage ? `${onlyStage === 'black' ? '黑片' : '亮片'}报废重量柏拉图` : '黑片与亮片综合报废重量柏拉图'}</strong><span>{responses ? `细分源字段 ${visibleFieldCount}${onlyStage ? '' : ` / ${FINE_DEFECT_FIELD_COUNT}`} 项${incompleteCategories ? ` · ${incompleteCategories} 类细分数据未与正式大类完全核对` : ''}` : '按当前筛选范围汇总全部可见细分报废重量'}</span></div>
|
||||
{loading && <div className="defect-pareto-status"><Spin size="small" />正在汇总细分报废重量</div>}
|
||||
{error && <Alert showIcon type="warning" message="细分报废重量读取失败" description={error} />}
|
||||
{!loading && !releaseId && <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="当前没有已发布数据版本" />}
|
||||
@@ -1044,7 +1071,7 @@ function DefectParetoPanel({ releaseId, query, externalScrapWeight, onUnauthoriz
|
||||
</section>;
|
||||
}
|
||||
|
||||
function SectionHeading({ title, subtitle }: { title: string; subtitle?: string }) {
|
||||
export function SectionHeading({ title, subtitle }: { title: string; subtitle?: string }) {
|
||||
return <div className="section-heading"><h2>{title}</h2>{subtitle && <span>{subtitle}</span>}</div>;
|
||||
}
|
||||
|
||||
@@ -1059,13 +1086,14 @@ function useCompactTable() {
|
||||
return compact;
|
||||
}
|
||||
|
||||
function MetricTable({
|
||||
rows, view, layoutView = view, pageSizeOverride, period, month, quarter, fullFields, rateBasis, onDetail, onBasis, onDrilldown, emptyText = '当前条件下暂无数据',
|
||||
export function MetricTable({
|
||||
ref, exportFilename, rows, view, layoutView = view, pageSizeOverride, period, month, quarter, fullFields, rateBasis, onDetail, onBasis, onDrilldown, onlyStage, defectDisplay = 'weight', emptyText = '当前条件下暂无数据',
|
||||
}: {
|
||||
ref?: React.Ref<{ exportExcel: () => Promise<void> }>; exportFilename: string;
|
||||
rows: MetricRow[]; view: ViewKind; layoutView?: ViewKind; pageSizeOverride?: number; period: PeriodKind; month: number; quarter: number; fullFields: boolean;
|
||||
rateBasis: 'original' | 'withoutHeadquartersScrap';
|
||||
onDetail: (row: MetricRow | null, stage: Stage, month?: number) => void; onBasis: () => void; onDrilldown: (row: MetricRow) => void;
|
||||
emptyText?: string;
|
||||
emptyText?: string; onlyStage?: Stage; defectDisplay?: 'weight'|'rate';
|
||||
}) {
|
||||
const compact = useCompactTable();
|
||||
const blackDefects = fullFields ? defectsFor(rows, 'black') : [];
|
||||
@@ -1080,30 +1108,47 @@ function MetricTable({
|
||||
onDetail(row, stage, isOverall && period === 'year' ? monthNumber((row as TrendMetricRow).month) || undefined : isOverall && period === 'month' ? month : undefined);
|
||||
};
|
||||
const numeric = (label: string, stage: Stage, field: 'qualifiedWeight' | 'scrapWeight' | 'totalWeight' | 'rate' | 'headquartersScrapWeight', className = '') => ({
|
||||
title: compact ? `${stage === 'black' ? '黑片' : '亮片'}${label}` : label,
|
||||
title: `${compact ? stage === 'black' ? '黑片' : '亮片' : ''}${defectDisplay === 'rate' && (field === 'scrapWeight' || field === 'headquartersScrapWeight') ? defectRateLabel(label) : label}`,
|
||||
exportRate: defectDisplay === 'rate' && (field === 'scrapWeight' || field === 'headquartersScrapWeight'),
|
||||
key: `${stage}-${field}`,
|
||||
align: 'center' as const,
|
||||
width: field === 'rate' ? 116 : 145,
|
||||
className: `${field === 'rate' ? `rate-cell ${stage}` : 'weight-cell'} ${className}`,
|
||||
render: (_: unknown, row: MetricRow) => <Button type="link" className="table-value" onClick={() => openRow(row, stage)}>{field === 'rate' ? rateText(visibleStageRate(row, stage)) : numberText(stageValue(row, stage, field))}</Button>,
|
||||
render: (_: unknown, row: MetricRow) => <Button type="link" className="table-value" tabIndex={-1} style={{ userSelect: 'text', WebkitUserSelect: 'text' }}>{field === 'rate' ? rateText(visibleStageRate(row, stage)) : defectDisplay === 'rate' && (field === 'scrapWeight' || field === 'headquartersScrapWeight') ? rateText(defectWeightRate(stageValue(row, stage, field),stageValue(row, stage, 'totalWeight'))) : numberText(stageValue(row, stage, field))}</Button>,
|
||||
});
|
||||
const defectColumns = (stage: Stage, names: string[]) => names.map(name => ({
|
||||
title: compact ? `${stage === 'black' ? '黑片' : '亮片'}${name}` : name,
|
||||
title: `${compact ? stage === 'black' ? '黑片' : '亮片' : ''}${defectDisplay === 'rate' ? defectRateLabel(name) : name}`,
|
||||
exportRate: defectDisplay === 'rate',
|
||||
key: `${stage}-defect-${name}`,
|
||||
align: 'center' as const,
|
||||
width: 130,
|
||||
render: (_: unknown, row: MetricRow) => {
|
||||
const value = defectList(row, stage).find(item => item.name === name);
|
||||
return <Button type="link" className="table-value" onClick={() => openRow(row, stage)}>{numberText(value?.weight ?? null)}</Button>;
|
||||
return <Button type="link" className="table-value" tabIndex={-1} style={{ userSelect: 'text', WebkitUserSelect: 'text' }}>{defectDisplay === 'rate' ? rateText(defectWeightRate(value?.weight,stageValue(row,stage,'totalWeight'))) : numberText(value?.weight ?? null)}</Button>;
|
||||
},
|
||||
}));
|
||||
const columns: ColumnsType<MetricRow> = [
|
||||
{ title: isOverall ? period === 'year' ? '月份' : '统计期间' : view === 'group' ? '产业部 / 业务分组' : view === 'product' ? '产品规格' : view === 'projectGroup' ? '项目组' : view === 'department' ? '产业部' : '对象', key: 'object', dataIndex: 'label', fixed: 'left', width: compact ? isOverall ? 100 : 180 : layoutView === 'product' ? 300 : layoutView === 'group' ? 260 : 220, render: (_: unknown, row) => <span className="object-cell">{view === 'department' || view === 'group' || view === 'product' ? <Button type="link" className="object-drilldown" onClick={() => onDrilldown(row)}>{title(row)} <span>›</span></Button> : <strong>{title(row)}</strong>}{view === 'group' && row.department && <small>{row.department}</small>}{view === 'product' && row.group && <small>{row.group}</small>}</span> },
|
||||
{ title: <button className="header-link" onClick={onBasis}>{rateBasis === 'original' ? '综合合格率' : '综合调整率'}</button>, key: 'compositeRate', dataIndex: 'compositeRate', align: 'center', fixed: compact ? undefined : 'left', width: 140, className: 'combined-column', render: (_: number | null, row: MetricRow) => <button className="combined-value" onClick={onBasis}>{rateText(visibleCompositeRate(row, rateBasis))}</button> },
|
||||
{ title: <span className="stage-heading black"><i />黑片</span>, children: [numeric('合格重量', 'black', 'qualifiedWeight'), ...(fullFields ? [numeric('适用总重量', 'black', 'totalWeight')] : []), numeric('报废重量', 'black', 'scrapWeight'), ...defectColumns('black', blackDefects), numeric('合格率', 'black', 'rate')] },
|
||||
{ title: <span className="stage-heading bright"><i />亮片</span>, children: [numeric('合格重量', 'bright', 'qualifiedWeight'), ...(fullFields ? [numeric('适用总重量', 'bright', 'totalWeight')] : []), numeric('报废重量', 'bright', 'scrapWeight'), ...(fullFields ? [numeric('本部报废重量', 'bright', 'headquartersScrapWeight')] : []), ...defectColumns('bright', brightDefects), { ...numeric(rateBasis === 'original' ? '合格率' : '不含本部报废调整率', 'bright', 'rate'), render: (_: unknown, row: MetricRow) => <Button type="link" className="table-value" onClick={() => openRow(row, 'bright')}>{rateText(visibleStageRate(row, 'bright', rateBasis))}</Button> }] },
|
||||
{ title: '操作', key: 'actions', fixed: compact ? undefined : 'right', width: 100, align: 'center', render: (_: unknown, row) => (row as TrendMetricRow).noData ? <span>—</span> : <Button type="link" onClick={() => openRow(row, 'black')}>来源明细</Button> },
|
||||
const allColumns: ColumnsType<MetricRow> = [
|
||||
{ title: isOverall ? period === 'year' ? '月份' : '统计期间' : view === 'group' ? '产业部 / 业务分组' : view === 'product' ? '产品规格' : view === 'projectGroup' ? '项目组' : view === 'department' ? '产业部' : '对象', key: 'object', dataIndex: 'label', fixed: 'left', width: compact ? isOverall ? 100 : 180 : layoutView === 'product' ? 300 : layoutView === 'group' ? 260 : 220, render: (_: unknown, row) => <span className="object-cell">{view === 'department' || view === 'group' || view === 'product' ? <Button type="link" className="object-drilldown" style={{ userSelect: 'text', WebkitUserSelect: 'text' }} onClick={() => { if (window.getSelection()?.isCollapsed !== false) onDrilldown(row); }}>{title(row)} <span>›</span></Button> : <strong>{title(row)}</strong>}{view === 'group' && row.department && <small>{row.department}</small>}</span> },
|
||||
{ title: <button className="header-link" onClick={onBasis}>{rateBasis === 'original' ? '综合合格率' : '综合调整率'}</button>, key: 'compositeRate', dataIndex: 'compositeRate', align: 'center', fixed: compact ? undefined : 'left', width: 140, className: 'combined-column', render: (_: number | null, row: MetricRow) => <button className="combined-value" tabIndex={-1} style={{ userSelect: 'text', WebkitUserSelect: 'text' }}>{rateText(visibleCompositeRate(row, rateBasis))}</button> },
|
||||
{ key: 'stage-black', title: <span className="stage-heading black"><i />黑片</span>, children: [numeric('合格重量', 'black', 'qualifiedWeight'), ...(fullFields ? [numeric('总重量', 'black', 'totalWeight')] : []), numeric('报废重量', 'black', 'scrapWeight'), ...defectColumns('black', blackDefects), numeric('合格率', 'black', 'rate')] },
|
||||
{ key: 'stage-bright', title: <span className="stage-heading bright"><i />亮片</span>, children: [numeric('合格重量', 'bright', 'qualifiedWeight'), ...(fullFields ? [numeric('总重量', 'bright', 'totalWeight')] : []), numeric('报废重量', 'bright', 'scrapWeight'), ...(fullFields ? [numeric('本部报废重量', 'bright', 'headquartersScrapWeight')] : []), ...defectColumns('bright', brightDefects), { ...numeric(rateBasis === 'original' ? '合格率' : '不含本部报废调整率', 'bright', 'rate'), render: (_: unknown, row: MetricRow) => <Button type="link" className="table-value" tabIndex={-1} style={{ userSelect: 'text', WebkitUserSelect: 'text' }}>{rateText(visibleStageRate(row, 'bright', rateBasis))}</Button> }] },
|
||||
{ title: '操作', key: 'actions', fixed: compact ? undefined : 'right', width: 100, align: 'center', render: (_: unknown, row) => (row as TrendMetricRow).noData ? <span>—</span> : <Button type="link" onClick={() => openRow(row, onlyStage || 'black')}>来源明细</Button> },
|
||||
];
|
||||
const columns = onlyStage ? allColumns.filter(column => !['compositeRate', `stage-${onlyStage === 'black' ? 'bright' : 'black'}`].includes(String(column.key))) : allColumns;
|
||||
useImperativeHandle(ref, () => ({
|
||||
exportExcel: () => downloadMetricWorkbook(exportFilename, columns, rows, (key, row) => {
|
||||
if (key === 'object') return [title(row), view === 'group' ? row.department : null].filter(Boolean).join(' / ');
|
||||
if (key === 'compositeRate') return visibleCompositeRate(row, rateBasis);
|
||||
const stage: Stage = key.startsWith('black-') ? 'black' : 'bright';
|
||||
if (key.startsWith(`${stage}-defect-`)) {
|
||||
const weight=defectList(row, stage).find(item => item.name === key.slice(`${stage}-defect-`.length))?.weight ?? null;
|
||||
return defectDisplay === 'rate' ? defectWeightRate(weight,stageValue(row,stage,'totalWeight')) : weight;
|
||||
}
|
||||
const field = key.slice(stage.length + 1) as 'qualifiedWeight' | 'scrapWeight' | 'totalWeight' | 'headquartersScrapWeight' | 'rate';
|
||||
if (defectDisplay === 'rate' && (field === 'scrapWeight' || field === 'headquartersScrapWeight')) return defectWeightRate(stageValue(row,stage,field),stageValue(row,stage,'totalWeight'));
|
||||
return field === 'rate' ? visibleStageRate(row, stage, stage === 'bright' ? rateBasis : 'original') : stageValue(row, stage, field);
|
||||
}),
|
||||
}));
|
||||
const dataSource = rows.map((row, index) => ({ ...row, key: row.key || `${title(row)}-${index}` }));
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(SUMMARY_PAGE_SIZE);
|
||||
@@ -1136,7 +1181,7 @@ function trendBarWidth(chartWidth: number, count: number): number {
|
||||
return Math.max(12, Math.min(64, Math.floor(((chartWidth - 132) / Math.max(count, 1)) * 0.8)));
|
||||
}
|
||||
|
||||
function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedPeriod, onMonth }: { rows: TrendMetricRow[]; mode: 'production' | 'defects'; stage: Stage; rateBasis: 'original' | 'withoutHeadquartersScrap'; targetRate: number | null; selectedPeriod?: string; onMonth: (value: number | string) => void }) {
|
||||
export function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedPeriod, onMonth, onlyStage }: { rows: TrendMetricRow[]; mode: 'production' | 'defects'; stage: Stage; rateBasis: 'original' | 'withoutHeadquartersScrap'; targetRate: number | null; selectedPeriod?: string; onMonth: (value: number | string) => void; onlyStage?: Stage }) {
|
||||
const container = useRef<HTMLDivElement>(null);
|
||||
const chart = useRef<ReturnType<typeof echarts.init> | null>(null);
|
||||
const onMonthRef = useRef(onMonth);
|
||||
@@ -1238,10 +1283,10 @@ function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedPeriod,
|
||||
};
|
||||
const base: echarts.EChartsCoreOption = {
|
||||
animation: false,
|
||||
textStyle: { fontFamily: '-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif', color: ink, fontSize: 12 },
|
||||
textStyle: { fontFamily: '-apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif', color: ink, fontSize: CHART_FONT_SIZE },
|
||||
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, fontSize: 12 } },
|
||||
tooltip: { trigger: 'axis', backgroundColor: surface, borderColor: line, borderWidth: 1, padding: [10, 13], textStyle: { color: ink, fontSize: 12 }, transitionDuration: 0, axisPointer: { type: 'line', lineStyle: { color: blue, width: 1, type: 'dashed' } }, formatter: (params: unknown) => formatTooltip(params, mode === 'defects') },
|
||||
legend: { type: 'scroll', top: 0, left: 9, right: 9, itemWidth: 14, itemHeight: 7, itemGap: 20, textStyle: { color: ink, fontSize: CHART_FONT_SIZE } },
|
||||
tooltip: { trigger: 'axis', backgroundColor: surface, borderColor: line, borderWidth: 1, padding: [10, 13], textStyle: { color: ink, fontSize: CHART_FONT_SIZE }, transitionDuration: 0, axisPointer: { type: 'line', lineStyle: { color: blue, width: 1, type: 'dashed' } }, formatter: (params: unknown) => formatTooltip(params, mode === 'defects') },
|
||||
xAxis: { type: 'category', data: labels, triggerEvent: true, axisLine: { lineStyle: { color: line } }, axisLabel: { color: ink, margin: 12 }, axisTick: { show: false } },
|
||||
};
|
||||
let option: echarts.EChartsCoreOption;
|
||||
@@ -1256,14 +1301,14 @@ function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedPeriod,
|
||||
silent: true,
|
||||
symbol: 'none',
|
||||
lineStyle: { color: '#c47a47', width: 1.5, type: 'dashed' as const },
|
||||
label: { show: true, formatter: `综合率目标 ${targetRate.toFixed(2)}%`, position: 'insideEndTop' as const, color: '#a55d30', fontSize: 11 },
|
||||
label: { show: true, formatter: `综合率目标 ${targetRate.toFixed(2)}%`, position: 'insideEndTop' as const, color: '#a55d30', fontSize: CHART_FONT_SIZE },
|
||||
data: [{ yAxis: targetRate }],
|
||||
} };
|
||||
option = {
|
||||
...base,
|
||||
yAxis: [
|
||||
{ type: 'value', name: '重量 / kg', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize: 11 }, axisLabel: { color: ink, fontSize: 11 }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } },
|
||||
{ type: 'value', name: '合格率 / %', nameGap: 18, min: minRate, max: maxRate, nameTextStyle: { color: ink, align: 'right', fontSize: 11 }, axisLabel: { color: ink, formatter: '{value}%', fontSize: 11 }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: false } },
|
||||
{ type: 'value', name: '重量 / kg', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, fontSize: CHART_FONT_SIZE }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } },
|
||||
{ type: 'value', name: '合格率 / %', nameGap: 18, min: minRate, max: maxRate, nameTextStyle: { color: ink, align: 'right', fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, formatter: '{value}%', fontSize: CHART_FONT_SIZE }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { show: false } },
|
||||
],
|
||||
series: [
|
||||
{ id: 'qualified-weight', name: `${stageName}合格重量`, type: 'bar', z: 1, stack: 'weight', yAxisIndex: 0, barWidth, itemStyle: { color: barColor }, emphasis: { itemStyle: { color: blue } }, data: barData('qualifiedWeight') },
|
||||
@@ -1278,13 +1323,17 @@ function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedPeriod,
|
||||
const palette = [blue, teal, '#bf7d58', '#9278bf', '#598eae'];
|
||||
option = {
|
||||
...base,
|
||||
yAxis: [{ type: 'value', name: '不良率 / %', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize: 11 }, axisLabel: { color: ink, formatter: '{value}%', fontSize: 11 }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } }],
|
||||
yAxis: [{ type: 'value', name: '不良率 / %', nameGap: 18, nameTextStyle: { color: ink, align: 'left', fontSize: CHART_FONT_SIZE }, axisLabel: { color: ink, formatter: '{value}%', fontSize: CHART_FONT_SIZE }, axisLine: { show: false }, axisTick: { show: false }, splitLine: { lineStyle: { color: line, type: 'dashed' } } }],
|
||||
series: names.map((name, index) => ({ id: `defect-${stage}-${name}`, name, type: 'line' as const, ...pointStyle, lineStyle: { width: 2, color: palette[index % palette.length] }, itemStyle: { color: palette[index % palette.length] }, data: rows.map(row => { const defect = row[stage].defects.find(item => item.name === name); return rateNumber(defectWeightRate(defect?.weight, row[stage].totalWeight)); }) })),
|
||||
};
|
||||
}
|
||||
if(onlyStage && mode === 'production') {
|
||||
const stageOption=option as {series?:Array<{id?:string}>;legend?:unknown};
|
||||
stageOption.series=stageOption.series?.filter(item=>item.id==='qualified-weight'||item.id==='scrap-weight'||item.id===`${onlyStage}-rate`);
|
||||
}
|
||||
instance.setOption(option, { replaceMerge: ['series', 'yAxis'], lazyUpdate: false });
|
||||
refreshBarMasks();
|
||||
}, [rows, mode, stage, rateBasis, targetRate, themeRevision, refreshBarMasks]);
|
||||
}, [rows, mode, stage, rateBasis, targetRate, themeRevision, refreshBarMasks, onlyStage]);
|
||||
|
||||
const dimmedPeriod = selectedPeriod === lineSelectedPeriod ? undefined : selectedPeriod;
|
||||
|
||||
@@ -1328,7 +1377,7 @@ function TrendChart({ rows, mode, stage, rateBasis, targetRate, selectedPeriod,
|
||||
</div>;
|
||||
}
|
||||
|
||||
function TrendTable({ rows, rateBasis, onMonth, showMonthLinks = true }: { rows: TrendMetricRow[]; rateBasis: 'original' | 'withoutHeadquartersScrap'; onMonth: (value: number | string) => void; showMonthLinks?: boolean }) {
|
||||
function TrendTable({ rows, rateBasis, onMonth, defectDisplay = 'weight', showMonthLinks = true }: { rows: TrendMetricRow[]; rateBasis: 'original' | 'withoutHeadquartersScrap'; onMonth: (value: number | string) => void; defectDisplay?: 'weight'|'rate'; showMonthLinks?: boolean }) {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(SUMMARY_PAGE_SIZE);
|
||||
useEffect(() => setCurrentPage(1), [rows]);
|
||||
@@ -1336,10 +1385,10 @@ function TrendTable({ rows, rateBasis, onMonth, showMonthLinks = true }: { rows:
|
||||
{ title: '统计期间', dataIndex: 'month', key: 'month', align: 'center', fixed: 'left', width: 130, render: (_: unknown, row) => <Button type="link" onClick={() => onMonth(row.month)}>{row.periodLabel || String(row.month)}</Button> },
|
||||
{ title: rateBasis === 'original' ? '综合合格率' : '综合调整率', dataIndex: 'compositeRate', key: 'compositeRate', align: 'center', width: 130, className: 'combined-column', render: (_: number | null, row: MetricRow) => rateText(visibleCompositeRate(row, rateBasis)) },
|
||||
{ title: '黑片合格重量 / kg', dataIndex: ['black', 'qualifiedWeight'], key: 'blackQualified', align: 'center', width: 160, render: value => numberText(value) },
|
||||
{ title: '黑片报废重量 / kg', dataIndex: ['black', 'scrapWeight'], key: 'blackScrap', align: 'center', width: 160, render: value => numberText(value) },
|
||||
{ title: defectDisplay === 'rate' ? '黑片报废率' : '黑片报废重量 / kg', dataIndex: ['black', 'scrapWeight'], key: 'blackScrap', align: 'center', width: 160, render: (_: unknown, row: TrendMetricRow) => defectDisplay === 'rate' ? rateText(defectWeightRate(row.black.scrapWeight,row.black.totalWeight)) : numberText(row.black.scrapWeight) },
|
||||
{ title: '黑片合格率', dataIndex: ['black', 'rate'], key: 'blackRate', align: 'center', width: 130, render: (_: number | null, row: TrendMetricRow) => rateText(visibleStageRate(row, 'black')) },
|
||||
{ title: '亮片合格重量 / kg', dataIndex: ['bright', 'qualifiedWeight'], key: 'brightQualified', align: 'center', width: 160, render: value => numberText(value) },
|
||||
{ title: '亮片报废重量 / kg', dataIndex: ['bright', 'scrapWeight'], key: 'brightScrap', align: 'center', width: 160, render: value => numberText(value) },
|
||||
{ title: defectDisplay === 'rate' ? '亮片报废率' : '亮片报废重量 / kg', dataIndex: ['bright', 'scrapWeight'], key: 'brightScrap', align: 'center', width: 160, render: (_: unknown, row: TrendMetricRow) => defectDisplay === 'rate' ? rateText(defectWeightRate(row.bright.scrapWeight,row.bright.totalWeight)) : numberText(row.bright.scrapWeight) },
|
||||
{ title: rateBasis === 'original' ? '亮片合格率' : '亮片不含本部报废调整率', dataIndex: ['bright', 'rate'], key: 'brightRate', align: 'center', width: 180, render: (_: number | null, row: TrendMetricRow) => rateText(visibleStageRate(row, 'bright', rateBasis)) },
|
||||
];
|
||||
return rows.length ? <div className="metric-table-scroll trend-data-table"><Table size="small" bordered columns={columns} dataSource={rows} rowKey={row => String(row.month)} pagination={{ current: currentPage, pageSize, showSizeChanger: rows.length > SUMMARY_PAGE_SIZE, pageSizeOptions: SUMMARY_PAGE_SIZE_OPTIONS, showTotal: (total, range) => `显示 ${range[0]}–${range[1]} 行,共 ${total} 个月`, onChange: (nextPage, nextPageSize) => { setPageSize(nextPageSize); setCurrentPage(nextPageSize === pageSize ? nextPage : 1); } }} scroll={{ x: 1130 }} />
|
||||
@@ -1347,17 +1396,17 @@ function TrendTable({ rows, rateBasis, onMonth, showMonthLinks = true }: { rows:
|
||||
</div> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="当前数据未返回趋势" />;
|
||||
}
|
||||
|
||||
function RecordsDrawer({
|
||||
open, row, stage, onStage, onClose, query, view, month, onUnauthorized,
|
||||
export function RecordsDrawer({
|
||||
open, row, stage, onStage, onClose, query, month, onUnauthorized, lockedStage,
|
||||
}: {
|
||||
open: boolean; row: MetricRow | null; stage: Stage; onStage: (stage: Stage) => void; onClose: () => void;
|
||||
query: QueryParams; view: ViewKind; month?: number; onUnauthorized: (error: unknown) => boolean;
|
||||
query: QueryParams; month?: number; onUnauthorized: (error: unknown) => boolean; lockedStage?: boolean;
|
||||
}) {
|
||||
const { message } = App.useApp();
|
||||
const [page, setPage] = useState(1);
|
||||
const [result, setResult] = useState<RecordsResponse | null>(null);
|
||||
const [response, setResponse] = useState<{ key: string; data: RecordsResponse } | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [failure, setFailure] = useState<{ key: string; message: string } | null>(null);
|
||||
const [field, setField] = useState<string>();
|
||||
const [fieldSearch, setFieldSearch] = useState('');
|
||||
const [sort, setSort] = useState<string>();
|
||||
@@ -1365,46 +1414,50 @@ function RecordsDrawer({
|
||||
const [selectedColumns, setSelectedColumns] = useState<string[]>();
|
||||
const [rawFields, setRawFields] = useState<string[]>([]);
|
||||
const [exporting, setExporting] = useState(false);
|
||||
|
||||
const recordQuery = useMemo(() => {
|
||||
const params: QueryParams = { ...query };
|
||||
if (month) { params.month = month; delete params.quarter; }
|
||||
if (row) {
|
||||
if (view === 'department') params.department = row.key === '__UNASSIGNED__' ? '__UNASSIGNED__' : (row.department || row.key);
|
||||
if (view === 'group') params.group = row.key === '__UNASSIGNED__' ? '__UNASSIGNED__' : (row.group || row.key);
|
||||
if (view === 'product') params.product = row.key === '__UNASSIGNED__' ? '__UNASSIGNED__' : (row.product || row.key);
|
||||
if (view === 'projectGroup') params.projectGroup = row.key === '__UNASSIGNED__' ? '__UNASSIGNED__' : (row.projectGroup || row.key);
|
||||
}
|
||||
return params;
|
||||
}, [query, row, view, month]);
|
||||
const [revision, setRevision] = useState(0);
|
||||
const exportController = useRef<AbortController | null>(null);
|
||||
useEffect(() => () => exportController.current?.abort(), []);
|
||||
const recordQuery = query;
|
||||
const requestParams = useMemo(() => ({ ...recordQuery, stage, page, pageSize: TABLE_PAGE_SIZE,
|
||||
...(field ? { field } : {}), ...(field && fieldSearch.trim() ? { search: fieldSearch.trim() } : {}),
|
||||
...(sort ? { sort, direction } : {}),
|
||||
}), [recordQuery, stage, page, field, fieldSearch, sort, direction]);
|
||||
const requestKey = JSON.stringify(requestParams);
|
||||
const result = response?.key === requestKey ? response.data : null;
|
||||
const error = failure?.key === requestKey ? failure.message : '';
|
||||
const fetching = loading || !result && !error;
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
const controller = new AbortController();
|
||||
setLoading(true);
|
||||
setError('');
|
||||
api.records({ ...recordQuery, stage, page, pageSize: TABLE_PAGE_SIZE,
|
||||
...(field ? { field } : {}), ...(field && fieldSearch.trim() ? { search: fieldSearch.trim() } : {}),
|
||||
...(sort ? { sort, direction } : {}),
|
||||
}, controller.signal).then(value => {
|
||||
setResult(value);
|
||||
setResponse(null); setFailure(null);
|
||||
api.records(requestParams, controller.signal).then(value => {
|
||||
if (controller.signal.aborted) return;
|
||||
const lastPage = Math.max(1, Math.ceil(value.total / value.pageSize));
|
||||
if (page > lastPage) { setPage(lastPage); return; }
|
||||
setResponse({ key: requestKey, data: value });
|
||||
const pageFields = value.rows.flatMap(record => Object.keys(record.raw || {}).filter(key => !isSystemVersionField(key)));
|
||||
if (pageFields.length) setRawFields(existing => [...new Set([...existing, ...pageFields])]);
|
||||
})
|
||||
.catch(errorValue => {
|
||||
if (controller.signal.aborted) return;
|
||||
if (!onUnauthorized(errorValue)) setError(chooseError(errorValue));
|
||||
if (!onUnauthorized(errorValue)) setFailure({ key: requestKey, message: chooseError(errorValue) });
|
||||
}).finally(() => { if (!controller.signal.aborted) setLoading(false); });
|
||||
return () => controller.abort();
|
||||
}, [open, recordQuery, stage, page, field, fieldSearch, sort, direction, onUnauthorized]);
|
||||
}, [open, requestKey, revision, onUnauthorized]);
|
||||
|
||||
const visibleRawFields = selectedColumns ?? rawFields.slice(0, 8);
|
||||
const exportRecords = async () => {
|
||||
const params: RecordExportParams = {
|
||||
year: recordQuery.year,
|
||||
...(recordQuery.extraFilters ? { extraFilters: recordQuery.extraFilters } : {}),
|
||||
...(recordQuery.columnFilters ? { columnFilters: recordQuery.columnFilters } : {}),
|
||||
...(lockedStage ? { stage } : {}),
|
||||
...(recordQuery.month !== undefined ? { month: recordQuery.month } : {}),
|
||||
...(recordQuery.quarter !== undefined ? { quarter: recordQuery.quarter } : {}),
|
||||
...(recordQuery.monthStart !== undefined ? { monthStart: recordQuery.monthStart } : {}),
|
||||
...(recordQuery.monthEnd !== undefined ? { monthEnd: recordQuery.monthEnd } : {}),
|
||||
...(recordQuery.department !== undefined ? { department: recordQuery.department } : {}),
|
||||
...(recordQuery.group !== undefined ? { group: recordQuery.group } : {}),
|
||||
...(recordQuery.product !== undefined ? { product: recordQuery.product } : {}),
|
||||
@@ -1413,9 +1466,12 @@ function RecordsDrawer({
|
||||
...(recordQuery.includeUnassigned !== undefined ? { includeUnassigned: recordQuery.includeUnassigned } : {}),
|
||||
...(recordQuery.releaseId !== undefined ? { releaseId: recordQuery.releaseId } : {}),
|
||||
};
|
||||
const controller = new AbortController();
|
||||
exportController.current?.abort(); exportController.current = controller;
|
||||
setExporting(true);
|
||||
try {
|
||||
const { blob, filename } = await api.exportRecords(params);
|
||||
const { blob, filename } = await api.exportRecords(params, controller.signal);
|
||||
if (controller.signal.aborted) return;
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
@@ -1424,11 +1480,11 @@ function RecordsDrawer({
|
||||
link.click();
|
||||
link.remove();
|
||||
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
message.success('明细 Excel 已开始下载,含黑片和亮片两个工作表');
|
||||
message.success(lockedStage ? '当前阶段明细 Excel 已开始下载' : '明细 Excel 已开始下载,含黑片和亮片两个工作表');
|
||||
} catch (errorValue) {
|
||||
message.error(chooseError(errorValue));
|
||||
if (!controller.signal.aborted && !onUnauthorized(errorValue)) message.error(chooseError(errorValue));
|
||||
} finally {
|
||||
setExporting(false);
|
||||
if (!controller.signal.aborted) setExporting(false);
|
||||
}
|
||||
};
|
||||
const fixedColumns: ColumnsType<RecordRow> = [
|
||||
@@ -1439,7 +1495,7 @@ function RecordsDrawer({
|
||||
return <details className="source-fields source-raw-fields">
|
||||
<summary>查看全部原始字段({fieldCount})</summary>
|
||||
<p>以下为该来源行导入时保存的字段值,按当前字段授权筛选。</p>
|
||||
<pre className="json-cell">{JSON.stringify(raw, null, 2)}</pre>
|
||||
<BusinessValue value={raw} />
|
||||
</details>;
|
||||
} },
|
||||
{ title: '工作表', dataIndex: 'sheet', key: 'sheet', width: 120 },
|
||||
@@ -1452,12 +1508,12 @@ function RecordsDrawer({
|
||||
{ title: '业务分组', dataIndex: 'group', key: 'group', width: 190 },
|
||||
{ title: '产品', dataIndex: 'product', key: 'product', width: 190 },
|
||||
...visibleRawFields.map(name => ({ title: name, key: `raw:${name}`, width: 180, ellipsis: true, render: (_: unknown, record: RecordRow) => String(record.raw?.[name] ?? '—') })),
|
||||
{ title: '规范化值与转换说明', key: 'transform', width: 260, render: (_: unknown, record: RecordRow) => <details className="source-fields"><summary>查看本行转换</summary><strong>规范化值</strong><pre className="json-cell">{JSON.stringify(withoutSystemVersionFields(record.normalized || {}), null, 2)}</pre><strong>转换说明</strong><ul>{(record.transformNotes || []).map((note, index) => <li key={index}>{typeof note === 'string' ? note : JSON.stringify(withoutSystemVersionFields(note))}</li>)}</ul></details> },
|
||||
{ title: '计算分量', dataIndex: 'components', key: 'components', width: 270, render: value => <details className="source-fields"><summary>查看计算分量</summary><pre className="json-cell">{JSON.stringify(withoutSystemVersionFields(value), null, 2)}</pre></details> },
|
||||
{ title: '规范化值与转换说明', key: 'transform', width: 260, render: (_: unknown, record: RecordRow) => <details className="source-fields"><summary>查看本行转换</summary><strong>规范化值</strong><BusinessValue value={withoutSystemVersionFields(record.normalized || {})} /><strong>转换说明</strong><ul>{(record.transformNotes || []).map((note, index) => <li key={index}>{typeof note === 'string' ? note : <BusinessValue value={withoutSystemVersionFields(note)} />}</li>)}</ul></details> },
|
||||
{ title: '计算分量', dataIndex: 'components', key: 'components', width: 270, render: value => <details className="source-fields"><summary>查看计算分量</summary><BusinessValue value={withoutSystemVersionFields(value)} /></details> },
|
||||
];
|
||||
|
||||
return <Drawer className="source-records-drawer" open={open} onClose={onClose} width={Math.min(1120, window.innerWidth)} title={<div className="drawer-title">来源明细 <small>{row?.label || (month ? MONTHS[month - 1] : '当前筛选条件')}</small></div>} destroyOnClose>
|
||||
<div className="drawer-controls"><Segmented value={stage} options={[{ label: '黑片', value: 'black' }, { label: '亮片', value: 'bright' }]} onChange={value => { onStage(value as Stage); setPage(1); setRawFields([]); setField(undefined); setFieldSearch(''); setSelectedColumns(undefined); setSort(undefined); }} aria-label="明细阶段" /><span>{result ? `共 ${result.total} 条来源记录 · 已载入 ${rawFields.length} 个原始字段` : '按当前查询条件获取原始来源行'}</span><Button size="small" icon={<DownloadOutlined />} loading={exporting} onClick={exportRecords} title="导出当前查询范围全部来源明细,含黑片和亮片两个工作表">导出明细 Excel</Button></div>
|
||||
<div className="drawer-controls"><Segmented disabled={lockedStage} value={stage} options={[{ label: '黑片', value: 'black' }, { label: '亮片', value: 'bright' }]} onChange={value => { onStage(value as Stage); setPage(1); setRawFields([]); setField(undefined); setFieldSearch(''); setSelectedColumns(undefined); setSort(undefined); }} aria-label="明细阶段" /><span>{result ? `共 ${result.total} 条来源记录 · 已载入 ${rawFields.length} 个原始字段` : '按当前查询条件获取原始来源行'}</span><Button size="small" icon={<DownloadOutlined />} loading={exporting} onClick={exportRecords} title={lockedStage ? '导出当前阶段和筛选范围的全部来源明细' : '导出当前查询范围全部来源明细,含黑片和亮片两个工作表'}>导出明细 Excel</Button></div>
|
||||
<div className="record-query-tools">
|
||||
<label><span>字段检索</span><Select {...readableSelectPopup} allowClear showSearch optionFilterProp="label" placeholder="选择原始字段" value={field} options={rawFields.map(name => ({ label: name, value: name }))} onChange={value => { setField(value); setPage(1); }} /></label>
|
||||
<Input allowClear disabled={!field} prefix={<SearchOutlined />} placeholder={field ? `搜索字段:${field}` : '先选择检索字段'} value={fieldSearch} onChange={event => { setFieldSearch(event.target.value); setPage(1); }} />
|
||||
@@ -1469,8 +1525,10 @@ function RecordsDrawer({
|
||||
]} onChange={value => { setSort(value); setPage(1); }} /></label>
|
||||
<Segmented value={direction} options={[{ label: '升序', value: 'asc' }, { label: '降序', value: 'desc' }]} onChange={value => { setDirection(value as 'asc' | 'desc'); setPage(1); }} aria-label="排序方向" />
|
||||
</div>
|
||||
{error && <Alert type="error" showIcon message="来源明细加载失败" description={error} />}
|
||||
{loading && !result ? <div className="loading-panel"><Spin />正在读取来源行…</div> : result?.rows.length ? <Table size="small" bordered columns={fixedColumns} dataSource={result.rows} rowKey="id" pagination={false} scroll={{ x: 1800 + visibleRawFields.length * 180 }} /> : !loading && <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={error ? '来源记录加载失败' : '当前条件没有来源记录'} />}
|
||||
{error && <Alert type="error" showIcon message="来源明细加载失败" description={error} action={<Button size="small" onClick={() => setRevision(value => value + 1)}>重试</Button>} />}
|
||||
{fetching ? <div className="loading-panel"><Spin />正在读取来源行…</div> : result?.rows.length ? <Table size="small" bordered columns={fixedColumns} dataSource={result.rows} rowKey="id" pagination={false} scroll={{ x: 1800 + visibleRawFields.length * 180 }} /> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={error ? '来源记录加载失败' : '当前条件没有来源记录'} />}
|
||||
{result && result.total > result.pageSize && <Pagination className="records-pagination" current={page} pageSize={result.pageSize} total={result.total} showTotal={total => `共 ${total} 条`} onChange={next => setPage(next)} />}
|
||||
</Drawer>;
|
||||
}
|
||||
|
||||
export { fullYearTrend };
|
||||
|
||||
Reference in New Issue
Block a user