云
17 小时以前 c2e8526f8f857be5e3a8c6f2b39c5efd424de33e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import dayjs from 'dayjs';
 
/** 日期查询包含结束日期当天的全部质检记录,分页与导出使用相同口径。 */
export function normalizeQcDateFilter<T extends object>(params: T): T {
  const normalized: Record<string, string[]> = {};
  for (const field of ['inspectDate', 'receiveDate'] as const) {
    const range = (params as { inspectDate?: string[]; receiveDate?: string[] })[field];
    if (!Array.isArray(range) || range.length !== 2) continue;
    const start = dayjs(range[0]);
    const end = dayjs(range[1]);
    if (!start.isValid() || !end.isValid()) continue;
    normalized[field] = [
      start.startOf('day').format('YYYY-MM-DD HH:mm:ss'),
      end.endOf('day').format('YYYY-MM-DD HH:mm:ss'),
    ];
  }
  return Object.keys(normalized).length > 0 ? { ...params, ...normalized } : params;
}