<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/taglibs.jspf"%>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <hejin:header title="批量结果管理"></hejin:header>

    <!-- 图片上传样式 -->
    <link rel="stylesheet" type="text/css" href="static/css/bootstrap/jquery.fileupload-ui.css">
    <style type="text/css">
        .span {
            position: absolute;
            left: 50%;
            top: 50%;
            margin-top: 5px;
        }
    </style>
</head>
<body>
<!-- 菜单 -->
<jsp:include page="../../menu.jsp"/>
<!-- BEGIN 面包屑 -->
<div class="container-fluid">
    <ol class="breadcrumb"><!-- BEGIN 面包屑 -->
        <li><a href="javascript:void(0);">系统管理</a></li>
        <li><a href="system/comparisonResult/comparisonResultIndex.do">批量结果</a></li>
    </ol>
</div>
<!-- END 面包屑 -->
<!-- BEGIN 条件 -->
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-1">
            <span class="span">批量计算</span>
        </div>
        <div class="col-sm-2">
            <div class="form-group">
                <select id="batchCalculate" name="batchCalculate" class="form-control">
                    <option value="" selected>--请选择--</option>
                    <option value="1">完成</option>
                    <option value="0">未完成</option>
                </select>
            </div>
        </div>
        <div class="col-sm-1">
            <span class="span">对比结果</span>
        </div>
        <div class="col-sm-2">
            <div class="form-group">
                <select id="comparisonResult" name="comparisonResult" class="form-control">
                    <option value="" selected>--请选择--</option>
                    <option value="1">一致</option>
                    <option value="0">不一致</option>
                </select>
            </div>
        </div>
        <div class="col-sm-2">
            <div class="form-group">
                <a class="btn btn-block btn-primary btn-query" id="searchBtn" data-target="#compose-modal"><i class="fa fa-pencil"></i>查询</a>
            </div>
        </div>
    </div>
</div>
<!-- END 条件 -->
<!-- BEGIN Tables -->
<div class="container-fluid">
    <div class="row"><!-- BEGIN row-fluid -->
        <div class="col-sm-12"><!-- BEGIN col-sm-12 -->
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">批量结果列表</h3>
                </div><!-- /.box-header -->
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-striped" id="table_log_user">
                        <thead>
                        <tr>
                            <th>批量计算</th>
                            <th>对比结果</th>
                            <th>对比结果描述</th>
                            <th>创建时间</th>
                            <th>备注</th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div><!-- END col-sm-12 -->
    </div><!-- END row-fluid -->
</div>
<!-- END Tables -->

<!--common js -->
<hejin:commonScript></hejin:commonScript>
<script type="text/javascript">
    Date.prototype.format = function(format)
    {
        var o = {
            "M+" : this.getMonth()+1, //month
            "d+" : this.getDate(),    //day
            "h+" : this.getHours(),   //hour
            "m+" : this.getMinutes(), //minute
            "s+" : this.getSeconds(), //second
            "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
            "S" : this.getMilliseconds() //millisecond
        }
        if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
                (this.getFullYear()+"").substr(4 - RegExp.$1.length));
        for(var k in o)if(new RegExp("("+ k +")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length==1 ? o[k] :
                            ("00"+ o[k]).substr((""+ o[k]).length));
        return format;
    }

    $(function(){
        // datatable load data
        var tables = $('#table_log_user').platformDataTable({
            "bSort":false,
            //数据源     返回数据必须封装aaData
            "sAjaxSource" : 'system/comparisonResult/loadComparisonResultList.do?'+ new Date().getTime(),
            "aoColumns" : [ //列
                {"sClass" : "center",
                    "mDataProp" : "batchCalculate",
                    "bSearchable" : false,
                    "fnRender" : function(obj) {
                        if(obj.aData.batchCalculate == null){
                            return "";
                        } else if(obj.aData.batchCalculate == '1') {
                            return "完成";
                        } else {
                            return "未完成";
                        }
                    }
                },
                {"sClass" : "center",
                    "mDataProp" : "comparisonResult",
                    "bSearchable" : false,
                    "fnRender" : function(obj) {
                        if(obj.aData.comparisonResult == null){
                            return "";
                        } else if(obj.aData.comparisonResult == '1') {
                            return "一致";
                        } else {
                            return "不一致";
                        }
                    }
                },
                {"sClass" : "center", "mDataProp" : "comparisonRemark"},
                {"sClass" : "center",
                    "mDataProp" : "createTime",
                    "bSearchable" : false,
                    "fnRender" : function(obj) {
                        var curTime = new Date(obj.aData.createTime);
                        return curTime.format("yyyy-MM-dd hh:mm:ss");
                    }
                },
                {"sClass" : "center", "mDataProp" : "remark"}
            ]
        });

        // 查询事件
        $('#searchBtn').click(function(){
            var batchCalculate = $('#batchCalculate').val();
            var comparisonResult = $('#comparisonResult').val();
            var hisResult = $('#hisResult').val();

            var data=[];// 存放json类型的查询条件，可以放多个
            data.push({ "name": "batchCalculate", "value": batchCalculate},
                    { "name": "comparisonResult", "value": comparisonResult},
                    { "name": "hisResult", "value": hisResult});
            //Ajax重新load控件数据
            drawTable(tables,data);
            tables.fnPageChange(0);
        });
    });

    function redirect(){
        if($('#page').val() && $('#page').val()>=0){
            var tables = $('#table_log_user').dataTable();
            var oSettings = tables.fnSettings();
            var maxPage = oSettings.fnRecordsTotal() % oSettings._iDisplayLength == 0?
            oSettings.fnRecordsTotal() / oSettings._iDisplayLength :
            Math.floor(oSettings.fnRecordsTotal() / oSettings._iDisplayLength)+ 1;
            if($('#page').val() == 0){
                $('#page').val(1);
            }
            if($('#page').val() > maxPage){
                $('#page').val(maxPage);
            }
            var redirectpage = $('#page').val() - 1;
            tables.fnPageChange(redirectpage);
        }else{
            return;
        }
    }

    function onlyNum(){
        $('#page').val($("#page").val().replace(/\D/g, ''));
    }
</script>
</body>
</html>