|
|
@@ -8,11 +8,11 @@
|
|
|
<div
|
|
|
class="month-year-display"
|
|
|
:disabled="disabled"
|
|
|
- :class="[inputClass, {'placeholder': !value}]"
|
|
|
+ :class="[inputClass, {'placeholder': !modelValue}]"
|
|
|
@click="openMenu"
|
|
|
>
|
|
|
<div class="display-text" :class="'display-text-'+alignment" :style="[{'text-align': alignment}]">{{ displayText }}</div>
|
|
|
- <span v-if="clearOption && value" class="vmp-input-append" @click.stop.prevent="clearSelect">
|
|
|
+ <span v-if="clearOption && modelValue" class="vmp-input-append" @click.stop.prevent="clearSelect">
|
|
|
<i class="vmp-clear-icon" />
|
|
|
</span>
|
|
|
</div>
|
|
|
@@ -59,7 +59,7 @@ import moment from 'moment';
|
|
|
export default {
|
|
|
name: 'VueMonthlyPicker',
|
|
|
props: {
|
|
|
- 'value': {
|
|
|
+ 'modelValue': {
|
|
|
type: String,
|
|
|
default: null,
|
|
|
},
|
|
|
@@ -110,7 +110,7 @@ export default {
|
|
|
default: true,
|
|
|
},
|
|
|
},
|
|
|
- emits: ['input', 'selected'],
|
|
|
+ emits: ['update:modelValue', 'selected'],
|
|
|
data () {
|
|
|
return {
|
|
|
showMenu: false,
|
|
|
@@ -133,12 +133,12 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
displayText () {
|
|
|
- if (this.value) {
|
|
|
+ if (this.modelValue) {
|
|
|
let valueMoment = null;
|
|
|
- if (typeof this.value === 'string') {
|
|
|
- valueMoment = moment(this.value);
|
|
|
+ if (typeof this.modelValue === 'string') {
|
|
|
+ valueMoment = moment(this.modelValue);
|
|
|
} else {
|
|
|
- valueMoment = this.value;
|
|
|
+ valueMoment = this.modelValue;
|
|
|
}
|
|
|
if (valueMoment && valueMoment.isValid()) {
|
|
|
return valueMoment.format(this.dateFormat);
|
|
|
@@ -164,7 +164,7 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
watch: {
|
|
|
- value: function (value) {
|
|
|
+ modelValue: function (value) {
|
|
|
this.setValue(value);
|
|
|
},
|
|
|
},
|
|
|
@@ -178,7 +178,7 @@ export default {
|
|
|
this.closeMenu();
|
|
|
}
|
|
|
}, false);
|
|
|
- this.setValue(this.value);
|
|
|
+ this.setValue(this.modelValue);
|
|
|
},
|
|
|
openMenu () {
|
|
|
if (!this.disabled) {
|
|
|
@@ -204,7 +204,7 @@ export default {
|
|
|
this.closeMenu();
|
|
|
},
|
|
|
selectPicker () {
|
|
|
- this.$emit('input', this.internalMomentValue.clone());
|
|
|
+ this.$emit('update:modelValue', this.internalMomentValue.clone());
|
|
|
this.$emit('selected', this.internalMomentValue.clone());
|
|
|
},
|
|
|
setValue (value) {
|
|
|
@@ -228,12 +228,12 @@ export default {
|
|
|
return true;
|
|
|
},
|
|
|
isCurrentSelected (year, monthIdx) {
|
|
|
- if (!this.value) {
|
|
|
+ if (!this.modelValue) {
|
|
|
return false;
|
|
|
}
|
|
|
- let checkValue = this.value;
|
|
|
- if (typeof this.value === 'string') {
|
|
|
- checkValue = moment(this.value);
|
|
|
+ let checkValue = this.modelValue;
|
|
|
+ if (typeof this.modelValue === 'string') {
|
|
|
+ checkValue = moment(this.modelValue);
|
|
|
}
|
|
|
if (checkValue && checkValue.isValid()) {
|
|
|
const currentMonth = checkValue.format('MM');
|
|
|
@@ -248,7 +248,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
clearSelect () {
|
|
|
- this.$emit('input', null);
|
|
|
+ this.$emit('update:modelValue', null);
|
|
|
this.$emit('selected', null);
|
|
|
},
|
|
|
},
|