<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../../inc.jsp"></jsp:include>
<script type="text/javascript" charset="utf-8">
	var datagrid;
	$(function() {

		datagrid = $('#lowpowerdatagrid')
				.datagrid(
						{
							url : 'lowpower!datagrid.do',
							pagination : true,
							pagePosition : 'bottom',
							pageSize : 20,
							pageList : [ 20, 40, 60, 80, 100, 120, 140, 160,
									200 ],
							fit : true,
							fitColumns : true,
							nowrap : true,
							border : false,
							idField : 'id',
							sortName : 'readtime',
							sortOrder : 'desc',
							checkOnSelect : true,
							selectOnCheck : true,
							frozenColumns : [ [ {
								title : 'id',
								field : 'id',
								width : 10,
								sortable : true,
								checkbox : true
							} ] ],
							columns : [ [ {
								title : '矿区',
								field : 'mineareaname',
								width : 120,

							}, {
								title : '姓名',
								field : 'personname',
								width : 120,

							}, {
								title : '卡号',
								field : 'cardcode',
								width : 120,

							}, {
								title : '电量',
								field : 'dl',
								width : 120,

							}, {
								title : '最后读取时间',
								field : 'readtime',
								width : 120,

							} ] ],

							toolbar : [ {
								text : '导出',
								iconCls : 'icon-edit',
								handler : function() {
									exportd();
								}
							}, '-' ],

							

							onRowContextMenu : function(e, rowIndex, rowData) {
								e.preventDefault();
								$(this).datagrid('unselectAll');
								$(this).datagrid('selectRow', rowIndex);
								$('#menu').menu('show', {
									left : e.pageX,
									top : e.pageY
								});
							}
						});

	});

	function _search() {
		datagrid.datagrid('load', dj.serializeObject($('#searchForm')));
	}
	function cleanSearch() {
		datagrid.datagrid('load', {});
		$('#searchForm input').val('');
	}
	function exportd() {
		Export('卡低电量信息', $('#lowpowerdatagrid'))

	}



	Date.prototype.format = function(format) {
		var date = {
			"M+" : this.getMonth() + 1,
			"d+" : this.getDate(),
			"h+" : this.getHours(),
			"m+" : this.getMinutes(),
			"s+" : this.getSeconds(),
			"q+" : Math.floor((this.getMonth() + 3) / 3),
			"S+" : this.getMilliseconds()
		};
		if (/(y+)/i.test(format)) {
			format = format.replace(RegExp.$1, (this.getFullYear() + '')
					.substr(4 - RegExp.$1.length));
		}
		for ( var k in date) {
			if (new RegExp("(" + k + ")").test(format)) {
				format = format.replace(RegExp.$1,
						RegExp.$1.length == 1 ? date[k] : ("00" + date[k])
								.substr(("" + date[k]).length));
			}
		}
		return format;
	}
	//console.log(newDate.format('yyyy-MM-dd h:m:s'));
</script>
</head>
<body class="easyui-layout" data-options="fit:true">
	<div data-options="region:'north',border:false,title:'过滤条件'"
		style="height: 55px;overflow: hidden;" align="left">
		<form id="searchForm">
			<table class="tableForm datagrid-toolbar"
				style="width: 100%;height: 100%;">
				<tr>
					<th>卡号：</th>
					<td><input name="cardcode" style="width:160px;" />
					<th>姓名：</th>
					<td><input name="personname" style="width:160px;" /></td>
					<th>矿区：</th>
					<td><select name="mineareacode" class="easyui-combotree"
						style="width:160px;"
						data-options="url:'${pageContext.request.contextPath}/minearea!doNotNeedSession_treeRecursive.do'"></select>
					</td>
					<td colspan="6"><a href="javascript:void(0);"
						class="easyui-linkbutton" onclick="_search();">过滤</a><a
						href="javascript:void(0);" class="easyui-linkbutton"
						onclick="cleanSearch();">取消</a></td>

				</tr>
				
			</table>
		</form>

	</div>


	<div data-options="region:'center',border:false"
		style="overflow: hidden;">
		<table id="lowpowerdatagrid"></table>
	</div>

	<div id="menu" class="easyui-menu" style="width:120px;display: none;">
		<!-- <div onclick="append();" data-options="iconCls:'icon-add'">增加</div>
		<div onclick="remove();" data-options="iconCls:'icon-remove'">删除</div>
		<div onclick="edit();" data-options="iconCls:'icon-edit'">编辑</div>
		 -->
		<div onclick="exportd();" data-options="iconCls:'icon-edit'">导出</div>
	</div>
	<div id="tttt" title="yyyy"></div>

</body>
</html>