<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SettlementList.aspx.cs" Inherits="Medical.MInterFace.SysRuralCooperative.SettlementList" %>

<%@ Register Src="../../Controls/Pager.ascx" TagName="Pager" TagPrefix="ucPager" %>
<%@ Register Src="../../Controls/LoadButton.ascx" TagName="LoadButton" TagPrefix="ucLoadButton" %>
<!DOCTYPE html>
<html>
<head>
    <title>新农合结算</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="../../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>
</head>
<body>
    <div class="pt-panel">
        <strong>新农合结算</strong>
        <form name="fCondition">
            <ucLoadButton:LoadButton ID="LoadButton1" runat="server"/>
            <dl>
                <dt>起始日期</dt>
                <dd><input type="text" runat="server" id="startDate" name="startDate" onclick="WdatePicker()" /></dd>
            </dl>
            <dl>
                <dt>截至日期</dt>
                <dd><input type="text" runat="server" id="endDate" name="endDate" onclick="WdatePicker()"/></dd>
            </dl>
            <dl>
                <dt><input type="checkbox" name="isNoSettlement" 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" style="width:1600px">
                <thead>
                    <tr>
                        <th rowspan='2'>操作</th>
                        <th rowspan='2'>门诊号</th>
                        <th rowspan='2'>处方编号</th>
                        <th rowspan='2'>姓名</th>
                        <th rowspan='2'>医疗证号</th>
                        <th rowspan='2'>诊断</th>
                        <th rowspan='2'>医生</th>
                        <th rowspan='2'>收费日期</th>
                        <th rowspan='2'>收费人</th>
                        <th colspan='2'>药品费</th>
                        <th rowspan='2'>一般诊疗费</th>
                        <th rowspan='2'>床位费</th>
                        <th rowspan='2'>检验费</th>
                        <th colspan='4'>检查费</th>
                        <th colspan='2'>治疗费</th>
                        <th rowspan='2'>手术费</th>
                        <th rowspan='2'>其他</th>
                        <th rowspan='2'>应收合计</th>
                        <th rowspan='2'>实收合计</th>
                        <th rowspan='2'>新农合统筹报销</th>
                    </tr>
                    <tr>
                        <th>西药</th>
                        <th>中药</th>
                        <th>心电图</th>
                        <th>B超</th>
                        <th>X线</th>
                        <th>其他</th>
                        <th>西医治疗费</th>
                        <th>中医治疗费</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
        <ucPager:Pager ID="gridPager" runat="server" />
    </div>
    <script>
        (function() {
            var url = "SettlementList.aspx",
            listbutton = '<%=Medical.MCommon.PageHelper.GetListButton() %>',
            button = $("<div>").append(listbutton),
            grid = new Grid({ id: "grid", url: url, pager: new Pager("gridPager"), bindFun: bindData });

            function init() {
                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);
                    if (target.is("input") && !target.is(":disabled")) {
                        var data = target.parent().parent().data("data");
                        switch (target.val()) {
                            case "查看":
                                top.openDialog("/MInterFace/SysRuralCooperative/SettlementDetails.aspx?key="+data.cID, "Settlement_Details", '结算信息 - 查看', 800, 500, 50, 50, callback);
                                break;
                            case "结算":
                                top.openDialog("/MInterFace/SysRuralCooperative/SettlementForm.aspx?key="+data.cID, "Settlement_Form", '疾病编码 - 选择', 500, 500, 50, 50, callback);
                                break;
                            case "取消结算":
                                cancelSettlement(data.cID);
                                break;
                        }
                    }
                });
            }
            function cancelSettlement(cID){
                $.get(url,{action:"cancelSettlement",id:cID},function(data){
                    if(data=="200"){
                        top.showTipsMsg('已取消成功!', 0, 3000);
                        grid.search();
                    } else {
                        top.showTipsMsg("操作失败，请稍后重试", 1, 3000);
                    }
                });
            }
            function callback(){
                grid.search(true);
            }
            function bindData(tr, data) {
                var buttonTemp = button.clone();
                if (data.XNH_JSBZ=='0') {//未结算
                    buttonTemp.find('[value="查看"]').removeClass("pt-button active").addClass("pt-button-disabled").attr("disabled", true);
                    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.wCode))
                .append($("<td>").html(data.cNum))
                .append($("<td>").html(data.wName))
                .append($("<td>").html(data.wMedicalCode))
                .append($("<td>").html(data.wDiagnosis))
                .append($("<td>").html(data.wDoctor))
                .append($("<td>").html(data.wChargeDate))
                .append($("<td>").html(data.wChargeMan))
                .append($("<td>").html(data.cWesternDrug))
                .append($("<td>").html(data.cChineseDrug))
                .append($("<td>").html(data.cGeneral))
                .append($("<td>").html(data.cObserve))
                .append($("<td>").html(data.cInspection))
                .append($("<td>").html(data.cECG))
                .append($("<td>").html(data.cBScan))
                .append($("<td>").html(data.cXRay))
                .append($("<td>").html(data.cIOther))
                .append($("<td>").html(data.cWesternCure))
                .append($("<td>").html(data.cChineseCure))
                .append($("<td>").html(data.cOperation))
                .append($("<td>").html(data.cOther))
                .append($("<td>").html(data.cReceivable))
                .append($("<td>").html(data.cReal))
                .append($("<td>").html(data.cExpenseAccount));
            }
            init();
        })();
    </script>
</body>
</html>
