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>
|
e8a990f5
Sergio Crisostomo
hide ranges in mo...
|
14
|
import { clearHours } 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
|
const selectedDays = this.dates.filter(Boolean).map(date => clearHours(new Date(date.getFullYear(), 0, 1)));
|
c46f385a
梁灏
update DatePicker
|
42
|
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
43
44
45
46
47
|
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);
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
48
|
cell.selected = selectedDays.includes(time);
|
c46f385a
梁灏
update DatePicker
|
49
50
51
52
53
54
55
56
57
58
59
60
|
cells.push(cell);
}
return cells;
}
},
methods: {
getCellCls (cell) {
return [
`${prefixCls}-cell`,
{
[`${prefixCls}-cell-selected`]: cell.selected,
|
ca8e830c
Sergio Crisostomo
move files to sub...
|
61
62
|
[`${prefixCls}-cell-disabled`]: cell.disabled,
[`${prefixCls}-cell-range`]: cell.range && !cell.start && !cell.end
|
c46f385a
梁灏
update DatePicker
|
63
|
}
|
b0893113
jingsam
add eslint
|
64
|
];
|
c46f385a
梁灏
update DatePicker
|
65
|
},
|
c46f385a
梁灏
update DatePicker
|
66
|
}
|
b0893113
jingsam
add eslint
|
67
68
|
};
</script>
|