<template>
<view class="leave_cont">
<view class="ul">
<view class="li">
<text>开始时间</text>
<view class="flex1">
<picker mode="date" :value="start_date" :start="start_date" :end="other" @change="bindDateChange">
<view class="date">{{start_date}}</view>
</picker>
</view>
</view>
<view class="li">
<text>结束时间</text>
<view class="flex1">
<picker mode="date" :value="start_date" :start="start_date" @change="bindDateChange2">
<view class="date">{{other}}</view>
</picker>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
const currentDate = this.getDate({
format: true
})
return {
start_date: currentDate,
end_date: currentDate,
other:'请输入'
}
},
computed: {
},
methods: {
// 选择日期
bindDateChange: function(e) {
this.start_date = e.target.value
},
bindDateChange2: function(e) {
this.end_date = e.target.value;
this.other = this.end_date;
},
// 获取当前时间
getDate(type) {
const date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
if (type === 'start') {
year = year - 60;
} else if (type === 'end') {
year = year + 2;
}
month = month > 9 ? month : '0' + month;;
day = day > 9 ? day : '0' + day;
return `${year}-${month}-${day}`;
},
}
}
</script>
<style>
.leave_cont .ul{
padding-left: 30rpx;
}
.leave_cont .ul .li{
display: flex;
align-items: center;
border-bottom: 1px solid #efefef;
}
.leave_cont .ul .li text{
padding: 40rpx 0;
font-size: 34rpx;
font-family: '黑体';
}
.leave_cont .ul .li .flex1{
flex: 1;
text-align: right;
padding-right: 25rpx;
color: #999999;
font-size: 32rpx;
}
.date{
height: 42rpx;
}
</style>