<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib  uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<!--[if lt IE 9]-->
	<script type="text/javascript" src="${pageContext.request.contextPath}/lib/html5shiv.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/lib/respond.min.js"></script>
	<!--[endif]-->
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/css/style.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/css/page.css" />
	<script>DD_belatedPNG.fix('*');</script>
	<title>动态列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页<span class="c-gray en">&gt;</span>动态列表<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
		<form action="news_list_en.html" method="post" onsubmit="return checkForm();">
			<div class="text-c" style="text-align: center;"> 发布时间范围：
				<input type="text" value="${startTime}" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss' })" id="startTime" name="startTime" class="input-text Wdate" style="width: 12%" placeholder="开始时间">
				-
				<input type="text" value="${endTime}" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss' })" id="endTime" name="endTime" class="input-text Wdate" style="width: 12%" PLACEHOLDER="结束时间">
				<span style="margin-left: 40px;">标题名称：
                        <input type="text" name="titleName" placeholder=" 请输入标题名称" style="width:250px" class="input-text" value="${titleName}">
                    </span>
				<button  class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>搜索</button>
			</div>
		</form>

		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="l"> <a onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
				<a class="btn btn-primary radius" title="添加" href="news_save_en.html" ><i class="Hui-iconfont">&#xe600;</i> 添加信息</a></span> <span class="r data_num">共有数据：<strong id="total">${news.total}</strong> 条</span> </div>

		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
				<thead>
				<tr class="text-c">
					<th width="30"><input type="checkbox" id="ckAll" onclick="checkBox(this)"></th>
					<th width="80">ID</th>
					<th width="200">标题</th>
					<th width="100">发布时间</th>
					<th width="100">排序</th>
					<th width="200">操作</th>
				</tr>
				</thead>
				<tbody>
				<c:forEach items="${news.list}" var="item">
					<tr class="text-c">
						<td><input type="checkbox" value="${item.id}" name="ck" onclick="checkName()"></td>
						<td>${item.id}</td>
						<td>${item.title}</td>
						<td>${item.times}</td>
						<td>${item.sort}</td>
						<td class="f-14 td-manage">
							<a style="text-decoration:none" class="ml-5" href="news_ById_en.html?id=${item.id}"  title="编辑"><i class="Hui-iconfont">&#xe6df; </i>编辑</a>
							<a style="text-decoration:none" class="ml-5" onClick="article_del(this,${item.id})"  title="删除"><i class="Hui-iconfont">&#xe6e2;</i>删除</a></td>
					</tr>
				</c:forEach>

				</tbody>
			</table>
		</div>
		<div id="PageNum">
			<section>
				<div class="bd points-goods-list">
					<ul class="pages">
						<li><a href="news_list_en.html?pageNum=1&titleName=${titleName}&startTime=${startTime}&endTime=${endTime}">首页</a></li>
						<li class="prev"><a href="news_list_en.html?pageNum=${news.prePage}&titleName=${titleName}&startTime=${startTime}&endTime=${endTime}">上一页</a></li>
						<c:forEach items="${news.navigatepageNums}" var="nav">
							<c:if test="${nav == news.pageNum}">
								<li ><a href="news_list_en.html?pageNum=${nav}&titleName=${titleName}&startTime=${startTime}&endTime=${endTime}" class="active">${nav}</a></li>
							</c:if>
							<c:if test="${nav != news.pageNum}">
								<li><a href="news_list_en.html?pageNum=${nav}&titleName=${titleName}&startTime=${startTime}&endTime=${endTime}">${nav}</a></li>
							</c:if>
						</c:forEach>
						<%--<li><a href="#" class="active">1</a></li>--%>
						<li class="next"><a href="news_list_en.html?pageNum=${news.nextPage}&titleName=${titleName}&startTime=${startTime}&endTime=${endTime}">下一页</a></li>
						<li><a href="news_list_en.html?pageNum=${news.pages}&titleName=${titleName}&startTime=${startTime}&endTime=${endTime}">末页</a></li>
					</ul>
				</div>
			</section>
		</div>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript">

    function checkForm() {
        var beginDate=$("#startTime").val();
        var endDate=$("#endTime").val();
        var d1 = new Date(beginDate.replace(/\-/g, "\/"));
        var d2 = new Date(endDate.replace(/\-/g, "\/"));
        if (d1>=d2){
            alert("开始时间不能大于结束时间！");

            $("[name=startTime]").focus();
            return false;
		}
		return true;
    }


    /*全选框*/
    function checkBox() {
        $("input[name='ck']").prop("checked",$("#ckAll").prop("checked"));
    }
    /*全选框*/
    function checkName(){
        if($("input[name='ck']:checked").length==$("input[name='ck']").length){
            //选中的name复选框长度如果等于总name复选框，则对全选框操作
            $("#ckAll").prop("checked",true);
        }else{
            $("#ckAll").prop("checked",false);
        }
    }


    /*批量删除*/
    function datadel() {
        var chkvalue ="" //定义一个数组
        $("input[name='ck']:checked").each(function () {
            chkvalue += $(this).val() + ",";
        });
        if(chkvalue==""){
            layer.msg('请选择要删除的新闻!',{icon:0,time:1000});
        }else{
            layer.confirm('确认要删除这些新闻吗？',function(){
                window.location.href = "delNews_en?chkvalue=" + chkvalue;
            });
        }
    }

    /*资讯-删除*/
    function article_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            var total=   $("#total").html();
            $.post("delNews_ById_en.html", {"id": id}, function () {
                $("#total").html(total-1);
                console.log(111);
                $(obj).parents("tr").remove();
                layer.msg('已删除!', {icon: 1, time: 1000});
            });
        });
    }
</script>
</body>
</html>