mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 12:58:38 +08:00
整理 closeOnSelect 逻辑
This commit is contained in:
parent
de42efad01
commit
d7e2852915
@ -229,9 +229,13 @@ export interface DatePickerState {
|
||||
}
|
||||
|
||||
export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
||||
static defaultProps: Pick<DateProps, 'viewMode' | 'shortcuts'> = {
|
||||
static defaultProps: Pick<
|
||||
DateProps,
|
||||
'viewMode' | 'shortcuts' | 'closeOnSelect'
|
||||
> = {
|
||||
viewMode: 'days',
|
||||
shortcuts: ''
|
||||
shortcuts: '',
|
||||
closeOnSelect: true
|
||||
};
|
||||
state: DatePickerState = {
|
||||
isOpened: false,
|
||||
@ -342,7 +346,8 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
||||
minTime,
|
||||
maxTime,
|
||||
dateFormat,
|
||||
timeFormat
|
||||
timeFormat,
|
||||
closeOnSelect
|
||||
} = this.props;
|
||||
|
||||
if (!moment.isMoment(value)) {
|
||||
@ -357,15 +362,17 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
||||
|
||||
onChange(value.format(format));
|
||||
|
||||
if (dateFormat && !timeFormat) {
|
||||
if (closeOnSelect && dateFormat && !timeFormat) {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
selectRannge(item: any) {
|
||||
const {closeOnSelect} = this.props;
|
||||
const now = moment();
|
||||
this.handleChange(item.date(now));
|
||||
this.close();
|
||||
|
||||
closeOnSelect && this.close();
|
||||
}
|
||||
|
||||
checkIsValidDate(currentDate: moment.Moment) {
|
||||
@ -465,7 +472,8 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
||||
popOverContainer,
|
||||
clearable,
|
||||
shortcuts,
|
||||
utc
|
||||
utc,
|
||||
closeOnSelect
|
||||
} = this.props;
|
||||
|
||||
const isOpened = this.state.isOpened;
|
||||
|
@ -172,7 +172,7 @@ export class DateRangePicker extends React.Component<
|
||||
ranges: 'yesterday,7daysago,prevweek,thismonth,prevmonth,prevquarter',
|
||||
iconClassName: 'fa fa-calendar',
|
||||
resetValue: '',
|
||||
closeOnSelect: false
|
||||
closeOnSelect: true
|
||||
};
|
||||
|
||||
innerDom: any;
|
||||
@ -389,7 +389,7 @@ export class DateRangePicker extends React.Component<
|
||||
startDate: range.startDate(now.clone()),
|
||||
endDate: range.endDate(now.clone())
|
||||
},
|
||||
closeOnSelect ? this.close : noop
|
||||
closeOnSelect ? this.confirm : noop
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4,11 +4,13 @@ import cx from 'classnames';
|
||||
import {filterDate} from '../../utils/tpl-builtin';
|
||||
import moment from 'moment';
|
||||
import 'moment/locale/zh-cn';
|
||||
import DateRangePicker from '../../components/DateRangePicker';
|
||||
import DateRangePicker, {
|
||||
DateRangePicker as BaseDateRangePicker
|
||||
} from '../../components/DateRangePicker';
|
||||
|
||||
export interface DateRangeProps extends FormControlProps {
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
disabled: boolean;
|
||||
format: string;
|
||||
joinValues: boolean;
|
||||
delimiter: string;
|
||||
@ -59,7 +61,7 @@ export default class DateRangeControl extends React.Component<
|
||||
? defaultValue.split(delimiter)
|
||||
: defaultValue;
|
||||
setPrinstineValue(
|
||||
DateRangePicker.formatValue(
|
||||
BaseDateRangePicker.formatValue(
|
||||
{
|
||||
startDate: filterDate(arr[0], data),
|
||||
endDate: filterDate(arr[1], data)
|
||||
@ -106,7 +108,7 @@ export default class DateRangeControl extends React.Component<
|
||||
|
||||
setPrinstineValue(
|
||||
arr
|
||||
? DateRangePicker.formatValue(
|
||||
? BaseDateRangePicker.formatValue(
|
||||
{
|
||||
startDate: filterDate(arr[0], data),
|
||||
endDate: filterDate(arr[1], data)
|
||||
|
Loading…
Reference in New Issue
Block a user