<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		

			    $('#contentTable thead tr th input.i-checks').on('ifChecked', function(event){ //ifCreated 事件应该在插件初始化之前绑定 
			    	  $('#contentTable tbody tr td input.i-checks').iCheck('check');
			    	});

			    $('#contentTable thead tr th input.i-checks').on('ifUnchecked', function(event){ //ifCreated 事件应该在插件初始化之前绑定 
			    	  $('#contentTable tbody tr td input.i-checks').iCheck('uncheck');
			    	});
			    
			
		});

		function getSelectedItem(){

			var size = $("#contentTable tbody tr td input.i-checks:checked").size();
			  if(size == 0 ){
					top.layer.alert('请至少选择一条数据!', {icon: 0, title:'警告'});
					return "-1";
				  }

			  if(size > 1 ){
					top.layer.alert('只能选择一条数据!', {icon: 0, title:'警告'});
					return "-1";
				  }
			    var id =  $("#contentTable tbody tr td input.i-checks:checkbox:checked").attr("id");

                var label = $("#contentTable tbody tr td input.i-checks:checkbox:checked").parent().parent().parent().find(".codelabel").html();
                return id+"_item_"+label;
		}
		function page(n,s){
			if(n) $("#pageNo").val(n);
			if(s) $("#pageSize").val(s);
			$("#searchForm").attr("action","${url}");
			$("#searchForm").submit();
	    	return false;
	    }
	</script>
</head>
<body class="gray-bg">
	<div class="">
    <div class="ibox-content">
		<!-- 查询条件 -->
	<div class="row">
	<div class="col-sm-12">
	<form:form id="searchForm" modelAttribute="obj" action="${url}" method="post" class="form-inline">
		<input type="hidden" name="url" value="${url}"/>
		<input type="hidden" name="fieldLabels" value="${fieldLabels}"/>
		<input type="hidden" name="fieldKeys" value="${fieldKeys}"/>
		<input type="hidden" name="searchKey" value="${searchKey}"/>
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->
		<div class="form-group">
			<span>${searchLabel}：</span>
				<form:input path="name" htmlEscape="false" maxlength="50" class=" form-control input-sm"/>
		
		 </div>	
	</form:form>
	<br/>
	</div>
	</div>
	
	<!-- 工具栏 -->
	<div class="row">
	<div class="col-sm-12">
		<div class="pull-right">
			<button  class="btn btn-primary btn-rounded btn-outline btn-sm " style="margin-right:10px;border:none;background:#0f92fb;border-radius: 0;color:#fff;width:40px" onclick="search()" >查询</button>
			<button  class="btn btn-primary btn-rounded btn-outline btn-sm " style="margin-right:30px;border:none;background:#34bf49;border-radius: 0;color:#fff;width:40px" onclick="reset()" >重置</button>
		</div>
	</div>
	</div>
	
	<table id="contentTable" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
		<thead>
			<tr>
				<th></th>
					<th>名称</th>
					<th>编号</th>
					<th>负责人</th>
			</tr>
		</thead>
		<tbody>
		<c:choose>
		<c:when test="${not empty page.list}">
		<c:forEach items="${page.list}" var="obj2">
				<tr>
					<td style="text-align:center;"> <input type="checkbox" id="${fns:getValue(obj2, 'id')}" class="i-checks"></td>
					<td style="text-align:center;" class="codelabel">${fns:getValue(obj2, 'name')}</td>
                    <td style="text-align:center;" class="codelabel4">${fns:getValue(obj2, 'number')}</td>
                    <td style="text-align:center;" class="codelabel3">${obj2.master.name}</td>
				</tr>
		</c:forEach>
		</c:when>
			<c:otherwise>
				<tr>
					<td colspan="15" align="center">
						暂无数据
					</td>
				</tr>
			</c:otherwise>
		</c:choose>

		</tbody>
	</table>
	<table:page page="${page}"></table:page>
	<br/>
	<br/>
	</div>
</div>
</body>
</html>