mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-23 11:30:35 +03:00
微调
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="calendar">
|
<div class="calendar">
|
||||||
<div class="calendar-header">
|
<div class="calendar-header">
|
||||||
<a v-show="showYearNav" class="calendar__prev-icon" @click="changeYear(-1)">«</a>
|
<a class="calendar__prev-icon" @click="changeYear(-1)">«</a>
|
||||||
<a v-show="currentPanel === 'date'" class="calendar__prev-icon" @click="changeMonth(-1)">‹</a>
|
<a v-show="currentPanel === 'date'" class="calendar__prev-icon" @click="changeMonth(-1)">‹</a>
|
||||||
<a v-show="showYearNav" class="calendar__next-icon" @click="changeYear(1)">»</a>
|
<a class="calendar__next-icon" @click="changeYear(1)">»</a>
|
||||||
<a v-show="currentPanel === 'date'" class="calendar__next-icon" @click="changeMonth(1)">›</a>
|
<a v-show="currentPanel === 'date'" class="calendar__next-icon" @click="changeMonth(1)">›</a>
|
||||||
<a @click="showMonths">{{months[currentMonth]}}</a>
|
<a @click="showMonths">{{months[currentMonth]}}</a>
|
||||||
<a @click="showYears">{{currentYear}}</a>
|
<a @click="showYears">{{currentYear}}</a>
|
||||||
@@ -37,23 +37,7 @@ export default {
|
|||||||
startAt: null,
|
startAt: null,
|
||||||
endAt: null,
|
endAt: null,
|
||||||
value: null,
|
value: null,
|
||||||
show: Boolean,
|
show: Boolean
|
||||||
disabledDays: {
|
|
||||||
type: Array,
|
|
||||||
default: function () { return [] }
|
|
||||||
},
|
|
||||||
showYearNav: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
notBefore: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
notAfter: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
const translation = this.$parent.translation
|
const translation = this.$parent.translation
|
||||||
@@ -142,9 +126,9 @@ export default {
|
|||||||
const endTime = this.endAt ? new Date(this.endAt).setHours(0, 0, 0, 0) : 0
|
const endTime = this.endAt ? new Date(this.endAt).setHours(0, 0, 0, 0) : 0
|
||||||
const today = new Date().setHours(0, 0, 0, 0)
|
const today = new Date().setHours(0, 0, 0, 0)
|
||||||
|
|
||||||
if (this.disabledDays.some(v => +new Date(v) === +cell.date) ||
|
if (this.$parent.disabledDays.some(v => +new Date(v) === +cell.date) ||
|
||||||
(this.notBefore !== '' && cell.date.getTime() < (new Date(this.notBefore)).getTime()) ||
|
(this.$parent.notBefore !== '' && cell.date.getTime() < (new Date(this.$parent.notBefore)).getTime()) ||
|
||||||
(this.notAfter !== '' && cell.date.getTime() > (new Date(this.notAfter)).getTime())) {
|
(this.$parent.notAfter !== '' && cell.date.getTime() > (new Date(this.$parent.notAfter)).getTime())) {
|
||||||
return 'disabled'
|
return 'disabled'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-24
@@ -22,11 +22,7 @@
|
|||||||
<template v-if="!range">
|
<template v-if="!range">
|
||||||
<calendar-panel @select="showPopup = false"
|
<calendar-panel @select="showPopup = false"
|
||||||
v-model="currentValue"
|
v-model="currentValue"
|
||||||
:show="showPopup"
|
:show="showPopup"></calendar-panel>
|
||||||
:disabledDays="disabledDays"
|
|
||||||
:showYearNav="showYearNav"
|
|
||||||
:notBefore="notBefore"
|
|
||||||
:notAfter="notAfter"></calendar-panel>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="datepicker-top">
|
<div class="datepicker-top">
|
||||||
@@ -35,20 +31,11 @@
|
|||||||
<calendar-panel style="width:50%;box-shadow:1px 0 rgba(0, 0, 0, .1)"
|
<calendar-panel style="width:50%;box-shadow:1px 0 rgba(0, 0, 0, .1)"
|
||||||
v-model="currentValue[0]"
|
v-model="currentValue[0]"
|
||||||
:end-at="currentValue[1]"
|
:end-at="currentValue[1]"
|
||||||
:show="showPopup"
|
:show="showPopup"></calendar-panel>
|
||||||
:disabledDays="disabledDays"
|
|
||||||
:showYearNav="showYearNav"
|
|
||||||
:notBefore="notBefore"
|
|
||||||
:notAfter="notAfter"
|
|
||||||
></calendar-panel>
|
|
||||||
<calendar-panel style="width:50%;"
|
<calendar-panel style="width:50%;"
|
||||||
v-model="currentValue[1]"
|
v-model="currentValue[1]"
|
||||||
:start-at="currentValue[0]"
|
:start-at="currentValue[0]"
|
||||||
:show="showPopup"
|
:show="showPopup"></calendar-panel>
|
||||||
:disabledDays="disabledDays"
|
|
||||||
:showYearNav="showYearNav"
|
|
||||||
:notBefore="notBefore"
|
|
||||||
:notAfter="notAfter"></calendar-panel>
|
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,10 +70,6 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: function () { return [] }
|
default: function () { return [] }
|
||||||
},
|
},
|
||||||
showYearNav: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
notBefore: {
|
notBefore: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
@@ -124,7 +107,6 @@ export default {
|
|||||||
showPopup (val) {
|
showPopup (val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
this.$nextTick(this.displayPopup)
|
this.$nextTick(this.displayPopup)
|
||||||
// this.displayPopup()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -146,9 +128,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
selectDate (date) {
|
|
||||||
|
|
||||||
},
|
|
||||||
closePopup () {
|
closePopup () {
|
||||||
this.showPopup = false
|
this.showPopup = false
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
<div id="app">
|
<div id="app">
|
||||||
<div class="demo">
|
<div class="demo">
|
||||||
<span class="label">default:</span>
|
<span class="label">default:</span>
|
||||||
<date-picker v-model="value1" lang="en"></date-picker>
|
<date-picker v-model="value1" lang="en" :not-after="notAfter"></date-picker>
|
||||||
</div>
|
</div>
|
||||||
<div class="demo">
|
<div class="demo">
|
||||||
<span class="label">range:</span>
|
<span class="label">range:</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user