update DatePicker

update DatePicker
This commit is contained in:
梁灏 2016-12-15 20:16:58 +08:00
parent 10f622acb9
commit c46f385a83
9 changed files with 565 additions and 56 deletions

View file

@ -6,7 +6,7 @@
<div :class="[prefixCls + '-header']">
<span></span><span></span><span></span><span></span><span></span><span></span><span></span>
</div>
<span :class="getCellCls(cell)" v-for="cell in cells"><em>{{ cell.text }}</em></span>
<span :class="getCellCls(cell)" v-for="cell in cells"><em :index="$index">{{ cell.text }}</em></span>
</div>
</template>
<script>
@ -126,8 +126,40 @@
}
},
methods: {
handleClick () {
handleClick (event) {
const target = event.target;
if (target.tagName === 'EM') {
const cell = this.cells[parseInt(event.target.getAttribute('index'))];
if (cell.disabled) return;
let year = this.year;
let month = this.month;
let day = cell.text;
if (cell.type === 'prev-month') {
if (month === 0) {
month = 11;
year--;
} else {
month--;
}
} else if (cell.type === 'next-month') {
if (month === 11) {
month = 0;
year++;
} else {
month++;
}
}
const newDate = new Date(year, month, day);
if (this.selectionMode === 'range') {
// todo
} else {
this.$emit('on-pick', newDate);
}
}
},
handleMouseMove () {