<!DOCTYPE html>
<!--[if IE 8]>
  <html lang="en" class="ie8 no-js">
  <![endif]-->
<!--[if IE 9]>
    <html lang="en" class="ie9 no-js">
    <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
<base href="#springUrl('/assets/adminlte/')" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>工作台</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet"
	href="plugins/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet"
	href="plugins/ionicons/css/ionicons.min.css">
	
<!-- DataTables -->
<link rel="stylesheet"
	href="plugins/datatables/dataTables.bootstrap.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
<!-- Date Picker -->
<link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet"
	href="plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet"
	href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<!--validate css-->
<link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
<!--fileinput css-->
<link rel="stylesheet"
	href="plugins/ztree/css/metroStyle/metroStyle.css" type="text/css" />

<link rel="stylesheet"
	href="plugins/bootstrap-fileinput/bootstrap-fileinput.css">
<link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
<link rel="stylesheet"
	href="plugins/daterangepicker/daterangepicker-bs3.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
<style type="text/css"></style>

<style>
.datepicker.dropdown-menu {
	z-index: 100000 !important
}
</style>
</head>
<!-- END HEAD -->

<body class="hold-transition skin-blue sidebar-mini">

	<div id="hiddenDiv" style="display:none">$!{imageText.content}</div>

	<div class="wrapper">
		<div id="treeSelect"></div>
		<div class="content-wrapper" style="margin-left: 0;">
			<section class="content-header">
				<h1>
					公众号菜单管理 <small>公众号菜单设置</small>
				</h1>
				<ol class="breadcrumb">
					<li><a href="#"> <i class="fa fa-dashboard"></i>首页
					</a></li>
					<li><a class="active">公众号菜单管理</a></li>
				</ol>
			</section>
			<!-- Main content -->
			<section class="content">
				<div class="row">

					<!-- /.col -->
					<div class="col-xs-12">
						<div class="box box-primary">
							<form role="form" id="replyForm"> 
								<div class="box-body">
									<input type="hidden" id="updateId" value="$!{menu.id}">
									<div class="form-group form-md-line-input">
										<label>菜单名称</label>
										<input type="text" class="form-control htmlescape" id="name" name="name"
											maxlength="10" placeholder="菜单名称" required="required"
											value="$!{menu.name}">
									</div>
									
									<div class="form-group form-md-line-input" >
									<label>菜单级别</label> 
										<div class="radio">
<!-- 										 <label> <input -->
<!-- 												type="radio" name="sendType" id="sendTypeText" -->
<!-- 												value="text" checked>文本 -->
<!-- 											</label> <label> <input type="radio" name="sendType" -->
<!-- 												id="sendTypeImage" value="image" >图片 -->
<!-- 											</label> --> 
											<label> <input type="radio" name="levelMenu"
												 checked value="1" >一级菜单 
											</label><label> <input type="radio" name="levelMenu"
												 value="2" >二级菜单
											</label>
										</div>
									</div>
									
									 <div class="form-group form-md-line-input" style="display:none" id="seachParent">
	                                     <label>父级菜单</label>
	                                     <select id="sel" class="form-control select2 select2-hidden-accessible" name="parentId"  tabindex="-1" >
											<option selected="selected" value="0">请选择</option>  
										 </select>
                                	</div>
									<div class="form-group form-md-line-input"> 
									<label>菜单内容</label> 
										<div class="radio">
<!-- 										 <label> <input -->
<!-- 												type="radio" name="sendType" id="sendTypeText" -->
<!-- 												value="text" checked>文本 -->
<!-- 											</label> <label> <input type="radio" name="sendType" -->
<!-- 												id="sendTypeImage" value="image" >图片 -->
<!-- 											</label> --> 
											<label> <input type="radio" name="source_type"
												id="sendMessage" checked value="1" >发送消息
											</label><label> <input type="radio" name="source_type"
												id="skipurl" value="2" >跳转网页
											</label>
											<label id="emptyCon"> <input type="radio" name="source_type"
												  value="3" >无内容
											</label> 
										</div>
									</div>
									<div class="form-group form-md-line-input" id="sendMessageSeach" style="display:none">
									<label>消息回复类型</label>
										<div class="radio">
										 
											<label> <input
												type="radio" name="replyType" id="replyTypeText"
												value="1" checked>文本
											</label>
											<label> <input type="radio" name="replyType"
												id="replyTypenews" value="2" >微信图文
											</label>
											<label> <input type="radio" name="replyType"
														   id="replyTypeLocalnews" value="3" >文章
											</label>
										</div> 
									</div>
									<div class="form-group form-md-line-input" id="contentText" style="display:none"> 
										<label for="content_source">文本内容</label>
										<br/>
										<textarea name="content_source" id="content_source"  maxlength="500" rows="5" cols="100">#if($menu.source_type=="1" && $menu.msg_type=="1")$!{menu.source_content}#end</textarea>
									</div>
									<div class="form-group form-md-line-input" id="skipurlSeach" style="display:none">
										<label for="url">URL链接地址</label> 
										<input type="text" class="form-control" id="url" name="url"
											maxlength="500" placeholder="跳转的URL" 
											value='#if($menu.source_type=="2" )$!{menu.source_content}#end'>
									</div>
									<div class="form-group form-md-line-input" id="contentnews" style="display:none">
										<label for="content_source">图文选择</label>
										<a id="newseach" href="javascript:void(0)"
										class="btn btn-primary">选择微信图文 </a>
										<input type="hidden" value="" id="imgtext">
										<br/> 
									</div>
									<div class="form-group form-md-line-input" id="contentlocalnews" style="display:none">
										<label for="content_source">文章选择</label>
										<a id="localnewssearch" href="javascript:void(0)"
										   class="btn btn-primary">选择文章 </a>
										<input type="hidden" value="" id="localArticle">
										<br/>
									</div>
									<input name="articleId" id="articleId" style="display: none;">
									<input name="articleName" id="articleName" style="display: none;">
									<div style="display: none;width: 100%;height: auto" id="newsShow">

									</div>
									<div class="form-group form-md-line-input">
										<label for="sort">排序值(一级菜单越大越靠左，二级菜单越大越靠下)</label>
										<input type="text" class="form-control" id="sort" name="sort"
											maxlength="10" placeholder="排序值" required="required"
											value="$!{menu.sort}"> 
									</div>
									<div class="col-xs-2" style="display: none">
										<input type="text" class="form-control required"
											   name="id" id="menuid" placeholder="菜单Id">
									</div>
								</div>
								<div class="box-footer">
									<input class="btn btn-primary" id="save" value="保存"
										type="submit"> <a href="#springUrl('/a/mpMenu/list')"
										class="btn btn-default">取消</a> 
								</div>
							</form>
						</div>
					</div>
				</div>
			</section>
		</div>
		<div class="control-sidebar-bg"></div>
	</div>
	<!-- ./wrapper -->
	<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
	<!-- Bootstrap 3.3.5 -->
	<script src="bootstrap/js/bootstrap.min.js"></script>
	<!-- SlimScroll -->
	<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
	<!-- FastClick -->
	<script src="plugins/fastclick/fastclick.min.js"></script>
	<!--fileinput js-->
	<script src="plugins/datatables/jquery.dataTables.min.js"></script>
	<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
	<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
	<!-- AdminLTE App -->
	<script src="dist/js/app.min.js"></script>
	<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js"
		type="text/javascript"></script>
	<script src="plugins/security/sha256.js" type="text/javascript"></script>
	<script src="plugins/ztree/js/jquery.ztree.all.min.js"
		type="text/javascript"></script>
	<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
	<script src="plugins/jquery-validation/js/localization/messages_zh.js"></script>
	<script src="js/jquery.form.min.js"></script>
	<!-- Uedit Start -->
	<script type="text/javascript" charset="utf-8"
		src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
	<!-- Uedit End -->
	<script type="text/javascript" charset="utf-8"
		src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
	<script src="common/js/seachImageText.js"></script> 
	<script src="common/js/cfapp.js"></script>
	<script src="common/js/dateUtils.js"></script>
	<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
	<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
	<script src="plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
	<!-- END PAGE LEVEL PLUGINS -->

	<script>
        var csrfheader = {name:'_csrf_header',value:'${_csrf.headerName}'};
        var csrftoken  = {name:'_csrf',value:'${_csrf.token}'};
	</script>
	<script>
	 var sSource = "#springUrl('/a/imagetext/seachImageText')";//根据选中的ID获取图文内容
	var articleList = "#springUrl('/a/article/newsList')";//微信图文列表
	 var localArticleList = "#springUrl('/a/cfarticle/listData')";//文章图文列表

	 var cfarticleOrderList = "#springUrl('/a/cfarticle/listDataInOrder')"; //获取
	if("$!{menu.id}"!=null && "$!{menu.id}"!=""){ 
		if("$!{menu.sourceType}"=="1" && "$!{menu.msgType}"=='2'){ //图文消息
			var selectImageText = "";
				if('$!{menu.newsItem}'!=""){
					selectImageText=eval('$!{menu.newsItem}');//已经选择好的微信素材内容
				}

			$("#articleId").val("$!{menu.sourceContent}");//选择好的微信素材mediaID
			var HTML = "";
			if(selectImageText){
				for(var i =0;i<selectImageText.length;i++){
					HTML+="<p>"+(i+1)+":<a href='"+selectImageText[i].url+"' target='_blank'>"+selectImageText[i].title+"</a></p>";
				}
			}
			$("#newsShow").html(HTML);
			$("#newsShow").show();
			$("#contentnews").show();
			$("#contentText").hide();

		}else if("$!{menu.sourceType}"=="1" && "$!{menu.msgType}"=='1'){//文本消息
			$("#content_source").val("$!{menu.sourceContent}".replace(/<br\/>/g, "\r\n"));
			$("#contentnews").hide();
			$("#contentText").show();  
		}else if("$!{menu.sourceType}"=="2"){//跳转网页
			$("#url").val("$!{menu.sourceContent}"); 
			$("#skipurlSeach").show(); 
		}else if("$!{menu.sourceType}"=="1" && "$!{menu.msgType}"=='3'){//文章图文
			$("#articleId").val("$!{menu.sourceContent}");//选择好的微信素材mediaID
			var HTML = "";
			var nameValue="";
			var sourceContentTemp = "$!{menu.sourceContent}";

			if(sourceContentTemp && sourceContentTemp!=""){
				$.ajax({
					type:"POST",
					url:cfarticleOrderList,
					data:{whereArticles:"$!{menu.sourceContent}",articles:"$!{menu.sourceContent}"},
					datatype: "json",
					//在请求之前调用的函数
					beforeSend:function(){

					},success:function(data){
						if(data.list){
							for(var i=0;i<data.list.length;i++){
								HTML+="<p>"+data.list[i].title+"</p>";
								nameValue+="<p>"+data.list[i].title+"</p>,";
							}
							$("#articleName").val(nameValue);
							$("#newsShow").html(HTML);

						}
					},error: function(){
					}
				});
			}
				$("#newsShow").show();
				$("#contentlocalnews").show();
				$("#contentText").hide();
		}

		if("$!{menu.msgType}"){

		$("input[name='replyType'][value='$!{menu.msgType}']").prop("checked",true);

		}else{
			
		}
		if("$!{menu.parentId}"=='0'){ 
			$("input[name='levelMenu'][value='1']").prop("checked",true);
			$("#seachParent").hide();
		}else{
			$("input[name='levelMenu'][value='2']").prop("checked",true);
			$("#seachParent").show();
			$("#seachParent").val("$!{menu.parentId}");
		} 
		$("input[name='source_type'][value='$!{menu.sourceType}']").prop("checked",true);

	}else{
		$("#sendMessageSeach").show();
		$("#contentText").show();
	}

	if("$!{menu.sourceType}"=="1"){//返回消息类型是固定返回，则回复配置的相应块显示
		$("#sendMessageSeach").show();
	}


	 
	 
		
	 Cfapp.init();

	 $('#newseach').on('click',function() {
		 Cfapp.f7({
			 dataUrl: articleList,
			 checkType: 'single', // 多选为multi
			 title: "选择微信图文",
			 btnoktext: "确定",
			 btncanceltext: "取消",
			 columns: ['选择', '图文标题', '最后更新时间'],
			 isSearch: '1',
			 aoColumns: [{
				 "mData": "media_id"
			 }, {
				 "mData": "title"
			 }, {
				 "mData": "wxUpdateTime"
			 }],
			 aoColumnDefs: [{
				 "aTargets": [0],
				 "mData": "media_id",
				 "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
					 var HTML = "";
					 if(c.news_item){
						 c.news_item=eval(c.news_item);
						 for(var i =0;i<c.news_item.length;i++){
							 HTML+="<p>"+(i+1)+":<a href='"+c.news_item[i].url+"' target='_blank'>"+c.news_item[i].title+"</a></p>";
						 }
					 }
					 return '<input type="radio" id="' + a + '" name="sel" data-value="' + a + '" data-name="' + HTML + '">';
				 }
			 },{
				 "aTargets": [1],
				 "mData": "id",
				 "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
					 var HTML = "";
					 if(c.news_item){
						 c.news_item=eval(c.news_item);
						 for(var i =0;i<c.news_item.length;i++){
							 HTML+="<p>"+(i+1)+":<a target='_blank' href='"+c.news_item[i].url+"'>"+c.news_item[i].title+"</a></p>";
						 }
					 }
					 return HTML;

				 }
			 },{
				 "aTargets": [2],
				 "mData": "wxUpdateTime",
				 "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
					 return dataUtils.dateFormat(a,"yyyy-MM-dd hh:mm");
				 }
			 }],
			 success: function () {
				 $("#newsShow").html($("#articleName").val());
				 $("#newsShow").show();
			 },
			 cancel: function () {

			 },
			 storeFields: 'articleId', // 储存的字段
			 displayFields:'articleName'
		 })
	 });




	 $('#localnewssearch').on('click',function() {
		 Cfapp.f7({
			 dataUrl: localArticleList,
			 checkType: 'multi', // 多选为multi
			 title: "选择文章",
			 btnoktext: "确定",
			 btncanceltext: "取消",
			 columns: ['选择', '文章标题', '所属栏目', '文章封面','文章类型'],
			 isSearch: '0',
			 searchColumns: ["title", "columnName"],//搜索的字段名称
			 searchColumnsRemarks: ['文章标题', '所属栏目'],//搜索的字段备注
			 aoColumns: [{
				 "mData": "id"
			 }, {
				 "mData": "title"
			 }, {
				 "mData": "columnName"
			 }, {
				 "mData": "bigimg"
			 },{
				 "mData": "type"
			 }],
			 aoColumnDefs: [{
				 "aTargets": [0],
				 "mData": "id",
				 "mRender": function (a, b, c, d) {
					 var HTML="<p>"+c.title+"</p>";
					 return '<input type="checkbox" id="' + a + '" name="sel" data-value="' + a + '" data-name="' + HTML + '">';
				 }
			 },{
				 "aTargets": [3],
				 "mData": "img",
				 "mRender": function (a, b, c, d) {//a表示createtime对应的值，c表示当前记录行对象
					 return "<img src='" + a + "' style='width: 80px;height:80px;' />";
				 }
			 },{
				 "aTargets": [4],
				 "mData": "type",
				 "mRender": function (a, b, c, d) {//a表示type值
					if(a==0){
						return "文章";
					}else{
						return "图集";
					}
				 }
			 }],
			 success: function () {
			 	var html = $("#articleName").val().replace(/<\/p>,/g,"</p>");
				 $("#newsShow").html(html);
				 $("#newsShow").show();
			 },
			 cancel: function () {

			 },
			 storeFields: 'articleId', // 储存的字段
			 displayFields: 'articleName'
		 })
	 });
	
		$("input[name='replyType']").change(function() { 
			if($(this).val()=="2"){//微信图文
				$("#contentnews").show();//图文选择按钮
				$("#contentText").hide(); //文本
				$("#contentlocalnews").hide();//选择文章按钮
				$("#newsShow").html("");
				$("#articleId").val("");
				$("#articleName").val("");
			}else if($(this).val()=="1"){
				$("#contentText").show();
				$("#contentnews").hide();
				$("#newsShow").hide();//选择图文预览div
				$("#contentlocalnews").hide();//选择文章按钮
			}else{//文章
				$("#contentnews").hide();//图文选择按钮
				$("#contentText").hide(); //文本
				$("#contentlocalnews").show();//选择文章按钮
				$("#newsShow").html("");
				$("#articleId").val("");
				$("#articleName").val("");
			}
		});
		
		$("input[name='source_type'").change(function(){
			console.log("11111111111111111111111");
			if($(this).val()=="1"){//发送消息
				$("#sendMessageSeach").show();
				$("#contentText").show();
				$("#skipurlSeach").hide();
			}else if($(this).val()=="2"){//跳转网页
				$("#sendMessageSeach").hide();
				$("#contentText").hide();
				$("#skipurlSeach").show(); 
			}else if($(this).val()=="3"){
				$("#sendMessageSeach").hide();
				$("#contentText").hide();
				$("#skipurlSeach").hide();
			}
		})
		
		$("input[name='levelMenu']").change(function(){ 
			if($(this).val()=="1"){//一级菜单
				$("#seachParent").val("0"); 
				$("#seachParent").hide();
				$("#emptyCon").show(); 
			}else if($(this).val()=="2"){//二级菜单
				$("#seachParent").show();
				$("#emptyCon").hide();
			}else{
				
			}
		})
		
		//var html="<div><p style='color:#000;font-size:15px;'>"+1234+"</p><p style='color:#666;font-size:12px;'>"+10月30+"</p><img style='width:200px;height:120px;' src='http://upload.cankaoxiaoxi.com/2016/1027/1477536068373.jpg'/><p style='color:#666;font-size:14px;'>"+123456789+"</p><p style='color:#000;font-size:13px;'>阅读全文</p></div>";
          $().ready(function() {

            $("#replyForm").validate({
            	rules: {
                    name: {
                      required: true,
                      htmlescape: true
                    },
                    sort:{
                      required:true,
                      number:true
                    }
                  },
                  messages: {
                    name: {
                      required: "请输入菜单名称",
                      htmlescape: "请您不要输入特殊字符!"
                    },
                    sort:{
                    	retuired:"请输入排序值",
                    	number:"必须为数字"
                    }
                  },
              submitHandler: function(form) {
            	 var parentId="";
            	 var sourceContent="";
            	 var msgType=$("input[name='replyType']:checked").val();
            	 var content="";
            	 if($("input[name='levelMenu']:checked").val()=="1"){
            		 parentId="0";
            	 }else{
            		 parentId=$("#sel").val();
            	 }
            	 if($("input[name='source_type']:checked").val()=="1" && $("input[name='replyType']:checked").val()=="1"){//回复消息并且为文本
            		 if($("#content_source").val()==null || $("#content_source").val()==""){
            			 var HTML="<label id='content-error' class='error' for='content'>请输入文本内容</label>"; 
                 		$("#content_source").after(HTML); 
                 		return false;
            		 }else{
            			 sourceContent=$("#content_source").val();
            		 }
            	 }
            	 
            	 if($("input[name='source_type']:checked").val()=="1" && $("input[name='replyType']:checked").val()=="2"){
            		 if($("#articleId").val()==null|| $("#articleId").val()==""){
            			 var HTML="<label id='content-error' class='error' for='content'>请选择图文</label>";
                 		$("#contentnews").after(HTML);
                 		return false; 
            		 }else{
            			 sourceContent=$("#articleId").val();
            		 }
            	 }

				  if($("input[name='source_type']:checked").val()=="1" && $("input[name='replyType']:checked").val()=="3"){
					  if($("#articleId").val()==null|| $("#articleId").val()==""){
						  var HTML="<label id='content-error' class='error' for='content'>请选择文章</label>";
						  $("#contentlocalnews").after(HTML);
						  return false;
					  }else{
						  sourceContent=$("#articleId").val();
					  }
				  }
            	 
            	 if($("input[name='source_type']:checked").val()=="2"){//URL
            		 if($("#url").val()==null || $("#url").val()==""){
            			var HTML="<label id='content-error' class='error' for='content'>请输入URL</label>";
                  		$("#url").after(HTML);
                  		return false;
            		 } 
            		 msgType=null;
            		 sourceContent=$("#url").val(); 
            	 }
            	 
            	 if($("input[name='source_type']:checked").val()=="3"){//URL
            		 msgType=null;
            	 } 
            	 
            	 content={
                 		id:$("#updateId").val(),
             			sourceContent:sourceContent,
                        sourcecontent:sourceContent,
             			sourceType:$("input[name='source_type']:checked").val(),
             			msgType:msgType,
             			sort:$("#sort").val(),
             			name:$("input[name='name']").val(),
             			parentId:parentId,
					   "_csrf_header":csrfheader.value,"_csrf":csrftoken.value
             			};
            	 
               
            	if(content!=null && content!=""){
            		$.ajax({
                        type:"POST",
                        url:"#springUrl('/a/mpMenu/addMpMenu')",
                        data:content,
                        datatype: "json",
                        //在请求之前调用的函数
                        beforeSend:function(){
                       	 
                        },success:function(data){
                       	 if(data.errorNo==0){
                       		 Cfapp.confirm({
                       			 message: "添加成功",
                       			 btnoktext:"继续添加",
                       			 btncanceltext:"关闭",
                       			 success:function(){
                       				 location.reload();
                       			 },
                       			cancel:function(){
                       				location.href = "#springUrl('/a/mpMenu/list')";
                       			 }
                       		   }) 
                       	 }else if(data.errorNo==2){
                       		 Cfapp.alert({
      	                          message: "修改成功",
      	                          btntext: "确定",
      	                          success: function () {
      	                        	location.href = "#springUrl('/a/mpMenu/list')";
      	                          }
      	                      }) 
                       	 }else if(data.errorNo==3){
                       		 Cfapp.alert({
      	                          message: "一级菜单最多3个",
      	                          btntext: "确定",
      	                          success: function () {
      	                              
      	                          }
      	                      })
                       	 }else if(data.errorNo==4){
                       		Cfapp.alert({
    	                          message: "二级菜单最多5个",
    	                          btntext: "确定",
    	                          success: function () {
    	                              
    	                          }
    	                      }) 
                       	 }
                        },error: function(){
                       	 Cfapp.alert({
   	                          message: "编辑失败",
   	                          btntext: "确定",
   	                          success: function () {
   	                        	location.href = "#springUrl('/a/mpMenu/list')";
   	                          }
   	                      })
                        }         
                     });
            	}
              }
            });
            
            $.ajax({
    			url : "#springUrl('/a/mpMenu/fetchMenu')",
 				type : "GET", 
 			    dataType: "json",   
 			    success : function(data) { 
 				var sel =  $("#sel");
 				sel.empty();
 		       	for(var i = 0 ; i < data["result"].length ; i++){
 		       		var option="";
 		       		if(data["result"][i].id=="$!{menu.parentId}"){
 		       		option = $("<option>").text(data["result"][i].name).val(data["result"][i].id).attr("selected","selected"); 		       			
 		       		}else{
 		       		option = $("<option>").text(data["result"][i].name).val(data["result"][i].id);	
 		       		}
 			       	sel.append(option);
 		       	}
 			},
 			error:function(){
 				
 			}
    	  })

          });</script>
</body>
<!-- END BODY -->
</html>