diff --git a/src/components/inline-calendar/index.vue b/src/components/inline-calendar/index.vue index 627456fb7..4fc109a29 100755 --- a/src/components/inline-calendar/index.vue +++ b/src/components/inline-calendar/index.vue @@ -34,7 +34,7 @@ v-for="(child,k2) in day" :data-date="formatDate(year, month, child)" :data-current="currentValue" - :class="buildClass(k2, child, formatDate(year, month, child) === currentValue && !child.isLastMonth && !child.isNextMonth)" + :class="buildClass(k2, child)" @click="select(k1,k2,child)"> 0) { + isCurrent = this.currentValue.indexOf(this.formatDate(this.year, this.month, child)) > -1 + } else { + isCurrent = this.currentValue === this.formatDate(this.year, this.month, child) + } + } const className = { current: child.current || isCurrent, 'is-disabled': child.disabled, @@ -159,10 +176,12 @@ export default { return className }, render (year, month) { - let data = getDays({ + let data = null + const value = this.multi ? this.currentValue[this.currentValue.length - 1] : this.currentValue + data = getDays({ year: year, month: month, - value: this.currentValue, + value, rangeBegin: this.convertDate(this.startDate), rangeEnd: this.convertDate(this.endDate), returnSixRows: this.returnSixRows, @@ -207,12 +226,42 @@ export default { if (!data.isBetween) { return } + let _currentValue = null if (!data.isLastMonth && !data.isNextMonth) { this.days[k1][k2].current = true - this.currentValue = [this.year, zero(this.month + 1), zero(this.days[k1][k2].day)].join('-') + _currentValue = [this.year, zero(this.month + 1), zero(this.days[k1][k2].day)].join('-') + } else { + _currentValue = [data.year, zero(data.month + 1), zero(data.day)].join('-') + } + if (this.multi) { + let index = this.currentValue.indexOf(_currentValue) + if (index > -1) { + this.currentValue.splice(index, 1) + } else { + this.currentValue.push(_currentValue) + } + } else { + this.currentValue = this.currentValue === _currentValue ? '' : _currentValue + } + + this.currentValueChange() + }, + currentValueChange () { + if (this.multi) { + for (let i = 0; i < this.currentValue.length; i++) { + this.$set(this.currentValue, i, this.convertDate(this.currentValue[i])) + } } else { - this.currentValue = [data.year, zero(data.month + 1), zero(data.day)].join('-') + this.currentValue = this.convertDate(this.currentValue) } + const value = this.multi ? this.currentValue[this.currentValue.length - 1] : this.currentValue + if (this.renderOnValueChange) { + this.render(null, null, value) + } else { + this.render(this.year, this.month, value) + } + this.$emit('input', this.currentValue) + this.$emit('on-change', this.currentValue) }, showChild (year, month, child) { if (this.replaceText(child.day, this.formatDate(year, month, child))) { @@ -224,7 +273,7 @@ export default { } } - +