add_select.html 5.09 KB
<!-- 新增选择站点 -->
<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>