iView之DatePicker的datetimerange校验
使用DatePicker的type是datetimerange时,处理开始--结束的持续时间校验如下。
遇到的问题:
时间弹出校验提示,但是程序还是会继续往下走,所以调完校验后,再做判断开始时间是否为true,再调接口。
view:
<Col span="8">
<FormItem label="时间段:" prop="dates">
<DatePicker type="datetimerange" placeholder="Select date" v-model="formValidate.dates"
style="width: 100%" @on-change="changeTime">
</DatePicker>
</FormItem>
</Col>
<Col span="8">
<FormItem class="inline-submit">
<Button type="primary" @click="queryClick">查询</Button>
</FormItem>
</Col>
js:
*****data:
formValidate: {
name: '',
dates: []
}, ruleValidate: { //表单校验
name: [
{required: true, message: 'The name cannot be empty', trigger: 'blur'}
],
dates: [{
required: true,
type: 'array',
message: "Please select the date",
trigger: 'blur',
fields: {
0: {type: "date", required: true, message: "Please select the date"},
1: {type: "date", required: true, message: "Please select the date"}
}
}]
}, *******methods:
handleSubmit(name) {
this.$refs[name].validate((valid) => {
if (valid) {
this.$Message.success('Success!');
} else {
this.$Message.error('Fail!');
}
});
}, queryClick() {
this.handleSubmit('formValidate1');
if (this.startDate) {
this.stationRequest(); //调接口
}
},
// 时间触发
changeTime(val) {
this.startDate = val[0];
this.endDate = val[1];
}
iView之DatePicker的datetimerange校验的更多相关文章
- iview组件DatePicker type="datetimerange绑定初始默认时间值
使用::value="[this.startTime,this.endTime]",绑定当天时间 如下: <DatePicker type="datetimeran ...
- vue+iview的form表单校验总结
这篇文章时关于如何使用iview的form表单校验.主要学习如何使用form校验(以校验文字长度为例),以及如何动态添加校验规则和异步校验. 1.为需要校验的表单添加form标签 <!--注意: ...
- iview form表单数值类型校验「iview自定义form表单校验器」
摘录iview表单验证 Form 组件基于 sync-validator 实现的数据验证,给 Form 设置属性 rules,同时给需要验证的 FormItem 设置属性 prop 指向对应字段即可. ...
- iview render Datepicker 起止时间限制
{ title: '开始时间', key: 'planDateFrom', minWidth: 120, sortable: true, align: 'center', render: (h, pa ...
- iview datepicker 选择的时间少一天
使用iview的datepicker时间选择器发现获取的value值是比实际要少一天,严格来说应该是时间格式不一样,datepicker获取的时间是UTC时间格式,也就是:yyyy-MM-ddTHH: ...
- vue/iview使用moment.js
方法一 main.js引入moment 获取当前时间 this.time = this.$moment()._d; // 当前时间 this.time0 =this.$moment().subtrac ...
- iview组件select之默认展示label,并传空value做方法入参
要求: 默认查询操作日期在当日的数据:(打开页面时默认选中时间.全部) 后台约定:选定“全部”这个条件,传的值是空"" 综上:使用select选择框的v-model绑定数据,使用: ...
- iview日期选择框,获取的日期总是少一天
使用iview的datepicker时间选择器发现获取的value值是比实际要少一天,严格来说应该是时间格式不一样,datepicker获取的时间是UTC时间 格式,也就是:yyyy-MM-ddTHH ...
- iview的table组件中加入超链接组件,可编辑组件,选择组件,日期组件
这篇文章主要介绍了iview的table组件中使用选择框,日期,可编辑表格,超链接等组件. 1.select选择组件 // tableColumn数组响应对象需要传入一个固定的option数组,如果该 ...
随机推荐
- 编译EasyDSS rtmp流媒体服务器遇到stray '_239' inprogram,stray '_187' inprogram,stray '_191' inprogram的解决办法
使用用户提供的交叉编译工具链编译easydss时遇到一个编译错误 stray '\239' inprogram stray '\187' inprogram stray '\191' inprogra ...
- Grunt 学习笔记【1】----基础知识
题记:虽然现在大家都在推Webpack,无奈业务需要,因此研究下Grunt. 说明:本文是基于Grunt 0.4.5版本. 一 说明 为何要用构建工具? 一句话:自动化.对于需要反复重复的任务,例如压 ...
- case_for_if 各种嵌套相结合
注明:本文是参考其他相关文章 整理,完全尊重原著作 #!/bin/bash usage() { cat << EOF EOF } main() { echo "猜分数赢大奖(0- ...
- Javascript闭包机制(转)
原文地址:http://www.felixwoo.com/archives/247 参考:http://www.ruanyifeng.com/blog/2009/08/learning_javascr ...
- Halcon下载、安装
下载地址: 官网:http://www.halcon.com/halcon/download/ Halcon学习网:http://www.ihalcon.com/read.php?tid=56 { 最 ...
- 【linux】crontab的环境变量问题
今天遇到一个奇怪的问题,同样一个脚本,手动执行没问题,加入到crontab中,就出现无法运行的情况,第一反应是环境变量问题 环境说明: 操作系统:centos 用户:test用户通过sudo su切换 ...
- ruby 字符串
字符串处理函数 1.返回字符串的长度 str.length => integer 2.判断字符串中是否包含另一个串 str.include? other_str => true or fa ...
- 05-树8 File Transfer(25 point(s)) 【并查集】
05-树8 File Transfer(25 point(s)) We have a network of computers and a list of bi-directional connect ...
- Linux--struct file结构体【转】
本文转载自:https://www.cnblogs.com/hanxiaoyu/p/5677677.html struct file(file结构体): struct file结构体定义在includ ...
- 吴恩达机器学习笔记(七) —— K-means算法
主要内容: 一.K-means算法简介 二.算法过程 三.随机初始化 四.二分K-means 四.K的选择 一.K-means算法简介 1.K-means算法是一种无监督学习算法.所谓无监督式学习,就 ...