17e1fcf1
梁灏
init DatePicker
|
1
|
<template>
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
2
3
4
5
6
7
8
9
10
|
<div :class="classes">
<span
:class="getCellCls(cell)"
v-for="cell in cells"
@click="handleClick(cell)"
@mouseenter="handleMouseMove(cell)"
>
<em>{{ cell.date.getFullYear() }}</em>
</span>
|
c46f385a
梁灏
update DatePicker
|
11
|
</div>
|
17e1fcf1
梁灏
init DatePicker
|
12
13
|
</template>
<script>
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
14
|
import { clearHours, isInRange } from '../util';
|
c46f385a
梁灏
update DatePicker
|
15
|
import { deepCopy } from '../../../utils/assist';
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
16
17
|
import mixin from './mixin';
import prefixCls from './prefixCls';
|
c46f385a
梁灏
update DatePicker
|
18
|
|
17e1fcf1
梁灏
init DatePicker
|
19
|
export default {
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
20
21
22
|
mixins: [ mixin ],
props: {/* in mixin */},
|
c46f385a
梁灏
update DatePicker
|
23
|
computed: {
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
24
|
classes() {
|
c46f385a
梁灏
update DatePicker
|
25
26
27
|
return [
`${prefixCls}`,
`${prefixCls}-year`
|
b0893113
jingsam
add eslint
|
28
|
];
|
c46f385a
梁灏
update DatePicker
|
29
30
|
},
startYear() {
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
31
|
return Math.floor(this.tableDate.getFullYear() / 10) * 10;
|
c46f385a
梁灏
update DatePicker
|
32
33
34
35
36
37
38
39
40
|
},
cells () {
let cells = [];
const cell_tmpl = {
text: '',
selected: false,
disabled: false
};
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
41
42
43
|
const rangeStart = this.rangeState.from && clearHours(new Date(this.rangeState.from.getFullYear(), 0, 1));
const rangeEnd = this.rangeState.to && clearHours(new Date(this.rangeState.to.getFullYear(), 0, 1));
const selectedDays = this.dates.filter(Boolean).map(date => clearHours(new Date(date.getFullYear(), 0, 1)));
|
c46f385a
梁灏
update DatePicker
|
44
|
|
c46f385a
梁灏
update DatePicker
|
45
|
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
46
47
48
49
50
51
52
|
for (let i = 0; i < 10; i++) {
const cell = deepCopy(cell_tmpl);
cell.date = new Date(this.startYear + i, 0, 1);
cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(cell.date) && this.selectionMode === 'year';
const time = clearHours(cell.date);
cell.range = isInRange(time, rangeStart, rangeEnd);
cell.selected = selectedDays.includes(time);
|
c46f385a
梁灏
update DatePicker
|
53
54
55
56
57
58
59
60
61
62
63
64
|
cells.push(cell);
}
return cells;
}
},
methods: {
getCellCls (cell) {
return [
`${prefixCls}-cell`,
{
[`${prefixCls}-cell-selected`]: cell.selected,
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
65
66
|
[`${prefixCls}-cell-disabled`]: cell.disabled,
[`${prefixCls}-cell-range`]: cell.range && !cell.start && !cell.end
|
c46f385a
梁灏
update DatePicker
|
67
|
}
|
b0893113
jingsam
add eslint
|
68
|
];
|
c46f385a
梁灏
update DatePicker
|
69
|
},
|
c46f385a
梁灏
update DatePicker
|
70
|
}
|
b0893113
jingsam
add eslint
|
71
72
|
};
</script>
|