Commit 4fccd7b5 by chenwq

优化时间筛选组件,添加禁用未来日期的功能,并更新仪表板使用的时间选项

1 parent e7c74a00
Pipeline #583 for 4fccd7b5 failed in 0 seconds
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* 外观只取 @uj/design-tokens 的 --uj-* 语义令牌,不写死色值。 * 外观只取 @uj/design-tokens 的 --uj-* 语义令牌,不写死色值。
* 状态矩阵:default / hover / active(aria-pressed) / focus-visible / disabled。 * 状态矩阵:default / hover / active(aria-pressed) / focus-visible / disabled。
*/ */
import type { Dayjs } from 'dayjs'; import dayjs, { type Dayjs } from 'dayjs';
import { UDatePicker } from '@uj/ui'; import { UDatePicker } from '@uj/ui';
import './PeriodFilter.css'; import './PeriodFilter.css';
...@@ -77,6 +77,7 @@ export function PeriodFilter<T extends string | number>({ ...@@ -77,6 +77,7 @@ export function PeriodFilter<T extends string | number>({
next && next[0] && next[1] ? [next[0], next[1]] : null, next && next[0] && next[1] ? [next[0], next[1]] : null,
) )
} }
disabledDate={(date) => date.isAfter(dayjs(), 'day')}
allowClear allowClear
/> />
) : null} ) : null}
......
...@@ -22,8 +22,15 @@ import { dashboardApi, type TrendPoint } from '@/api'; ...@@ -22,8 +22,15 @@ import { dashboardApi, type TrendPoint } from '@/api';
import { errorDetail } from '@/utils/error'; import { errorDetail } from '@/utils/error';
import './index.css'; import './index.css';
/** 指标卡与趋势卡共用同一组档位定义,文案与后端 dateType 的实际含义保持一致。 */ /** 顶部指标的 dateType:今日 / 昨日 / 本月 / 上月。 */
const PERIODS: ReadonlyArray<PeriodOption<number>> = [ const BOARD_PERIODS: ReadonlyArray<PeriodOption<number>> = [
{ value: 1, label: '今日' },
{ value: 2, label: '昨日' },
{ value: 3, label: '本月' },
{ value: 4, label: '上月' },
];
/** 趋势接口的 dateType:近 7 日 / 本月 / 上月 / 近 30 日。 */
const TREND_PERIODS: ReadonlyArray<PeriodOption<number>> = [
{ value: 1, label: '近7日' }, { value: 1, label: '近7日' },
{ value: 2, label: '本月' }, { value: 2, label: '本月' },
{ value: 3, label: '上月' }, { value: 3, label: '上月' },
...@@ -126,7 +133,7 @@ function Trend({ title, load }: { title: string; load: (type: number) => Promise ...@@ -126,7 +133,7 @@ function Trend({ title, load }: { title: string; load: (type: number) => Promise
<UText strong>{title}趋势</UText> <UText strong>{title}趋势</UText>
<PeriodFilter <PeriodFilter
value={type} value={type}
options={PERIODS} options={TREND_PERIODS}
onChange={setType} onChange={setType}
ariaLabel={`${title}趋势时间筛选`} ariaLabel={`${title}趋势时间筛选`}
/> />
...@@ -202,7 +209,7 @@ export default function Dashboard() { ...@@ -202,7 +209,7 @@ export default function Dashboard() {
<div> <div>
<PeriodFilter <PeriodFilter
value={dateType} value={dateType}
options={PERIODS} options={BOARD_PERIODS}
onChange={setDateType} onChange={setDateType}
range={range} range={range}
onRangeChange={setRange} onRangeChange={setRange}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!