<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OfflineRLSearch.aspx.cs" Inherits="M_Main.ChargesNew.OfflineRLSearch" %>


<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript" src="../jscript/DateControl.js"></script>
    <script type="text/javascript" src="../jscript/JSClient.js"></script>
    <script type="text/javascript" src="../jscript/ajax.js"></script>
    <script type="text/javascript" src="../jscript/Keydown.js" event="onkeydown" for="document"></script>

    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script src="../jscript/JSClient.js" type="text/javascript"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/icon.css" />
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
    <link href="../css/framesearch.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>

    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <link href="../css/framesearch_old.css" type="text/css" rel="stylesheet" />
    <link href="../css/button.css" rel="stylesheet" />
    <script src="../jscript/DateFormat.js" type="text/javascript"></script>
    <script src="../jscript/format.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        input {
            /*width: 91.7%;*/
        }
    </style>
</head>
<body>
    <form id="frmForm" runat="server">
        <input id="IsDelete" name="IsDelete" runat="server" value="0" type="hidden" />
        <input id="IsLs" name="IsLs" runat="server" value="1" type="hidden" />
        <input type="hidden" id="LsData" name="LsData" />
        <div class="SearchContainer" id="TableContainer">
        </div>
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" data-options="iconCls:'icon-search',closed: true,modal:true"
            style="width: 700px; height: 250px;">

            <table class="DialogTable">
                <tr class="hid-tr">
                    <td class="TdTitle">项目名称
                    </td>
                    <td colspan="3">
                        <input id="CommName" name="CommName" runat="server" onclick="SelComm();" style="width: 90%" />
                        <input id="CommID" size="1" type="hidden" name="CommID" runat="server" />
                        <input id="hidCommId" size="1" type="hidden" name="hidCommId" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">收据类型
                    </td>
                    <td class="TdContentSearch">
                        <select id="DrReceive" runat="server" name="DrReceive">
                            <option value="1" selected>收款收据</option>
                            <option value="2">预存收据</option>
                            <%--<option value="3">退款票据</option>--%>
                        </select></td>
                    <td class="TdTitle"></td>
                    <td class="TdContentSearch"></td>
                </tr>
                <tr>
                    <td class="TdTitle">客户名称</td>
                    <td class="TdContentSearch">
                        <input id="CustName" searcher="SelCust"
                            name="CustName" class="easyui-searchbox" runat="server" data-options="editable:false" /><input id="CustID" style="width: 8px; height: 19px" type="hidden"
                                size="1" name="CustID" runat="server" /><input id="hiCustName" style="width: 12px; height: 19px" type="hidden"
                                    size="1" name="hiCustName" runat="server" /></td>
                    <td class="TdTitle">可选房号
                    </td>
                    <td class="TdContentSearch">
                        <select id="SelectRoomID" class="easyui-combobox" data-options="editable:false,panelHeight: 'auto'" name="SelectRoomID" onchange="javascript:SelectRoomID_OnChange();" runat="server">
                            <option selected></option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">房屋编号</td>
                    <td class="TdContentSearch">
                        <input id="RoomSign" searcher="SelRoom"
                            name="RoomSign" class="easyui-searchbox" runat="server" data-options="editable:false" /><input id="RoomID" style="width: 8px; height: 22px" type="hidden"
                                size="1" name="RoomID" runat="server" /><input id="hiRoomSign" style="width: 8px; height: 22px" type="hidden"
                                    size="1" name="hiRoomSign" runat="server" /></td>
                    <td class="TdTitle">收据号码</td>
                    <td class="TdContent">
                        <input id="BillsSign" type="text"
                            name="BillsSign" runat="server" /></td>
                </tr>

                <tr>
                    <td class="TdTitle">收费日期</td>
                    <td class="TdContent" colspan="3"><input id="EditBeginDate" class="Wdate" style="width: 40%;margin-left:6px;margin-right:6px" onclick="WdatePicker({ startDate: '%y-%M-01 00:00:00', dateFmt: 'yyyy-MM-dd', alwaysUseStartDate: true })" type="text" maxlength="50" name="EditBeginDate" runat="server">
                        到<input class="Wdate" id="EditEndDate" style="width: 40%;margin-left:6px" onclick="WdatePicker({ startDate: '%y-%M-01 00:00:00', dateFmt: 'yyyy-MM-dd', alwaysUseStartDate: true })" type="text" maxlength="50" name="EditEndDate" runat="server">
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">认领时间</td>
                    <td class="TdContent" colspan="3"><input class="Wdate" id="rldateBegin" style="width: 40%;margin-left:6px" 
                            onclick="WdatePicker({ startDate: '%y-%M-01 00:00:00', dateFmt: 'yyyy-MM-dd', alwaysUseStartDate: true })" type="text" maxlength="50" name="rldateBegin" runat="server">
                         到<input class="Wdate" id="rldateEnd" style="width: 40%;margin-left:6px" 
                            onclick="WdatePicker({ startDate: '%y-%M-01 00:00:00', dateFmt: 'yyyy-MM-dd', alwaysUseStartDate: true })" type="text" maxlength="50" name="rldateEnd" runat="server">
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">认领人</td>
                    <td class="TdContent">
                        &nbsp;<input type="text" id="rlUserName" name="rlUserName" runat="server" /></td>
                </tr>
                <tr>
                    <td align="center" colspan="4">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="LoadList();">查询</a>
                    </td>
                </tr>
            </table>
        </div>

        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">

            function InitFunction() {
                var h = $(window).height();
                $("#TableContainer").css("height", h + "px");
                $('#SelectRoomID').css("width", 150 + 'px');

                if ($("#hidCommId").val() != '0') {
                    $('.hid-tr').hide();
                }
            }
            InitFunction();

            function SelComm() {
                if ($("#hidCommId").val() != '0')
                    return;

                var w = $(window).width() * 0.7;
                HDialog.Open(w, 500, '../DialogNew/SelComm.aspx?IsCheck=0&isCommID=0', "选择管理项目", false, function callback(_Data) {
                    var arrRet = JSON.parse(_Data);
                    $("#CommID").val(arrRet.id);
                    $("#CommName").val(arrRet.name);
                });
            }

            function SelCust() {

                if ($("#CommID").val() == '') {
                    HDialog.Info("请选择项目");
                    return;
                }
                $('#CustName').searchbox("setValue", '');
                $('#CustID').val('');
                $('#RoomSign').searchbox("setValue", '');
                $('#RoomID').val('');
                $('#SelectRoomID').combobox({ data: [], valueField: 'RoomID', textField: 'RoomText' });


                var w = 700;
                var h = 400;

                var conent = "../DialogNew/CustDlg.aspx?CommID=" + $("#CommID").val();

                HDialog.Open(w, h, conent, '客户选择', false, function callback(_Data) {
                    var data = JSON.parse(_Data);
                    $('#CustName').searchbox("setValue", data.CustName);
                    $('#CustID').val(data.CustID);


                    $.tool.DataGet('Choose', 'CustRoomSigns', "CustID=" + data.CustID,
                        function Init() {
                        },
                        function callback(_Data) {

                            varObjects = eval("(" + _Data.replace(/\\/g, "/") + ")"); //转换为json对象
                            if (varObjects.length > 0) {

                                var RoomData = [];
                                for (var i = 0; i < varObjects.length; i++) {

                                    var vIsDelLive = varObjects[i].IsDelLive;
                                    var strTmp = "";

                                    if (vIsDelLive == 1) {
                                        strTmp = "(历史)";
                                    }
                                    var RoomID = varObjects[i].RoomID;
                                    var RoomSign = varObjects[i].RoomSign;
                                    var Buildarea = varObjects[i].BuildArea;

                                    var RoomText = RoomSign + "(" + Buildarea + ")" + strTmp;

                                    RoomData.push({ "RoomText": RoomText, "RoomID": RoomID + "|" + Buildarea });

                                }
                                $('#SelectRoomID').combobox({
                                    data: RoomData,
                                    valueField: 'RoomID',
                                    textField: 'RoomText',
                                    onChange: function (n, o) {


                                        var data = $('#SelectRoomID').combobox('getData');
                                        if (data.length > 0) {
                                            for (var i = 0; i < data.length; i++) {
                                                if (n == data[i].RoomID) {

                                                    $('#RoomSign').searchbox('setValue', data[i].RoomText);
                                                    var buildArea = data[i].RoomID.split("|")[1];
                                                    $('#BuildArea').val(buildArea);
                                                    $('#CalcArea').val(buildArea);
                                                    $('#RoomID').val(data[i].RoomID.split("|")[0]);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                });
                            }
                        },
                        function completeCallback() {
                        },
                        function errorCallback() {
                        });

                });
            }
            function SelRoom() {
                if ($("#CommID").val() == '') {
                    HDialog.Info("请选择项目");
                    return;
                }

                $('#CustName').searchbox("setValue", '');
                $('#CustID').val('');
                $('#RoomSign').searchbox("setValue", '');
                $('#RoomID').val('');
                $('#SelectRoomID').combobox({ data: [], valueField: 'RoomID', textField: 'RoomText' });


                var conent = "../DialogNew/RoomDlg.aspx?CommID=" + $("#CommID").val();


                var w = $(window).width();
                var h = $(window).height();

                HDialog.Open(w, h, conent, '房屋选择', false, function callback(_Data) {
                    var data = JSON.parse(_Data);
                    $('#RoomSign').searchbox("setValue", data.RoomSign);
                    $('#CustName').searchbox("setValue", data.CustName);
                    $('#CustID').val(data.CustID);
                    $('#RoomID').val(data.RoomID);

                    $('#BuildArea').val(data.BuildArea);
                    $('#CalcArea').val(data.BuildArea);
                });
            }




            var columnReceipts = [[
                { field: 'ReceID', title: 'ReceID', width: 50, align: 'left', sortable: true, hidden: true },
                { field: 'CommName', title: '项目名称', width: 100, align: 'left', sortable: true },
                { field: 'CustName', title: '客户名称', width: 100, align: 'left', sortable: true },
                { field: 'RoomSign', title: '房屋编号', width: 100, align: 'left', sortable: true },
                { field: 'RoomName', title: '房屋名称', width: 100, align: 'left', sortable: true },
                { field: 'BillsSign', title: '票据号码', width: 100, align: 'left', sortable: true },
                { field: 'BillsAmount', title: '票据金额', width: 100, align: 'left', sortable: true },

                //{
                //    field: 'BillsSign', title: '票据号码', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {
                //        var str = "<a class=\"HrefStyle\"  href='#' onclick=\"ViewDetail('票据修改','" + row.ReceID + "');\">" + row.BillsSign + "</a>";
                //        return str;
                //    }
                //},
                { field: 'ChequeBill', title: '支/汇票号', width: 100, align: 'left', sortable: true },
                {
                    field: 'BillsDate', title: '收费日期', width: 150, align: 'left', sortable: true, formatter: function (value, row, index) {
                        var str = formatDate(row.BillsDate, "yyyy-MM-dd HH:mm:ss");
                        return str;
                    }
                },
                { field: 'ChargeMode', title: '收款方式', width: 180, align: 'left', sortable: true },
                { field: 'UserName', title: '收款人', width: 80, align: 'left', sortable: true },
                { field: 'ReceMemo', title: '备注', width: 100, align: 'left', sortable: true },
                { field: 'rlamount', title: '认领金额', width: 80, align: 'left', sortable: true },
                { field: 'rlUserName', title: '认领人', width: 80, align: 'left', sortable: true },
                { field: 'rldate', title: '认领时间', width: 150, align: 'left', sortable: true },
                {
                    field: '操作', title: '操作', width: 80, align: 'left', sortable: true, formatter: function (value, row, index) {
                        var str = "<a class=\"HrefStyle\"  href='#' onclick=\"ViewDetail('" + row.ReceID + "');\">查看</a>";
                        return str;
                    }
                }


            ]];

            var columnPrecReceipts = [[
                { field: 'ReceID', title: 'ReceID', width: 50, align: 'left', sortable: true, hidden: true },
                { field: 'CommName', title: '项目名称', width: 100, align: 'left', sortable: true },
                { field: 'CustName', title: '客户名称', width: 100, align: 'left', sortable: true },
                { field: 'RoomSign', title: '房屋编号', width: 100, align: 'left', sortable: true },
                { field: 'RoomName', title: '房屋名称', width: 100, align: 'left', sortable: true },
                { field: 'BillsSign', title: '票据号码', width: 100, align: 'left', sortable: true },
                //{
                //    field: 'BillsSign', title: '票据号码', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {
                //        var str = "<a class=\"HrefStyle\"  href='#' onclick=\"ViewDetail('票据修改','" + row.ReceID + "');\">" + row.BillsSign + "</a>";
                //        return str;
                //    }
                //},
                { field: 'BillsAmount', title: '票据金额', width: 100, align: 'left', sortable: true },
                { field: 'ChequeBill', title: '支/汇票号', width: 100, align: 'left', sortable: true },
                {
                    field: 'BillsDate', title: '收费日期', width: 150, align: 'left', sortable: true, formatter: function (value, row, index) {
                        var str = formatDate(row.BillsDate, "yyyy-MM-dd HH:mm:ss");
                        return str;
                    }
                },
                { field: 'ChargeMode', title: '收款方式', width: 180, align: 'left', sortable: true },
                { field: 'UserName', title: '收款人', width: 80, align: 'left', sortable: true },
                { field: 'ReceMemo', title: '备注', width: 100, align: 'left', sortable: true },
                { field: 'rlamount', title: '认领金额', width: 100, align: 'left', sortable: true },
                { field: 'rlUserName', title: '认领人', width: 80, align: 'left', sortable: true },
                { field: 'rldate', title: '认领时间', width: 150, align: 'left', sortable: true },
                {
                    field: '操作', title: '操作', width: 80, align: 'left', sortable: true, formatter: function (value, row, index) {
                        var str = "<a class=\"HrefStyle\"  href='#' onclick=\"ViewDetail('" + row.ReceID + "');\">查看</a>";
                        return str;
                    }
                }


            ]];

            var toolbar = [
                {
                    text: '筛选',
                    iconCls: 'icon-search',
                    handler: function () {
                        $('#SearchDlg').parent().appendTo($("form:first"))
                        $('#SearchDlg').dialog('open');

                    }
                }, '-'
                , {
                    text: '反核销',
                    iconCls: 'icon-undo',
                    handler: function () {
                        LSRelateCancel();
                    }
                }, '-'
                , {
                    text: '导出Excel',
                    iconCls: 'icon-page_white_excel',
                    handler: function () {
                        window.open("../ChargesNew/OfflineRLSearchExcel.aspx?CommID=" + $("#CommID").val() + "&DrReceive=" + $('#DrReceive').val());
                    }
                }
            ];
            function LSRelateCancel() {

                var row = $("#TableContainer").datagrid("getSelected");
                if (row == null || row.length == 0) {
                    HDialog.Info('请选择要操作的费用！');
                    return;
                }

                var receid = row.ReceID;
                console.log(receid);

                $.tool.DataGet('Allinpay', 'LSRelateCancel', 'random=' + Math.random() + '&ReceID=' + receid,
                    function Init() {
                    },
                    function callback(_Data) {
                        HDialog.Info('反核销成功！');
                        LoadList(true);
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });
            }

            function ViewDetail(ReceID) {

                HDialog.Open('1500', '650', '../ChargesNew/OfflineRLDetailSearch.aspx?ReceID=' + ReceID + "&CommID=" + $("#CommID").val(), '查看明细', false, function callback(_Data) {
                    
                });
            }

            function LoadList(init) {
                if (!init && $("#CommID").val() == '') {
                    HDialog.Info("请选择项目");
                    return;
                }
                var column = columnReceipts;

                if ($('#DrReceive').val() == "1") {
                    column = columnReceipts;
                }
                if ($('#DrReceive').val() == "2") {
                    column = columnPrecReceipts;
                }

                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataPostControl.aspx',
                    method: "post",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    fitColumns: true,
                    remoteSort: false,
                    singleSelect: true,
                    pagination: true,
                    width: "100%",
                    toolbar: toolbar,
                    sortOrder: "asc",
                    singleSelect: true,
                    selectOnCheck: false,
                    checkOnSelect: false,
                    rownumbers: true,
                    border: false,
                    toolbar: toolbar,
                    sortOrder: "asc",
                    onBeforeLoad: function (param) {
                        if ($('#DrReceive').val() == "1") {
                            param = $.JQForm.GetParam("FeesReceipts", "ReceiveFeesCancelRlResult", "TableContainer", param);
                        }
                        if ($('#DrReceive').val() == "2") {
                            param = $.JQForm.GetParam("FeesReceipts", "PreCostsReceiptsRlResult", "TableContainer", param);
                        }
                        //if ($('#DrReceive').val() == "3") {
                        //    param = $.JQForm.GetParam("FeesReceipts", "RefundFeesReceiptsAll", "TableContainer", param);
                        //}
                    },
                    onLoadSuccess: function (data) {
                    }
                });

                $('#SearchDlg').dialog('close');
            }

            LoadList(true);

        </script>
    </form>
</body>
</html>


