elementui 时间日期选择器限制支持传参

<div class="item spec" v-else>
    <div style="text-align: center;font-weight: 600;    margin-top: 20px;">
      出发
    </div>
    <el-form-item label="出发时间:" :verify="['NotNull']"
      :prop="'travelInfos.' + index + '.evectionInfo[0].startTime'">
      <el-date-picker v-model="item.evectionInfo[0].startTime" type="date" placeholder="选择日期"
        value-format="yyyy-MM-dd" @change="val => {subsidyCount(val, index);}" :picker-options="pickerOptions0(index,0)">
      </el-date-picker>
    </el-form-item>
    <el-form-item label="到达时间:" :verify="['NotNull']"
      :prop="'travelInfos.' + index + '.evectionInfo[0].endTime'">
      <el-date-picker v-model="item.evectionInfo[0].endTime" type="date" placeholder="选择日期"
        value-format="yyyy-MM-dd" :picker-options="pickerOptions1(index,0)">
      </el-date-picker>
    </el-form-item>
 </div>
 export default {
    data() {
        return {
            pickerOptions0: {},
            pickerOptions1: {},
        }
    },
    created(){
        this.pickerOptions0 = function (index,flag)  {
        // 返程
        let date = '',dateStart = ''
        if(index==0) {
          // 行程1
          date = this.detailForm.travelInfos[index].evectionInfo[0].endTime

        }else date = this.detailForm.travelInfos[index-1].evectionInfo[1].endTime
        console.log(index,flag,date)
        return {
          disabledDate(time) {
            if(index==0 && flag==0) return time.getTime() > Date.now() - 8.64e6;
            else return time.getTime() < new Date(date).getTime() - 8.64e7 || time.getTime() > Date.now() - 8.64e6 
          }
        }
      }
      this.pickerOptions1 = function (index,flag)  {
        let date = this.detailForm.travelInfos[index].evectionInfo[flag].startTime
        return {
          disabledDate(time) {
            return time.getTime() <= new Date(date).getTime() - 8.64e7 || time.getTime() > Date.now() - 8.64e6;
          }
        }
      }
    },
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值