@{
    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 style="width:100px;">签到时间:</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>
                    <select class="chosen-select" data-placeholder="请选择业务员" id="logionUser" style="width:120px">
                        <option value=""></option>
                        @{
                            if (@ViewBag.ddluser != null && @ViewBag.ddluser.Rows.Count > 0)
                            {
                                for (int i = 0; i < @ViewBag.ddluser.Rows.Count; i++)
                                {
                                    <option value='@ViewBag.ddluser.Rows[i]["TypeID_"]'>@ViewBag.ddluser.Rows[i]["FullName"] </option>
                                }
                            }
                        }
                    </select>
                </td>
                <td style="width:100px;">客户名称:</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 style="width:100px;">
                    误差范围：
                </td>
                <td>
                    <input type="number" id="minAccuracy" class="form-control" />
                </td>
                <td>
                    <input type="number" id="maxAccuracy" class="form-control" />
                </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>
                     <input id="hidCount" type="hidden" value="0" />
                </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="GetBtypeSignTable"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
        $(function () {
            $('#GetBtypeSignTable').bootstrapTable({
                url: '../DataQuery/GetBtypeSignList',         //请求后台的URL（*）
                method: 'post',                      //请求方式（*）
                toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: true,                      //是否显示行间隔色
                pagination: true,                   //是否显示分页（*）
                sortOrder: "asc",
                sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
                pageNumber: 1,                       //初始化加载第一页，默认第一页
                pageSize: 15,                       //每页的记录行数（*）
                pageList: [15, 30, 50],        //可供选择的每页的行数（*）
                minimumCountColumns: 2,  //最少允许的列数
                height: $(".centerdiv").height()-20,               //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
                uniqueId: "nub",            //每一行的唯一标识，一般为主键列
                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: 'LNAME', title: '线路名称' },
                   { field: 'BNAME', title: '客户名称' },
                   { field: 'ADDRESS', title: '客户地址' },
                   { field: 'ENAME', title: '业务员' },
                   { field: 'ACCURACY', title: '偏离差(米)' },
                    { field: 'BFADDRESS', title: '到店地址' },
                   { field: 'TIME', title: '到店时间' },
                   { field: 'ENDTIME', title: '离店时间' },
                   { field: 'INTIME', title: '服务时间' },
                   { field: 'OUTTIME', title: '在途时间' }
                ], onLoadSuccess: function (data) {
                    $("#hidCount").val(data.total);
                }
            });
            $(window).resize(function () { $('#GetBtypeSignTable').bootstrapTable('resetView'); });
        });
        //列表查询
        $("#btnSearch").on("click", function () {
            var stardate = $("#pmStartDate").val();
            var enddate = $("#pmEndDate").val();
            var rsNum = $("#uploadliginid").val();
            var loginUser = $("#logionUser option:selected").val();
            var minAccuracy = $("#minAccuracy").val();
            var maxAccuracy = $("#maxAccuracy").val();
            $('#GetBtypeSignTable').bootstrapTable("refresh", {
                url: "../DataQuery/GetBtypeSignList?stardate=" + stardate + "&enddate=" + enddate + "&EtypeId=" + loginUser + "&customerId=" + rsNum + "&maxAccuracy=" + maxAccuracy + "&minAccuracy=" + minAccuracy
            })
        });

        //Excel导出
        $("#btnExcel").on("click", function () {
            var stardate = $("#pmStartDate").val();
            var enddate = $("#pmEndDate").val();
            var rsNum = $("#uploadliginid").val();
            var loginUser = $("#logionUser option:selected").val();
            var minAccuracy = $("#minAccuracy").val();
            var maxAccuracy = $("#maxAccuracy").val();
            window.location.href = '../DataQuery/GetExcelBtypeSignList?stardate=' + stardate + "&enddate=" + enddate + "&EtypeId=" + loginUser + "&customerId=" + rsNum + "&pagesize=" + parseInt($("#hidCount").val()) + "&page=0&maxAccuracy=" + maxAccuracy + "&minAccuracy=" + minAccuracy
        });

        //选择客户
        function ClientName() {
            layer.open({
                type: 2,
                title: '@ViewBag.Title 客户信息',
                shadeClose: false,
                shade: 0.5,
                area: ['80%', '70%'],
                content: '../CommonSelector/ClientSelector'
            });
        }
        //content: '/DataQuery/ClientName'

        //清除选择的客户
        function Clear() {
            $("#rsNum").val("");
            $("#uploadliginid").val("");
        }
    </script>
