cylAdd.html
3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<div class="page-head">
<div class="page-title">
<h1>添加用户</h1>
</div>
</div>
<ul class="page-breadcrumb breadcrumb">
<li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
<li><span class="active">用油管理</span> <i class="fa fa-circle"></i></li>
<li><a href="cylList.html" data-pjax>车辆存油</a> <i class="fa fa-circle"></i></li>
<li><span class="active">添加存油</span></li>
</ul>
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption">
<i class="icon-equalizer font-red-sunglo"></i> <span
class="caption-subject font-red-sunglo bold uppercase">表单</span>
</div>
</div>
<div class="portlet-body form">
<form action="/addCyl" class="form-horizontal" id="cyl_add_form" >
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
您的输入有误,请检查下面的输入项
</div>
<div class="form-body">
<div class="form-group">
<label class="col-md-3 control-label">内部编号</label>
<div class="col-md-4">
<input type="text" class="form-control" name="nbbm" >
<span class="help-block"> 车辆内部编号</span>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">油箱容量</label>
<div class="col-md-4">
<input type="text" class="form-control" name="cxrl" >
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">存油量</label>
<div class="col-md-4">
<input type="text" class="form-control" name="cyl" >
</div>
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-offset-3 col-md-4">
<button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button>
<a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
</div>
</div>
</div>
</form>
<!-- END FORM-->
</div>
</div>
<script>
$(function(){
var form = $('#cyl_add_form');
var error = $('.alert-danger', form);
//表单 validate
form.validate({
errorElement : 'span',
errorClass : 'help-block help-block-error',
focusInvalid : false,
invalidHandler : function(event, validator) {
error.show();
App.scrollTo(error, -200);
},
highlight : function(element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight : function(element) {
$(element).closest('.form-group').removeClass('has-error');
},
success : function(label) {
label.closest('.form-group').removeClass('has-error');
},
submitHandler : function(f) {
var params = form.serializeJSON();
error.hide();
console.log(params);
//检查一下用户是否存在
$get('/cyl/all', {nbbm_eq: params.nbbm}, function(list){
if(!list || list.length == 0){
console.log(params);
$.ajax({
url: '/cyl/save',
type: 'POST',
traditional: true,
data: params,
success: function(res){
layer.msg('添加信息成功.');
loadPage('cylList.html');
}
});
/* $post('/user', params, function(res){
layer.msg('添加用户成功.');
loadPage('list.html');
}); */
}
else
layer.alert('内部编码【' + params.nbbm + '】已存在', {icon: 2, title: '提交被拒绝'});
});
}
});
});
</script>