iview 开始时间不能大于结束时间

var vprojectEndTime = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入结束时间"));
      } else if (value <= this.parkItemForm.projectStartTime) {
        callback(new Error("结束时间不能小于开始时间"));
      } else {
        callback();
      }
    };
    var vprojectStartTime = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入开始时间"));
      } else if (value >= this.parkItemForm.projectEndTime) {
        callback(new Error("开始时间不能大于结束时间"));
      } else {
        callback();
      }
    };

  

projectStartTime: [
          // {
          //   required: true,
          //   message: "请输入开始时间",
          //   trigger: "change",
          //   type: "date",
          // },
          {
            required: true,
            validator: vprojectStartTime,
            trigger: "change",
            type: "date",
          },
        ],
        projectEndTime: [
          // {
          //   required: true,
          //   message: "请输入结束时间",
          //   trigger: "change",
          //   type: "date",
          // },
          {
            required: true,
            validator: vprojectEndTime,
            trigger: "change",
            type: "date",
          },
        ],
   getprojectStartTime(e) {
      this.parkItemForm.projectStartTime = e;
    },
    getprojectEndTime(e) {
      this.parkItemForm.projectEndTime = e;
    },
 <FormItem label="项目建设开始时间" prop="projectStartTime">
            <DatePicker
              type="datetime"
              clearable
              placeholder="开始时间"
              :style="'width:' + width_Input"
              v-model="parkItemForm.projectStartTime"
              format="yyyy-MM-dd hh:mm:ss"
              @on-change="getprojectStartTime"
              :options="optionss"
            ></DatePicker>
          </FormItem>
          <FormItem label="项目建设结束时间" prop="projectEndTime">
            <DatePicker
              type="datetime"
              placeholder="结束时间"
              :style="'width:' + width_Input"
              clearable
              v-model="parkItemForm.projectEndTime"
              format="yyyy-MM-dd hh:mm:ss"
              @on-change="getprojectEndTime"
              :options="optionss"
            ></DatePicker>
          </FormItem>

 

posted @ 2022-05-19 16:49  abcByme  阅读(194)  评论(0编辑  收藏  举报