feat(platform): add customer time window presets
This commit is contained in:
@@ -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 ? (
|
||||
|
||||
Reference in New Issue
Block a user