logInfo.html 4.56 KB
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>日志查询</title>
    <link href="../css/frame.css" rel="stylesheet" />
    <link href="../scripts/easyui/themes/default/easyui.css" rel="stylesheet" />
    <style type="text/css">
        .title {
            width: 70px;
            text-align: right;
            padding-right: 5px;
        }
        .content {
            width: 120px;
            text-align: left;
            padding-left: 5px;
        }
    </style>
</head>
<body class="easyui-layout">
    <div data-options="region:'north',border:false,split:false" style="height: 45px;padding:8px;">
        <table>
            <tr>
                <td class="title">开始时间:</td>
                <td class="content">
                    <input id="beginTime" type="text" name="beginTime" value="1-1" class="Wdate" readonly="true" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endTime\')}',minDate:'#F{$dp.$D(\'endTime\',{d:-7})}'})" style="width: 100px;" />
                </td>
                <td class="title">
                    结束时间:
                </td>
                <td class="content">
                    <input id="endTime" type="text" name="endTime" value="12-31" class="Wdate" readonly="true" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'beginTime\')}',maxDate:'#F{$dp.$D(\'beginTime\',{d:7})}'})" style="width: 100px;" />
                </td>
                <td>                   
                    <a id="btnExport" class="settingBtn" data-options="iconCls: 'icon-export'" style="width:100px;margin-right:3px">导出</a>
                </td>
            </tr>
        </table>
    </div>

    <script src="../scripts/easyui/jquery.min.js"></script>
    <script src="../scripts/easyui/jquery.easyui.min.js"></script>
    <script src="../scripts/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="../scripts/utilities.js"></script>
    <script src="../scripts/My97DatePicker/WdatePicker.js"></script>
    <script src="../scripts/dateTimeExtension.js"></script>
    <script type="text/javascript">
        $().ready(function () {
            //获取最新的日期
            var now = new Date();
            var yestoday = new Date(now - 86400000);
            $("#beginTime").val(yestoday.format("yyyy-MM-dd"));
            $("#endTime").val(now.format("yyyy-MM-dd"));
            $("#btnExport").click(exportLog);
        });

        //导出日志
        function exportLog() {
            var beginTime = $("#beginTime").val();
            var endTime = $("#endTime").val();
            if (!beginTime || !endTime) {
                $.messager.alert("提示", "请选择开始时间及结束时间!", "warning");
                return;
            }else if (beginTime > endTime) {
                $.messager.alert("提示", "开始时间不能大开结束时间!", "warning");
                return;
            }
            //
            var beginTimeParts = beginTime.split("-");
            var endTimeParts = endTime.split("-");
            var url = "/do/trafficController/downloadLog";
            //显示假的进度条
            $.messager.progress({
                title: "导出",
                msg: "导出中,请稍候...",
                text: "",
                interval:1000
            });
            $.ajax({
                type: "GET",
                url: url,
                data: {
                    startYear: beginTimeParts[0],
                    startMonth: beginTimeParts[1],
                    startDay: beginTimeParts[2],
                    endYear: endTimeParts[0],
                    endMonth: endTimeParts[1],
                    endDay : endTimeParts[2]
                },
                dataType: "json",
                error: function(jqXHR, textStatus, error) {
                    $.messager.progress("close");
                    $.messager.alert("出错", "请求出错,信息: "+error, "error");
                },
                success: function (data, textStatus, jqXHR) {
                    $.messager.progress("close");
                    //下载日志文件
                    if (data.error == 1) {
                        //alert(data.feedback.Msg);
                        var fileUrl = "/do/trafficController/downloadFile?FilePath=" + data.feedback.FilePath;
                        downloadByIframe(fileUrl);
                    } else {
                        $.messager.alert("出错", data.feedback.Msg, "info");
                    }
                }
            });
        }
    </script>
</body>
</html>