add_select.html
5.09 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<!-- 新增选择站点 -->
<div class="modal fade" id="add_select_mobal" tabindex="-1" role="basic" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">新增站点</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" action="/" method="post" id="formBootbox" role="form">
<div class="alert alert-danger display-hide" id="requiredname">
<button class="close" data-close="alert"></button>
站点名称为必填项
</div>
<div class="alert alert-danger display-hide" id="serchrname">
<button class="close" data-close="alert"></button>
系统无法生成,请选择其他方式新增
</div>
<input type="hidden" name="stationPoint" id="stationPoint" />
<div class="form-group" id="formRequ">
<label class="col-md-3 control-label"><span class="required"> * </span>站点名称:</label>
<div class="col-md-9" id="errorInfo">
<input type="text" class="form-control input-medium" id="stationNamebootbox" name="stationNamebootbox">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">新增方式:</label>
<div class="col-md-9">
<div class="icheck-list">
<label>
<input type="radio" class="icheck" name="baseRes" value=0 checked> 系统生成
</label>
<label >
<input type="radio" class="icheck" name="baseRes" value=1 > 手动添加
</label>
<label>
<input type="radio" class="icheck" name="baseRes" value=2> 系统引用
</label>
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" id="nextButton">下一步</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
$('#add_select_mobal').modal({
show : true,
backdrop: 'static',
keyboard: false
});
var form = $('#formBootbox');
var requiredname = $('#requiredname', form);
//提交
$('#nextButton').on('click', function() {
form.submit();
});
//form validate
form.validate({
errorElement : 'span',
errorClass : 'help-block help-block-error',
focusInvalid : false,
rules : {
'stationNamebootbox' : {
minlength : 2,
required : true,
maxlength : 10
}
},
invalidHandler : function(event, validator) {
requiredname.show();
App.scrollTo(requiredname, -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();
var stationNamebootbox = params.stationNamebootbox;
var baseRes = params.baseRes;
if(baseRes == 0) {
WorldsBMap.localSearchFromAdreesToPoint(stationNamebootbox,mapB,function(Points) {
if(Points) {
addStationNameValue = stationNamebootbox;
addSttationPoints = Points;
requiredname.hide();
$('#add_select_mobal').modal('hide');
polyType = 'r';
$.get('add.html', function(m){$(pjaxContainer).append(m);});
} else {
// 缺少ID
layer.confirm('【系统无法生成,请选择其他方式新增】', {btn : [ '返回' ],icon: 3, title:'提示' }, function(index){
layer.close(index);
});
}
});
}else if(baseRes==1) {
// 手动添加
addStationNameValue = stationNamebootbox;
requiredname.hide();
$('#add_select_mobal').modal('hide');
drawingManager.open();
drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON);
drawingManager.addEventListener('polygoncomplete', function(e) {
if (e.getPath().length <= 2) {
alert('坐标点不能小于等于两个');
// 清除地图覆盖物
map.clearOverlays();
// 加载该线路下所有站点位置添加到地图上
return;
}
pointE = e;
polyType = 'd';
addSttationPoints = pointE.getBounds().getCenter().lng+ ' ' + pointE.getBounds().getCenter().lat;
$.get('add.html', function(m){$(pjaxContainer).append(m);});
});
}else if(baseRes==2) {
// 系统引用
}
}
});
});
</script>