date-picker.vue
2.99 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
81
82
83
84
85
86
87
<template>
<div class="comp">
<div class="date-mask" v-if="visible" @click="showCalendar()"></div>
<div class="ipt-wrap" :class="{'readonly':readonly}">
<input v-bind:value="value" v-on:input="$emit('input', $event.target.value)" @click="showCalendar(true)" class="ipt" :style="cusStyle" type="type" :readonly="readonly" :placeholder="placeholder || $t('form.datePicker.datePlaceholder')">
</div>
<div v-if="visible" class="date-wrap">
<div class="calendar-wrap">
<!-- 标题 -->
<div class="nav-wrap">
<div class="date-wrap">
<div class="pointer nav-btn" @click="onPrevHandler">
<img src="@/assets/images/form/date-picker/data-picker-icon-up.png">
</div>
<div @click="onTypeHandler()" class="date">
<span class="pointer">
<template v-if="dateType == 1">
<!-- {{year}}年{{month}}月 -->
{{getDateType1}}
</template>
<template v-if="dateType == 2">
{{getDateType2}}
</template>
<template v-if="dateType == 3">
{{yearRange}}
</template>
</span>
</div>
<div class="pointer nav-btn" @click="onNextHandler">
<img src="@/assets/images/form/date-picker/data-picker-icon-down.png">
</div>
</div>
</div>
<!-- 日历躯干 日 -->
<div v-if="dateType == 1" class="con day">
<!-- 日历表头 -->
<div class="th tr">
<div class="td" :class="{'disable':!weekend}">{{getDayList[0]}}</div>
<div class="td">{{getDayList[1]}}</div>
<div class="td">{{getDayList[2]}}</div>
<div class="td">{{getDayList[3]}}</div>
<div class="td">{{getDayList[4]}}</div>
<div class="td">{{getDayList[5]}}</div>
<div class="td" :class="{'disable':!weekend}">{{getDayList[6]}}</div>
</div>
<!-- 日历主体 -->
<div class="tr">
<div class="td" v-for="(item,index) in fortmatMonthData" :key="index">
<div @click="selectDay(item.disable ? null : item)" v-if="item && item.date" class="pointer point" :class="{'act':item && activity(item),'disable':item.disable}">
<div>{{item && item.date || ""}}</div>
</div>
</div>
</div>
</div>
<!-- 月 -->
<div v-if="dateType == 2" class="con month">
<div class="tr">
<div class="td" v-for="(item,index) in monthList" :key="index">
<div @click="selectMonth(item.disable ? null : item)" class="pointer point" :class="{'disable':item.disable}">
{{getMonthByIndex(item.month)}}
</div>
</div>
</div>
</div>
<!-- 年 -->
<div v-if="dateType == 3" class="con year">
<div class="tr">
<div class="td" v-for="(item,index) in yearList" :key="index">
<div @click="selectYear(item.disable ? null : item)" class="pointer point " :class="{'disable':item.disable}" >
{{item.year}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script src="./date-picker.js"></script>
<style lang="scss" scoped>
@import "./date-picker.scss";
</style>