<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>微信移动医保对账</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/common.css}">
    <script th:src="@{/layui/jquery-3.4.1.min.js}"></script>
    <script th:src="@{/layui/layui.js}"></script>
    <style>
        .panel {padding:16px;background:#fff;margin-top:10px;border:1px solid #e6e6e6;box-shadow:0 1px 3px rgba(0,0,0,0.08);border-radius:6px;}
        .panel-title {font-size:16px;font-weight:600;margin-bottom:8px;}
        .result-ok {color:#16b777;font-weight:bold;}
        .result-bad {color:#ff5722;font-weight:bold;}
        .data-row {margin-top:12px;display:flex;flex-wrap:wrap;gap:16px;}
        .data-box {padding:12px;border:1px solid #f0f0f0;border-radius:6px;min-width:260px;background:#fafafa;}
        .data-box span {display:block;line-height:1.8;}
    </style>
</head>
<body class="layui-layout-body">
<div style="left:8px;right:8px;bottom:8px;top:8px;position:absolute;overflow-y:auto;">
    <div class="toolbar" id="titleDiv">
        <div style="display:inline-block;">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label">对账日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input formWidthTwo" id="tradeDate" placeholder="yyyy-MM-dd" th:value="${endTime}">
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="search()"><i class="layui-icon layui-icon-search"></i>查询</button>
                </div>
            </form>
        </div>
    </div>

    <div class="panel">
        <div class="panel-title">微信移动医保对账结果</div>
        <div class="data-row">
            <div class="data-box">
                <span>银行-医疗总费用：<span id="bank_medfee">0.00</span></span>
                <span>HIS-医疗总费用：<span id="his_medfee">0.00</span></span>
                <span>差额：<span id="diff_medfee">0.00</span></span>
            </div>
            <div class="data-box">
                <span>银行-账户支付：<span id="bank_acct_pay">0.00</span></span>
                <span>HIS-账户支付：<span id="his_acct_pay">0.00</span></span>
                <span>差额：<span id="diff_acct_pay">0.00</span></span>
            </div>
            <div class="data-box">
                <span>银行-统筹支付：<span id="bank_fund_pay">0.00</span></span>
                <span>HIS-统筹支付：<span id="his_fund_pay">0.00</span></span>
                <span>差额：<span id="diff_fund_pay">0.00</span></span>
            </div>
            <div class="data-box">
                <span>结果：<span id="stmt_rslt" class="result-ok">平</span></span>
                <span id="stmt_rslt_dscr"></span>
            </div>
        </div>
    </div>
</div>
<script th:inline="javascript">
    let layer, laydate;
    layui.use(['laydate','layer'], function(){
        laydate = layui.laydate; layer = layui.layer;
        laydate.render({elem:'#tradeDate',type:'date'});
    });

    function fmt(v){return (v===null||v===undefined||v==='')?'0.00':parseFloat(v).toFixed(2);}

    function search(){
        let tradeDate = $("#tradeDate").val();
        if(!tradeDate){layer.msg("请选择对账日期");return;}
        let param = {trade_date: tradeDate};
        $.ajax({
            url:'/mobileYbReconciliation/findData',
            method:'post',
            contentType:'application/json;charset=UTF-8',
            data:JSON.stringify(param),
            success:function(res){
                if(res.errCode==='0'){
                    $("#bank_medfee").text(fmt(res.bank_medfee));
                    $("#bank_acct_pay").text(fmt(res.bank_acct_pay));
                    $("#bank_fund_pay").text(fmt(res.bank_fund_pay));
                    $("#his_medfee").text(fmt(res.his_medfee));
                    $("#his_acct_pay").text(fmt(res.his_acct_pay));
                    $("#his_fund_pay").text(fmt(res.his_fund_pay));
                    $("#diff_medfee").text(fmt(res.diff_medfee));
                    $("#diff_acct_pay").text(fmt(res.diff_acct_pay));
                    $("#diff_fund_pay").text(fmt(res.diff_fund_pay));
                    const ok = res.stmt_rslt === '0';
                    $("#stmt_rslt").text(ok?'平':'不平').attr('class', ok?'result-ok':'result-bad');
                    $("#stmt_rslt_dscr").text(res.stmt_rslt_dscr||'');
                }else{
                    layer.alert(res.errMsg||'查询失败');
                }
            },
            error:function(){
                layer.alert('请求失败');
            }
        });
    }
</script>
</body>
</html>

