fix: datetime-range修复picker改动 (#3314)

Co-authored-by: hongyang03 <hongyang03@baidu.com>
This commit is contained in:
HongYang 2021-12-30 20:22:13 +08:00 committed by GitHub
parent 1c21a0c977
commit 1aa45a631f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -245,7 +245,7 @@
background: #fff; background: #fff;
box-shadow: 0 0 2px 2px rgba(0,0,0,0.02); box-shadow: 0 0 2px 2px rgba(0,0,0,0.02);
border-radius: 24px; border-radius: 24px;
overflow-x: scroll; overflow-x: auto;
position: relative; position: relative;
height: px2rem(48px); height: px2rem(48px);
line-height: px2rem(48px); line-height: px2rem(48px);
@ -345,7 +345,7 @@
} }
&-time { &-time {
height: px2rem(200px); height: px2rem(180px);
&-title { &-title {
border: var(--Calendar-borderWidth) solid var(--borderColorDarken); border: var(--Calendar-borderWidth) solid var(--borderColorDarken);
border-left: none; border-left: none;
@ -358,4 +358,11 @@
margin: 0 auto; margin: 0 auto;
} }
} }
.#{$ns}CalendarTime {
height: px2rem(130px);
overflow: hidden;
}
.#{$ns}PickerColumns-header {
display: none;
}
} }

View File

@ -252,8 +252,8 @@ export class CalendarMobile extends React.Component<
if (startDate) { if (startDate) {
let obj = { let obj = {
dateTime: newTime, dateTime: newTime,
startDate: endDate ? startDate : startDate?.clone().set({hour: newTime[0], minute: newTime[1], second: 0}), startDate: endDate ? startDate : startDate?.clone().set({hour: newTime[0], minute: newTime[1], second: newTime[2] || 0}),
endDate: !endDate ? endDate : endDate?.clone().set({hour: newTime[0], minute: newTime[1], second: 0}) endDate: !endDate ? endDate : endDate?.clone().set({hour: newTime[0], minute: newTime[1], second: newTime[2] || 0})
}; };
this.setState(obj, () => { this.setState(obj, () => {
onChange && onChange(this.state); onChange && onChange(this.state);
@ -361,7 +361,7 @@ export class CalendarMobile extends React.Component<
) { ) {
return this.setState( return this.setState(
{ {
endDate: newValue.clone().endOf(precision).set({hour: dateTime[0], minute: dateTime[1], second: 0}) endDate: newValue.clone().endOf(precision).set({hour: dateTime[0], minute: dateTime[1], second: dateTime[2] || 0})
}, },
() => { () => {
onChange && onChange(this.state, () => embed && confirm && confirm()); onChange && onChange(this.state, () => embed && confirm && confirm());
@ -371,7 +371,7 @@ export class CalendarMobile extends React.Component<
this.setState( this.setState(
{ {
startDate: newValue.clone().startOf(precision).set({hour: dateTime[0], minute: dateTime[1], second: 0}), startDate: newValue.clone().startOf(precision).set({hour: dateTime[0], minute: dateTime[1], second: dateTime[2] || 0}),
endDate: undefined endDate: undefined
}, },
() => { () => {
@ -477,7 +477,7 @@ export class CalendarMobile extends React.Component<
locale={locale} locale={locale}
useMobileUI={true} useMobileUI={true}
showToolbar={false} showToolbar={false}
viewDate={moment().set({hour: dateTime[0], minute: dateTime[1], second: 0})} viewDate={moment().set({hour: dateTime[0], minute: dateTime[1], second: dateTime[2] || 0})}
/> />
</div> </div>
); );

View File

@ -214,6 +214,7 @@ export class CustomTimeView extends TimeView {
this.setState((prevState: State) => { this.setState((prevState: State) => {
return {...prevState, ...time} return {...prevState, ...time}
}); });
this.props.onChange && this.props.onChange(value);
} }
renderTimeViewPicker = () => { renderTimeViewPicker = () => {