<%@page import="com.qmth.qrzk.repository.utils.Consts"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/init.jsp"%>
<c:set var="skeletonStatus" value="<%=Consts.SkeletonStatus.dicMap%>" scope="request"/>
<c:set var="defaultSkeletonToApproveStatus" value="<%=Consts.SkeletonStatus.TOAPPROVE%>" scope="request"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel='stylesheet' href='${ctx}/resources/css/easyui.css' type='text/css' media='screen' />
<link rel='stylesheet' href='${ctx}/resources/css/easyui/icon.css' type='text/css' media='screen' />
<link rel='stylesheet' href='${ctx}/resources/css/user-center-style.css' type='text/css' media='screen' />
<%@ include file="../common/top.jsp"%>
<script type="text/javascript" src="${ctx}/resources/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/validator.js"></script>
<%@ include file="../common/validation.jsp"%>
<title>查询细目表</title>
</head>
<body>
 <%@ include file="../common/header.jsp"%>
    <div id="content" class="content">
        <%@ include file="../common/sub_menu.jsp"%>
        <div class="page" id="page" >
        <div class="page-header" >查询细目表</div>
        <div class="page-body">
	        <div>
	            <form id="search-form" method="post" >
	            	<select name="status" id="status">
	            		<option value="">请选择状态</option>
	            		<c:forEach items="${skeletonStatus}" var="m">
            			<option value="${m.key }" <security:authorize ifAnyGranted="SECRETARY" ><c:if test="${m.key==defaultSkeletonToApproveStatus}">selected="selected"</c:if></security:authorize>>${m.value }</option>
            			</c:forEach>
	            	</select>
		            <input name="name" placeholder="细目表名称"/>
		            <button id="searchBtn">查询</button>
	            </form>
			</div>
	        <div class="right" style="min-height:300px;position: relative;">
	             <div id="list-wrap posts" class="listview">
	                 <table id="dg" class="easyui-datagrid"
	                     data-options="fitColumns:true,singleSelect:true,striped:true,pagination:true,
	                     idField:'id',toolbar: '#tb'">
	                     <thead>
	                         <tr class="title">
	                             <th data-options="field:'name',width:160">细目表名称</th>
	                             <th data-options="field:'course',formatter: formatCourseName,width:120">课程名称</th>
	                             <th data-options="field:'book',formatter: formatBookName,width:150">教材名称</th>
	                             <th data-options="field:'chapterSize',width:80">章节总数</th>
	                             <th data-options="field:'keyChapters',width:80">重点章节</th>
	                             <th data-options="field:'statusName',width:80">状态</th>
	                             <th data-options="field:'createdTime',formatter: formatDate,width:80">创建时间</th>
	                         </tr>
	                     </thead>
	                   </table>
	                   <div id="tb" style="height:auto">
					         <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" id="viewBtn">查看</a> 
					   </div>
	               </div>
	            </div>
	        </div>
        </div>
    </div>
</body>
</html>
<script language="javascript">
$(document).ready(function(){
	$("#viewBtn").click(function(){
		var rowData = $("#dg").datagrid('getSelected');
		if(rowData != null){
			var url = "${ctx}/paperSkeleton/viewskeletondetail/"+rowData.id;
			window.location.href = url;
		}
	});
	
	$("#dg").datagrid({
	    onDblClickRow: function (rowIndex, rowData) {
	    	$("#viewBtn").click();
	    }
	});
	
	$('#search-form').submit(function(event){
        event.preventDefault(); 
        var param = $('#search-form').serializeJson();
        param = $.extend(param, {page:1,rows:10});
        $('#dg').datagrid({
        	'url':'${ctx}/paperSkeleton/queryPaperSkeletons',
        	'queryParams':param
        });
    });
    window.setTimeout(function(){$('#search-form').submit();},200);
});

function formatDate(date){
	var d=undefined;
	if(typeof(date)=="undefined"){
		d=new Date();
	}else{
		d = new Date(date);
	}
	
	return (d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate());
}

function formatCourseName(date){
	return date.name;
}

function formatBookName(date){
	return date.name;
}
</script>
        