add.vm 21.4 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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
  
 
 <link rel="stylesheet" href="/assets/css/map.css" />
	 
	 
							
							
<div class="page-content">
<div class="page-header">
    <span class="pull-right"><a href="/pick/list.do" class="btn btn-white btn-default">返回</a></span>
    <h1>
        <small>
            <i class="icon-double-angle-right"></i>
          	添加提货点
        </small>
    </h1>
</div>
<!-- /.page-header -->

<div class="row">
<div class="col-xs-12">

<form class="form-horizontal bv-form" role="form" method="post" action="/pick/save.do" id="addForm" >

<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 市场名称: </label>

    <div class="col-xs-12 col-sm-4">
        <span class="block input-icon input-icon-right">
        <input type="text" placeholder="市场名称" name="pickName" required data-bv-message="必须填写!" data-bv-stringlength-message="超出了最大范围!" data-bv-stringlength="" data-bv-stringlength-max="125" maxlength="125" class="width-100" value="" data-bv-field="cfg.configCode">
        <i class="ace-icon fa  fa-asterisk orange"></i>
        </span>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-5"> 市场编码: </label>

    <div class="col-xs-12 col-sm-4">
        <span class="block input-icon input-icon-right">
        <input type="text" placeholder="市场编码" name="pickCode" required data-bv-message="必须填写!" data-bv-stringlength-message="超出了最大范围!" data-bv-stringlength="" data-bv-stringlength-max="125" maxlength="125" class="width-100" value="" data-bv-field="cfg.configName">
        <i class="ace-icon fa  fa-asterisk orange"></i>
        </span>
    
    </div>
</div>

<div class="form-group" id="add_position">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 联系方式: </label>
	<input type="hidden" name="personName" id="contpId">
	<input type="hidden" name="personTel" id="contnId">
     <div class="col-xs-12 col-sm-4"  >
        <span class="block input-icon input-icon-right">
    <input type="text" placeholder="联系人姓名" pickupname name="personName0" id="personName0" required data-bv-message="必须填写!" onfocus="submitBtDisab();" data-bv-stringlength-message="超出了最大范围!" data-bv-stringlength="" data-bv-stringlength-max="50" maxlength="50" class="col-sm-6" value="" data-bv-field="cfg.configCode">
      <input type="text" placeholder="联系电话" pickuptel name="personTel0" id="personTel0" required data-bv-message="必须填写!" onfocus="submitBtDisab();" data-bv-stringlength-message="超出了最大范围!" data-bv-stringlength="" data-bv-stringlength-max="125" maxlength="125" class="col-sm-6" value="" data-bv-field="cfg.configCode">
        </span>
    </div>
   <div> <a href="javascript:void(0);">  <i class="fa fa-plus " id="add_contact" style=" line-height: 25px; margin-top: 5px;  "></i></a></div>
</div>
<div class="form-group">
	<label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 市场地址: </label>
     <div class="col-xs-12 col-sm-4">
     <div class="begin" id="begin">
				</div>
        
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-6">  </label>

     <div class="col-xs-12 col-sm-4">
        <span class="block input-icon input-icon-right">
        <input type="text" placeholder="精确到街道和门牌号" name="addressTxt" required data-bv-message="必须填写!" data-bv-stringlength-message="超出了最大范围!" data-bv-stringlength="" data-bv-stringlength-max="125" maxlength="125" class="width-100" value="" data-bv-field="cfg.configCode">
        <i class="ace-icon fa  fa-asterisk orange"></i>
        </span>
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-6">  </label>

     <div class="col-xs-12 col-sm-4">
        <span class="block input-icon input-icon-right" style="color:red;font-size: 14px;">
      		修改了市场地址请记得修改坐标位置
        </span>
    </div>
</div>
 <div class="form-group">
    <label class="col-sm-3 control-label no-padding-right"  for="form-field-6"> 坐标位置: </label>
     <div class="col-xs-12 col-sm-4"   >
     <div class="input-group">
       <input type="hidden"   id="longitudeId"  name="longitude"  >
 		 <input type="hidden"   id="latitudeId" name="latitude">
  <input type="text" class="form-control" id="positionTxt" placeholder="请选择位置"  readonly="readonly"   >
  <span class="input-group-addon" style="cursor: pointer;"  onclick="chosePosition()" >选择位置 </span>
</div>
    </div>

</div>

<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 市场描述: </label>

    <div class="col-xs-12 col-sm-4">
        <span class="block input-icon input-icon-right">
        <textarea class="form-control limited" name="remark" style="height:100px" data-bv-stringlength-message="超出了最大范围!" data-bv-stringlength="" data-bv-stringlength-max="512" maxlength="512" data-bv-field="cfg.remark"></textarea>
        </span>
    </div>
</div>

<div class="form-group" style="display:none">
    <label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 是否是市场: </label>
	<input type="hidden" name="isMarket" id="markId" value="1"> 
    <div class="col-xs-12 col-sm-4">
    	<label>
            <input id="unlock-inputtype" checked class="ace" type="radio" attrtype="attr_desc" name="form-field-radio" value="1" >
            <span class="lbl">是</span>
        </label> 
        <!-- <label>
            <input id="lock-inputtype"   #if(!${assetsUtils.collIsEmpty($marketList)}) checked #else disabled  #end  class="ace" type="radio" attrtype="attr_desc" name="form-field-radio" value="2" onClick="changeMark(2)">
            <span class="lbl">否</span>
            #if(${assetsUtils.collIsEmpty($marketList)})
            (请先添加市场,再添加提货点)
            #end
        </label>    -->
        
    </div>
</div>

    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 本公司市场: </label>
        <div class="col-xs-12 col-sm-4">
            <label>
                <input id="unlock-inputtype" class="ace" name="myself" type="radio" checked attrtype="attr_desc" name="form-field-radio" value="1" >
                <span class="lbl">是</span>
            </label>
            <label>
				<input id="lock-inputtype"   class="ace" name="myself" type="radio" attrtype="attr_desc" name="form-field-radio" value="2" >
				<span class="lbl">否</span>
        	</label>

        </div>
    </div>

<!-- <div id="isPickup" #if(${assetsUtils.collIsEmpty($marketList)}) style="display:none;" #end>
	<div class="form-group">
	    <label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 提货点简称: </label>

	   <div class="col-xs-12 col-sm-4">
	        <span class="block input-icon input-icon-right">
	        <select id="glsc" style="width:100%;" name="parentPickId">
	        	<option value="-1"> --- 请选择关联市场 --- </option>
	        	#foreach($market in $marketList)
	        	<option value="$market.id">$market.pickName</option>
	        	#end
	        </select>
	        </span>
	    </div>
	</div>
</div> -->
<div id="notMarketId"> 
	<div class="form-group">
	    <label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 市场简称 : </label>

	   <div class="col-xs-12 col-sm-4">
	        <span class="block input-icon input-icon-right">
	        <input type="text" placeholder="市场简称" id="thdjc" name="abbreviation" required data-bv-message="必须填写!" data-bv-stringlength-message="超出了最大范围!" data-bv-stringlength="" data-bv-stringlength-max="125" maxlength="125" class="width-100" value="" data-bv-field="cfg.configCode">
	        <i class="ace-icon fa  fa-asterisk orange"></i>
	        </span>
	    </div>
	</div>
	<div class="form-group">
	    <label class="col-sm-3 control-label no-padding-right" for="form-field-6">  </label>

	   <div class="col-xs-12 col-sm-4">
	        <span class="block input-icon input-icon-right">
	        用于分站运营切换城市时显示
	        </span>
	   </div>
	</div>


	<div class="form-group">
	    <label class="col-sm-3 control-label no-padding-right" for="form-field-6"> 关联城市: </label>
		<input type="hidden" id="cityDetail" name="cityDetail">
	    <div class="col-xs-12 col-sm-4">
	    	<div style="height:250px; width:413px; border:#CCC solid 1px;">
	        	<div style="height:250px; width:174px; border-right:#CCC solid 1px; float:left">
	            	<div class="che_tit">选择省份</div>
	                <div class="che_box">
	                	<ul id="procityId">
	                	#foreach($cty in $city)
	                 <li><label class="position-relative"><input  type="checkbox" class="ace" value="$!{cty.regionId}" onclick="getcity($!{cty.regionId},this);"><span class="lbl" id="regId$!{cty.regionId}">&nbsp;$cty.regionName</span></label>  </li>
	                	#end
	                        
	                    </ul>
	                </div>
	            </div>
	            <div style="height:250px; width:236px;float:right">
	            	<div class="che_tit"><label class="position-relative"><input type="checkbox" class="ace" id="checkAllId" onclick="checkAll()"><span class="lbl"></span></label> 城市全选</div>
	                <div class="che_box">
	                	<ul id="newLevlcityId" >
	                  </ul>
	                </div>
	            </div>
	        </div>    
	    </div>
	</div>
</div>
<div class="clearfix form-actions">
    <div class="col-md-offset-3 col-md-9">
<!--         <button class="btn btn-info" type="button" onclick="submitForm()"> -->
			<button class="btn btn-info" type="submit" id="submitBuId" >
	            <i class="icon-ok bigger-110"></i>
	        	提交
	        </button>
	        <a href="/pick/list.do" class="btn">
	            <i class="icon-undo bigger-110"></i>
	          	  返回
	        </a>
    </div>
</div>
</form>
</div>
</div>
</div>



							<!-- PAGE CONTENT ENDS -->
						</div><!-- /.col -->
					</div><!-- /.row -->
				</div><!-- /.page-content -->
			</div><!-- /.main-content -->
		<!-- basic scripts -->
		
		<div id="modal-form" class="modal" tabindex="-1">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">选择位置
                <button type="button" class="close" data-dismiss="modal" style="font-size: 20px">×</button>
                <h4 id="xzml" class="blue bigger"></h4>
            </div>
                <div class="modal-body overflow-visible">
					                        <div id="preview">
					        <div id="float_search_bar">
					            <label>区域:</label>
					            <input type="text"  id="keyword" />
					            <button id="search_button">查找</button>
					            <span>点击地图获取坐标</span>
					        </div>
					        <div id="map_container"></div>
					    </div>
					    <div id="result" style="margin-top: 4px;"></div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-sm" data-dismiss="modal">
                        <i class="icon-remove"></i>
                        取消
                    </button>

                    <button id="qd"    class="btn btn-sm btn-primary" type="button" onclick="sure()"  >
                        <i class="icon-ok"></i>
                        确定
                    </button>
                </div>

        </div>
    </div>

</div>
<script src="/assets/js/selectCity/selectCity.js""></script> 
<link rel="stylesheet" href="$!{webUtils.getAssetsPath("/css/validator/bootstrapValidator.min.css")}" />
<script type="text/javascript" src="$!{webUtils.getAssetsPath("/js/validator/bootstrapValidator.min.js")}"></script>
<script type="text/javascript">
$(function (){
	var config = {
		box: "#begin"
		, names: {
			province : "province"
			, city: "city"
			, county: "addressId"
		}
	}
	var sCity = $.selectCity(config);
})
function changeMark(val){
	if(val==2){
		$("#notMarketId input").attr("disabled",true); 
		$("#notMarketId").css('display','none'); 
		$('#isPickup').show();
	}if(val==1){
		$("#notMarketId input").attr("disabled",false); 
		$("#notMarketId").css('display','block'); 
		$('#isPickup').hide();
	}
	$("#markId").val(val);
}



function chosePosition(){
	var address = $(".address_city").find("option:selected").text(); 
	var pro = $(".address_province").find("option:selected").text(); 
	var are = $(".address_county").find("option:selected").text(); 
	$("#submitBuId").attr("disabled",false); 
	var addressTxt="北京";
	if(address=="市"){
			addressTxt="北京";
			alert("请先选择市场地址!");
			return;
	}else{
		 addressTxt = pro+address+are;
		if(are=="区/县"){
			 addressTxt = pro+address;
		}if(address=="其他城市"){
			addressTxt = pro;
		}
		 
	}
	$("#modal-form").modal();
	 $("#keyword").val(addressTxt);
	  local.search(addressTxt);
	  
}
//posiotion
 </script>
 <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script>
    <script type="text/javascript">
        function getUrlParas(){
            var hash = location.hash,
                para = {},
                tParas = hash.substr(1).split("&");
            for(var p in tParas){
                if(tParas.hasOwnProperty(p)){
                    var obj = tParas[p].split("=");
                    para[obj[0]] = obj[1];
                }
            }
            return para;
        }
        var para = getUrlParas(),
            center = para.address?decodeURIComponent(para.address) : "北京",
            city = para.city?decodeURIComponent(para.city) : "北京";
    
//         document.getElementById("keyword").value = center;
    
        var marker_trick = false;
        var map = new BMap.Map("map_container");
        map.enableScrollWheelZoom();
    
        var marker = new BMap.Marker(new BMap.Point(116.404, 39.915), {
            enableMassClear: false,
            raiseOnDrag: true
		 });
        marker.enableDragging();
        map.addOverlay(marker);
    
        map.addEventListener("click", function(e){
            if(!(e.overlay)){
                map.clearOverlays();
                marker.show();
                marker.setPosition(e.point);
                setResult(e.point.lng, e.point.lat);
            }
        });
        marker.addEventListener("dragend", function(e){
            setResult(e.point.lng, e.point.lat);
        });
    
        var local = new BMap.LocalSearch(map, {
            renderOptions:{map: map},
			 pageCapacity: 1
        });
        local.setSearchCompleteCallback(function(results) {
            if(local.getStatus() !== BMAP_STATUS_SUCCESS) {
            	var address = $(".address_city").find("option:selected").text(); 
            	var pro = $(".address_province").find("option:selected").text(); 
      		var  addressTxt = pro+address;
        	$("#modal-form").modal();
        	 $("#keyword").val(addressTxt);
        	  local.search(addressTxt);
            } else {
			     marker.hide();
			}
        });
        local.setMarkersSetCallback(function(pois) {
            for(var i=pois.length; i--; ) {
                var marker = pois[i].marker;
                marker.addEventListener("click", function(e) {
                    marker_trick = true;
                    var pos = this.getPosition();
                    setResult(pos.lng, pos.lat);
                });
            }
        });
    
        window.onload = function() {
          
            document.getElementById("search_button").onclick = function() {
                local.search(document.getElementById("keyword").value);
            };
            document.getElementById("keyword").onkeyup = function(e) {
                var me = this;
                e = e || window.event;
                var keycode = e.keyCode;
                if(keycode === 13){
                    local.search(document.getElementById("keyword").value);
                }
            };
        
        };
        
        /*
         * setResult : 定义得到标注经纬度后的操作
         * 请修改此函数以满足您的需求
         * lng: 标注的经度
         * lat: 标注的纬度
         */
        function setResult(lng, lat){
//             document.getElementById("result").innerHTML = lng + ", " + lat;
            $("#longitudeId").val(lng);
            $("#latitudeId").val(lat);
        }
       function sure(){
	if($("#longitudeId").val()==""){
		alert("请在地图上将市场的地址定位到具体的地点!");
	}else{
		$('#modal-form').modal('hide');
        $("#positionTxt").val("("+$("#longitudeId").val()+","+ $("#latitudeId").val()+")");
	}
    	   
       }
       function getcity(cityId,e){
    	   $("#submitBuId").attr("disabled",false); 
    	   if(e.checked){
    			$.ajax({
        			type : 'post',
        			url :  "/city/getCityInfo.do?parentId="+cityId,
        			success : function(data) {
        				var html="";
        				for(key in data){
##        					#foreach($selectCity in $selectCity)
##        					if($selectCity.cityId==data[key].regionId){
##        						continue;
##        					}
##        					#end
        					html+="<li id=licity"+cityId+"><label class='position-relative' style='width:236px;'><input type='checkbox' value="+data[key].regionId+" class='ace'><span class='lbl'>"+data[key].regionName+'('+$("#regId"+cityId).text()+')'+"</span></label>  </li>"
                        	
        				}
        				$("#newLevlcityId").append(html);
        			},
        			error : function() {
        				alert("网络超时!");
        			}
        		});
    	   }else{
    		    $("#newLevlcityId li").remove("li[id=licity"+cityId+"]");
    	   }
    	
       }
       function checkAll(){
    		var check = $("#newLevlcityId li label input[type=checkbox]");
    		for(var i=0;i<check.length;i++){
    			if($("#checkAllId").is(':checked')){
    				 if(!check[i].disabled){
    					 check[i].checked=true;
    				 }				
    			} else{
    				check[i].checked=false;
    			}
    		}
       }
   </script>
   <script type="text/javascript">
   var tag=1;
   $(function(){
		$("#add_contact").on("click",function(){
			var contact_con =  '<div class="form-group"><label class="col-sm-3 control-label no-padding-right" for="form-field-6"> </label><div class="col-xs-12 col-sm-4"> <span class="block input-icon input-icon-right">'
				+'<input type="text" pickupname  placeholder="联系人姓名"  id=personName'+tag+' name=xrxm'+tag+' required onfocus="submitBtDisab()"  class="col-sm-6" value=""  >'
		        +'<input type="text" pickuptel  placeholder="联系电话" id=personTel'+tag+' name=xrdh'+tag+' required onfocus="submitBtDisab()" data-bv-message="必须填写!" class="col-sm-6"   value=""  >'
		        +'</span>  '     
		        +'</div><div> <a href="javascript:void(0);" class="remove_contact">  <i class="fa fa-minus " style=" line-height: 25px; margin-top: 5px;  "></i></a></div></div>';
	        var html = $(contact_con);
	        
			$("#add_position").after(html);
	            tag = parseInt(tag)+1;
	        $(html).find(".remove_contact").on("click",function(){
	        	tag = tag-1;
	            $(this).parents(".form-group").remove();
	        });
		});	
	});
   $(document).ready(function() {
   $('#addForm').bootstrapValidator({ submitHandler: function(validator, form, submitButton) {
		if($("#positionTxt").val()==""){
			   alert("请选择位置");
				submitBtDisab();
			   return;
		}
	   var name="";
		var tele="";
		var put = $("input[pickupname]");
		var tel = $("input[pickuptel]");
		for(var i=0;i<put.length;i++){
			 var mobile = /^1[3-8]\d{9}$/ ;
			    var rtel = /^(\d{3,4}-)\d{7,9}$/g;
			if(put[i].value==""||tel[i].value==""){
				alert("请填写联系人的联系方式");
				submitBtDisab();
				return;
			}
			    if(rtel.test(tel[i].value)||(tel[i].value.length==11 && mobile.test(tel[i].value))){
			    	name+=put[i].value+",";
			    	tele+=tel[i].value+",";
			    }else{
			    	alert("请填写正确联系方式");
			    	submitBtDisab();
			    	return;
			    }
			
		}
 	 $("#contpId").val(name);
 	 $("#contnId").val(tele);
 	 var proId="";
		var procheck = $("#procityId li label input[type=checkbox]");
		for(var i=0;i<procheck.length;i++){
			if(procheck[i].checked==true){
				proId+=procheck[i].value+',';
			}
		}
	   var id="";
		var check = $("#newLevlcityId li label input[type=checkbox]");
		for(var i=0;i<check.length;i++){
			if(check[i].checked==true){
					id+=check[i].value+',';
			}
		}
		$("#cityDetail").val(proId+id);
		var ismk =	$("#markId").val();
		if(ismk=='2' && $('#glsc').val() == '-1'){
			alert("请选择关联提货点");
			submitBtDisab();
			return;
		}
		if(ismk=="1"&&$.trim($("#thdjc").val())==""){
			alert("请填写提货点简称");
			submitBtDisab();
			return;
		}
		if(ismk=="1"&&id==""){
			alert("请选择关联城市");
			submitBtDisab();
			return true;
		}
 	    var data = $('#addForm').serializeArray();
 	    $.ajax({
			url: "/pick/save.do",
			type : "post",
			data : data,
			success : function (data){ 
				if(data.code==1){
					window.location = "$!{webUtils.getLocalPath("pick/list.do")}";
				}else{
					alert(data.msg);
					submitBtDisab();
				}
			}
		});
	   return true;
   }});
   
   //$("#notMarketId input").attr("disabled",true);

   });
   function submitBtDisab(){
		$("#submitBuId").attr("disabled",false); 
   }
   </script>
</div>