赞
踩
起始时间不能超过截止时间,截止时间不能早于起始时间
- <view class="select-dates">
- <text class="date_title">起始:</text>
- <picker mode="date" :value="dateform.startTime" :start="startDate" :end="dateform.overTime" @change="bindDateChange">
- <view class="uni-input" v-if="dateform.startTime===''">请选择</view>
- <view class="uni-input" v-else>{{dateform.startTime}}</view>
- </picker>
- </view>
- <view class="select-dates">
- <text class="date_title">截止:</text>
- <picker mode="date" :value="dateform.overTime" :start="dateform.startTime" @change="bindDateChange2">
- <view class="uni-input" v-if="dateform.overTime===''">请选择</view>
- <view class="uni-input" v-else>{{dateform.overTime}}</view>
- </picker>
- </view>
- computed: {
- startDate() {
- return this.getDate('start');
- },
- endDate() {
- return this.getDate('end');
- }
- },
- methods: {
- // 获取时间
- 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}`;
- },
- // 选择开始时间
- bindDateChange(e) {
- this.dateform.startTime = e.detail.value
- },
- // 选择结束时间
- bindDateChange2(e) {
- this.dateform.overTime = e.target.value;
- },
- // 按照时间查找
- findDate(){
- if(this.dateform.startTime===''||this.dateform.overTime===''){
- uni.showModal({
- title: '提示',
- content: `请选择起始时间和结束时间后,再点击查询`,
- showCancel: false
- });
- }else{
- getTask(this.dateform).then(res => {
- this.tasklistArr = JSON.parse(JSON.stringify(res.data.data));
- })
- }
-
- },
- // 清除时间
- cleardateForm(){
- this.dateform.startTime="";
- this.dateform.overTime="";
- getTask(this.dateform).then(res => {
- this.tasklistArr = JSON.parse(JSON.stringify(res.data.data));
- })
- },
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。