|
|
@@ -18,10 +18,10 @@ module.exports = {
|
|
|
start: 1990,
|
|
|
end: 2050,
|
|
|
years: [],
|
|
|
- year: this.dateValue,
|
|
|
+ year: '',
|
|
|
}
|
|
|
},
|
|
|
- props: ["dateValue", "readonly"],
|
|
|
+ props: ["modelValue", "readonly"],
|
|
|
methods: {
|
|
|
/**
|
|
|
* 初始化时间年份列表
|
|
|
@@ -37,19 +37,30 @@ module.exports = {
|
|
|
_self.years.sort(function (a, b) {
|
|
|
return b - a;
|
|
|
});
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断年份是否存在,如果年不存在就添加
|
|
|
+ */
|
|
|
+ checkYear: function(value){
|
|
|
+ if(value != null && value.length == 4 && this.years.indexOf(value) < 0){
|
|
|
+ this.years.push(value);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
mounted: function () {
|
|
|
this.initYear();
|
|
|
},
|
|
|
watch: {
|
|
|
"year": function () {
|
|
|
- this.$emit('selected', this.year);
|
|
|
+ this.$emit('update:modelValue', this.year);
|
|
|
},
|
|
|
|
|
|
- "dateValue": function () {
|
|
|
- this.year = this.dateValue;
|
|
|
+ "modelValue": {
|
|
|
+ handler: function(newValue, oldValue){
|
|
|
+ this.year = newValue;
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
}
|
|
|
}
|
|
|
}
|