<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AllotConfirm.aspx.cs" Inherits="Medical.MBusiness.SysAllot.AllotConfirm" %>

<%@ Register Src="../../Controls/Date.ascx" TagName="Date" TagPrefix="ucDate" %>
<%@ Register Src="../../Controls/Pager.ascx" TagName="Pager" TagPrefix="ucPager" %>
<%@ Register Src="../../Controls/LoadButton.ascx" TagName="LoadButton" TagPrefix="ucLoadButton" %>
<!DOCTYPE html>
<html>
<head>
    <title><%=ModuleName%></title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/myLib/jsHelper_Form.js" type="text/javascript"></script>
    <script src="../../js/myLib/Pager.js" type="text/javascript"></script>
    <script src="../../js/myLib/Grid.js" type="text/javascript"></script>
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" style="display:none" >
        <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0"></embed>
    </object>
    <script src="../../Scripts/LodopFuncs.js" type="text/javascript"></script>
    <script src="../../js/myLib/Print.js" type="text/javascript"></script>
</head>
<body>
    <div class="pt-panel">
        <strong><%=ModuleName%></strong>
        <form name="fCondition" class="pt-padding">
        <ucLoadButton:LoadButton ID="LoadButton1" runat="server"/>
        <dl>
            <dt>调出仓库</dt>
            <dd><input type="text" name="outWarehouse" /></dd>
        </dl>
        <dl>
            <dt>调入仓库</dt>
            <dd><input type="text" name="inWarehouse" /></dd>
        </dl>
        <dl>
            <dt>入库单号</dt>
            <dd><input type="text" name="num" /></dd>
        </dl>
        <ucDate:Date ID="ucDate" runat="server" />
        <dl>
            <dt><input type="checkbox" name="isConfirm" value="1" checked="checked" /></dt>
            <dd>只显示未入库确认</dd>
        </dl>
        </form>
    </div>
    <div class="pt-panel pt-below">
        <strong>查询一览</strong>
        <div class="pt-grid_frame">
            <table class="pt-grid" id="grid">
                <thead>
                    <tr>
                        <th style="width:200px">操作</th>
                        <th>调拨单号</th>
                        <th>调出仓库</th>
                        <th>调入仓库</th>
                        <th>调拨日期</th>
                        <th>经手人</th>
                        <th>是否确认</th>
                        <th>确认时间</th>
                        <th>确认人</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <ucPager:Pager ID="gridPager" runat="server" />
    </div>
    <script>
        (function() {
            var url = "AllotConfirm.aspx",
            dialogUrl = "/MBusiness/SysAllot/AllotForm.aspx",
            dialogFormName = "Allot_Form",
            listbutton = '<%=Medical.MCommon.PageHelper.GetListButton() %>',
            button = $("<div>").append(listbutton),
            grid = new Grid({ id: "grid", url: url, pager: new Pager("gridPager"), bindFun: bindData }),
            title = '<%=ModuleName %>',
            printModule = new Print({model:2});

            function init() {
                grid.search();
                bindEvents();
            }

            function bindEvents() {
                $("#btnQuery").click(function() {
                    grid.search(true);
                });
                grid.control.click(function(e) {
                    var target = $(e.target);
                    if (target.is("input") && !target.is(":disabled")) {
                        var data = target.parent().parent().data("data");
                        switch (target.val()) {
                            case "查看":
                                top.openDialog(dialogUrl + "?type=view&key=" + data.Num, dialogFormName, title + ' - 查看', 1000, 530, 50, 50);
                                break;
                            case "调拨确认":
                                top.showConfirmMsg("要调拨确认吗?", function(r) {
                                    if (r) {
                                        confirm(data.Num);
                                    }
                                });
                                break;
                            case "打印":
                                print(data.Num);
                                break;
                        }
                    }
                });
            }
            function print(num) {
                $.get(url, { action: "print", num: num }, function(data) {
                    printModule.print(data, false)
                })
            }
            function confirm(num) {
                $.get(url, { action: "confirm", num: num }, function(data) {
                    if (parseInt(data, 10) == 200) {
                        top.showTipsMsg('调拨确认操作成功!', 0, 3000);
                        location.reload();
                    } else {
                        top.showTipsMsg("操作失败!", 1, 4000);
                    }
                });
            }
            function bindData(tr, data) {
                var confirm = data.Confirm == "已确认", buttonTemp = button.clone();
                if (confirm) {
                    buttonTemp.find('[value="调拨确认"]').removeClass("pt-button active").addClass("pt-button-disabled").attr("disabled", true);
                } else {
                    buttonTemp.find('[value="打印"]').removeClass("pt-button active").addClass("pt-button-disabled").attr("disabled", true);
                }
                tr.append($("<td>").html(buttonTemp.html()))
                .append($("<td>").html(data.Num))
                .append($("<td>").html(data.Warehouse))
                .append($("<td>").html(data.Date))
                .append($("<td>").html(data.Supplier))
                .append($("<td>").html(data.Man))
                .append($("<td>").html(data.Confirm))
                .append($("<td>").html(data.ConfirmDate))
                .append($("<td>").html(data.ConfirmMan));
            }
            init();
        })();
    </script>
</body>
</html>

