mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
feat: 时间类的事件和动作补充
This commit is contained in:
parent
be000fb38a
commit
15c36bc608
@ -417,25 +417,29 @@ export default class DateControl extends React.PureComponent<
|
||||
@autobind
|
||||
dispatchEvent(event: React.SyntheticEvent<HTMLElement> | string, data: any = {}) {
|
||||
const {dispatchEvent} = this.props;
|
||||
dispatchEvent(event, createObject(data));
|
||||
const dispatcher = dispatchEvent(event, createObject(data));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 动作
|
||||
doAction(action: Action, data: object, throwErrors: boolean) {
|
||||
const {resetValue, onChange} = this.props;
|
||||
if (action.actionType === 'clear') {
|
||||
onChange('');
|
||||
}
|
||||
if (action.actionType === 'reset') {
|
||||
onChange(resetValue || '');
|
||||
onChange(resetValue ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
// 值的变化
|
||||
@autobind
|
||||
handleChange(data: any) {
|
||||
async handleChange(data: any) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject(data));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
this.props.onChange(data);
|
||||
this.dispatchEvent('change', data);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -167,22 +167,29 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
||||
@autobind
|
||||
dispatchEvent(event: React.SyntheticEvent<HTMLElement> | string, data: any = {}) {
|
||||
const {dispatchEvent} = this.props;
|
||||
dispatchEvent(event, createObject(data));
|
||||
const dispatcher = dispatchEvent(event, createObject(data));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 动作
|
||||
doAction(action: Action, data: object, throwErrors: boolean) {
|
||||
const {resetValue, onChange} = this.props;
|
||||
if (includes(['clear', 'reset'], action.actionType)) {
|
||||
onChange(resetValue || '');
|
||||
if (action.actionType === 'clear') {
|
||||
onChange(resetValue ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
// 值的变化
|
||||
@autobind
|
||||
handleChange(data: any) {
|
||||
async handleChange(data: any) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject(data));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
this.props.onChange(data);
|
||||
this.dispatchEvent('change', data);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -164,22 +164,29 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
||||
@autobind
|
||||
dispatchEvent(event: React.SyntheticEvent<HTMLElement> | string, data: any = {}) {
|
||||
const {dispatchEvent} = this.props;
|
||||
dispatchEvent(event, createObject(data));
|
||||
const dispatcher = dispatchEvent(event, createObject(data));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 动作
|
||||
doAction(action: Action, data: object, throwErrors: boolean) {
|
||||
const {resetValue, onChange} = this.props;
|
||||
if (includes(['clear', 'reset'], action.actionType)) {
|
||||
onChange(resetValue || '');
|
||||
if (action.actionType === 'clear') {
|
||||
onChange(resetValue ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
// 值的变化
|
||||
@autobind
|
||||
handleChange(data: any) {
|
||||
async handleChange(data: any) {
|
||||
const {dispatchEvent} = this.props;
|
||||
const dispatcher = dispatchEvent('change', createObject(data));
|
||||
if (dispatcher?.prevented) {
|
||||
return;
|
||||
}
|
||||
this.props.onChange(data);
|
||||
this.dispatchEvent('change', data);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -45,6 +45,9 @@ export default class QuarterRangeControl extends InputDateRange {
|
||||
maxDate={maxDate ? filterDate(maxDate, data, format) : undefined}
|
||||
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
||||
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
||||
onChange={this.handleChange}
|
||||
onFocus={this.dispatchEvent}
|
||||
onBlur={this.dispatchEvent}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -18,28 +18,6 @@ export interface YearRangeControlSchema
|
||||
|
||||
export default class YearRangeControl extends InputDateRange {
|
||||
|
||||
// 派发有event的事件
|
||||
@autobind
|
||||
dispatchEvent(event: React.SyntheticEvent<HTMLElement> | string, data: any = {}) {
|
||||
const {dispatchEvent} = this.props;
|
||||
dispatchEvent(event, createObject(data));
|
||||
}
|
||||
|
||||
// 动作
|
||||
doAction(action: Action, data: object, throwErrors: boolean) {
|
||||
const {resetValue, onChange} = this.props;
|
||||
if (includes(['clear', 'reset'], action.actionType)) {
|
||||
onChange(resetValue || '');
|
||||
}
|
||||
}
|
||||
|
||||
// 值的变化
|
||||
@autobind
|
||||
handleChange(data: any) {
|
||||
this.props.onChange(data);
|
||||
this.dispatchEvent('change', data);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
className,
|
||||
|
Loading…
Reference in New Issue
Block a user