日期组件完善

This commit is contained in:
yaoyanan
2021-03-23 17:29:44 +08:00
parent 102e6e3705
commit 19c784051e
+15 -16
View File
@@ -10,8 +10,7 @@
:value="momVal"
:showTime="true"
:format="dateFormat"
:getCalendarContainer="getCalendarContainer"
/>
:getCalendarContainer="getCalendarContainer"></a-date-picker>
<!--YYYY-MM-DD-->
<a-date-picker
v-if="showType === 'day'"
@@ -22,8 +21,7 @@
:value="momVal"
:showTime="false"
:format="dateFormat"
:getCalendarContainer="getCalendarContainer"
/>
:getCalendarContainer="getCalendarContainer"></a-date-picker>
<!--YYYY-MM-->
<a-month-picker
v-if="showType === 'month'"
@@ -31,7 +29,7 @@
:value="momVal"
:disabled="disabled || readOnly"
:format="dateFormat"
@change="handleMonthChange"/>
@change="handleMonthChange"></a-month-picker>
<!--YYYY-->
<a-date-picker
v-if="showType === 'year'"
@@ -39,9 +37,12 @@
mode="year"
:format="dateFormat"
:value="year"
:open='yearShowOne'
@disabledDate="disabledDate"
:disabled="disabled || readOnly"
:open="yearShowOne"
:getCalendarContainer="getCalendarContainer"
@openChange="openChangeOne"
@panelChange="panelChangeOne"/>
@panelChange="panelChangeOne"></a-date-picker>
</div>
</template>
<script>
@@ -96,12 +97,9 @@
yearShowOne:false, //控制年份模态框的显示与否
year:'',
decorator:"",
momVal:!dateStr?null:moment(dateStr,this.dateFormat)
momVal:!dateStr?null:moment(dateStr,this.dateFormat),
}
},
mounted(){
console.log(this.showTime)
},
watch: {
value (val) {
if(!val){
@@ -112,6 +110,9 @@
}
},
methods: {
disabledDate(current){
return new Date(current._d).setFullYear((new Date(current._d).getFullYear())) < new Date(moment()._d).setFullYear((new Date(moment()._d).getFullYear() - 1))
},
moment,
handleDateChange(mom,dateStr){
this.$emit('change', dateStr);
@@ -122,17 +123,15 @@
// 弹出日历和关闭日历的回调
openChangeOne(status){
//status是打开或关闭的状态
if(status){
this.yearShowOne = true
}
this.yearShowOne = status
},
// 得到年份选择器的值
panelChangeOne(value){
this.yearShowOne = false
let year = moment(value,this.dateFormat).year().toString() // 处理成字符串
this.year = value //组件显示的
this.$emit('change',year)
this.yearShowOne = false
},
}
},
//2.2新增 在组件内定义 指定父组件调用时候的传值属性和事件类型 这个牛逼
model: {