@{
    ViewBag.Title = "客户照片签到汇总";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<div class="topdiv">
    <div class="ibox-content">
        <table class="table table-bordered table-striped table-hover">
            <tr>
                <td>签到时间:</td>
                <td>
                    <input type="text" class="form-control" onfocus="WdatePicker({isShowClear:false,readOnly:true})" id="pmStartDate" value="@ViewBag.pmStartDate" />
                </td>
                <td>
                    <input type="text" class="form-control" onfocus="WdatePicker({isShowClear:false,readOnly:true})" id="pmEndDate" value="@ViewBag.pmEndDate" />
                </td>
                <td>客户名称:</td>
                <td>
                    <input id="uploadliginid" type="hidden" />
                    <input type="text" id="rsNum" class="form-control" readonly="true" />
                </td>
                <td>
                    <span onclick="ClientName()" class="glyphicon glyphicon-plus btn btn-default"></span>
                    <span onclick="Clear()" class="glyphicon glyphicon-minus btn btn-default"></span>
                </td>
                <td>
                    <input type="checkbox" value="a" name="chk1" id="chk1" />签到数为0
                    <input type="checkbox" value="b" name="chk2" id="chk2" />照片数为0
                </td>
                <td>
                    <button class="btn btn-default" id="btnSearch"><i class="glyphicon glyphicon-zoom-in"></i> 查询</button>
                </td>
                <td>
                    <button class="btn btn-default" id="btnExcel"><i class="glyphicon glyphicon-download-alt"></i> 导出</button>
                </td>
                <td>
                    <button class="btn btn-default" id="btnReturn"><i class="glyphicon glyphicon-triangle-top"></i> 返回上层</button>
                    <input id="hidBtypeid" type="hidden" value="@ViewBag.hidBtypeid" />
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="centerdiv">
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-content form-inline ">
                <table id="CusSignimageCountTable"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
        $(function () {
            var obj = document.getElementById("chk1");
            var value = obj.checked;
            obj.checked = true;// 设置复选框为选中状态

            var obj1 = document.getElementById("chk2");
            var value1 = obj1.checked;
            obj1.checked = true;// 设置复选框为选中状态

            $('#CusSignimageCountTable').bootstrapTable({
                url: '../DataQuery/GetCusSignimageCountList?chk1=a&chk2=b',         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                pagination: true,                   //是否显示分页（*）
                sortOrder: "asc",
                undefinedText: "",//排序方式
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 15,                       //每页的记录行数（*）
                pageList: [15, 30, 50],        //可供选择的每页的行数（*）
                minimumCountColumns: 2,  //最少允许的列数
                height: $(".centerdiv").height()-20,               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "BtypeId",            //每一行的唯一标识，一般为主键列
                clickToSelect: true,              //是否启用点击选中行
                sortable: true,                     //是否启用排序
                silentSort: true,
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
                strictSearch: false,
                paginationFirstText: '首页',
                paginationLastText: '末页',
                paginationPreText: '上一页',
                paginationNextText: '下一页',
                showColumns: false,            //是否显示所有的列
                showRefresh: false,              //是否显示刷新按钮
                showToggle: false,                     //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                detailView: false,                   //是否显示父子表
                queryParams: function (params) {
                    return {
                        pagesize: params.limit,//页面大小
                        page: params.offset, //页码
                        stardate: $("#pmStartDate").val(),
                        enddate: $("#pmEndDate").val(),
                    };
                },//传递参数（*）
                columns: [
                      {
                          field: "index", title: "序号", align: "center", width: 50, edit: false, formatter: function (value, row, index) {
                              return row.index = index + 1; //返回行号
                          }
                      },
                        {
                            field: 'fullname', title: '名称', formatter: function (value, row, index) {
                                $("#parid").val(row.parid);
                                return "<span style='cursor:pointer'>" + row.BName + "</span>";
                            }
                        },
                    { field: 'LName', title: '线路名称' },
                    { field: 'LoginName', title: '业务员' },
                    { field: 'SignCount', title: '签到数' },
                    { field: 'ImageCount', title: '照片数' }
                ],
                onClickCell: function (field, value, row) {
                    if (field == 'fullname') { //点击客户事件
                        if (row["Sonnum"] == "0") {
                            layer.msg("已到最底层", { icon: 1, time: 2000 });
                            return;
                        }
                        var stardate = $("#pmStartDate").val();
                        var enddate = $("#pmEndDate").val();
                        var btypeid = row["BtypeId"];
                        var str1;
                        $("input:checkbox[name='chk1']:checked").each(function () { // 签到数为0
                            str1 = $(this).val();  // 每一个被选中项的值
                        });

                        var str2;
                        $("input:checkbox[name='chk2']:checked").each(function () { // 签到数为0
                            str2 = $(this).val();  // 每一个被选中项的值
                        });
                        $('#CusSignimageCountTable').bootstrapTable("refresh", {
                            url: "../DataQuery/GetCusSignimageCountList?customerId=" + btypeid + "&stardate=" + stardate + "&enddate=" + enddate + "&chk1=" + str1 + "&chk2=" + str2+"&type=down"
                        })
                    }
                }
            });
            $(window).resize(function () {
                $('#CusSignimageCountTable').bootstrapTable('resetView');
            });
        });
        //点击客户事件
        function SelBNameData(btypeid, Sonnum) {
            if (Sonnum == "0") {
                layer.msg("已到最底层!", { icon: 1, time: 2000 });
                return;
            }
            $('#CusSignimageCountTable').bootstrapTable("refresh", {
                url: "../DataQuery/GetCusSignimageCountList?customerId=" + btypeid
            })
        }

        //查询列表
        $("#btnSearch").on("click", function () {
            var stardate = $("#pmStartDate").val();
            var enddate = $("#pmEndDate").val();
            var rsNum = $("#uploadliginid").val();
            var str1;
            $("input:checkbox[name='chk1']:checked").each(function () { // 签到数为0
                str1 = $(this).val();  // 每一个被选中项的值
            });

            var str2;
            $("input:checkbox[name='chk2']:checked").each(function () { // 签到数为0
                str2 = $(this).val();  // 每一个被选中项的值
            });

            $('#CusSignimageCountTable').bootstrapTable("refresh", {
                url: "../DataQuery/GetCusSignimageCountList?stardate=" + stardate + "&enddate=" + enddate + "&customerId=" + rsNum + "&chk1=" + str1 + "&chk2=" + str2
            })
        });

        //Excel导出
        $("#btnExcel").on("click", function () {
            var stardate = $("#pmStartDate").val();
            var enddate = $("#pmEndDate").val();
            var rsNum = $("#uploadliginid").val();
            window.location.href = '../DataQuery/GetExcelCusSignimageCountList?stardate=' + stardate + "&enddate=" + enddate + "&customerId=" + rsNum + "&flag=0"
        });
        //返回上层
        $("#btnReturn").on("click", function () {
            var typeid = $("#hidBtypeid").val();
            var stardate = $("#pmStartDate").val();
            var enddate = $("#pmEndDate").val();
            var str1;
            $("input:checkbox[name='chk1']:checked").each(function () { // 签到数为0
                str1 = $(this).val();  // 每一个被选中项的值
            });

            var str2;
            $("input:checkbox[name='chk2']:checked").each(function () { // 签到数为0
                str2 = $(this).val();  // 每一个被选中项的值
            });
            $('#CusSignimageCountTable').bootstrapTable("refresh", {
                url: "../DataQuery/GetTopCusSignimageCountList?customerId=" + typeid + "&stardate=" + stardate + "&enddate=" + enddate + "&chk1=" + str1 + "&chk2=" + str2
            })
        });
        //选择客户
        function ClientName() {
            layer.open({
                type: 2,
                title: '@ViewBag.Title 客户信息',
                shadeClose: false,
                shade: 0.5,
                area: ['80%', '70%'],
                content: '../CommonSelector/ClientSelector'
            });
        }
        //清除选择的客户
        function Clear() {
            $("#rsNum").val("");
            $("#uploadliginid").val("");
        }
    </script>
