首页 > 其他分享 >elment ui 限制开始时间之后的时间

elment ui 限制开始时间之后的时间

时间:2022-09-05 11:13:58浏览次数:55  
标签:00 let getTime elment dateNow 时间 time Date ui

开始时间之后的时间

 pickerOptions2:{ // 开始时间之后的时间
      disabledDate:(time) => {
          let dateNow = new Date(this.ruleForm.renewContractValidityStrartTime).getTime()
          let rangeTime = (time.getTime() < dateNow )
        return rangeTime;
      }
      },
<el-form-item label="续签合同有效期:" label-width="150px" prop="renewContractValidityEndTime">
              <el-date-picker
                disabled
                v-model="ruleForm.renewContractValidityStrartTime"
                type="datetime"
                placeholder="选择日期">
              </el-date-picker>
              <span>至</span>
              <el-date-picker
                v-model="ruleForm.renewContractValidityEndTime"
                disabled
                type="datetime"
                @click="addDefaultTime"
                value-format="timestamp"
                :picker-options="pickerOptions2"
                placeholder="选择日期"
                :default-value="ruleForm.renewContractValidityStrartTime"
                >
              </el-date-picker>
            </el-form-item>

选择上半个月,下半个月

 <el-form-item label="付款日期:" prop="upSelectTime" v-if="([2,3].indexOf(ruleForm.settlementMethod)> -1)" required>
              <el-form-item prop="upSelectTime" class="m_b_20" required>
                <div style="display:flex">
                  <div class="m_r_20">上半月</div>
                  <el-date-picker
                    class="picker_range"
                    disabled
                    v-model="ruleForm.upSelectTime"
                    type="daterange"
                    format="dd"
                    value-format="timestamp"
                    :picker-options="pickerOptions">
                  </el-date-picker>
                </div>
              </el-form-item>
              <el-form-item prop="subSelectTime" required>
                <div style="display:flex">
                  <div class="m_r_20">下半月</div>
                  <el-date-picker
                    class="picker_range"
                    v-model="ruleForm.subSelectTime"
                    disabled
                    type="daterange"
                    format="dd"
                    value-format="timestamp"
                    :picker-options="pickerOptions1">
                  </el-date-picker>
                </div>
              </el-form-item>
            </el-form-item>
 pickerOptions: { // 限制只能选择上半月
      disabledDate(time) {
          let dateNow = new Date().toLocaleDateString().split('/') 
          let startTime = new Date((dateNow[0] + '-' + dateNow[1] + '-' + 1 + ' 00:00:00')).getTime()
          let endTime = new Date(dateNow[0] + '-' + dateNow[1] + '-' + 15 + ' 00:00:00').getTime()
          let rangeTime = (time.getTime() < startTime || time.getTime() > endTime)
        return rangeTime;
      }
      },
      pickerOptions1:{ // 限制只能选择下半月
      disabledDate(time) {
          let dateNow = new Date().toLocaleDateString().split('/')
          let startTime = new Date((dateNow[0] + '-' + dateNow[1] + '-' + 16 + ' 00:00:00')).getTime()
          let endTime = new Date(dateNow[0] + '-' + dateNow[1] + '-' + 28 + ' 00:00:00').getTime()
          let rangeTime = (time.getTime() < startTime || time.getTime() > endTime)
        return rangeTime;
      }
      },

 

标签:00,let,getTime,elment,dateNow,时间,time,Date,ui
From: https://www.cnblogs.com/shuihanxiao/p/16657383.html

相关文章