@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<div class="centerdiv">
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <button class="btn btn-default" id="btnExcel"><i class="glyphicon glyphicon-download-alt"></i> 导 出</button>
                <table id="statisticsTab"></table>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        var begindate = parent.$("#pmStartDate").val();
        var enddate = parent.$("#pmEndDate").val();
        var btypeid = parent.$('#uploadliginid').val(); //客户iD
        var loginid = parent.$('#salesmanBtypeid').val(); //选中的值
        $.ajax({
            url: "../DataQuery/GetCustomerCardStat",
            data: {
                btypeid: btypeid,
                loginid: loginid,
                begindate: begindate,
                enddate: enddate
            },
            datatype: "json",
            type: "post",
            success: function (data) {
                if (data != "") {
                    var columns = [];

                    var jsondata = JSON.parse(data);
                    for (var key in jsondata[0]) {
                        var temp = { field: key, title: key, align: 'center', width: 50 };
                        columns.push(temp);
                    }
                    Statistics(jsondata, columns);
                }
            },
            error: function () {
                layer.msg("加载失败", { time: 2000 });
            }
        })

    })
    function Statistics(data, columns) {
        $('#statisticsTab').bootstrapTable('destroy').bootstrapTable({
            toolbar: '#toolbar',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            pagination: false,                   //是否显示分页（*）
            sortOrder: "asc",                   //排序方式
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            minimumCountColumns: 2,  //最少允许的列数
            uniqueId: "btypeid",            //每一行的唯一标识，一般为主键列
            clickToSelect: true,              //是否启用点击选中行
            sortable: true,                     //是否启用排序
            silentSort: true,
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: false,
            showColumns: false,            //是否显示所有的列
            showRefresh: false,              //是否显示刷新按钮
            showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
            cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            columns: columns,
            data: data,
        });
        $(window).resize(function () {
            $('#statisticsTab').bootstrapTable('resetView');
        });
    }
    //Excel导出
    $("#btnExcel").on("click", function () {
        var begindate = parent.$("#pmStartDate").val();
        var enddate = parent.$("#pmEndDate").val();
        var btypeid = parent.$('#uploadliginid').val(); //客户iD
        var loginid = parent.$('#salesmanBtypeid').val(); //选中的值
        window.location.href = '../DataQuery/GetExcelCustomerCardStat?btypeid=' + btypeid + "&loginid=" + loginid + "&begindate=" + begindate + "&enddate=" + enddate
    });

</script>
