/// <reference path="jquery-1.10.2.min.js" />
var pageindex = 1;
var pagesize = 10;
var pagecount = 0;

function QueryID_btn() {
    var newid = $.trim($("#New_ID").val());
    $("#newlists ul").not(":eq(0)").remove();
    $.post("/ajax/Admin_NewsQuery.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "1", "newid": newid }, function (data) {
        var data = eval('(' + data + ')');
        pagecount = data.pagecount;
        $("#newlists").html("").append(data.pagelist);
        layui.use(['laypage', 'layer'], function () {
            var nums = pagesize; //每页出现的数据量
            var laypage = layui.laypage
            , layer = layui.layer;
            laypage.render({
                elem: 'pager'
               , count: pagecount //总页数
               , groups: 1
                , jump: function (obj) {
                    pageindex = obj.curr;//获取到当前页
                    $.post("/ajax/Admin_NewsQuery.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "1", "newid": newid }, function (data) {
                        var data = eval('(' + data + ')');
                        pagecount = data.pagecount;
                        $("#newlists").html("").append(data.pagelist);
                    });

                }
            });
        });
    })
}
 



function QueryName_btn() {
    var newname = $.trim($("#New_Name").val());
    $("#newlists ul").not(":eq(0)").remove();
    $.post("/ajax/Admin_NewsQuery.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "2", "newname": newname }, function (data) {
        var data = eval('(' + data + ')');
        pagecount = data.pagecount;
        $("#newlists").html("").append(data.pagelist);
        layui.use(['laypage', 'layer'], function () {
            var nums = pagesize; //每页出现的数据量
            var laypage = layui.laypage
            , layer = layui.layer;
            laypage.render({
                elem: 'pager'
               , count: pagecount //总页数
               , groups: 1
                , jump: function (obj) {
                    pageindex = obj.curr;//获取到当前页
                    $.post("/ajax/Admin_NewsQuery.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": "2", "newname": newname }, function (data) {
                        var data = eval('(' + data + ')');
                        pagecount = data.pagecount;
                        $("#newlists").html("").append(data.pagelist);
                    });

                }
            });
        });
    })
}











        function FormatToDate(val) {
            if (val != null) {
                var date = new Date(parseInt(val.replace("/Date(", "").replace(")/", ""), 10));
                //月份为0-11，所以+1，月份小于10时补个0
                var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                return date.getFullYear() + "-" + month + "-" + currentDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
            }
            return "";
        }


        function Newsdel_btn(id) {
            if (!confirm("确定要删除吗？") == true) {

                return true;

            } else {
            $.post("/ajax/Admin_NewsQuery.ashx", { "type": "del", "id": id }, function (data) {
                if (data == "ok") {
                    alert("删除成功");
                    window.location.href = "./Admin_NewList.aspx";
                } else {
                    alert("删除失败");
                }


            });
            }
        }
    