import type { MetricRow, QueryParams, ViewKind } from './types'; /** Freeze the clicked metric's filters and release together for every detail/export request. */ export function freezeSourceRecordsQuery(query: QueryParams, releaseId: string, view: ViewKind, row: MetricRow | null, month?: number): QueryParams { if (!releaseId) throw new Error('指标数据尚未就绪,请重新查询后打开来源明细。'); const frozen = JSON.parse(JSON.stringify(query)) as QueryParams; frozen.releaseId = releaseId; if (month) { frozen.month = month; delete frozen.quarter; } if (row && view !== 'overall') { const dimension = view === 'projectGroup' ? 'projectGroup' : view; frozen[dimension] = row.key === '__UNASSIGNED__' ? '__UNASSIGNED__' : row[dimension] || row.key; } return frozen; }