-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: find tickets by evaluation create time (#943)
- Loading branch information
Showing
9 changed files
with
173 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
next/web/src/App/Admin/Tickets/Filter/FilterForm/PresetRangePicker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { useMemo, useState } from 'react'; | ||
import moment, { Moment } from 'moment'; | ||
import { DatePicker, Select } from 'antd'; | ||
|
||
const { RangePicker } = DatePicker; | ||
|
||
const EMPTY_VALUE = ''; | ||
const RANGE_VALUE = 'range'; | ||
|
||
const options = [ | ||
{ value: EMPTY_VALUE, label: '所有时间' }, | ||
{ value: 'today', label: '今天' }, | ||
{ value: 'yesterday', label: '昨天' }, | ||
{ value: 'week', label: '本周' }, | ||
{ value: 'month', label: '本月' }, | ||
{ value: 'lastMonth', label: '上月' }, | ||
{ value: RANGE_VALUE, label: '选择时间段' }, | ||
]; | ||
|
||
interface PresetRangePickerProps { | ||
value?: string; | ||
onChange: (value?: string) => void; | ||
disabled?: boolean; | ||
} | ||
|
||
export function PresetRangePicker({ value, onChange, disabled }: PresetRangePickerProps) { | ||
const rangeValue = useMemo(() => { | ||
if (value?.includes('..')) { | ||
return value.split('..').map((str) => moment(str)); | ||
} | ||
}, [value]); | ||
|
||
const [rangeMode, setRangeMode] = useState(rangeValue !== undefined); | ||
|
||
const handleChange = (value: string) => { | ||
if (value === RANGE_VALUE) { | ||
setRangeMode(true); | ||
return; | ||
} | ||
setRangeMode(false); | ||
onChange(value === EMPTY_VALUE ? undefined : value); | ||
}; | ||
|
||
const handleChangeRange = (range: [Moment, Moment] | null) => { | ||
if (!range) { | ||
onChange(undefined); | ||
return; | ||
} | ||
const [starts, ends] = range; | ||
onChange(`${starts.toISOString()}..${ends.toISOString()}`); | ||
}; | ||
|
||
const showRangePicker = rangeMode || rangeValue !== undefined; | ||
return ( | ||
<> | ||
<Select | ||
className="w-full" | ||
options={options} | ||
value={showRangePicker ? RANGE_VALUE : value ?? EMPTY_VALUE} | ||
onChange={handleChange} | ||
disabled={disabled} | ||
/> | ||
{showRangePicker && ( | ||
<div className="pl-2 border-l border-gray-300 border-dashed"> | ||
<div className="my-2 text-[#475867] text-sm font-medium">时间段</div> | ||
<RangePicker | ||
className="w-full" | ||
value={rangeValue as any} | ||
onChange={handleChangeRange as any} | ||
showTime={{ | ||
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')], | ||
}} | ||
/> | ||
</div> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters