date-picker: fix week highlight on year boundary (#13883)

When the selected week spans across two years (e.g. 2018-12-30 2019-01-05),
they should be highlighted in both month tables.
pull/13988/head
Sean 2019-01-03 00:43:37 -06:00 committed by Jiewei Qian
parent 9579d00b27
commit 5f181c31e3
1 changed files with 7 additions and 3 deletions

View File

@ -32,7 +32,7 @@
</template>
<script>
import { getFirstDayOfMonth, getDayCountOfMonth, getWeekNumber, getStartDateOfMonth, nextDate, isDate, clearTime as _clearTime} from '../util';
import { getFirstDayOfMonth, getDayCountOfMonth, getWeekNumber, getStartDateOfMonth, prevDate, nextDate, isDate, clearTime as _clearTime} from '../util';
import Locale from 'element-ui/src/mixins/locale';
import { arrayFindIndex, arrayFind, coerceTruthyValueToArray } from 'element-ui/src/utils/util';
@ -321,8 +321,12 @@
newDate.setDate(parseInt(cell.text, 10));
const valueYear = isDate(this.value) ? this.value.getFullYear() : null;
return year === valueYear && getWeekNumber(newDate) === getWeekNumber(this.value);
if (isDate(this.value)) {
const dayOffset = (this.value.getDay() - this.firstDayOfWeek + 7) % 7 - 1;
const weekDate = prevDate(this.value, dayOffset);
return weekDate.getTime() === newDate.getTime();
}
return false;
},
markRange(minDate, maxDate) {