@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
@section head{}
@section scripts{
    <script type="text/javascript">
        $(function () {
            $("#btnCheckCus").show();
            $("#rsNum").show();
            $("#user").hide();
            $("#pmStartDate").hide();
            $("#imgType").hide();
            $("#pmEndDate").hide();
            $("#hidBtnType").val("btypename");
            $.ajax({
                url: "../DataQuery/PhotoList",
                data: {
                    pagetype: "btypename",
                },
                datatype: "text",
                type: "post",
                success: function (data) {
                    document.getElementById("photoList").innerHTML = data;
                }
            })
        });

        //按客户查询
        $("#btnSeachName").on("click", function () {
            $("#btnCheckCus").show();
            $("#rsNum").show();
            $("#rsNum").val("");
            $("#user").hide();
            $("#pmStartDate").hide();
            $("#imgType").hide();
            $("#pmEndDate").hide();
            $("#hidBtnType").val("btypename");
            $.ajax({
                url: "../DataQuery/PhotoList",
                data: {
                    pagetype: "btypename",
                },
                datatype: "text",
                type: "post",
                success: function (data) {
                    document.getElementById("photoList").innerHTML = data;
                }
            })
        });

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

        //按业务员查询
        $("#btnSeachUser").on("click", function () {
            $("#btnCheckCus").hide();
            $("#rsNum").hide();
            $("#rsNum").val("");
            $("#user").show();
            $("#imgType").hide();
            $("#pmStartDate").hide();
            $("#pmEndDate").hide();
            $("#hidBtnType").val("emporename");
            $.ajax({
                url: "../DataQuery/PhotoList",
                data: {
                    pagetype: "emporename",
                },
                datatype: "text",
                type: "post",
                success: function (data) {
                    document.getElementById("photoList").innerHTML = data;
                }
            })
        });

        //按类型查询
        $("#btnSeachType").on("click", function () {
            $("#btnCheckCus").hide();
            $("#rsNum").hide();
            $("#user").hide();
            $("#imgType").show();
            $("#pmStartDate").hide();
            $("#pmEndDate").hide();
            $("#hidBtnType").val("ptypetype");
            $.ajax({
                url: "../DataQuery/PhotoList",
                data: {
                    pagetype: "ptypetype",
                },
                datatype: "text",
                type: "post",
                success: function (data) {
                    document.getElementById("photoList").innerHTML = data;
                }
            })
        });

        //弹出照片页面
        function GetImgList(id) {
            var btnType = $("#hidBtnType").val();
            $("#hidPid").val(id);

            layer.open({
                type: 2,
                title: '@ViewBag.Title 客户信息',
                shadeClose: false,
                shade: 0.5,
                area: ['80%', '90%'],
                content: '../DataQuery/ImageData?btnType=' + btnType + '&id=' + id
            });
        }
        //按时间查询
        $("#btnSeachTime").on("click", function () {
            $("#btnCheckCus").hide();
            $("#rsNum").hide();
            $("#user").hide();
            $("#imgType").hide();
            $("#pmStartDate").show();
            $("#pmEndDate").show();
            $("#hidBtnType").val("imagetime");

            $.ajax({
                url: "../DataQuery/PhotoList",
                data: {
                    pagetype: "imagetime",
                },
                datatype: "text",
                type: "post",
                success: function (data) {
                    document.getElementById("photoList").innerHTML = data;
                }
            })
        });

        //列表查询
        $("#btnSeach").on("click", function () {
            var stardate = $("#pmStartDate").val();
            var enddate = $("#pmEndDate").val();
            var rsNum = $("#uploadliginid").val();  //客户ID
            var loginUser = $("#user option:selected").val();  //业务员
            var imgType = $("#imgType option:selected").val();  //业务员
            var btnType = $("#hidBtnType").val();  //查询类型
            $.ajax({
                url: "../DataQuery/PhotoList",
                data: {
                    pagetype: btnType,
                    tdate: stardate,
                    endate: enddate,
                    btypeid: rsNum,
                    userid: loginUser,
                    imgType: imgType
                },
                datatype: "text",
                type: "post",
                success: function (data) {
                    document.getElementById("photoList").innerHTML = data;

                }
            })
        });

        //刷新图片
        $("#btnRefresh").on("click", function () {
            $.ajax({
                url: "../DataQuery/RefreshImage",
                data: {
                },
                datatype: "text",
                type: "post",
                success: function (data) { 
                    document.getElementById("photoList").innerHTML = data;
                }
            })
        });

    </script>
}
<div class="topdiv">
    <div class="ibox-content">
        <table class="table table-bordered table-striped table-hover">
            <tr>
                <td style="width: 160px">
                    <input id="uploadliginid" type="hidden" />
                    <input type="text" id="rsNum" readonly="true" />
                    <select id="user">
                        @{
                            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>
                    <select id="imgType" style="width: 110px">
                        <option value="">----请选择----</option>
                        @{
                            if (@ViewBag.imgdt != null && @ViewBag.imgdt.Rows.Count > 0)
                            {
                                for (int i = 0; i < @ViewBag.imgdt.Rows.Count; i++)
                                {
                                    <option value='@ViewBag.imgdt.Rows[i]["TypeID_"]'>@ViewBag.imgdt.Rows[i]["FullName"] </option>
                                }
                            }
                        }
                    </select>
                    <input type="text" style="width: 110px" onfocus="WdatePicker({isShowClear:false,readOnly:true})" id="pmStartDate" value="@ViewBag.pmStartDate" />

                </td>
                <td style="width: 160px">
                    <input type="text" style="width: 110px" onfocus="WdatePicker({isShowClear:false,readOnly:true})" id="pmEndDate" value="@ViewBag.pmEndDate" />
                    <button id="btnCheckCus" class="glyphicon glyphicon-plus btn btn-default"></button>
                    @*<span id="btnCheckUser" class="glyphicon glyphicon-plus btn btn-mini"></span>*@
                </td>
                <td>
                    <button id="btnSeach" class="btn btn-default"><i class="glyphicon glyphicon-zoom-in"></i> 查询</button>
                    <button id="btnRefresh" class="btn btn-default"><i class="glyphicon glyphicon-refresh"></i> 刷新</button>
                    <button id="btnSeachTime" class="btn btn-default" style="float: right; margin-right: 3px;"><i class="glyphicon glyphicon-search"></i> 时间</button>
                    <button id="btnSeachType" class="btn btn-default" style="float: right; margin-right: 3px;"><i class="glyphicon glyphicon-search"></i> 类型</button>
                    <button id="btnSeachUser" class="btn btn-default" style="float: right; margin-right: 3px;"><i class="glyphicon glyphicon-search"></i> 业务员</button>
                    <button id="btnSeachName" class="btn btn-default" style="float: right; margin-right: 3px;"><i class="glyphicon glyphicon-search"></i> 客户名称</button>
                    <input id="hidBtnType" type="hidden" />
                    <input id="hidPid" type="hidden" />
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="centerdiv">
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div id="photoList">
                </div>
            </div>
        </div>
    </div>
</div>
