<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/html5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/css/bootstrap.min-3.3.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/select2/select2.min.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<style>
#datainit{
 margin-left:5px;
}

</style>
<title>分销商管理操作</title>
</head>
<body>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/select2/select2.min.js"></script>
<div class="codeView">
			<form action="/tooth/admin/drp/EditPlaceInfoSubmit" method="post" class="form form-horizontal" id="form-Validform" novalidate="novalidate">
				<input type="hidden" name="id" value=${placeInfo.id} ></input>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>公司名称：</label>
					<div class="formControls col-xs-6 col-sm-6">
						<input type="text" class="input-text" datatype="*2-30" nullmsg="用户名不能为空" placeholder="用户名，昵称" nullmsg="用户名不能为空" value="${placeInfo.name}" name="name" id="name">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
					<div class="formControls col-xs-6 col-sm-6">
						<input type="text" class="input-text" datatype="*2-16" placeholder="姓名" nullmsg="姓名不能为空" value="${placeInfo.userName}" name="userName" id="username">
					</div>
				</div>

				<%--<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属角色：</label>
					<div class="formControls col-xs-6 col-sm-6"> <span class="select-box">
						<select class="select" size="1" id="roleId" name="roleId">
						  <option value="${placeInfo.roleId}" selected> ${placeInfo.roleName} </option>
						</select>
						</span> </div>
				</div>--%>
				
			       <div id="isHide" class="row cl hide" >
						<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>区域：</label>
						<div class="formControls col-xs-6 col-sm-6">
							<input type="text" class="input-text" value="${placeInfo.areaName}"  placeholder="请输入城市，多个城市用逗号隔开"  name="areaName" id="areaName">
						</div>
					</div>

				<%-- <div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否订货:</label>
					<div class="formControls col-xs-6 col-sm-6"> <span class="select-box">
						<select class="select" size="1" id="isOrder" name="isOrder">
							<c:choose>
							    <c:when test="${isOrder == 1}">
							        <option value=1 selected>否</option>
							        <option value=2 >是</option>
							    </c:when>
							    <c:otherwise>
							        <option value=1 >否</option>
							        <option value=2 selected>是</option>
							    </c:otherwise>
							</c:choose>
						</select>
						</span> </div>
				</div> --%>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>二维码功能:</label>
					<div class="formControls col-xs-6 col-sm-6"> <span class="select-box">
						<select class="select" size="1" id="hasQrcode" name="hasQrcode">
							<c:choose>
							    <c:when test="${placeInfo.hasQrcode==2}">
							        <option value=1 >没有</option>
							        <option value=2 selected>是</option>
							    </c:when>
							    <c:otherwise>
							        <option value=1 selected>没有</option>
							        <option value=2 >是</option>
							    </c:otherwise>
							</c:choose>
						</select>
						</span> </div>
				</div>
				<%--<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">选择父级：</label>
					<div class="formControls col-xs-6 col-sm-6"> 
						<select class="select"  id="getPid"  name="PlacePid">
							<option value=${placeInfo.placePid} id="getPid2" selected="selected">minglen</option>
						</select>
						 </div>
				</div>--%>
				<%--<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">选择模板：</label>
					<div class="formControls col-xs-6 col-sm-6"> 
						<select class="select"  id="templateId"  name="templateId">
						<option value=${placeInfo.templateId} selected>${placeInfo.templateName}</option>
						</select>
					</div>
				</div>--%>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>联系方式：</label>
					<div class="formControls col-xs-6 col-sm-6">
						<input type="text" class="input-text" autocomplete="off" dataType="m" value="${placeInfo.tel}"placeholder="手机/电话" nullmsg="联系方式不能为空" name="tel" id="tel">
					</div>
				</div>

				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>代理商地址：</label>
					<div class="formControls col-xs-6 col-sm-6">
						<input type="text" class="input-text" dataType="*" placeholder="分销联系地址" value="${placeInfo.addr}" name="addr" nullmsg="联系地址不能为空" id="addr">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">备注：</label>
					<div class="formControls col-xs-6 col-sm-6">
						<textarea class="textarea" id="remark-text" placeholder="说点什么...最少输入10个字符" name="remark" onkeyup="textarealength(this,500)">${placeInfo.remark}</textarea>
						<p class="textarea-numberbar"><em class="textarea-length">0</em>/500</p>
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					    
						 <input class="btn btn-primary" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					     <input class="btn btn-primary" type="button" onclick="closeWindow()"  value="&nbsp;&nbsp;取消&nbsp;&nbsp;">
					</div>
				</div>
			</form>
		</div>



<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript"> 
$(function(){ 
	$(function(){
        textarealength($("#remark-text")[0],500);
        $("#form-Validform").Validform({
		    tiptype:4, 
		    ajaxPost:true, 
		    beforeCheck:function(curform){
		    	var placeRole = $('#placeRole').val();
		    },
		    callback:function(data){ 
		      if(data.result=="200"){ 
		        layer.msg(data.message, {icon:data.message,time: 1000}, function(){ 
		        	 var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		        	 parent.searchInfo();
		       	     parent.layer.close(index); 
		        	 //parent.searchInfo();
		          });  
		      } 
		      else{ 
		        layer.msg(data.message, {icon: data.message,time: 3000}); 
		      } 
		    } 
		  });  
		}); 
  $('#saveInfo').click( function () { 
	  $("#form-Validform").submitForm(false);
  });
  
  roleHide();
}); 


function roleHide() {
	var textstr = $('#roleId').find("option:selected").text();
	if (null != textstr && textstr != '') {
		textstr = textstr.trim();
	}
	if(textstr == '省代'){
		$("#isHide").removeClass("hide");
	}else{
		$("#isHide").addClass("hide");
	}
}

$("#roleId").change(function(){
	var textstr=$("#roleId").find("option:selected").text();
	if(textstr=='省代'){
		if ($('#isHide').hasClass('hide')) {
			$("#isHide").removeClass("hide");
		}
	}else{
		$("#isHide").addClass("hide");
	}
});

//关闭窗口
function closeWindow(){
	  var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	  parent.layer.close(index);
}

var flage=false;
var flage2=false;
//选择分销商角色的触发事件
$("#roleId").click(function(){ 
	if(flage){ return;};
	 $.ajax({
         "type" : "post",
         "url" : "/tooth/admin/drp/getSelectList",
         "dataType" : "json",
         "data" :{
        	 "type":"1"
         },
         "success" : function(resp) {
        	// alert(resp);
        	 var htmloption="";
        	 for(var i=0,l=resp.length;i<l;i++){
        		 htmloption=htmloption+"<option value='"+resp[i].roleId+"'>"+resp[i].roleName+"</option>";
        	 }
        	 $("#roleId").html(htmloption);
        	 flage=true;
         },
         "error":function(data){
  			  alert(data.message);
  			  alert("操作失败，请联系管理员！");
  		  }
	 });
});
	 $("#templateId").click(function(){ 
		 if(flage2){ return;};
		 $.ajax({
	         "type" : "post",
	         "url" : "/tooth/admin/drp/getSelectList",
	         "dataType" : "json",
	         "data" :{
	        	 "type":"2"
	         },
	         "success" : function(resp) {
	        	 //alert(resp);
	        	 var htmloption="<option value=0 >无模板</option>";
	        	 for(var i=0,l=resp.length;i<l;i++){
	        		 htmloption=htmloption+"<option value='"+resp[i].templateId+"' selected>"+resp[i].templateName+"</option>";
	        	 }
	        	 $("#templateId").html(htmloption);
	        	 flage2=true;
	         },
	         "error":function(data){
	  			  alert(data.message);
	  			  alert("操作失败，请联系管理员！");
	  		  }
		 });
	 
	/* var svalue=$(this).children('option:selected').val();
	if(svalue==1){
		$("#placeRole").html("<option value=1 selected>分销商</option>");
	}else if(svalue==2){
		$("#placeRole").html("<option value=2 selected>门店</option><option value=3>决策者</option><option value=4>特殊决策者</option><option value=7>奶粉厂商</option>");
	}else{
		$("#placeRole").html("<option value=5 selected>导购</option><option value=6>医生或护士</option>");
	} */
	
})




/* $('#store').click(function(){
	if ($('#store').is(":checked")) {
		$("[name='jurisdiction']").prop("checked",true);
	} else {
		$("[name='jurisdiction']").prop("checked",false);
	}
}); */

var pageNo=1;
//下拉搜索框
$("#getPid").select2({
  language: "zh-CN",
  ajax: {
    url: "/tooth/admin/drp/searchPlaceInfoParent",
    dataType: 'json',
    delay: 250,
    data: function (params) {
      return {
        search: params.term, // search term
        pageNo: pageNo,
      //  type:$("#placeType").val()=='1'?0:parseInt($("#placeType").val())-1
      };
    },
    processResults: function (data, params) {
      // parse the results into the format expected by Select2
      // since we are using custom formatting functions we do not need to
      // alter the remote JSON data, except to indicate that infinite
      // scrolling can be used
      params.page = params.page || 1;
      pageNo=pageNo+1;
      console.info(JSON.stringify(data));
      return {
        results: data.data,
        pagination: {
          more: (params.page * 15) < data.totalNumber
        }
      };
    },
    cache: true
  },
  escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
  minimumInputLength: 1,
  templateResult:function(item){ //下拉框渲染拉下列表的格式
		var itemStr="<option value='"+item.id+"' selected>"+item.name+"</option>";
		return itemStr;
	}, 
  templateSelection:function(item){ //下拉框渲染选择后的格式
	    //alert(item.supperId);
        //$("#supperId").val(item.supperId);
		var itemStr="<option value='"+item.id+"' selected>"+item.name+"</option>";
		return itemStr;
	} 
});

$("#select2-getPid-container").find("option").html("${placeInfo.parentName}");
</script> 


</body>
</html>