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

<%@ Register Src="../../Controls/Condition.ascx" TagName="Condition" TagPrefix="ucCondition" %>
<%@ Register Src="../../Controls/Date.ascx" TagName="Date" TagPrefix="ucDate" %>
<%@ Register Src="../../Controls/Pager.ascx" TagName="Pager" TagPrefix="ucPager" %>
<%@ Register Src="../../Controls/Grid.ascx" TagName="Grid" TagPrefix="ucGrid" %>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../css/bill.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/My97DatePicker/My97DatePicker/WdatePicker.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>
    <script src="../../js/myLib/jsHelper_Base.js" type="text/javascript"></script>
    <style>
        .rpTree{font: 12px "微软雅黑","宋体"; width:100%; height:350px; border-top:1px solid #ccc;cursor:pointer; overflow-y:auto}
        .rpTree ul{ margin:0;list-style:none; padding:0}
        .rpTree li{ padding-left:10px; margin-top:2px}
    </style>
</head>
<body>
    <table>
        <tr>
            <td>
               <div class="pt-bill">
                   <form name="fCondition">
                        <div class="pt-padding">
                            <input type="button" id="btnQuery" class="pt-button active" value="查询" />
                        </div>
                        <ucCondition:Condition ID="name" Text="姓名" Name="name" runat="server" />
                        <ucDate:Date ID="ucDate" runat="server" />
                   </form>
                   <div class="pt-grid_frame" style="height:400px">
                        <ucGrid:Grid ID="grid" runat="server" />
                   </div>
                   <ucPager:Pager ID="gridPager" runat="server" />
               </div>
            </td>
            <td style="width:250px">
                <div id="Recipe">
                    <h1>Rp</h1>
                    <div class="rpTree">
                        <ul id="rpContent"></ul>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <script>
        var WesternHistroy = (function() {
            var dataSplit = 'Θ ☺ ☻'.split(' '), //单元格、行、表分隔符
            url = "ChineseHistory.aspx",
            grid = new Grid({ id: "grid", url: url, pager: new Pager("gridPager"), bindFun: bindData });
            function init() {
                top.art.dialog.data('recipeHistory', ""); //清空数据
                var name = top.art.dialog.data('wName');
                $(fCondition.name).val(name);
                DateValidate(document.getElementById("startDate"), document.getElementById("endDate"));
                grid.search();
                bindEvents();
            }
            function bindEvents() {
                $("#btnQuery").click(function() {
                    grid.search(true);
                });
                grid.control.click(function(e) {
                    var target = $(e.target), tr = null;
                    if (target.is("input")) {
                        tr = target.parent().parent();
                    } else if (target.is("td")) {
                        tr = target.parent();
                    } else if (target.is("tr")) {
                        tr = target;
                    }
                    if (tr != null) {
                        //设置高亮
                        tr.siblings().removeClass("pt-highlight");
                        tr.addClass("pt-highlight");
                        bindRp(tr.data("data").wNum);
                    }
                    if (target.is("input")) {
                        top.art.dialog.data('recipeHistory', tr.data("data").wNum); // 存储数据
                        top.art.dialog.close('Chinese_History');
                    }
                });
            }
            function bindRp(num) {
                $.get(url, { action: "getRp", num: num }, function(data) {
                    $("#rpContent").html(data);
                });
            }
            function bindData(tr, data) {
                tr.append($("<td>").html('<input type="button" value="调用" class="pt-button active" />'))
                .append($("<td>").html(data.wDate))
                .append($("<td>").html(data.wNum))
                .append($("<td>").html(data.wDiagnosis));
            }
            init();
        })();
    </script>
</body>
</html>

