This commit is contained in:
wintsa 2026-08-21 14:47:42 +08:00
parent 1f315a40da
commit 807e1e016b

View File

@ -168,18 +168,6 @@ const defaultTemplateFilterNode = {
label: '默认模板', label: '默认模板',
} as const; } as const;
const overallSummaryKey = 'summary'; const overallSummaryKey = 'summary';
const pivotGridWanValueFields = new Set([
'lowValue',
'centerValue',
'highValue',
'maxValue',
'minValue',
'avgValue',
'medianValue',
'standardDeviation',
'interquartileRange',
]);
// const mockGeoLocationPayload = { // const mockGeoLocationPayload = {
// checkStrictly: true, // checkStrictly: true,
// type: 3, // type: 3,
@ -301,9 +289,6 @@ function formatNumber(value: number, maximumFractionDigits: number) {
function formatCostValue(value: number) { function formatCostValue(value: number) {
const absValue = Math.abs(value); const absValue = Math.abs(value);
if (absValue >= 10000) {
return `${formatNumber(value / 10000, 2)}万元`;
}
const fractionDigits = absValue > 0 && absValue < 1 ? 4 : 2; const fractionDigits = absValue > 0 && absValue < 1 ? 4 : 2;
return `${formatNumber(value, fractionDigits)}`; return `${formatNumber(value, fractionDigits)}`;
} }
@ -324,16 +309,7 @@ function formatChartValue(value: number, metricKey: MetricKey) {
return formatAreaMetricValue(value); return formatAreaMetricValue(value);
} }
function formatGridWanValue(value: number) {
const wanValue = value / 10000;
const fractionDigits = Math.abs(wanValue) > 0 && Math.abs(wanValue) < 1 ? 4 : 2;
return formatNumber(wanValue, fractionDigits);
}
function formatGridMetricValue(value: number, metricKey: MetricKey) { function formatGridMetricValue(value: number, metricKey: MetricKey) {
if (metricKey === 'cost') {
return formatGridWanValue(value);
}
const absValue = Math.abs(value); const absValue = Math.abs(value);
const fractionDigits = absValue > 0 && absValue < 1 ? 4 : 2; const fractionDigits = absValue > 0 && absValue < 1 ? 4 : 2;
return formatNumber(value, fractionDigits); return formatNumber(value, fractionDigits);
@ -1102,7 +1078,7 @@ function App() {
); );
const pivotGridColumnDefs = useMemo<(ColDef<PivotGridRow> | ColGroupDef<PivotGridRow>)[]>( const pivotGridColumnDefs = useMemo<(ColDef<PivotGridRow> | ColGroupDef<PivotGridRow>)[]>(
() => { () => {
const valueUnit = requestMetricKey === 'cost' ? '元' : '元/m²'; const valueUnit = requestMetricKey === 'cost' ? '元' : '元/m²';
const valueColumnMinWidth = requestMetricKey === 'cost' ? 112 : 142; const valueColumnMinWidth = requestMetricKey === 'cost' ? 112 : 142;
const valueFormatter = ({ value }: ValueFormatterParams<PivotGridRow, number | null>) => ( const valueFormatter = ({ value }: ValueFormatterParams<PivotGridRow, number | null>) => (
value == null ? '' : formatGridMetricValue(Number(value), requestMetricKey) value == null ? '' : formatGridMetricValue(Number(value), requestMetricKey)
@ -1231,12 +1207,6 @@ function App() {
const exportPivotGrid = useCallback(() => { const exportPivotGrid = useCallback(() => {
pivotGridApiRef.current?.exportDataAsCsv({ pivotGridApiRef.current?.exportDataAsCsv({
fileName: '建筑设施对象统计表.csv', fileName: '建筑设施对象统计表.csv',
processCellCallback: ({ column, value }) => {
if (value == null) return '';
return pivotGridWanValueFields.has(column.getColId())
? String(Number(value) / 10000)
: String(value);
},
}); });
setGridContextMenuPosition(null); setGridContextMenuPosition(null);
}, []); }, []);