<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <%@ include file="../../common/head.jsp"%>
    <cs:initFile/>
</head>
<body>
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
            	 <cs:form_validate formId="addMenuForm"/>
                  <form class="form-horizontal" action="add.cs" id="addMenuForm" method="POST">
                      <div class="form-group">
                          <label class="col-sm-3 control-label">上级分类：</label>
                          <div class="col-sm-6">
                              <select class="form-control m-b" id="pid" name="pid" onchange="menuChange(this)" validate="{required:true}" validateMessage="{required:'请选择分类'}">
                              		<option value="">请选择</option>
                              		<c:forEach items="${firstCategory }" var="superMenu">
                              			<option value="${superMenu.id }" 
                              				<c:if test="${superMenu.id == mgmProductCategory.id }"> selected</c:if> 
                              			>${superMenu.gcName}</option>
                              		</c:forEach>
                              </select>
                          </div>
                      </div>
                     <script type="text/javascript">
                     function menuChange(obj){
                    	 var ss = $(obj).children('option:selected').val();  
                         if (ss == "0") {  
                        	 $('#lb').css("display", "block");
                         } else if (ss != "0") {  
                        	 $('#lb').css("display", "none");
                         } 
                         $.ajax({
                             type: "get",
                             url: "<%=basePath%>mgmProductCategoryCtl/nextCategory.cs",
                             data: {id:ss},
                             dataType: "json",
                             success: function(data){
                                    if(data.type == "1"){
                                    	$("#tlb").css("display","none");
                                    	$("#tolb").css("display","none");
                                    	$("#xm").css("display","block");
                                    	
                                    }else if(data.type == "2"){
                                    	$("#tlb").css("display","block");
                                    	$("#tolb").css("display","block");
                                    	$("#xm").css("display","none");
                                    	data.mlist.forEach(function(val,index,arr){
                                    		  $("#ptid").append("<option value='"+val.id+"'>"+ val.gcName+"</option>");            
                                    		});
                                    	
                                    }
                                 }
                         });
                         
                     }
                     
                     function twoMenuChange(obj){
                    	 var ss = $(obj).children('option:selected').val();  
                    	 if (ss == "0") {  
                        	 $('#tolb').css("display", "block");
                         } else if (ss != "0") {  
                        	 $('#tolb').css("display", "none");
                         } 
                    	 
                    	 
                         $.ajax({
                             type: "get",
                             url: "<%=basePath%>mgmProductCategoryCtl/nextCategory.cs",
                             data: {id:ss},
                             dataType: "json",
                             success: function(data){
                            	   if(data.type == "2"){
                            		 if(data.twotype == "2"){
                            			 
                            		 }else if(data.twotype == "3"){
                            			 $("#thlb").css("display","block");
                                     	data.mlist.forEach(function(val,index,arr){
                                     		  $("#pSid").append("<option value='"+val.id+"'>"+ val.gcName+"</option>");            
                                     		});
                            		 }
                            	   }
                                 }
                         });
                         
                     }
                     
                     </script>
                     
                     <div id="tlb" class="form-group" style="display:none;"  validate="{required:true}" validateMessage="{required:'请选择分类'}">
                          <label class="col-sm-3 control-label">二级分类：</label>
                          <div class="col-sm-6">
                              <select class="form-control m-b" id="ptid" name="ptid" onchange="twoMenuChange(this)">
                              		<option value="">请选择</option>
                              </select>
                          </div>
                      </div>
                      
                      <div id="thlb" class="form-group" style="display:none;"  validate="{required:true}" validateMessage="{required:'请选择分类'}"> 
                          <label class="col-sm-3 control-label">三级分类：</label>
                          <div class="col-sm-6">
                              <select class="form-control m-b" id="pSid" name="pSid" >
                              		<option value="">请选择</option>
                              </select>
                          </div>
                      </div>
                      
                     <div class="form-group">
                          <label class="col-sm-3 control-label">名称：</label>
                          <div class="col-sm-6">
                              <input id="gcName" name="gcName" class="form-control" validate="{required:true, minlength:1}" validateMessage="{required:'请输入菜单名称,不能重复',minlength:'至少一个字符以上'}" >
                          </div>
                      </div>
                     
                      <div class="form-group">
                            <label class="col-sm-3 control-label">分类图标：</label>
                            <div class="col-sm-6">
                                <cs:file name="gcIcon" type="100"  num="1"></cs:file>
                            </div>
                      </div>
                      
                     <div id="xm" class="form-group" style="display:none;"> 
                          <label class="col-sm-3 control-label">所属项目：</label>
                          <div class="col-sm-6">
                              <select class="form-control m-b" id="projectId" name="projectId" validate="{required:true}" validateMessage="{required:'请选择所属项目'}" >
                              		<option value="">请选择</option>
                              		<c:forEach items="${project }" var="superMenu">
                              			<option  value="${superMenu.id }" >${superMenu.name}</option>
                              		</c:forEach>
                              </select>
                          </div>
                      </div>
                     
                     <div id="tolb" class="form-group" style="display:none;">
                          <label class="col-sm-3 control-label">产品级数：</label>
                          <div class="col-sm-6">
                              <select class="form-control m-b" id="twoType" name="twoType" validate="{required:true, minlength:1}" validateMessage="{required:'请选择分类类型'}">
                              		<option value="">请选择</option>
                              		<option value="2">2级</option>
                              		<option value="3">3级</option>
                              		
                              </select>
                          </div>
                      </div>
                     
                      <div id="lb" class="form-group" <c:if test="${mgmProductCategory != null }">style="display:none;"</c:if>>
                          <label class="col-sm-3 control-label">分类类型：</label>
                          <div class="col-sm-6">
                              <select class="form-control m-b" id="type" name="type" validate="{required:true, minlength:1}" validateMessage="{required:'请选择分类类型'}">
                              		<option value="">请选择</option>
                              		<option value="1">项目类型</option>
                              		<option value="2">产品类型</option>
                              		
                              </select>
                          </div>
                      </div>
                      <div class="form-group">
                          <label class="col-sm-3 control-label" >权重：</label>
                          <div class="col-sm-6">
                              <input validate="{required:true, min:0}" validateMessage="{required:'请输入权重数值',min:'请输入大于0的数字'}" id="gcSort" name="gcSort"  class="form-control" >
                          </div> 
                      </div>
                      
                      <div class="form-group">
                          <label class="col-sm-3 control-label">关键字：</label>
                          <div class="col-sm-6">
                              <input id="gcKeywords" name="gcKeywords" class="form-control" validate="{required:true, minlength:1}" validateMessage="{required:'请输入分类关键字',minlength:'至少一个字符以上'}" >
                          </div>
                      </div>
                      
                      <div class="form-group">
                          <label class="col-sm-3 control-label">描述：</label>
                          <div class="col-sm-6">
                          <textarea rows="12" cols="" id="gcDesc" name="gcDesc" class="form-control"></textarea>
                          </div>
                      </div>
                      
                      <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3 pull-left">
                                    <button class="btn btn-default btn-dlg-close">取消</button>
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                       </div>
                      
                  </form>
            </div>
        </div>

    </div>


</body>

</html>

