<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control", "no-cache");
	response.setDateHeader("Expires", -10);
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@include file="/WEB-INF/views/base.jsp"%>
<!DOCTYPE html>
<html>

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>菜单模块</title>


<%@include file="/WEB-INF/views/common_base_css.jsp"%>

    <style type="text/css">
        .chosen-container {
            width: 100% !important;
        }

        .Meunbut {
            cursor: pointer;
        }

        .anim-welcome {
            border: 1px solid red;
            animation: anim 3s;
        }
    </style>


<%@include file="/WEB-INF/views/common_base_script.jsp"%>
<script src="${jsPath }/sysmenu/sysmenu.js"></script>
<script type="text/javascript">
	var basePath = "<%=basePath %>";
	 function deleteMenufunc(menuid){
      swal({
          title: "删除菜单？",
          text: "确认删除？",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          closeOnConfirm: false
      }, function () {
      	 	$.ajax({
				type : 'POST',
				async : false,
				url : basePath + 'sysMenu/deleteMenu.json',
				data : {'menuid':menuid},
				dataType : 'json',
				success : function(data){
					if (data.success) {
						swal("删除成功!", "菜单删除完成！", "success");
						$("#forRemove"+menuid).remove();
              		} else {
                  		swal("删除失败!", data.info, "error");
              		}
				}
			})	
      	
      });

  }

</script>

<style>
body.DTTT_Print {
	background: #fff;
}

.DTTT_Print #page-wrapper {
	margin: 0;
	background: #fff;
}

button.DTTT_button,div.DTTT_button,a.DTTT_button {
	border: 1px solid #e7eaec;
	background: #fff;
	color: #676a6c;
	box-shadow: none;
	padding: 6px 8px;
}

button.DTTT_button:hover,div.DTTT_button:hover,a.DTTT_button:hover {
	border: 1px solid #d2d2d2;
	background: #fff;
	color: #676a6c;
	box-shadow: none;
	padding: 6px 8px;
}

.dataTables_filter label {
	margin-right: 5px;
}
</style>
</head>

<body>
	<input type="hidden" id="currentMenu" value="${currentMenu }">
	<div id="wrapper">

		<jsp:include page="../menu.jsp"></jsp:include> 
		<div id="page-wrapper" class="gray-bg">
			<jsp:include page="../head.jsp"></jsp:include>
			<jsp:include page="../pageNav.jsp"></jsp:include>
			
			<div class="wrapper wrapper-content animated fadeInRight">
				<div class="row">
					<div class="ibox-content m-b-sm border-bottom">
						<div class="row">
							<div class="col-sm-6">
								<div class="form-group">
									<label class="control-label" for="product_name">菜单名称</label>
									<input type="text" id="menucnname" name="menucnname" value="${menucnname.menucnname }"
														placeholder="菜单名称" class="form-control">
								</div>
							</div>
							<div class="col-sm-6">
								<div class="form-group">
									<label class="control-label" for="status">查询</label>
									<button onclick="query()" class="btn btn-w-m btn-success form-control">
														<i class="fa fa-search"></i>&nbsp;&nbsp;查询
													</button>
								</div>
							</div>
						</div>
					</div>

						<div class="ibox float-e-margins">
							<div class="ibox-title">

								<a href="createMenu" class="btn btn-w-m btn-primary"><i
									class="fa fa-plus-square"></i>&nbsp;&nbsp;新增</a>

							</div>
							<div class="ibox-content">
								<table id="MenuTable" class="table table-hover">
									<thead>
										<tr>
											<th>菜单名称</th>
											<th>链接地址</th>
											<th>上级菜单</th>
											<th>菜单图标</th>
											<th>菜单类型</th>
											<th>菜单状态</th>
											<th>创建用户</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody id="menu_tree_body">
										
									</tbody>
								</table>
						</div>
						</div>
					</div>
				 </div>




		</div>
	</div>


	

	
	<script>
		$(document).ready(
			function() {
				$('.dataTables-example')
					.dataTable({
						responsive : true,
						"dom" : 'T<"clear">lfrtip',
						"tableTools" : {
						"sSwfPath" : "${jsPath }/plugins/dataTables/swf/copy_csv_xls_pdf.swf"
					}
				});
			initDataTree();	
		});
		
		function initDataTree(){
			var menucnname = $("#menucnname").val();	
			var currentMenu = $("#currentMenu").val();
			
			$.ajax({
				type : 'POST',
				async : false,
				url : basePath + 'sysMenu/initDataTree',
				data : {'menucnname' : menucnname },
				dataType : 'html',
				success : function(data){
					$("#menu_tree_body").html(data);
					$("#menu_tree_body").find("span.Meunbut").each(function(){
						var menuId = $(this).attr("menuid");
						var level = $(this).attr("level");
						if(level == '2' && menuId != currentMenu) {
							$(this).click();
						}
					});
					
				}
			})
		}
		function query(){
			initDataTree();
		}
	</script>
</body>

</html>
