<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/include/header.jsp"%>
<link type="text/css" rel="stylesheet" href="${ctx}/css/baseFrame.css" />
<link type="text/css" rel="stylesheet" href="${ctx}/css/index.css" />
<title>查询系统用户列表</title>
</head>
<body>
<body class="bg1">
	<div class="headCon">
		<%@ include file="/WEB-INF/jsp/top.jsp"%>
	</div>
	<div class="searchCon">
		<ul>
			<hna:permission privilege="sysUser.view">
			<li><a href="${ctx}/sysUser/list.do">用户管理</a></li>
			</hna:permission>
			<hna:permission privilege="sysRole.view">
			<li><a href="${ctx}/sysRole/list.do">角色管理</a></li>
			</hna:permission>
			<hna:permission privilege="sysAuthority.view">
			<li><a href="${ctx}/sysAuthority/list.do">权限管理</a></li>
			</hna:permission>
			<hna:permission privilege="sysLog.view">
			<li><a href="${ctx}/sysLog/list.do">日志查看</a></li>
			</hna:permission>
			<hna:permission privilege="sysTask.issuing">
			<li><a href="${ctx}/sysTask/list.do">任务管理</a></li>
			</hna:permission>
			<!--<li><a href="${ctx}/sysPersonal/list.do">个人管理</a></li>-->
		</ul>
	</div>
	<!-- <div id="resultCon1" class="resultCon" style="margin-left: 255px;"> -->
	<div class="resultCon" style="margin-left: 255px; position:relative;">
		<div class="wrap">
			<!--right start-->
			<div class="m_right">
				<div class="switch" id="switch"></div>
				<div class="p_bar">您当前的位置：【请根据具体情况修改】</div>
				<div class="action_box m_t10 t_c" id="queryDiv">
					<!-- 查询条件 : 注意加上 data-qname -->
					<!-- 行政级别编码: <input type="text" data-qname="code" class="input_txt" /> -->
					<div style="width: 100%">
						<span> 部门名称： <input type="text" name="deptname" />
						</span>
					</div>
					<div style="width: 100%">
						<span> <input type="button" class="b_btn" value="添加"
							id="addBtn" />
						</span> <span> <input type="button" class="a_btn" value="查询"
							id="searchBtn" />
						</span>
					</div>
				</div>
				<table id="tbwrap" class="table_list"></table>
				<div class="page eui-pager-custom" id="j_pager"></div>
			</div>
			<!--right end-->
		</div>
	</div>
	<script type="text/html" id="tb_template">
		<thead>
			<tr>
				<th>部门名称</th>
				<th>部门简称</th>
				<th>部门地址</th>
				<th>是否虚构部门</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody data-type="body">
			<!if(list.length>0) { !>
				<!for(var i=0,len=list.length;i<len;i++){
					var item = list[i],classItem = (i%2!=0)?"odd td_odd":"even";
				!>
				<tr class="gradeA <!=classItem!>">
					<td title="<!=item["deptCnName"]!>"><!=item["deptCnName"]!></td>
					<td title="<!=item["deptReferred"]!>"><!=item["deptReferred"]!></td>
					<td title="<!=item["deptAddress"]!>"><!=item["deptAddress"]!></td>
					<td title="<!=item["isFictionName"]!>"><!=item["isFictionName"]!></td>
					<td>
						<a title="详情" data-value="<!=item["deptId"]!>" data-name="<!=item["deptCnName"]!>" class="detail">详情</a>
						<a title="修改" data-value="<!=item["deptId"]!>" data-name="<!=item["deptCnName"]!>" class="edit">修改</a>
						<a title="删除" data-value="<!=item["deptId"]!>" data-name="<!=item["deptCnName"]!>" class="delete">删除</a>
					</td>
				</tr>
			<!}!>
			<!}else{!>
				<tr>
					<td colspan="6"> 暂无数据</td>
				</tr>
			<!}!>
		</tbody>
	</script>



	<script type="text/javascript">
		var sysDeptDialog;
		$(function() {
			// 1、添加
			$("#addBtn").click(function() {
				seajs.use("component/dialog", function(dialog) {
					sysDeptDialog = new dialog({
						"width" : 800,
						"height" : 500,
						"contentType" : "iframe",
						"html" : "${ctx}/sysDept/toAdd.do",
						// 内容
						"title" : "添加部门" //标题
					});
				});
			});

			// 2、详细
			$("#tbwrap").delegate(
					".detail",
					"click",
					function() {
						// 2.1 获取主键
						var sysDeptId = $(this).data("value");
						var sysDeptName = $(this).data("name");
						// 2.2 弹窗窗口，显示详细信息
						seajs.use("component/dialog", function(dialog) {
							sysDeptDialog = new dialog({
								"width" : 800,
								"height" : 600,
								"contentType" : "iframe",
								"html" : "${ctx}/sysDept/view.do?deptId="
										+ sysDeptId, // 内容
								"title" : "查看"+sysDeptName+"详细信息" //标题
							});
						});
					});

			// 3、编辑
			$("#tbwrap").delegate(
					".edit",
					"click",
					function() {
						// 3.1 获取主键
						var sysDeptId = $(this).data("value");

						// 3.2 弹窗窗口，显示详细信息
						seajs.use("component/dialog", function(dialog) {
							sysDeptDialog = new dialog({
								"width" : 800,
								"height" : 600,
								"contentType" : "iframe",
								"html" : "${ctx}/sysDept/toEdit.do?deptId="
										+ sysDeptId,
								// 内容
								"title" : "编辑详细信息" //标题
							});
						});
					});
			// 4、删除
			$("#tbwrap")
					.delegate(
							".delete",
							"click",
							function() {
								var sysDeptId = $(this).data("value");

								if (confirm('确定删除？')) {
									$
											.post(
													"${ctx}/sysDept/delete.do",
													{
														deptId : sysDeptId,
														CSRFToken : $(
																"#CSRFToken")
																.val()
													},
													function(result) {
														if ("succ" == result) {
															alert("操作成功");
															// 刷新列表页面
															top.location
																	.replace("${ctx}/sysDept/list.do?ts="
																			+ new Date()
																					.getTime()); //如果操作成功则跳到列表界面 
															// 关闭弹窗窗口
															parent.sysDeptDialog
																	.close();
														} else if ("notThroughSecurityCheck" == result["isThroughSecurityCheck"]) { // 如果不通过安全检查
															var mess = result["mess"];
															$
																	.post(
																			"${ctx}/common/notThroughSecurityCheck.do?ts="
																					+ new Date()
																							.getTime(),
																			mess,
																			function(
																					res) {
																				alert(res);
																			},
																			"json");

														} else {
															alert(result);
														}
													}, "json");
								}

							});
			// 5、查询
			$("#searchBtn").click(function() {
				search();
			});

			// 页面加载完成调用查询分页
			search();
		});
	</script>

	<script type="text/javascript">
		function search() {
			// 这里放包含查询条件的DIV
			var paramData = easyUitls.getQueryDivDefault("queryDiv");

			seajs
					.use(
							[ "component/table" ],
							function(uiTable) {
								$
										.post(
												"${ctx}/sysDept/ajaxPage.do",
												paramData,
												function(data) {
													var table = new uiTable(
															{
																"con" : "#tbwrap",//放table的容器
																"data" : {
																	"list" : data.dataList
																//渲染需要的数据
																},
																"template" : "tb_template",//渲染的模板
																"pager" : {//翻页
																	"con" : "#j_pager",//翻页容器
																	"data" : {
																		"currentPage" : data.currentPage,//当前页
																		"pageCount" : data.pageCount,
																		"rowCount" : data.rowCount
																	},
																	//翻页样式
																	template : '<ul><a title="首页" class="page_first" data-role="first" href="#">首页</a><a title="上一页" class="page_prev" href="#" data-role="prev">上一页</a><span data-value="pageNum" class="pageNum"></span><a title="下一页" class="page_next" href="#" data-role="next">下一页</a><a title="尾页" class="page_last" href="#" data-role="last">尾页</a></ul><div class="pageGo">共<span data-role="rowCount"></span>条 跳转到 <input type="text" data-target="input" class="page_input"/><a href="#" data-role="go" class="go">GO</a></div>'
																}
															});
													table
															.getPager()
															.bind(
																	"changePage",
																	function(
																			event,
																			page,
																			hander) {//点击翻页时
																		$
																				.post(
																						"${ctx}/sysDept/ajaxPage.do",
																						paramData,
																						function(
																								change) {
																							table
																									.render({//重新渲染
																										list : change.dataList
																									//传入新的渲染数据
																									});
																							hander({
																								"currentPage" : change.currentPage,
																								"pageCount" : change.pageCount,
																								"rowCount" : change.rowCount
																							});
																						});
																	});
												});
							});
		}
	</script>
	<script src="${ctx}/js/lib/perfect-scrollbar.jquery.js"></script>
	<script>
	     $(function () {
		    $(".resultCon").perfectScrollbar();
		    $(".searchCon").perfectScrollbar();
			resize();
            $(window).resize(function(){
				resize();
			});			
	    });
	    function resize(){
			//获取窗口高度
			var windowheight=$(window).height();
			var leftList = windowheight-40;
			$(".searchCon").css({"height":leftList+"px"});
			$(".resultCon").css({"height":leftList-12+"px"});
			//$(".tableMain").css({"height":windowheight-40-42-131+"px"});
			//$(".table_list").css({"height":windowheight-40-42-100-85+"px"});
			$(".searchCon").perfectScrollbar("update");
			$(".resultCon").perfectScrollbar("update");
		}
	</script>
	<%@ include file="/include/footer.jsp"%>
</body>
</html>
