//@ sourceURL=zy_daily.js
var LODOP; //声明为全局变量
//默认打印机下标
var printIndex = -1;
//数据缓存
var fullData;
$(function () {
    initFeeTable();
    //重置查询参数
    $('#btn_clean').click(function () {
        cleanParams();
    });
    //初始化页面上面的按钮事件
    $("#btn_daily").click(function (t) {
        dcountCharge();
    });

    setTimeout(function () {
        getLodop();
    }, 800);
});

/**
 * 列表类型按钮切换事件
 * @param object
 */
function reportButtonChange(object) {
    $("#pay_mark_group").find("button").each(function (index, element) {
        if ($(element).hasClass("btn-primary")) {
            $(element).removeClass("btn-primary").addClass("btn-default");
        }
    });
    $(object).removeClass("btn-default").addClass("btn-primary");
    initFeeTable();
}


/**
 * 初始化收费表格
 */
function initFeeTable() {
    $('#tb_table').bootstrapTable("destroy");
    $("#report_table").removeClass("in").addClass("hide");
    var payMarkGroup = getIndex("pay_mark_group");
    if (payMarkGroup == 0) {
        getRjbb();
    } else if (payMarkGroup == 1) {
        getFsyjjmx();
    } else if (payMarkGroup == 2) {
        getJsbrmx();
    } else if (payMarkGroup == 3) {
        getJsfydjbb();
    } else if (payMarkGroup == 4) {
        getJsYjjDetailList();
    }

}


/**
 * 获取日结报表
 */
function getRjbb() {
    $("#report_table").removeClass("hide").addClass("in");
    $.ajax({
        type: "GET",
        url: '/thmz/getZyDailySettlementVo',
        contentType: "application/json;charset=UTF-8",
        dataType: "json",
        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
        success: function (res) {
            if (res == '401' || res == 401) {
                window.location.href = '/thmz/login/view'
                return;
            }
            if (res.code == 0) {
                var user = res.user;
                var data = res.data;
                fullData = data;
                $("#userIdCode").html(user.userCode);
                $("#username").html(user.userName);
                $("#lastDailyDate").html(format(data.lastDailyDate, "yyyy-MM-dd HH:mm:ss"));
                $("#currentDate").html(format(data.currentDate, "yyyy-MM-dd HH:mm:ss"));
                $("#depositCashNum").html(data.depositCashNum);
                $("#depositCashAmount").html(data.depositCashAmount.toFixed(2));
                $("#jsbkCashAmount").html(data.jsbkCashAmount.toFixed(2));

                $("#depositWxNum").html(data.depositWxNum);
                $("#depositWxAmount").html(data.depositWxAmount.toFixed(2));
                $("#jsbkWxAmount").html(data.jsbkWxAmount.toFixed(2));

                $("#depositZfbNum").html(data.depositZfbNum);
                $("#depositZfbAmount").html(data.depositZfbAmount.toFixed(2));
                $("#jsbkZfbAmount").html(data.jsbkZfbAmount.toFixed(2));

                $("#depositYbNum").html(data.depositYbNum);
                $("#depositYbAmount").html(data.depositYbAmount.toFixed(2));
                $("#jsbkYbAmount").html(data.jsbkYbAmount.toFixed(2));

                $("#depositYlkNum").html(data.depositYlkNum);
                $("#depositYlkAmount").html(data.depositYlkAmount.toFixed(2));
                $("#jsbkYlkAmount").html(data.jsbkYlkAmount.toFixed(2));

                $("#depositQtNum").html(data.depositQtNum);
                $("#depositQtAmount").html(data.depositQtAmount.toFixed(2));
                $("#jsbkQtAmount").html(data.jsbkQtAmount.toFixed(2));

                $("#depositTotalNum").html(data.depositTotalNum);
                $("#depositTotalAmount").html(data.depositTotalAmount.toFixed(2));
                $("#jsbkTotalAmount").html(data.jsbkTotalAmount.toFixed(2));

                $("#returnCashNum").html(data.returnCashNum);
                $("#returnCashAmount").html(data.returnCashAmount.toFixed(2));
                $("#jstkCashAmount").html(data.jstkCashAmount.toFixed(2));

                $("#returnWxNum").html(data.returnWxNum);
                $("#returnWxAmount").html(data.returnWxAmount.toFixed(2));
                $("#jstkWxAmount").html(data.jstkWxAmount.toFixed(2));

                $("#returnZfbNum").html(data.returnZfbNum);
                $("#returnZfbAmount").html(data.returnZfbAmount.toFixed(2));
                $("#jstkZfbAmount").html(data.jstkZfbAmount.toFixed(2));

                $("#returnYbNum").html(data.returnYbNum);
                $("#returnYbAmount").html(data.returnYbAmount.toFixed(2));
                $("#jstkYbAmount").html(data.jstkYbAmount.toFixed(2));

                $("#returnYlkNum").html(data.returnYlkNum);
                $("#returnYlkAmount").html(data.returnYlkAmount.toFixed(2));
                $("#jstkYlkAmount").html(data.jstkYlkAmount.toFixed(2));

                $("#returnQtNum").html(data.returnQtNum);
                $("#returnQtAmount").html(data.returnQtAmount.toFixed(2));
                $("#jstkQtAmount").html(data.jstkQtAmount.toFixed(2));

                $("#returnTotalNum").html(data.returnTotalNum);
                $("#returnTotalAmount").html(data.returnTotalAmount.toFixed(2));
                $("#jstkTotalAmount").html(data.jstkTotalAmount.toFixed(2));

                $("#yjjsjhjCashAmount").html(data.yjjsjhjCashAmount.toFixed(2));
                $("#jsbtCashAmount").html(data.jsbtCashAmount.toFixed(2));

                $("#yjjsjhjWxAmount").html(data.yjjsjhjWxAmount.toFixed(2));
                $("#jsbtWxAmount").html(data.jsbtWxAmount.toFixed(2));

                $("#yjjsjhjZfbAmount").html(data.yjjsjhjZfbAmount.toFixed(2));
                $("#jsbtZfbAmount").html(data.jsbtZfbAmount.toFixed(2));

                $("#yjjsjhjYbkAmount").html(data.yjjsjhjYbkAmount.toFixed(2));
                $("#jsbtYbkAmount").html(data.jsbtYbkAmount.toFixed(2));

                $("#yjjsjhjYlkAmount").html(data.yjjsjhjYlkAmount.toFixed(2));
                $("#jsbtYlkAmount").html(data.jsbtYlkAmount.toFixed(2));

                $("#yjjsjhjQtAmount").html(data.yjjsjhjQtAmount.toFixed(2));
                $("#jsbtQtAmount").html(data.jsbtQtAmount.toFixed(2));

                $("#yjjsjhjHjAmount").html(data.yjjsjhjHjAmount.toFixed(2));
                $("#jsbtHjAmount").html(data.jsbtHjAmount.toFixed(2));

                $("#yjjsjhjHjAmountStr").html(data.yjjsjhjHjAmountStr);
                $("#jsbtHjAmountStr").html(data.jsbtHjAmountStr);

                $("#sjhjCashAmount").html(data.sjhjCashAmount.toFixed(2));
                $("#sjhjWxAmount").html(data.sjhjWxAmount.toFixed(2));
                $("#sjhjZfbAmount").html(data.sjhjZfbAmount.toFixed(2));

                $("#sjhjYbkAmount").html(data.sjhjYbkAmount.toFixed(2));
                $("#sjhjYlkAmount").html(data.sjhjYlkAmount.toFixed(2));
                $("#zzAmount").html(data.zzAmount.toFixed(2));

                $("#jzAmount").html(data.jzAmount.toFixed(2));
                $("#totalByybdf").html(data.totalByybdf.toFixed(2));
                $("#fpxjAmount").html(data.fpxjAmount.toFixed(2));

                $("#totalCharge").html(data.totalCharge.toFixed(2));
                $("#depositByjzAmount").html(data.depositByjzAmount.toFixed(2));
                $("#receiptAmount").html(data.receiptAmount.toFixed(2));
                $("#fpCount").html(data.fpCount);
                var refunfZyDepositFileList = data.refunfZyDepositFileList;
                if (refunfZyDepositFileList.length == 0) {
                    $("#sfzffpmx_table").css("display", "none");
                } else if (refunfZyDepositFileList.length > 0) {
                    $("#sfzffpmx_table").css("display", "inline-block");
                    var html = '';
                    for (var i = 0; i < refunfZyDepositFileList.length; i++) {
                        html += '<tr>';
                        html += '<td>' + refunfZyDepositFileList[i].inpatient_no.trim() + '</td>';
                        html += '<td>' + refunfZyDepositFileList[i].amount.toFixed(2) + '</td>';
                        html += '<td>' + refunfZyDepositFileList[i].receipt_no.trim() + '</td>';
                        html += '<td>' + format(refunfZyDepositFileList[i].hs_time, "yyyy-MM-dd HH:mm:ss") + '</td>';
                        html += '<td>' + refunfZyDepositFileList[i].depo_type_name + '</td>';
                        if(refunfZyDepositFileList[i].deleted==undefined){
                            html += '<td>退费</td>';
                        }else {
                            html += '<td>作废</td>';
                        }
                        html += '</tr>';
                    }
                    $("#sfzffpmx").html(html);
                }
                $("#hsJe").html(data.hsJe.toFixed(2));
                $("#receiptNoBegin").html(data.receiptNoBegin);
                $("#receiptNoEnd").html(data.receiptNoEnd);
                $("#jsReceiptNoBegin").html(data.jsReceiptNoBegin);
                $("#jsReceiptNoEnd").html(data.jsReceiptNoEnd);
                $("#username_zbr").html(user.userName);
            } else if (res.code == -1) {
                new PNotify({
                    title: '错误提示',
                    text: res.message,
                    type: 'error',
                    hide: true,
                    styling: 'bootstrap3'
                });
            }
        }
    });
}

/**
 * 结算病人明细
 */
function getJsbrmx() {
    $('#tb_table').bootstrapTable({
        data: fullData.zyChargeDetailList,         //请求后台的URL（*）
        //method: 'post',                      //请求方式（*）
        toolbar: '#toolbar',                //工具按钮用哪个容器
        striped: true,                      //是否显示行间隔色
        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true,                   //是否显示分页（*）
        sortable: true,                     //是否启用排序
        sortOrder: "asc",                   //排序方式
        //queryParams: queryParams,           //传递参数（*）
        sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1,                       //初始化加载第一页，默认第一页
        pageSize: 10,                       //每页的记录行数（*）
        pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
        search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: true,
        showColumns: false,                  //是否显示所有的列
        showRefresh: false,                  //是否显示刷新按钮
        minimumCountColumns: 2,             //最少允许的列数
        clickToSelect: true,                //是否启用点击选中行
        uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
        showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
        cardView: false,                    //是否显示详细视图
        detailView: false,
        //rowStyle:rowStyle,//通过自定义函数设置行样式
        ajaxOptions: {
            headers: {
                'Accept': 'application/json',
                'Authorization': 'Bearer ' + localStorage.getItem("token")
            }
        },
        columns: [
            {
                field: 'inpatient_no',
                title: '住院号',
                align: "center",
                valign: 'middle'
            }, {
                field: 'name',
                title: '姓名',
                align: "center",
                valign: 'middle',
            }, {
                field: 'charge1',
                title: '西药费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge2',
                title: '中草药费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge3',
                title: '床位费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge4',
                title: 'B 超',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge5',
                title: '手术器械使用费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge6',
                title: '心电监护',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge7',
                title: '体外反搏',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge8',
                title: '电胸电图',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge9',
                title: '心脑电图',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge10',
                title: '麻醉费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge11',
                title: '透视照片',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge12',
                title: '手术费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge13',
                title: '化验',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge14',
                title: '输血',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge15',
                title: '输氧',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge16',
                title: '接生',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge17',
                title: '护婴',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge18',
                title: 'ＣＴ',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge19',
                title: '护理',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge20',
                title: '陪护',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge21',
                title: '理疗费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge22',
                title: '抢救',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge23',
                title: '卫生处理',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge24',
                title: '消毒',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge25',
                title: '治疗费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge26',
                title: '其他',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge27',
                title: '材料费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge28',
                title: '中成药费',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'total_charge',
                title: '总费用',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }
        ]
    });
}

/**
 * 发生预交金明细
 */
function getFsyjjmx() {
    $('#tb_table').bootstrapTable({
        data: fullData.chargeZyDepositFileList,         //请求后台的URL（*）
        //method: 'post',                      //请求方式（*）
        toolbar: '#toolbar',                //工具按钮用哪个容器
        striped: true,                      //是否显示行间隔色
        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true,                   //是否显示分页（*）
        sortable: true,                     //是否启用排序
        sortOrder: "asc",                   //排序方式
        //queryParams: queryParams,           //传递参数（*）
        sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1,                       //初始化加载第一页，默认第一页
        pageSize: 10,                       //每页的记录行数（*）
        pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
        search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: true,
        showColumns: false,                  //是否显示所有的列
        showRefresh: false,                  //是否显示刷新按钮
        minimumCountColumns: 2,             //最少允许的列数
        clickToSelect: true,                //是否启用点击选中行
        uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
        showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
        cardView: false,                    //是否显示详细视图
        detailView: false,
        //rowStyle:rowStyle,//通过自定义函数设置行样式
        ajaxOptions: {
            headers: {
                'Accept': 'application/json',
                'Authorization': 'Bearer ' + localStorage.getItem("token")
            }
        },
        columns: [
            {
                field: 'inpatient_no',
                title: '住院号',
                align: "center",
                valign: 'middle'
            }, {
                field: 'name',
                title: '姓名',
                align: "center",
                valign: 'middle',
            }, {
                field: 'ward_name',
                title: '科别',
                align: "center",
                valign: 'middle',
            }, {
                field: 'receipt_no',
                title: '收据号',
                align: "center",
                valign: 'middle'
            }, {
                field: 'amount',
                title: '金额',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'depo_type_name',
                title: '收费方式',
                align: "center",
                valign: 'middle',
            }, {
                field: 'op_id_name',
                title: '操作员',
                align: "center",
                valign: 'middle',
            }
        ]
    });
}


/**
 * 结算费用登记报表
 */
function getJsfydjbb() {
    $('#tb_table').bootstrapTable({
        data: fullData.jsfydjbb,         //请求后台的URL（*）
        //method: 'post',                      //请求方式（*）
        toolbar: '#toolbar',                //工具按钮用哪个容器
        striped: true,                      //是否显示行间隔色
        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true,                   //是否显示分页（*）
        sortable: true,                     //是否启用排序
        sortOrder: "asc",                   //排序方式
        //queryParams: queryParams,           //传递参数（*）
        sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1,                       //初始化加载第一页，默认第一页
        pageSize: 10,                       //每页的记录行数（*）
        pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
        search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: true,
        showColumns: false,                  //是否显示所有的列
        showRefresh: false,                  //是否显示刷新按钮
        minimumCountColumns: 2,             //最少允许的列数
        clickToSelect: true,                //是否启用点击选中行
        uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
        showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
        cardView: false,                    //是否显示详细视图
        detailView: false,
        //rowStyle:rowStyle,//通过自定义函数设置行样式
        ajaxOptions: {
            headers: {
                'Accept': 'application/json',
                'Authorization': 'Bearer ' + localStorage.getItem("token")
            }
        },
        columns: [
            {
                field: 'ward_name',
                title: '病区',
                align: "center",
                valign: 'middle'
            }, {
                field: 'in_no',
                title: '住院号',
                align: "center",
                valign: 'middle'
            }, {
                field: 'name',
                title: '姓名',
                align: "center",
                valign: 'middle',
            }, {
                field: 'responce_type_name',
                title: '身份类型',
                align: "center",
                valign: 'middle',
            }, {
                field: 'admiss_date',
                title: '入院日期',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return format(value, "yyyy-MM-dd");
                }
            }, {
                field: 'deposit',
                title: '预交金',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge_bk',
                title: '补款金额',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge_tk',
                title: '退款金额',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge_self',
                title: '自付金额',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'charge_jz',
                title: '记账金额',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'total_charge',
                title: '总金额',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'receipt_no',
                title: '发票号',
                align: "center",
                valign: 'middle',
            }
        ]
    });
}


/**
 * 结算预交金明细
 */
function getJsYjjDetailList() {
    $('#tb_table').bootstrapTable({
        data: fullData.jsYjjDetailList,         //请求后台的URL（*）
        //method: 'post',                      //请求方式（*）
        toolbar: '#toolbar',                //工具按钮用哪个容器
        striped: true,                      //是否显示行间隔色
        cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true,                   //是否显示分页（*）
        sortable: true,                     //是否启用排序
        sortOrder: "asc",                   //排序方式
        //queryParams: queryParams,           //传递参数（*）
        sidePagination: "client",           //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1,                       //初始化加载第一页，默认第一页
        pageSize: 10,                       //每页的记录行数（*）
        pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
        search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: true,
        showColumns: false,                  //是否显示所有的列
        showRefresh: false,                  //是否显示刷新按钮
        minimumCountColumns: 2,             //最少允许的列数
        clickToSelect: true,                //是否启用点击选中行
        uniqueId: "ID",                     //每一行的唯一标识，一般为主键列
        showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
        cardView: false,                    //是否显示详细视图
        detailView: false,
        //rowStyle:rowStyle,//通过自定义函数设置行样式
        ajaxOptions: {
            headers: {
                'Accept': 'application/json',
                'Authorization': 'Bearer ' + localStorage.getItem("token")
            }
        },
        columns: [
            {
                field: 'inpatient_no',
                title: '住院号',
                align: "center",
                valign: 'middle'
            }, {
                field: 'name',
                title: '姓名',
                align: "center",
                valign: 'middle',
            }, {
                field: 'admiss_times',
                title: '住院次数',
                align: "center",
                valign: 'middle',
            }, {
                field: 'receipt_no',
                title: '收据号',
                align: "center",
                valign: 'middle'
            }, {
                field: 'depo_amount',
                title: '金额',
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    if (value == null || value == undefined || value == "") {
                        return "";
                    }
                    return value.toFixed(2);
                }
            }, {
                field: 'op_id_name',
                title: '操作员',
                align: "center",
                valign: 'middle',
            }
        ]
    });
}



/**
 * 获取按钮组选择的下标
 * @param id
 * @returns {number}
 */
function getIndex(id) {
    var index = 0;
    var item = $("#" + id).find("button");
    for (var i = 0; i <= item.length; i++) {
        if ($(item[i]).hasClass("btn-primary")) {
            index = i;
            break;
        }
    }
    return index;
}


/**
 * 查询默认打印机
 */
function setPrint() {
    if (printIndex >= 0) {
        return;
    }
    $.ajax({
        type: "GET",
        url: '/thmz/getLastWindowsByCurrentUser',
        contentType: "application/json;charset=UTF-8",
        dataType: "json",
        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
        async: false,
        success: function (res) {
            if (res == '401' || res == 401) {
                window.location.href = '/thmz/login/view'
                return;
            }
            if (res.code == 0) {
                printIndex = res.data.cgPrintIndex;
            } else {
                printIndex = -1;
            }
        }
    });
}


/**
 * 清空查询条件
 */
function cleanParams() {
    $("#printNum").val(null);

}

/**
 * 费用结算
 */
function dcountCharge() {
    $.ajax({
        type: "GET",
        url: '/thmz/dayclosing?dateEnd='+$("#currentDate").html(),
        contentType: "application/json;charset=UTF-8",
        dataType: "json",
        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
        success: function (res) {
            if (res == '401' || res == 401) {
                window.location.href = '/thmz/login/view'
                return;
            }
            if (res.code == 0) {
                var printNum = $("#printNum").val();
                if (printNum == null || printNum == undefined || printNum == '') {
                    printNum = 1;
                }
                for (var i = 0; i < printNum; i++) {
                    setPrint();
                    LODOP = getLodop();
                    LODOP.PRINT_INITA(6, 0, "210mm", "297mm", "住院收费收入日报表");
                    LODOP.SET_PRINT_STYLE("FontSize", 9); //字体大小
                    //设置默认打印机
                    LODOP.SET_PRINTER_INDEX(printIndex);
                    LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "210mm");
                    LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "297mm");
                    var strStyle = "<style>table{width: 96%;margin-top: 20px;margin-bottom: 10px;} table,td,th {border-width: 1px;border-style: solid;border-collapse: collapse}</style>";
                    LODOP.ADD_PRINT_HTM("0mm", "5mm", "200mm", "280mm", strStyle + document.getElementById("report_table_1").innerHTML);
                    LODOP.NewPageA();
                    LODOP.ADD_PRINT_HTM("0mm", "5mm", "200mm", "280mm", document.getElementById("zbr_div").innerHTML);
                    LODOP.PRINT();
                    //LODOP.PREVIEW();
                    //刷新数据
                    getRjbb();
                }
                successMesage(res);
            } else {
                errorMesage(res);
            }
        }
    });
}



