dateMonths.vue
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<style type="text/css">
.datepicker table tr td span.disabled{
color: #ccc;
}
</style>
<template>
<div class="datepicker-months vue-show-imo">
<table class=" table-condensed">
<thead>
<tr>
<th class="prev" @click="prev">
<i class="fa fa-chevron-left fi-arrow-left"></i>
</th>
<th colspan="5" class="date-switch">{{year}}</th>
<th class="next" @click="next">
<i class="fa fa-chevron-right fi-arrow-right"></i>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7" >
<span :class="{active1:month===+m,disabled:isnot(m),month:'month'}" v-for="m in months" v-text="m" @click="selectMonth(m)"></span>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
props:["dateTime","mo","end"],
data(){
return {
months:['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
}
},
computed:{
year() {
return this.dateTime.year
},
month(){
return this.dateTime.month+1
}
},
methods:{
prev() {
this.currentMonth = ""
this.dateTime.year-=1;
},
next() {
this.currentMonth = ""
this.dateTime.year+=1
},
selectMonth(value){
if(this.isnot(value)){
return
}
this.dateTime.month=+value-1
this.mo=''
this.dateTime._hasdefault=true
},
isnot(value){
if(this.end){
var _a=this.end.split('-');
if(this.dateTime.year>_a[0]){
return true;
}
if(+value>_a[1]){
return true;
}
}
return false;
}
},
ready() {
this.currentMonth = this.dateTime.month
}
}
</script>