feat(platform): add customer time window presets

This commit is contained in:
lingniu
2026-07-05 19:28:25 +08:00
parent 0bfc47bc1c
commit 0c3c6e7b3d
4 changed files with 142 additions and 26 deletions

View File

@@ -121,6 +121,16 @@ function customerStatusTitle(title?: string) {
return title === '来源不完整' ? '数据通道不完整' : title;
}
function dateText(offsetDays = 0) {
const date = new Date();
date.setHours(0, 0, 0, 0);
date.setDate(date.getDate() + offsetDays);
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}`;
}
export function AppShell({
activePage,
linkIssueCount,
@@ -161,6 +171,13 @@ export function AppShell({
const dateFrom = customerTimeWindow?.dateFrom ?? '';
const dateTo = customerTimeWindow?.dateTo ?? '';
const applyTimeWindowPreset = (days: number) => {
onCustomerTimeWindowChange?.({
dateFrom: dateText(-(days - 1)),
dateTo: dateText()
});
};
const search = () => {
const value = keyword.trim();
if (!value) {
@@ -283,6 +300,12 @@ export function AppShell({
onChange={(event) => onCustomerTimeWindowChange?.({ dateFrom, dateTo: event.currentTarget.value })}
/>
</label>
<div className="vp-topbar-time-window-presets">
<button type="button" aria-label="顶部时间窗 今天" onClick={() => applyTimeWindowPreset(1)}></button>
<button type="button" aria-label="顶部时间窗 近7天" onClick={() => applyTimeWindowPreset(7)}>7</button>
<button type="button" aria-label="顶部时间窗 近30天" onClick={() => applyTimeWindowPreset(30)}>30</button>
<button type="button" aria-label="顶部时间窗 清空" onClick={() => onCustomerTimeWindowChange?.({})}></button>
</div>
</div>
{currentVehicleLabel ? <Tag color="grey">{currentVehicleLabel}</Tag> : null}
{currentVehicleStatus ? (