
function detailFormatter(val) {
    return '<span title="' + val + '">' + val + '</span>';
}
function refresh() {
    $("#selAuthority").combobox("reset");
	$("#txtStartDate").datebox("reset");
    $("#txtEndDate").datebox("reset");
    $('#dg').datagrid('load', {});
}

function query() {

    var startDate = $("#txtStartDate").datebox("getValue");
    var endDate = $("#txtEndDate").datebox("getValue");
    var keyword = $('#txtKeyword').val();

    if (startDate == "" && endDate != "") {
        $.tools.alert(lang.PEASD);
        return;
    }

    if (startDate != "" && endDate == "") {
        $.tools.alert(lang.PETED);
        return;
    }

    if (startDate != "" && endDate != "") {
        startDate += " 00:00:00";
        endDate += " 23:59:59";

        var start = new Date(startDate.replace("-", "/"));
        var end = new Date(endDate.replace("-", "/"));
        if (end < start) {
            $.tools.alert(lang.EDMBGTOETSD);
            return;
        }
    }

    var authorityId = $("#selAuthority").combobox("getValue");

    var params = {
        authorityId: authorityId != 0 ? authorityId : undefined,
        startDate: startDate != "" ? startDate : undefined,
        endDate: endDate != "" ? endDate : undefined,
        keyword: keyword
    };

    $('#dg').datagrid({ url: '/SysSystemLogs/LoadAllByPage/', queryParams: params });
}

//删除数据
function delData() {
    var rows = $('#dg').datagrid('getSelections');
    if (!rows || rows.length == 0) {
        $.tools.alert(lang.PleaseSelectTheData);
        return;
    }

    var param;
    $.each(rows, function (i, n) {
        if (i == 0) {
            param = "idList=" + n.ID;
        }
        else {
            param += "&idList=" + n.ID;
        }
    });

    $.tools.delPost(param, "/SysSystemLogs/Delete/", function () {
        $('#dg').datagrid("clearSelections");
        $('#dg').datagrid("reload");
    }, this);
}

function clearData() {
    $.tools.confrimPost(lang.CCAL, null, "/SysSystemLogs/DeleteAll/", function () {
        $('#dg').datagrid("clearSelections");
        $('#dg').datagrid("reload");
    }, this);
}

$(function () {
    var curTime = new Date();
    var startTime = new Date(curTime.getTime() - 7 * 24 * 60 * 60 * 1000);
    $("#txtStartDate").datebox("setValue", startTime.format('yyyy-MM-dd hh:mm:ss'));
    $("#txtEndDate").datebox("setValue", curTime.format('yyyy-MM-dd hh:mm:ss'));
});