feat(platform): add global customer time window

This commit is contained in:
lingniu
2026-07-05 19:21:52 +08:00
parent 4085268971
commit 0bfc47bc1c
4 changed files with 148 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ export default function App() {
const [qualityFilters, setQualityFilters] = useState<Record<string, string>>(
initialRoute.page === 'quality' || initialRoute.page === 'alert-events' ? qualityFiltersFromRoute(initialRoute) : {}
);
const [customerTimeWindow, setCustomerTimeWindow] = useState<Record<string, string>>(timeWindowFiltersFromRoute(initialRoute));
const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null);
const [activeAlertRuleCount, setActiveAlertRuleCount] = useState<number | null>(null);
const [p0AlertRuleCount, setP0AlertRuleCount] = useState<number | null>(null);
@@ -143,6 +144,10 @@ export default function App() {
if (route.page === 'quality' || route.page === 'alert-events') {
setQualityFilters(qualityFiltersFromRoute(route));
}
const routeTimeWindow = timeWindowFiltersFromRoute(route);
if (routeTimeWindow.dateFrom || routeTimeWindow.dateTo) {
setCustomerTimeWindow(routeTimeWindow);
}
setActiveProtocol(route.protocol ?? '');
setHistoryTab(route.filters?.tab ?? (route.page === 'history-query' ? 'raw' : 'location'));
};
@@ -446,6 +451,14 @@ export default function App() {
};
const currentCustomerTaskTimeWindow = () => {
const globalDateFrom = customerTimeWindow.dateFrom?.trim();
const globalDateTo = customerTimeWindow.dateTo?.trim();
if (globalDateFrom || globalDateTo) {
return {
...(globalDateFrom ? { dateFrom: globalDateFrom } : {}),
...(globalDateTo ? { dateTo: globalDateTo } : {})
};
}
const candidates = activePage === 'mileage'
? [mileageFilters, historyFilters, qualityFilters]
: activePage === 'history' || activePage === 'history-query'
@@ -535,12 +548,19 @@ export default function App() {
};
return (
<AppShell activePage={activePage} linkIssueCount={linkIssueCount} activeAlertRuleCount={activeAlertRuleCount} p0AlertRuleCount={p0AlertRuleCount} platformRelease={platformRelease} currentVehicleStatus={currentVehicleStatus} currentVehicleLabel={currentVehicleLabel} currentVehicleConsistency={currentVehicleConsistency} onChange={navigatePage} onCustomerTask={openCustomerTask} onVehicleSearch={openVehicle}>
<AppShell activePage={activePage} linkIssueCount={linkIssueCount} activeAlertRuleCount={activeAlertRuleCount} p0AlertRuleCount={p0AlertRuleCount} platformRelease={platformRelease} currentVehicleStatus={currentVehicleStatus} currentVehicleLabel={currentVehicleLabel} currentVehicleConsistency={currentVehicleConsistency} customerTimeWindow={customerTimeWindow} onCustomerTimeWindowChange={setCustomerTimeWindow} onChange={navigatePage} onCustomerTask={openCustomerTask} onVehicleSearch={openVehicle}>
{pages[activePage]}
</AppShell>
);
}
function timeWindowFiltersFromRoute(route: ReturnType<typeof parseAppHash>): Record<string, string> {
return {
...(route.filters?.dateFrom ? { dateFrom: route.filters.dateFrom } : {}),
...(route.filters?.dateTo ? { dateTo: route.filters.dateTo } : {})
};
}
function qualityFiltersFromRoute(route: ReturnType<typeof parseAppHash>): Record<string, string> {
return {
...(route.keyword ? { keyword: route.keyword } : {}),