<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<html>
<head>
    <title>科室统计</title>
    <meta charset="utf-8">
    <!-- 解决部分兼容性问题，如果安装了GCF，则使用GCF来渲染页面，如果未安装GCF，则使用最高版本的IE内核进行渲染。 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!-- 页面按原比例显示 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript" src="${path}/static/js/echarts.min.js"></script>
    <%@include file="../../jspf/comm.jspf" %>
    <style>

        .body {
            overflow-x: hidden;
            overflow-y: hidden;
            height: calc(100vh - 0px);
        !important;
        }

        .divCss {
            margin-top: 5px;
        }

        .divCss2 {
            margin-top: 5px;
            margin-left: 20px;
        }

        .divCss8 {
            margin-top: 5px;
            margin-right: 20px;
        }

        /* dataTables表头居中 */
        .table > thead:first-child > tr:first-child > th {
            text-align: center !important;
        }

        #toolbar > div {
            margin-top: 0px;
        !important;
        }

        #dataDiv {
            margin-left: 10px;
            margin-right: 10px;
            height: auto;
        }

        .toolbarCss {
            margin-right: 20px;
            margin-bottom: 0px;
        !important;
        }

        .fixed-table-toolbar .bs-bars .pull-right{
            height: 20px;
        !important;
        }

        /*选中行颜色*/
        .fixed-table-container tbody .selected td {
            background-color: #9acfea;
        }
    </style>
</head>

<body>
<div class="row" id="dataDiv">
    <!--搜索-->
    <form style="margin-top:20px;">
        <div class="form-inline">
            <div class="form-group divCss8" style="height: 18px;margin-top: -7px;">
                <label>出院科室:</label>
                <%--<select class="input-sm form-control" id="deptName">--%>
                <%--<option value="">全部</option>--%>
                <%--&lt;%&ndash;<option value="在院">在院</option>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<option value="未归档">未归档</option>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<option value="归档中">归档中</option>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<option value="初审">初审</option>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<option value="已认证">已认证</option>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<option value="已归档">已归档</option>&ndash;%&gt;--%>
                <%--</select>--%>
                <select class="selectpicker bla bla bli" multiple data-live-search="true" name="deptName"
                        id="deptName" data-actions-box="true" data-deselect-all-text="取消全选" data-select-all-text="全选" data-none-results-text="没找到相应记录{0}"
                        title="请输入出院科室">
                    <option value="">全部</option>
                </select>
            </div>
            <div class="form-group divCss">
                <label>出院日期:</label>
                <div class="input-daterange input-group" id="datepicker">
                    <input type="text" class="input-sm form-control" name="start" id="startDate"/>
                    <span class="input-group-addon">-</span>
                    <input type="text" class="input-sm form-control" name="end" id="endDate"/>
                </div>
            </div>
            <div class="form-group divCss8">
                <label>迟交天数为:</label>
                <input type="text" class="input-sm form-control" id="overdueDays" placeholder="请输入迟交天数">
                <label>天</label>
            </div>
            <button type="button" class="btn btn-primary btn-sm divCss" id="searchBtn">查询</button>
            <button type="button" class="btn btn-info btn-sm divCss" id="excelBtn">条件导出</button>
            <button type="button" class="btn btn-danger btn-sm divCss" id="excelBtn2">未归档导出</button>

        </div>
    </form>
    <!--数据表格-->
    <table id="table" class="table table-striped"></table>
    <div id="toolbar" class="btn-group pull-right toolbarCss" >
        <div class="columns columns-right btn-group pull-right">
            <div class="btn-group btn-info">
                <select id="sel_exportoption" class="form-control">                
                    <option value="">导出当前页面数据</option>                                   
                    <option value="all">导出全部数据</option>                                 
                    <option value="selected">导出选中数据</option>
                </select>
            </div>
            <button class=" btn btn-success" style="height: 34px" type="button" id="refreshBtn" name="refresh"
                    aria-label="Refresh"
                    title="Refresh">
                <i class="glyphicon glyphicon-refresh icon-refresh"></i>
            </button>
        </div>


    </div>
</div>
<%--<div class="row" style="background-color:#fff;height:400px;margin-left:30px;">--%>
<%--<div class="col-sm-3" style="background-color:#ECF0F5;height:400px;" id="chartmainTwo">sss</div>--%>
<%--<div class="col-sm-4" style="margin-left:2%;background-color:#ECF0F5;height:400px;" id="chartmainThree">sss</div>--%>
<%--<div class="col-sm-4" style="margin-left:2%;background-color:#ECF0F5;height:400px;" id="chartmainFour">ss</div>--%>
<%--</div>--%>
<div class="row" style="margin-top: 20px;margin-left:20px;background-color:#ECF0F5;width:97%;height:600px;"
     id="chartmainTwo"></div>

<div class="row" style="margin-top: 20px;margin-left:20px;background-color:#ECF0F5;width:97%;height:600px;"
     id="chartmainOne"></div>
</body>
<script>
    var tipLoad = 1;

    $(function () {
        function getDept() {
            //获取科室列表
            $.ajax({
                url: "${path}/inHosp/getDept",
                type: "POST",
                data: {effective: 1, typecode: "dept_code"},
                success: function (result) {
                    if (result != null) {
                        for (var i = 0; i < result.length; i++) {
                            $("#deptName").append("<option value=" + result[i].code + ">" + result[i].name + "</option>");
                        }
                    }
                    $(".selectpicker").selectpicker('refresh');
                }
            });
        }

        getDept();

        //日期控件
        $(".input-daterange").datepicker({
            format: "yyyy-mm-dd",
            language: "zh-CN"
        });

        var url = window.location.href;
        var index = url.substring(url.lastIndexOf('?') + 1).replace("num=", "");
        if (index != null && index != "" && index.indexOf("excel") != -1) {
            $("#excelBtn").show();
            $("#toolbar").show();
        } else {
            $("#excelBtn").hide();
            $(".columns-right").hide();
        }
        if (index != null && index != "" && index.indexOf("excel2") != -1) {
            $("#excelBtn2").show();
        } else {
            $("#excelBtn2").hide();
        }


        var myChartOne = echarts.init(document.getElementById('chartmainOne'));
        var myChartTwo = echarts.init(document.getElementById('chartmainTwo'));
        // var myChartThree = echarts.init(document.getElementById('chartmainThree'));
        // var myChartFour = echarts.init(document.getElementById('chartmainFour'));
        var deptArr = ['科室1', '科室3', '科室4', '科室5', '科室6', '科室7', '科室8', '科室9'];
        var outArr = [400, 400, 300, 300, 300, 400, 400, 400, 300];
        var fileArr = [400, 500, 500, 500, 500, 400, 400, 500, 500];
        var unFileArr = [400, 600, 700, 700, 1000, 400, 400, 600, 700];
        var deathArr = [400, 500, 500, 500, 500, 400, 400, 500, 500];
        var arr = [80, 34, 39, 35, 38, 36, 34, 36, 34];
        var day2Arr = [25, 22, 26, 28, 27, 26, 23, 36, 34];
        var day3Arr = [15, 12, 16, 18, 17, 16, 13, 36, 34];
        var day7Arr = [10, 10, 10, 18, 17, 10, 63, 36, 34];
        //获取部门统计列表
        var entity = {};
        entity.deptCode = $("#deptName").val();
        entity.startDate = $("#startDate").val();
        entity.endDate = $("#endDate").val();
        $.ajax({
            url: "${path}/vCount/vCountNumList",
            type: "POST",
            data: entity,
            success: function (result) {
                var optionOne;
                var optionTwo;
                if (result != null) {
                    deptArr = [];
                    outArr = [];
                    fileArr = [];
                    unFileArr = [];
                    deathArr = [];


                    arr = [];
                    day2Arr = [];
                    day3Arr = [];
                    day7Arr = [];
                    for (var i = 0; i < result.length; i++) {
                        if (result[i].deptName != null && result[i].deptName != '') {
                            //科室
                            deptArr.push(result[i].deptName);
                            //出院数
                            outArr.push(result[i].outNum);
                            //归档数
                            fileArr.push(result[i].fileNum);
                            //未归档数
                            unFileArr.push(result[i].unfileNum);
                            //死亡数
                            deathArr.push(result[i].deathNum);
                            //归档率
                            arr.push(result[i].fileRate);
                            //2日归档率
                            day2Arr.push(result[i].day2Rate);
                            //3日归档率
                            day3Arr.push(result[i].day3Rate);
                            //7日归档率
                            day7Arr.push(result[i].day7Rate);
                        }
                    }
                    optionOne = {
                        backgroundColor: '#ECF0F5',
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: { // 坐标轴指示器，坐标轴触发有效
                                type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                            }
                        },
                        toolbox: {
                            //show: true,
                            feature: {
                                //mark: {show: true},
                                //dataView : {show: true, readOnly: false},
                                magicType: {show: true, type: ['line', 'bar']},
                                restore: {show: true},
                                saveAsImage: {show: true}
                            }
                        },
                        grid: {
                            left: '2%',
                            right: '4%',
                            bottom: '14%',
                            top: '16%',
                            containLabel: true
                        },
                        legend: {
                            data: ['出院人数', '已归档', '未归档', '死亡人数'],
                            //right: 10,
                            top: 12,
                            textStyle: {
                                color: "#323a5e"
                            },
                            itemWidth: 12,
                            itemHeight: 10,
                            // itemGap: 35
                        },
                        xAxis: {
                            type: 'category',
                            data: deptArr,
                            axisLine: {
                                lineStyle: {
                                    color: '323a5e'

                                }
                            },
                            axisLabel: {
                                // interval: 0,
                                // rotate: 40,
                                textStyle: {
                                    fontFamily: 'Microsoft YaHei'
                                }
                            },
                        },

                        yAxis: {
                            type: 'value',
                            max: '1200',
                            axisLine: {
                                show: false,
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: '#ccc'
                                }
                            },
                            axisLabel: {}
                        },
                        "dataZoom": [{
                            "show": true,
                            "height": 12,
                            "xAxisIndex": [
                                0
                            ],
                            bottom: '8%',
                            "start": 10,
                            "end": 90,
                            handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                            handleSize: '110%',
                            handleStyle: {
                                color: "#d3dee5",

                            },
                            textStyle: {
                                color: "#90979c"
                            },
                            borderColor: "#90979c"
                        }, {
                            "type": "inside",
                            "show": true,
                            "height": 15,
                            "start": 1,
                            "end": 35
                        }],
                        series: [{
                            name: '出院人数',
                            type: 'bar',
                            barWidth: '15%',
                            itemStyle: {
                                normal: {
                                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                        offset: 0,
                                        color: '#fccb05'
                                    }, {
                                        offset: 1,
                                        color: '#f5804d'
                                    }]),
                                    barBorderRadius: 12,
                                },
                            },
                            data: outArr
                        },
                            {
                                name: '已归档',
                                type: 'bar',
                                barWidth: '15%',
                                itemStyle: {
                                    normal: {
                                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                            offset: 0,
                                            color: '#8bd46e'
                                        }, {
                                            offset: 1,
                                            color: '#09bcb7'
                                        }]),
                                        barBorderRadius: 11,
                                    }

                                },
                                data: fileArr
                            },
                            {
                                name: '未归档',
                                type: 'bar',
                                barWidth: '15%',
                                itemStyle: {
                                    normal: {
                                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                            offset: 0,
                                            color: '#248ff7'
                                        }, {
                                            offset: 1,
                                            color: '#6851f1'
                                        }]),
                                        barBorderRadius: 11,
                                    }
                                },
                                data: unFileArr
                            }, {
                                name: '死亡人数',
                                type: 'bar',
                                barWidth: '15%',
                                itemStyle: {
                                    normal: {
                                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                            offset: 0,
                                            color: '#DBDB70'
                                        }, {
                                            offset: 1,
                                            color: '#EAEAAE'
                                        }]),
                                        barBorderRadius: 11,
                                    }

                                },
                                data: deathArr
                            },]
                    };

                    var app = {
                        currentIndex: -1,
                    };
                    setInterval(function () {
                        var dataLen = optionOne.series[0].data.length;

                        // 取消之前高亮的图形
                        myChartOne.dispatchAction({
                            type: 'downplay',
                            seriesIndex: 0,
                            dataIndex: app.currentIndex
                        });
                        app.currentIndex = (app.currentIndex + 1) % dataLen;
                        //console.log(app.currentIndex);
                        // 高亮当前图形
                        myChartOne.dispatchAction({
                            type: 'highlight',
                            seriesIndex: 0,
                            dataIndex: app.currentIndex,
                        });
                        // 显示 tooltip
                        myChartOne.dispatchAction({
                            type: 'showTip',
                            seriesIndex: 0,
                            dataIndex: app.currentIndex
                        });


                    }, 1000);


                    optionTwo = {
                        backgroundColor: '#ECF0F5',
                        title: {
                            text: '归档率变化',
                            textStyle: {
                                color: "#ccc"
                            }
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            data: ['归档率%', '2日归档率%', '3日归档率%', '7日归档率%'],
                            textStyle: {
                                color: "#000"
                            }
                        },
                        grid: {
                            top: 'middle',
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            height: '80%',
                            containLabel: true
                        },
                        toolbox: {
                            show: true,
                            feature: {
                                mark: {show: true},
                                //dataView: {show: true, readOnly: false},
                                magicType: {show: true, type: ['line', 'bar']},
                                restore: {show: true},
                                saveAsImage: {show: true}
                            }
                        },

                        calculable: true,
                        xAxis: [
                            {
                                type: 'category',
                                boundaryGap: false,
                                data: deptArr,
                                axisTick: {
                                    show: true //隐藏X轴刻度
                                },
                                axisLabel: {
                                    show: true,
                                    textStyle: {
                                        color: "#000" //X轴文字颜色
                                    }
                                },
                            }
                        ],
                        yAxis: [
                            {
                                type: 'value',
                                name: "%",
                                nameTextStyle: {
                                    color: "#000"
                                },
                                axisLabel: {
                                    formatter: '{value}%'
                                },
                                axisLabel: {
                                    show: true,
                                    textStyle: {
                                        color: "#000"
                                    }
                                },
                                splitLine: {
                                    lineStyle: {
                                        type: 'dashed',
                                        color: '#DDD'
                                    }
                                },
                            }
                        ],
                        "dataZoom": [{
                            "show": true,
                            "height": 12,
                            "xAxisIndex": [
                                0
                            ],
                            bottom: '8%',
                            "start": 10,
                            "end": 90,
                            handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                            handleSize: '110%',
                            handleStyle: {
                                color: "#d3dee5",

                            },
                            textStyle: {
                                color: "#90979c"
                            },
                            borderColor: "#90979c"
                        }, {
                            "type": "inside",
                            "show": true,
                            "height": 15,
                            "start": 1,
                            "end": 35
                        }],
                        series: [
                            {
                                name: '归档率%',
                                type: 'line',
                                min: 10,
                                max: 100,
                                data: arr,
                                // markPoint : {
                                //     data : [
                                //         {name : '周最高', value : 39, xAxis: 2, yAxis: 39}
                                //     ]
                                // },
                                lineStyle: {
                                    normal: {
                                        width: 5,
                                        color: {
                                            type: 'linear',

                                            colorStops: [{
                                                offset: 0,
                                                color: '#9F5F9F' // 0% 处的颜色
                                            },
                                                {
                                                    offset: 0.4,
                                                    color: '#9F5F9F' // 100% 处的颜色
                                                }, {
                                                    offset: 1,
                                                    color: '#9F5F9F' // 100% 处的颜色
                                                }
                                            ],
                                            globalCoord: false // 缺省为 false
                                        },
                                        shadowColor: 'rgba(71,216,190, 0.5)',
                                        shadowBlur: 10,
                                        shadowOffsetY: 7
                                    }
                                },
                                itemStyle: {
                                    normal: {
                                        color: '#9F5F9F',
                                        borderWidth: 10,
                                        /*shadowColor: 'rgba(72,216,191, 0.3)',
                                         shadowBlur: 100,*/
                                        borderColor: "#AAF487"
                                    }
                                },
                                smooth: true,
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            },
                            {
                                name: '2日归档率%',
                                type: 'line',
                                min: 10,
                                max: 100,
                                data: day2Arr,
                                // markPoint : {
                                //     data : [
                                //         {name : '周最低', value : 22, xAxis: 1, yAxis: 22}
                                //     ]
                                // },
                                lineStyle: {
                                    normal: {
                                        width: 5,
                                        color: {
                                            type: 'linear',

                                            colorStops: [{
                                                offset: 0,
                                                color: '#F6D06F' // 0% 处的颜色
                                            },
                                                {
                                                    offset: 0.4,
                                                    color: '#F9A589' // 100% 处的颜色
                                                }, {
                                                    offset: 1,
                                                    color: '#F9A589' // 100% 处的颜色
                                                }
                                            ],
                                            globalCoord: false // 缺省为 false
                                        },
                                        shadowColor: 'rgba(249,165,137, 0.5)',
                                        shadowBlur: 10,
                                        shadowOffsetY: 7
                                    }
                                },

                                itemStyle: {
                                    normal: {
                                        color: '#F6D06F',
                                        borderWidth: 10,
                                        /*shadowColor: 'rgba(72,216,191, 0.3)',
                                         shadowBlur: 100,*/
                                        borderColor: "#F6D06F"
                                    }
                                },
                                smooth: true,
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            }
                            ,
                            {
                                name: '3日归档率%',
                                type: 'line',
                                min: 10,
                                max: 100,
                                data: day3Arr,
                                // markPoint : {
                                //     data : [
                                //         {name : '周最低', value : 12, xAxis: 1, yAxis: 22}
                                //     ]
                                // },
                                lineStyle: {
                                    normal: {
                                        width: 5,
                                        color: {
                                            type: 'linear',

                                            colorStops: [{
                                                offset: 0,
                                                color: '#C6D06F' // 0% 处的颜色
                                            },
                                                {
                                                    offset: 0.4,
                                                    color: '#C6D06F' // 100% 处的颜色
                                                }, {
                                                    offset: 1,
                                                    color: '#C6D06F' // 100% 处的颜色
                                                }
                                            ],
                                            globalCoord: false // 缺省为 false
                                        },
                                        shadowColor: 'rgba(249,165,137, 0.5)',
                                        shadowBlur: 10,
                                        shadowOffsetY: 7
                                    }
                                },

                                itemStyle: {
                                    normal: {
                                        color: '#C6D06F',
                                        borderWidth: 10,
                                        /*shadowColor: 'rgba(72,216,191, 0.3)',
                                         shadowBlur: 100,*/
                                        borderColor: "#F6D06F"
                                    }
                                },
                                smooth: true,
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            }
                            ,
                            {
                                name: '7日归档率%',
                                type: 'line',
                                min: 10,
                                max: 100,
                                data: day7Arr,
                                // markPoint : {
                                //     data : [
                                //         {name : '周最低', value : 12, xAxis: 1, yAxis: 22}
                                //     ]
                                // },
                                lineStyle: {
                                    normal: {
                                        width: 5,
                                        color: {
                                            type: 'linear',

                                            colorStops: [{
                                                offset: 0,
                                                color: '#06D06F' // 0% 处的颜色
                                            },
                                                {
                                                    offset: 0.4,
                                                    color: '#06D06F' // 100% 处的颜色
                                                }, {
                                                    offset: 1,
                                                    color: '#06D06F' // 100% 处的颜色
                                                }
                                            ],
                                            globalCoord: false // 缺省为 false
                                        },
                                        shadowColor: 'rgba(249,165,137, 0.5)',
                                        shadowBlur: 10,
                                        shadowOffsetY: 7
                                    }
                                },

                                itemStyle: {
                                    normal: {
                                        color: '#06D06F',
                                        borderWidth: 10,
                                        /*shadowColor: 'rgba(72,216,191, 0.3)',
                                         shadowBlur: 100,*/
                                        borderColor: "#F6D06F"
                                    }
                                },
                                smooth: true,
                                markLine: {
                                    data: [
                                        {type: 'average', name: '平均值'}
                                    ]
                                }
                            }
                        ]
                    };


                }
                //使用制定的配置项和数据显示图表
                myChartOne.setOption(optionOne);
                //使用制定的配置项和数据显示图表
                myChartTwo.setOption(optionTwo);
            }
        });


    });


    //处理导出内容,这个方法可以自定义某一行、某一列、甚至某个单元格的内容,也就是将其值设置为自己想要的内容
    // function DoOnCellHtmlData(cell, row, col, data) {
    //     if (row == 0) {
    //         return data;
    //     }
    //
    //     //由于备注列超过6个字的话,通过span标签处理只显示前面6个字,如果直接导出的话会导致内容不完整,因此要将携带完整内容的span标签中title属性的值替换
    //     if (col == 4 || col == 11 || col == 7) {
    //         var spanObj = $(data);//将带 <span title="val"></span> 标签的字符串转换为jQuery对象
    //         var title = spanObj.attr("title");//读取<span title="val"></span>中title属性的值
    //         //var span = cell[0].firstElementChild;//读取cell数组中的第一个值下的第一个元素
    //         if (typeof (title) != 'undefined') {
    //             return title;
    //         }
    //     }
    //
    //     return data;
    // }

    function initTable() {
        if (tipLoad == 1) {
            $("#table").bootstrapTable({ // 对应table标签的id
                //method: 'POST',
                url: "${path}/vCount/vCountList", // 获取表格数据的url
                contentType: "application/x-www-form-urlencoded",//一种编码。好像在post请求的时候需要用到。这里用的get请求，注释掉这句话也能拿到数据
                //dataField: "data",//这是返回的json数组的key.默认是"rows".这里只有前后端约定好就行
                cache: false, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
                striped: true,  //表格显示条纹，默认为false
                pagination: true, // 在表格底部显示分页组件，默认false
                paginationShowPageGo: true,
                pageList: [10, 20, 50, 100], // 如果设置了分页，设置可供选择的页面数据条数。设置为All 则显示所有记录。
                smartDisplay: false,
                pageSize: 2, // 页面数据条数
                pageNumber: 1, // 初始化加载第一页，默认第一页
                sidePagination: 'server', // 设置为服务器端分页     客户端：client
                search: false,
                showColumns: true,
                // sortable: true,
                // sortOrder: "asc",
                toolbar: '#toolbar',//指定工具栏
                searchOnEnterKey: true, //设置为 true时，按回车触发搜索方法，否则自动触发搜索方法
                undefinedText: '--', //当数据为 undefined 时显示的字符
                singleSelect: false,//设置True 将禁止多选
                clickToSelect: true,//设置true 将在点击行时，自动选择rediobox 和 checkbox
                //height: 560,     //定义表格的高度。
                searchTimeOut: 500,// 默认500  设置搜索超时时间。
                toolbarAlign: 'right',// 指定 toolbar 水平方向的位置。'left' 或 'right'
                paginationDetailHAlign: 'left',//指定 分页详细信息 在水平方向的位置。'left' 或 'right'。
                showHeader: true,//是否显示列头。
                trimOnSearch: true,//设置为 true 将自动去掉搜索字符的前后空格。
                //是否显示导出按钮
                showExport: true,
                //导出表格方式（默认basic：只导出当前页的表格数据；all：导出所有数据；selected：导出选中的数据）
                exportDataType: "basic",
                //导出文件类型
                exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
                exportOptions: {
                    fileName: document.title
                },
                // showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                // cardView: false,                    //是否显示详细视图
                // detailView: false,                   //是否显示父子表
                queryParams: function (params) {
                    var currPageSize = this.pageSize;
                    if (currPageSize == 2) {
                        currPageSize = 10;
                    }

                    var limit = null;
                    var offset = params.offset;
                    //判断是否导出全部all
                    if ($("#sel_exportoption").val() == "all") {
                        offset = 0;
                        limit = this.totalRows;
                        this.pageSize = limit;
                    } else {
                        limit = currPageSize;
                        this.pageSize = currPageSize;
                    }

                    var deptName = $("#deptName").val();
                    if (deptName.indexOf("") != -1) {
                        deptName = "";
                    } else {
                        deptName = $("#deptName").val().toString();
                    }
                    var temp = {
                        limit: limit,     //页面大小
                        offset: offset,   //页码
                        //order: params.order,      //排位命令（desc，asc）
                        deptCode: deptName.toString(),
                        startDate: $("#startDate").val(),
                        endDate: $("#endDate").val(),
                        overdueDays: $("#overdueDays").val()

                    };
                    return temp;
                },
                sortName: 'id', // 要排序的字段
                sortOrder: 'desc', // 排序规则
                columns: [{
                    title: '全选',
                    field: 'select',   //复选框
                    checkbox: true,
                    width: 25,
                    align: 'center',
                    valign: 'middle'

                },
                    {
                        title: '序号',
                        field: 'id',
                        align: 'center',
                        valign: 'middle',
                        //sortable: true,
                        // visible: false,
                        formatter: function (value, row, index) {
                            return index + 1;
                        }
                    },
                    {
                        title: '科室代码',
                        field: 'deptCode',
                        align: 'left',
                        valign: 'middle',
                    },
                    {
                        title: '科室名称',
                        field: 'deptName',
                        align: 'left',
                        valign: 'middle',
                    },
                    // {
                    //     title: '在院人数',
                    //     field: 'inNum',
                    //     align: 'center',
                    //     valign: 'middle',
                    // },
                    {
                        title: '出院合计',
                        field: 'isOutNum',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '迟交合计',
                        field: 'timeOutNum',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '迟交率',
                        field: 'timeOutRate',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            var val;
                            if (row.timeOutRate != null && row.timeOutRate != '') {
                                val = (row.timeOutRate * 100) + "%";
                            }

                            return val;
                        }
                    },
                    {
                        title: '及时合计',
                        field: 'inTime',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '及时率',
                        field: 'inTimeRate',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            var val;
                            if (row.inTimeRate != null && row.inTimeRate != '') {
                                val = (row.inTimeRate * 100) + "%";
                            }

                            return val;
                        }
                    },
                ],
                onLoadSuccess: function (result) {  //加载成功时执行
                    //console.info("加载成功");
                    tipLoad = 0;
                },
                onLoadError: function () {  //加载失败时执行
                    //console.info("加载数据失败");
                    tipLoad = 0;
                }

            });
        }
    }


    //查询
    $('#searchBtn').click(function () {
        //查询之后重新从第一页算起
        if (tipLoad == 0) {
            $("#table").bootstrapTable("refreshOptions", {pageNumber: 1});
        } else {
            toastr.warning("正在查询，请稍等...");
        }
        //$(".selectpicker").selectpicker('deselectAll');
        // $('#table').bootstrapTable('destroy');
        //$('#table').bootstrapTable('refreshOptions', {limit: 1, offset: 10});
        //刷新
        //$('#table').bootstrapTable('refresh');
    });

    //获取table的高度
    function getHeight() {
        return $(window).height() - 100;
    }

    initTable();

    //2.初始化select的change事件
    $("#sel_exportoption").change(function () {
        $('#table').bootstrapTable('refreshOptions', {
            exportDataType: $(this).val()
        });
    });
    $("#refreshBtn").click(function () {
        //刷新
        $('#table').bootstrapTable('refresh');
    });

    //导出excel功能
    $("#excelBtn").click(function () {
        var deptName = $("#deptName").val();
        if (deptName.indexOf("") != -1) {
            deptName = "";
        } else {
            deptName = $("#deptName").val().toString();
        }
        var startDate = $("#startDate").val();
        var endDate = $("#endDate").val();
        window.location.href = "${path}/vCount/exportExcel?deptCode=" + deptName + "&startDate=" + startDate
            + "&endDate=" + endDate;

    });
    //导出excel功能
    $("#excelBtn2").click(function () {
        //var deptName = "" + $("#deptName").val();
        var deptName = $("#deptName").val();
        if (deptName.indexOf("") != -1) {
            deptName = "";
        } else {
            deptName = $("#deptName").val().toString();
        }
        var startDateTo = $("#startDate").val();
        var endDateTo = $("#endDate").val();
        var archivestate="归档中,初审,复审退回,提交,主任退回";

        window.location.href = "${path}/vCount/exportExcel2?deptName=" + deptName + "&startDateTo=" + startDateTo
            + "&endDateTo=" + endDateTo+ "&archivestate=" + archivestate;
    });


</script>

</html>