From 20d1f19c2dee0a9b68928b2ff46fb9ed742da1a5 Mon Sep 17 00:00:00 2001 From: mengxiong10 <15623530290@163.com> Date: Tue, 9 Apr 2019 20:00:05 +0800 Subject: [PATCH] feat: `select-year` and `select-month` (#290) --- src/calendar.vue | 3 +++ src/index.vue | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/calendar.vue b/src/calendar.vue index e0d4c76..f7a3f36 100644 --- a/src/calendar.vue +++ b/src/calendar.vue @@ -106,6 +106,7 @@ export default { type: String, default: 'YYYY-MM-DD' }, + index: Number, // below user set defaultValue: { validator: function (val) { @@ -338,6 +339,7 @@ export default { if (this.type.toLowerCase() === 'year') { return this.selectDate(new Date(this.now)) } + this.dispatch('DatePicker', 'select-year', [year, this.index]) this.showPanelMonth() }, selectMonth (month) { @@ -345,6 +347,7 @@ export default { if (this.type.toLowerCase() === 'month') { return this.selectDate(new Date(this.now)) } + this.dispatch('DatePicker', 'select-month', [month, this.index]) this.showPanelDate() }, selectTime (time) { diff --git a/src/index.vue b/src/index.vue index af71c17..bd1956c 100644 --- a/src/index.vue +++ b/src/index.vue @@ -67,6 +67,7 @@ v-if="!range" v-bind="$attrs" ref="calendarPanel" + :index="-1" :type="innerType" :date-format="innerDateFormat" :value="currentValue" @@ -79,6 +80,7 @@ style="box-shadow:1px 0 rgba(0, 0, 0, .1)" v-bind="$attrs" ref="calendarPanel" + :index="0" :type="innerType" :date-format="innerDateFormat" :value="currentValue[0]" @@ -89,6 +91,7 @@ @select-time="selectStartTime">