Skip to content

Commit

Permalink
Merge pull request #804 from XiaoMi/feature/daterange
Browse files Browse the repository at this point in the history
update
  • Loading branch information
solarjoker authored Nov 28, 2019
2 parents 6d8adba + ef1c331 commit 49769bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions components/date-picker/DateRangePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ class DateRangePanel extends Component {
* @param {Number} year 当前年份
* @param {Number} month 当前月份
*/
getHeaderCenterContent (year, month) {
getHeaderCenterContent (year, month, flag) {
const { localeDatas, locale } = this.props
const {currentView} = this.state
if (currentView === 'year') {
const { layout } = this.state
if (layout[flag] === 'year') {
return (year - 4) + '~' + (year + 7)
}
let arr = [localeDatas.datePicker.monthShort[month - 1]]
Expand Down Expand Up @@ -192,7 +192,7 @@ class DateRangePanel extends Component {
this.setState({ layout })
}}
>
{this.getHeaderCenterContent(year, month)}
{this.getHeaderCenterContent(year, month, lr)}
</span>
{
<div className='hi-datepicker__header-btns'>
Expand Down Expand Up @@ -283,15 +283,15 @@ class DateRangePanel extends Component {
}

getRangeDateStr () {
let {leftDate, rightDate, showMask} = this.state
let { range, showMask, leftDate, rightDate } = this.state
let { format } = this.props
format = format.substr(format.match(/[H|h]\s*/).index)
const cls = classNames(
showMask && 'hi-datepicker__time-text'
)
return (
<span className={cls}>
{`${dateFormat(leftDate, format)} - ${dateFormat(rightDate, format)}`}
{`${dateFormat(range.startDate ? range.startDate : leftDate, format)} - ${dateFormat(range.endDate ? range.endDate : rightDate, format)}`}
</span>
)
}
Expand Down Expand Up @@ -450,6 +450,7 @@ class DateRangePanel extends Component {
date={date}
onPick={(d, r) => {
this.setState({
range: d,
leftDate: d.startDate,
rightDate: d.endDate
})
Expand Down
8 changes: 4 additions & 4 deletions components/date-picker/WeekRangePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export default class WeekRangePanel extends Component {
* @param {Number} year 当前年份
* @param {Number} month 当前月份
*/
getHeaderCenterContent (year, month) {
getHeaderCenterContent (year, month, flag) {
const { localeDatas, locale } = this.props
const {currentView} = this.state
if (currentView === 'year') {
const { layout } = this.state
if (layout[flag] === 'year') {
return (year - 4) + '~' + (year + 7)
}
let arr = [localeDatas.datePicker.monthShort[month - 1]]
Expand Down Expand Up @@ -105,7 +105,7 @@ export default class WeekRangePanel extends Component {
const layout = Object.assign({}, this.state.layout, {[lr]: 'year'})
this.setState({ layout })
}}>
{this.getHeaderCenterContent(year, month)}
{this.getHeaderCenterContent(year, month, lr)}
</span>
<div className='hi-datepicker__header-btns'>
<span onClick={() => this.changeMonth(false, lr)} ><Icon name='right' /></span>
Expand Down

0 comments on commit 49769bb

Please sign in to comment.