feat(platform): remove default history vehicle
This commit is contained in:
@@ -32,7 +32,6 @@ type RawFieldRow = {
|
||||
};
|
||||
|
||||
const defaultFilters: HistoryFilters = {
|
||||
keyword: 'LB9A32A24R0LS1426',
|
||||
includeFields: false
|
||||
};
|
||||
|
||||
@@ -55,6 +54,24 @@ function nextDate(value: string) {
|
||||
return date.toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function todayDateString() {
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
function previousDateString(value: string) {
|
||||
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
|
||||
if (!match) return value;
|
||||
const date = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]) - 1);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
function splitFields(value?: string) {
|
||||
return (value ?? '')
|
||||
.split(/[\n,]/)
|
||||
@@ -168,10 +185,24 @@ function analyzeTrajectoryAnomalies(rows: HistoryLocationRow[]): TrajectoryAnoma
|
||||
}
|
||||
|
||||
function mergeInitialFilters(initialVin: string, initialProtocol?: string, initialFilters: Record<string, string> = {}): HistoryFilters {
|
||||
const hasExplicitFilters = Object.keys(initialFilters).length > 0;
|
||||
const hasExplicitScope = Boolean(
|
||||
initialVin?.trim() ||
|
||||
initialProtocol?.trim() ||
|
||||
initialFilters.keyword?.trim() ||
|
||||
initialFilters.protocol?.trim() ||
|
||||
initialFilters.dateFrom?.trim() ||
|
||||
initialFilters.dateTo?.trim() ||
|
||||
initialFilters.fields?.trim()
|
||||
);
|
||||
const today = todayDateString();
|
||||
const defaultDateRange = hasExplicitScope ? {} : {
|
||||
dateFrom: previousDateString(today),
|
||||
dateTo: today
|
||||
};
|
||||
return {
|
||||
...defaultFilters,
|
||||
keyword: initialVin || (hasExplicitFilters ? '' : defaultFilters.keyword),
|
||||
...defaultDateRange,
|
||||
keyword: initialVin || '',
|
||||
protocol: initialProtocol,
|
||||
...initialFilters,
|
||||
includeFields: isIncludeFieldsEnabled(initialFilters.includeFields)
|
||||
@@ -1075,6 +1106,9 @@ export function History({
|
||||
<Typography.Text type="secondary">
|
||||
面向车辆服务的历史数据检索入口。先按车辆和时间缩小范围,再导出位置、原始记录或字段明细,用于客户问询、BI 核对和问题追溯。
|
||||
</Typography.Text>
|
||||
<Typography.Text type="tertiary">
|
||||
默认查询最近一天,不预置任何车辆;输入 VIN、车牌或手机号后进入单车证据交付。
|
||||
</Typography.Text>
|
||||
<Space wrap>
|
||||
<Button size="small" theme="solid" type="primary" onClick={() => openQueryTab('location')}>查询位置历史</Button>
|
||||
<Button size="small" onClick={() => openQueryTab('raw')}>查询原始记录</Button>
|
||||
|
||||
Reference in New Issue
Block a user