<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/taglib/c.tld" prefix="c"%>
<%@ include file="../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="../common/top.jsp"%>
</head>
<body class="easyui-layout">
	<%@ include file="../common/header.jsp"%>
	<%@ include file="../leftMenu/sys-admin.jsp"%>
	<div data-options="region:'center',title:'首页 -【系统管理】- 教研室管理'">
		<div class="easyui-layout" data-options="fit:true,border:false">
			<div data-options="region:'north',border:false" class="domain">
				<form class="form-inline" id="search-form">
					<span class="help-inline">名称：</span>
					<input class="input-small" type="text" name="name"/>
					<span class="help-inline">地区：</span>
					<span id="area-select"></span>
					<input type="hidden" name="province"/>
					<input type="hidden" name="city"/>
					<button class="btn">
						<i class="icon-search"></i>&nbsp;查询
					</button>
					<a href="${ctx}/admin/department/add" class="btn btn-primary">
						<i class="icon-plus icon-white"></i> 添加
					</a>	
				</form>
			</div>
			<div data-options="region:'center'" style="border-color: #ccc; border-left: none;">
				<table class="easyui-datagrid" id="dg"
					data-options="loadMsg:'正在查询请稍等...',pagination:'true',url:'${ctx}/admin/department/pagelist.json',rownumbers:true,singleSelect:true,fit:true,border:false,fitColumns:true,striped:true">
					<thead>
						<tr>
							<th width="30%" data-options="field:'name',"><strong>名称</strong></th>
							<th width="10%" data-options="field:'province',"><strong>省份</strong></th>
							<th width="10%" data-options="field:'city',"><strong>地市</strong></th>
							<th width="10%" data-options="field:'enable',formatter:formatStatus"><strong>状态</strong></th>
							<th width="20%" data-options="field:'timeCreate',formatter:formatTime"><strong>创建时间</strong></th>
							<th width="20%" data-options="field:'operate',formatter:operate"><strong>操作</strong></th>
						</tr>
					</thead>
				</table>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(document).ready(function() {
		$("#area-select").chinaprovinces({valueType:'name',change:function(province,city,area){
			$("#search-form :input[name='province']").val(province);
			$("#search-form :input[name='city']").val(city);
		}});
		
		$('#search-form').submit(function(event) {
			event.preventDefault();
			var query = $('#search-form').serializeJson();
			$('#dg').datagrid('load', query);
		});
	});

	function operate(value, row, index) {
		return '<a class="btn btn-small" href="${ctx}/admin/department/edit/'
				+ row.id
				+ '">修改</a>&nbsp;&nbsp;<a class="btn btn-small" href="${ctx}/admin/department/admin/'
				+ row.id + '">设置管理员</a>';
	}
	
	function formatStatus(value, row, index) {
        return value?'启用':'停用';
	}
	
	function formatTime(value, row, index) {
		var date = new Date(value);
        return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
	}
</script>
</html>
