HEL-327: align calculator, profile and page skeletons with HEL-325 prototype.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
施工员
2026-09-01 10:40:21 +08:00
co-authored by Cursor multica-agent
parent 225a07f69e
commit 17fd140d3f
6 changed files with 381 additions and 223 deletions
+174 -77
View File
@@ -5,10 +5,10 @@ declare(strict_types=1);
<div class="page-head">
<div>
<h1 class="page-title">计算工具</h1>
<div class="page-sub">本地浏览器计算,结果仅供参考,不写入档案数据</div>
<?php fusionToolsTabs('acceptance_discount_calculator'); ?>
<div class="page-sub">利息计算 · 承兑贴现(与原系统同口径本地试算,结果仅供参考)</div>
</div>
</div>
<?php fusionToolsTabs('acceptance_discount_calculator'); ?>
<div class="calc-grid">
<div class="editor-card">
<div class="cr-group">
@@ -16,56 +16,84 @@ declare(strict_types=1);
<div class="cr"><span class="cr-label">票据类型</span><div class="cr-ctl"><div class="opt-row">
<label><input type="radio" name="dc_bill" value="bank" checked> 银行承兑汇票</label>
<label><input type="radio" name="dc_bill" value="commercial"> 商业承兑汇票</label>
</div>
<p class="cr-hint" id="dc_risk_hint">银承信用风险相对较低;商承请结合承兑人资信评估。</p>
</div></div>
<span class="cr-hint" style="margin:0;" id="dc_risk_hint">银承:流通性较好,贴现利率通常低于商承。</span>
</div></div></div>
<div class="cr"><label for="dc_face">票面金额(元)</label><div class="cr-ctl">
<input id="dc_face" type="text" inputmode="decimal">
<input id="dc_face" type="text" inputmode="decimal" autocomplete="off" style="max-width:230px">
<div class="cr-hint"><span id="dc_face_fmt"></span> <span id="dc_face_cap"></span></div>
</div></div>
<div class="cr"><label for="dc_issue">出票日期</label><div class="cr-ctl"><input id="dc_issue" type="date"></div></div>
<div class="cr"><span class="cr-label">到期日</span><div class="cr-ctl"><div class="opt-row">
<label><input type="radio" name="dc_mat_mode" value="date" checked> 指定日期</label>
<label><input type="radio" name="dc_mat_mode" value="after"> 见票后定期</label>
<div class="cr"><span class="cr-label">出票 / 贴现日期</span><div class="cr-ctl"><div class="cr-inline" style="gap:16px;">
<span style="display:inline-flex;align-items:center;gap:8px;">
<span style="font-size:12.5px;color:var(--text-2);">出票日期</span>
<input id="dc_issue" type="date" style="width:150px">
</span>
<span style="display:inline-flex;align-items:center;gap:8px;">
<span style="font-size:12.5px;color:var(--text-2);">贴现日期</span>
<input id="dc_discount" type="date" style="width:150px">
</span>
<span class="cr-hint" style="margin:0;">贴现日留空取当天</span>
</div></div></div>
<div class="cr" id="dc_row_mat_date"><label for="dc_maturity">到期日期</label><div class="cr-ctl"><input id="dc_maturity" type="date"></div></div>
<div class="cr" id="dc_row_mat_after" style="display:none"><label for="dc_months">期限(月)</label><div class="cr-ctl"><div class="cr-inline">
<input id="dc_months" type="number" min="1" max="12" step="1" value="6" style="width:80px">
<div class="cr"><span class="cr-label">到期日</span><div class="cr-ctl"><div class="cr-inline" style="gap:16px;">
<span class="opt-row" style="min-height:0;gap:14px;">
<label><input type="radio" name="dc_mat_mode" value="date" checked> 指定日期</label>
<label><input type="radio" name="dc_mat_mode" value="after"> 见票后定期</label>
</span>
<span id="dc_row_mat_date" class="cr-pair">
<span style="font-size:12.5px;color:var(--text-2);">到期日期</span>
<input id="dc_maturity" type="date" style="width:150px">
</span>
</div></div></div>
<div class="cr" id="dc_row_mat_after" hidden><label for="dc_months">期限(月)</label><div class="cr-ctl"><div class="cr-inline">
<input id="dc_months" type="number" min="1" max="12" step="1" value="6" style="width:84px">
<button type="button" class="btn btn--plain btn--sm" id="dc_apply_months">推算到期日</button>
<span class="cr-hint" style="margin:0" id="dc_mat_preview"></span>
</div></div></div>
<div class="cr"><label for="dc_discount">贴现日期</label><div class="cr-ctl"><input id="dc_discount" type="date"></div></div>
<div class="cr"><span class="cr-label">节假日</span><div class="cr-ctl"><div class="opt-row">
<label><input type="checkbox" id="dc_holiday"> 到期日遇双休日/法定节假日顺延至下一工作日</label>
</div></div></div>
</div>
<div class="cr-group">
<div class="section-title">贴现条件</div>
<div class="cr"><label for="dc_rate">贴现年利率 %</label><div class="cr-ctl">
<div class="cr-inline">
<input id="dc_rate" type="text" inputmode="decimal" style="width:110px">
<span class="ref-chips">
<button type="button" class="btn btn--plain btn--sm" data-ref="1.85">国股参考</button>
<button type="button" class="btn btn--plain btn--sm" data-ref="2.15">城商参考</button>
<button type="button" class="btn btn--plain btn--sm" data-ref="2.45">农商参考</button>
</span>
</div>
</div></div>
<div class="cr"><span class="cr-label">计息基准</span><div class="cr-ctl"><div class="cr-static">360 天/年(票据贴现常用)</div></div></div>
<div class="cr"><span class="cr-label">加天规则</span><div class="cr-ctl"><div class="opt-row">
<label><input type="checkbox" id="dc_remote"> 异地(+3 天在途)</label>
<div class="section-title">贴现参数</div>
<div class="cr"><label for="dc_rate">贴现年利率 %</label><div class="cr-ctl"><div class="cr-inline">
<input id="dc_rate" type="text" inputmode="decimal" autocomplete="off" style="width:100px">
<span class="ref-chips">
<button type="button" class="btn btn--plain btn--sm" data-ref="1.85">国股参考</button>
<button type="button" class="btn btn--plain btn--sm" data-ref="2.15">城商参考</button>
<button type="button" class="btn btn--plain btn--sm" data-ref="2.45">农商参考</button>
</span>
</div></div></div>
<div class="cr"><label for="dc_day_rule">计息方式</label><div class="cr-ctl">
<select id="dc_day_rule" style="max-width:360px">
<div class="cr"><label for="dc_day_rule">计息方式</label><div class="cr-ctl"><div class="cr-inline">
<select id="dc_day_rule" style="width:280px;max-width:100%;">
<option value="exclusive" selected>记首不记尾(贴现日至到期前一日)</option>
<option value="inclusive">记首记尾(对比用)</option>
</select>
</div></div>
<span class="cr-hint" style="margin:0;">计息基准:360 天/年(票据贴现常用)</span>
</div></div></div>
</div>
<div class="cr-group">
<div class="section-title">反向推算(选填其一)</div>
<div class="cr"><label for="dc_net_in">实付金额(元)</label><div class="cr-ctl"><input id="dc_net_in" type="text" inputmode="decimal" placeholder="反推利率"></div></div>
<div class="cr"><label for="dc_per10">每10万扣息(元)</label><div class="cr-ctl"><input id="dc_per10" type="text" inputmode="decimal" placeholder="反推利率"></div></div>
<div class="section-title">加天规则</div>
<div class="cr"><span class="cr-label">顺延与在途</span><div class="cr-ctl"><div class="cr-inline" style="gap:26px;">
<span style="display:inline-flex;align-items:center;gap:9px;">
<button type="button" class="switch" role="switch" aria-checked="false" data-switch data-bind-check="dc_remote" aria-label="异地加 3 天在途"></button>
<span style="font-size:13px;">异地(+3 天在途)</span>
<input type="checkbox" class="visually-hidden" id="dc_remote" tabindex="-1">
</span>
<span style="display:inline-flex;align-items:center;gap:9px;">
<button type="button" class="switch" role="switch" aria-checked="false" data-switch data-bind-check="dc_holiday" aria-label="到期日遇双休日或法定节假日顺延"></button>
<span style="font-size:13px;">到期日遇双休日 / 法定节假日顺延至下一工作日</span>
<input type="checkbox" class="visually-hidden" id="dc_holiday" tabindex="-1">
</span>
</div></div></div>
</div>
<div class="cr-group">
<div class="section-title">反向推算<span style="font-weight:500;font-size:11.5px;color:var(--text-3);margin-left:8px;">选填其一,优先按实付金额</span></div>
<div class="cr"><span class="cr-label">反推利率</span><div class="cr-ctl"><div class="cr-inline" style="gap:16px;">
<span style="display:inline-flex;align-items:center;gap:8px;">
<span style="font-size:12.5px;color:var(--text-2);">实付金额(元)</span>
<input id="dc_net_in" type="text" inputmode="decimal" autocomplete="off" placeholder="反推利率" style="width:150px">
</span>
<span style="display:inline-flex;align-items:center;gap:8px;">
<span style="font-size:12.5px;color:var(--text-2);">每10万扣息(元)</span>
<input id="dc_per10" type="text" inputmode="decimal" autocomplete="off" placeholder="反推利率" style="width:150px">
</span>
</div></div></div>
</div>
<div class="cr-actions">
<button type="button" class="btn btn--primary" id="dc_calc">计算</button>
@@ -76,24 +104,34 @@ declare(strict_types=1);
</div>
<div class="calc-side">
<div class="summary-card" id="dc_result">
<div class="drawer-eyebrow">计算结果</div>
<p class="calc-note" id="dc_result_placeholder">填写左侧并点击「计算」</p>
<div id="dc_result_body" style="display:none">
<div class="ha-label" style="font-size:11px;font-weight:700;letter-spacing:.12em;color:var(--gold)">贴现利息</div>
<div class="calc-result-hero num"><span id="dc_out_int">—</span></div>
<div class="summary-row"><span>贴现天数</span><b class="num" id="dc_out_days">—</b></div>
<div class="calc-note" id="dc_out_day_note"></div>
<div class="summary-row"><span>实付金额</span><b class="gold num" id="dc_out_net">—</b></div>
<div class="summary-row"><span>年化成本率</span><b id="dc_out_ann">—</b></div>
<div class="section-title" style="margin:0 0 8px;">计算结果</div>
<div id="dc_result_body">
<div style="padding:6px 0 4px;">
<div style="font-size:11px;font-weight:700;letter-spacing:.12em;color:var(--gold)">实付金额</div>
<div class="calc-result-hero num" id="dc_out_net">—</div>
<div class="calc-caps-block">
<span class="caps-label">大写</span>
<span class="calc-caps" id="dc_out_cap">—</span>
<button type="button" class="caps-copy" id="dc_caps_copy">复制</button>
</div>
</div>
<div class="summary-row"><span>贴现利息</span><b class="num" id="dc_out_int">—</b></div>
<div class="summary-row"><span>贴现天数</span><b class="num"><span id="dc_out_days">—</span> <span style="font-weight:500;font-size:11px;color:var(--text-3);" id="dc_out_day_note"></span></b></div>
<div class="summary-row"><span>天数拆解</span><b class="num" id="dc_out_break" style="font-weight:600;font-size:12px;">—</b></div>
<div class="summary-row"><span>年化成本率</span><b class="num" id="dc_out_ann">—</b></div>
<div class="summary-row"><span>每10万扣息</span><b class="num" id="dc_out_p10">—</b></div>
<div class="summary-row" id="dc_row_shift" hidden><span>到期日顺延至</span><b class="num" id="dc_out_shift">—</b></div>
<div class="rev-line" id="dc_rev_line"></div>
<div class="calc-note" id="dc_out_note">填写左侧并点击「计算」后,结果区保持此骨架即时更新</div>
<div class="calc-formula num" id="dc_out_formula">票面 × 年利率 ÷ 360 × 天数 = 贴现利息</div>
<button type="button" class="btn btn--plain" id="dc_copy_side" style="width:100%;margin-top:12px;">复制结果</button>
</div>
</div>
<div class="editor-card">
<div class="section-title" style="margin-top:0">本地历史记录</div>
<p class="calc-group-note">保存在本浏览器,最多对照多次试算。</p>
<ul id="dc_hist_list" class="calc-hist"></ul>
<button type="button" class="btn btn--plain btn--sm" id="dc_hist_clear" style="margin-top:8px">清空历史</button>
<div class="section-title" style="margin-top:0;">本地历史记录</div>
<div class="calc-group-note" style="margin:-4px 0 6px;">保存在本浏览器,可对比多次试算(最多 30 条)</div>
<div id="dc_hist_list"></div>
<div style="margin-top:10px;"><button type="button" class="btn btn--plain btn--sm" id="dc_hist_clear">清空历史</button></div>
</div>
</div>
</div>
@@ -125,9 +163,15 @@ declare(strict_types=1);
var nd=Math.min(day,last);
return new Date(ny,nmo,nd);
}
function toast(msg){ if(window.fusionToast) window.fusionToast(msg); else alert(msg); }
function copyText(t){
if(!t) return;
if(navigator.clipboard) navigator.clipboard.writeText(t).then(function(){toast('已复制');},function(){alert(t);});
else alert(t);
}
function syncBillHint(){
var v=document.querySelector('input[name="dc_bill"]:checked').value;
document.getElementById('dc_risk_hint').textContent=v==='bank'?'银承:流通性较好,贴现利率通常低于商承。':'商承:请重点评估承兑人信用;贴现利率通常高于银承。';
document.getElementById('dc_risk_hint').textContent=v==='bank'?'银承:流通性较好,贴现利率通常低于商承。':'商承:请重点评估承兑人信用;贴现利率通常高于商承。';
}
document.querySelectorAll('input[name="dc_bill"]').forEach(function(r){r.addEventListener('change',syncBillHint);});
syncBillHint();
@@ -139,12 +183,13 @@ declare(strict_types=1);
function syncFace(){var v=parseNum(document.getElementById('dc_face').value); document.getElementById('dc_face_fmt').textContent=isFinite(v)&&v>0?('格式化:'+fmtMoney(v)):'';
document.getElementById('dc_face_cap').textContent=isFinite(v)&&v>0?('大写:'+toRmbUpper(Math.floor(v))):'';}
document.getElementById('dc_face').addEventListener('input',syncFace);
function syncMatRows(){
var m=document.querySelector('input[name="dc_mat_mode"]:checked').value;
document.getElementById('dc_row_mat_date').hidden=m!=='date';
document.getElementById('dc_row_mat_after').hidden=m!=='after';
}
document.querySelectorAll('input[name="dc_mat_mode"]').forEach(function(r){
r.addEventListener('change',function(){
var m=document.querySelector('input[name="dc_mat_mode"]:checked').value;
document.getElementById('dc_row_mat_date').style.display=m==='date'?'':'none';
document.getElementById('dc_row_mat_after').style.display=m==='after'?'':'none';
});
r.addEventListener('change',syncMatRows);
});
document.getElementById('dc_apply_months').addEventListener('click',function(){
var iss=document.getElementById('dc_issue').value; if(!iss){alert('请先填出票日');return;}
@@ -183,13 +228,30 @@ declare(strict_types=1);
if(!(face>0)||!(net>0)||!(days>0)||net>=face) return NaN;
return (face-net)*360/(face*days)*100;
}
function clearResult(){
document.getElementById('dc_out_net').textContent='—';
document.getElementById('dc_out_cap').textContent='—';
document.getElementById('dc_out_int').textContent='—';
document.getElementById('dc_out_days').textContent='—';
document.getElementById('dc_out_day_note').textContent='';
document.getElementById('dc_out_break').textContent='—';
document.getElementById('dc_out_ann').textContent='—';
document.getElementById('dc_out_p10').textContent='—';
document.getElementById('dc_row_shift').hidden=true;
document.getElementById('dc_rev_line').textContent='';
document.getElementById('dc_out_note').textContent='填写左侧并点击「计算」后,结果区保持此骨架即时更新';
document.getElementById('dc_out_formula').textContent='票面 × 年利率 ÷ 360 × 天数 = 贴现利息';
window._dc_last=null;
}
function calc(){
document.getElementById('dc_rev_line').textContent='';
var face=parseNum(document.getElementById('dc_face').value);
var dis=document.getElementById('dc_discount').value;
var matRaw=document.getElementById('dc_maturity').value;
var matEff=effectiveMaturity();
var rule=document.getElementById('dc_day_rule').value;
var remote=document.getElementById('dc_remote').checked;
var holiday=document.getElementById('dc_holiday').checked;
var days=discountDays(dis,matEff,rule,remote);
if(!(face>0)){ alert('票面金额须大于0'); return; }
if(!dis||!matEff){ alert('请完善贴现日与到期日'); return; }
@@ -198,18 +260,19 @@ declare(strict_types=1);
var per10=parseNum(document.getElementById('dc_per10').value);
var rate=parseNum(document.getElementById('dc_rate').value);
var intr;
var revLine='';
if(isFinite(netIn)&&netIn>0&&netIn<face){
rate=rateFromNet(face,netIn,days);
if(!isFinite(rate)||!(rate>0)){ alert('无法根据实付金额反推利率,请检查天数与金额'); return; }
intr=face-netIn;
document.getElementById('dc_rate').value=rate.toFixed(4);
document.getElementById('dc_rev_line').textContent='已按实付金额反推贴现年利率:'+rate.toFixed(4)+'%';
revLine='已按实付金额反推贴现年利率:'+rate.toFixed(4)+'%';
} else if(isFinite(per10)&&per10>0){
intr=per10*(face/100000);
rate=(intr*360/(face*days))*100;
if(!isFinite(rate)||!(rate>0)){ alert('无法根据每10万扣息反推利率'); return; }
document.getElementById('dc_rate').value=rate.toFixed(4);
document.getElementById('dc_rev_line').textContent='已按每10万扣息反推贴现年利率:'+rate.toFixed(4)+'%';
revLine='已按每10万扣息反推贴现年利率:'+rate.toFixed(4)+'%';
} else {
if(!(rate>0)){ alert('请输入贴现年利率,或填写反推字段'); return; }
intr=calcForward(face,rate,days);
@@ -217,47 +280,81 @@ declare(strict_types=1);
var net=face-intr;
var ann=net>0 ? (intr/net)*(360/days)*100 : NaN;
var p10=face>0? intr/(face/100000):NaN;
document.getElementById('dc_out_days').textContent=String(days);
document.getElementById('dc_out_day_note').textContent=(remote?'(含异地+3天)':'')+(document.getElementById('dc_holiday').checked?';到期日已按工作日顺延':'');
document.getElementById('dc_out_int').textContent=fmtMoney(intr);
var extra=remote?3:0;
var base=days-extra;
var shiftDays=0;
if(holiday && matRaw && matEff){
var dRaw=parseYmd(matRaw), dEff=parseYmd(matEff);
if(dRaw&&dEff) shiftDays=Math.max(0, Math.round((dEff-dRaw)/86400000));
}
var dayNote=(remote?'(含异地+3天)':'')+(holiday?';到期日已按工作日顺延':'');
var bill=document.querySelector('input[name="dc_bill"]:checked').value==='commercial'?'商业承兑汇票':'银行承兑汇票';
document.getElementById('dc_out_net').textContent=fmtMoney(net);
document.getElementById('dc_out_cap').textContent=toRmbUpper(Math.floor(net))||'—';
document.getElementById('dc_out_int').textContent=fmtMoney(intr)+' 元';
document.getElementById('dc_out_days').textContent=String(days)+' 天';
document.getElementById('dc_out_day_note').textContent=dayNote;
document.getElementById('dc_out_break').textContent='计息 '+base+(shiftDays?('(含顺延 '+shiftDays+')'):'')+(remote?' + 异地 3':'');
document.getElementById('dc_out_ann').textContent=isFinite(ann)?(ann.toFixed(4)+'%'):'—';
document.getElementById('dc_out_p10').textContent=isFinite(p10)?fmtMoney(p10):'—';
document.getElementById('dc_result_placeholder').style.display='none';
document.getElementById('dc_result_body').style.display='block';
window._dc_last={face:face,intr:intr,net:net,days:days,w:face/10000};
document.getElementById('dc_out_p10').textContent=isFinite(p10)?(fmtMoney(p10)+' 元'):'—';
document.getElementById('dc_row_shift').hidden=!shiftDays;
if(shiftDays) document.getElementById('dc_out_shift').textContent=matEff;
document.getElementById('dc_rev_line').textContent=revLine;
document.getElementById('dc_out_note').textContent='票据类型:'+bill+' · '+(rule==='inclusive'?'记首记尾':'记首不记尾')+' · 360 天/年';
document.getElementById('dc_out_formula').textContent=fmtMoney(face)+' × '+(+rate).toFixed(4)+'% ÷ 360 × '+days+' 天 = '+fmtMoney(intr);
window._dc_last={face:face,intr:intr,net:net,days:days,w:face/10000,rate:(+rate).toFixed(4),
text:'票面'+(face/10000).toFixed(2)+'万 | 贴现息'+fmtMoney(intr)+'元 | 实付'+fmtMoney(net)+'元 | 天数'+days+'天'};
}
function copyRes(){
if(!window._dc_last){ alert('请先计算'); return; }
var w=window._dc_last.w, t='票面'+w.toFixed(2)+'万 | 贴现息'+fmtMoney(window._dc_last.intr)+'元 | 实付'+fmtMoney(window._dc_last.net)+'元 | 天数'+window._dc_last.days+'天';
if(navigator.clipboard) navigator.clipboard.writeText(t).then(function(){alert('已复制');},function(){alert(t);});
else alert(t);
copyText(window._dc_last.text);
}
function saveHist(){
if(!window._dc_last){ alert('请先计算'); return; }
var key='dc_hist_v1', arr=JSON.parse(localStorage.getItem(key)||'[]');
arr.unshift({t:Date.now(),...window._dc_last,rate:document.getElementById('dc_rate').value});
arr.unshift({t:Date.now(),face:window._dc_last.face,intr:window._dc_last.intr,net:window._dc_last.net,days:window._dc_last.days,rate:window._dc_last.rate});
arr=arr.slice(0,30); localStorage.setItem(key,JSON.stringify(arr)); renderHist();
}
function renderHist(){
var arr=JSON.parse(localStorage.getItem('dc_hist_v1')||'[]');
var ul=document.getElementById('dc_hist_list'); ul.innerHTML='';
arr.forEach(function(r,i){
var li=document.createElement('li');
li.textContent=new Date(r.t).toLocaleString()+' — 实付 '+fmtMoney(r.net)+' / 息 '+fmtMoney(r.intr)+' / '+r.days+'天 / 利率'+r.rate+'%';
ul.appendChild(li);
});
var box=document.getElementById('dc_hist_list');
if(!arr.length){
box.innerHTML='<div class="calc-note" style="padding:10px 0 4px;">暂无历史记录,计算后点击「保存记录」</div>';
return;
}
box.innerHTML=arr.map(function(r,i){
var wan=((r.face||0)/10000).toFixed(2);
var when=new Date(r.t);
var ts=isNaN(when.getTime())?String(r.t):when.toLocaleString();
return '<div class="hist-row"><div><div class="hist-main num">'+wan+' 万 · '+(r.rate||'')+'%</div><div class="hist-sub num">'+ts+' · '+(r.days||'')+' 天</div></div><div class="hist-amt num">'+fmtMoney(r.net)+'</div><button type="button" class="btn btn--plain btn--sm" data-hist-fill="'+i+'">回填</button></div>';
}).join('');
}
document.getElementById('dc_hist_list').addEventListener('click',function(e){
var b=e.target.closest('[data-hist-fill]');
if(!b) return;
var arr=JSON.parse(localStorage.getItem('dc_hist_v1')||'[]');
var r=arr[+b.getAttribute('data-hist-fill')];
if(!r) return;
if(r.face) document.getElementById('dc_face').value=String(r.face);
if(r.rate) document.getElementById('dc_rate').value=String(r.rate);
syncFace();
});
document.getElementById('dc_calc').addEventListener('click',calc);
document.getElementById('dc_copy').addEventListener('click',copyRes);
document.getElementById('dc_copy_side').addEventListener('click',copyRes);
document.getElementById('dc_caps_copy').addEventListener('click',function(){
var t=document.getElementById('dc_out_cap').textContent;
if(!t||t==='—'){ alert('请先计算'); return; }
copyText(t);
});
document.getElementById('dc_save').addEventListener('click',saveHist);
document.getElementById('dc_hist_clear').addEventListener('click',function(){ localStorage.removeItem('dc_hist_v1'); renderHist(); });
document.getElementById('dc_reset').addEventListener('click',function(){
document.getElementById('dc_face').value=''; document.getElementById('dc_rate').value='';
document.getElementById('dc_issue').value=''; document.getElementById('dc_maturity').value='';
document.getElementById('dc_net_in').value=''; document.getElementById('dc_per10').value='';
syncFace(); document.getElementById('dc_result_body').style.display='none';
document.getElementById('dc_result_placeholder').style.display='block';
var t=new Date(); document.getElementById('dc_discount').value=ymd(t);
syncFace(); clearResult();
});
renderHist();
})();
+61 -34
View File
@@ -5,16 +5,16 @@ declare(strict_types=1);
<div class="page-head">
<div>
<h1 class="page-title">计算工具</h1>
<div class="page-sub">本地浏览器计算,结果仅供参考,不写入档案数据</div>
<?php fusionToolsTabs('interest_calculator'); ?>
<div class="page-sub">利息计算 · 承兑贴现(与原系统同口径本地试算,结果仅供参考)</div>
</div>
</div>
<?php fusionToolsTabs('interest_calculator'); ?>
<div class="calc-grid">
<div class="editor-card">
<div class="cr-group">
<div class="section-title" style="margin-top:0;">金额与利率</div>
<div class="cr"><label for="ic_principal">本金(元)</label><div class="cr-ctl">
<input id="ic_principal" type="text" inputmode="decimal" autocomplete="off" placeholder="如 1000000">
<input id="ic_principal" type="text" inputmode="decimal" autocomplete="off" placeholder="如 1000000" style="max-width:230px">
<div class="cr-hint"><span id="ic_principal_fmt"></span> <span id="ic_principal_cap"></span></div>
</div></div>
<div class="cr"><label for="ic_rate">利率数值</label><div class="cr-ctl"><div class="cr-inline">
@@ -36,7 +36,7 @@ declare(strict_types=1);
<input id="ic_days" type="number" min="0" step="1" style="width:110px" placeholder="正整数">
<span class="cr-hint" style="margin:0;" id="ic_days_hint">正整数;与起止日期互斥</span>
</div></div></div>
<div class="cr" id="ic_row_range" style="display:none"><span class="cr-label">起止日期</span><div class="cr-ctl"><div class="cr-inline">
<div class="cr" id="ic_row_range" hidden><span class="cr-label">起止日期</span><div class="cr-ctl"><div class="cr-inline">
<input id="ic_d1" type="date">
<span style="color:var(--text-3);">至</span>
<input id="ic_d2" type="date">
@@ -45,7 +45,6 @@ declare(strict_types=1);
</div>
<div class="cr-group">
<div class="section-title">计息口径</div>
<div class="calc-group-note">银行贷款档案计息常用 360 天基准;365 仅作对照。</div>
<div class="cr"><label for="ic_count_mode">结息方式</label><div class="cr-ctl">
<select id="ic_count_mode" style="max-width:320px">
<option value="exclusive" selected>记首不记尾(算头不算尾)</option>
@@ -67,25 +66,30 @@ declare(strict_types=1);
</div>
<div class="calc-side">
<div class="summary-card" id="ic_result_wrap">
<div class="drawer-eyebrow">计算结果</div>
<p class="calc-note" id="ic_placeholder">请先填写左侧数据并点击「计算」</p>
<div id="ic_result_body" style="display:none">
<div class="ha-label" style="font-size:11px;font-weight:700;letter-spacing:.12em;color:var(--gold)">应付利息</div>
<div class="calc-result-hero num" id="ic_out_interest">—</div>
<div class="calc-caps-block" id="ic_caps_block">
<span class="caps-label">大写</span>
<span class="calc-caps" id="ic_out_cap">—</span>
<div class="section-title" style="margin:0 0 8px;">计算结果</div>
<div id="ic_result_body">
<div style="padding:6px 0 4px;">
<div style="font-size:11px;font-weight:700;letter-spacing:.12em;color:var(--gold)">应付利息</div>
<div class="calc-result-hero num" id="ic_out_interest">—</div>
<div class="calc-caps-block" id="ic_caps_block">
<span class="caps-label">大写</span>
<span class="calc-caps" id="ic_out_cap">—</span>
<button type="button" class="caps-copy" id="ic_caps_copy">复制</button>
</div>
</div>
<div class="summary-row"><span>本息合计</span><b class="gold num" id="ic_out_total">—</b></div>
<div class="summary-row"><span>本息合计</span><b class="num" id="ic_out_total">—</b></div>
<div class="summary-row"><span>实际计息天数</span><b class="num" id="ic_out_days">—</b></div>
<div class="summary-row"><span>参考日利率</span><b id="ic_out_daily">—</b></div>
<div class="summary-row"><span>参考日利率</span><b class="num" id="ic_out_daily" style="font-weight:600;font-size:12px;">—</b></div>
<div class="calc-note" id="ic_out_note">填写左侧数据并点击「计算」后,结果区保持此骨架即时更新</div>
<div class="calc-formula num" id="ic_out_formula">本金 × 利率 ÷ 基准 × 天数</div>
<button type="button" class="btn btn--plain" id="ic_copy_side" style="width:100%;margin-top:12px;">复制结果</button>
</div>
</div>
</div>
</div>
<script>
(function(){
var DIG='零壹贰叁肆伍陆柒捌玖', UNIT=['','拾','佰','仟'], GRP=['','万','亿','兆'];
var DIG='零壹贰叁肆伍陆柒捌玖', UNIT=['','拾','佰','仟'];
function sectionFour(n){
var s='', str=('0000'+n).slice(-4);
for(var i=0;i<4;i++){
@@ -117,6 +121,22 @@ declare(strict_types=1);
p[0]=p[0].replace(/\B(?=(\d{3})+(?!\d))/g,',');
return p.join('.');
}
function toast(msg){ if(window.fusionToast) window.fusionToast(msg); else alert(msg); }
function copyText(t){
if(!t) return;
if(navigator.clipboard) navigator.clipboard.writeText(t).then(function(){toast('已复制');},function(){alert(t);});
else alert(t);
}
function clearResult(){
document.getElementById('ic_out_interest').textContent='—';
document.getElementById('ic_out_cap').textContent='—';
document.getElementById('ic_out_total').textContent='—';
document.getElementById('ic_out_days').textContent='—';
document.getElementById('ic_out_daily').textContent='—';
document.getElementById('ic_out_note').textContent='填写左侧数据并点击「计算」后,结果区保持此骨架即时更新';
document.getElementById('ic_out_formula').textContent='本金 × 利率 ÷ 基准 × 天数';
window._ic_last=null;
}
function syncPrincipalFmt(){
var raw=document.getElementById('ic_principal').value;
var v=parseNum(raw);
@@ -139,7 +159,7 @@ declare(strict_types=1);
}
return daysFromRange(document.getElementById('ic_d1').value,document.getElementById('ic_d2').value,cm);
}
function dailyRef(P,Rk,rate,basis){
function dailyRef(Rk,rate,basis){
var b=+basis;
if(Rk==='annual') return (rate/100)/b;
if(Rk==='monthly') return (rate/100)/30;
@@ -152,6 +172,9 @@ declare(strict_types=1);
if(Rk==='monthly') return P*(rate/100)*(days/30);
return P*(rate/100)*days;
}
function resultText(){
return '利息 '+document.getElementById('ic_out_interest').textContent+' | 本息合计 '+document.getElementById('ic_out_total').textContent+' | 天数 '+document.getElementById('ic_out_days').textContent;
}
function calc(){
var P=parseNum(document.getElementById('ic_principal').value);
var rate=parseNum(document.getElementById('ic_rate').value);
@@ -162,19 +185,18 @@ declare(strict_types=1);
if(!(rate>0)){ alert('请输入有效利率'); return; }
if(!isFinite(days)||days<0){ alert('请检查计息天数或起止日期'); return; }
var intr=interestAmount(P,Rk,rate,days,basis);
var dref=dailyRef(P,Rk,rate,basis);
document.getElementById('ic_out_interest').textContent=fmtMoney(intr)+' 元';
var dref=dailyRef(Rk,rate,basis);
var cm=document.getElementById('ic_count_mode').value;
var kindTxt={annual:'年利率',monthly:'月利率',daily:'日利率'}[Rk];
var formula=Rk==='annual'?(fmtMoney(P)+' × '+rate+'% ÷ '+basis+' × '+days+' 天'):(Rk==='monthly'?(fmtMoney(P)+' × '+rate+'% ÷ 30 × '+days+' 天'):(fmtMoney(P)+' × '+rate+'% × '+days+' 天'));
document.getElementById('ic_out_interest').textContent=fmtMoney(intr);
document.getElementById('ic_out_total').textContent=fmtMoney(P+intr)+' 元';
document.getElementById('ic_out_days').textContent=String(days);
document.getElementById('ic_out_daily').textContent=(dref*100).toFixed(6)+'%(按当前利率种类换算,仅供参考)';
var cap=document.getElementById('ic_out_cap'); if(cap) cap.textContent=toRmbUpper(Math.floor(intr))||'—';
document.getElementById('ic_result_body').style.display='block';
var ph=document.getElementById('ic_placeholder'); if(ph) ph.style.display='none';
}
function copyTxt(){
var t='利息 '+document.getElementById('ic_out_interest').textContent+' | 本息合计 '+document.getElementById('ic_out_total').textContent+' | 天数 '+document.getElementById('ic_out_days').textContent;
if(navigator.clipboard) navigator.clipboard.writeText(t).then(function(){alert('已复制');},function(){alert(t);});
else alert(t);
document.getElementById('ic_out_days').textContent=String(days)+' 天';
document.getElementById('ic_out_daily').textContent=(dref*100).toFixed(6)+'%';
document.getElementById('ic_out_cap').textContent=toRmbUpper(Math.floor(intr))||'—';
document.getElementById('ic_out_note').textContent='参考日利率按当前利率种类换算,仅供参考 · '+kindTxt+' '+rate+'% · '+(cm==='inclusive'?'记首记尾':'记首不记尾')+' · '+basis+' 天/年';
document.getElementById('ic_out_formula').textContent=formula;
window._ic_last={text:resultText()};
}
function resetAll(){
document.getElementById('ic_principal').value='';
@@ -183,16 +205,15 @@ declare(strict_types=1);
document.getElementById('ic_d1').value='';
document.getElementById('ic_d2').value='';
syncPrincipalFmt();
document.getElementById('ic_result_body').style.display='none';
var ph=document.getElementById('ic_placeholder'); if(ph) ph.style.display='block';
clearResult();
}
document.getElementById('ic_principal').addEventListener('input',syncPrincipalFmt);
document.getElementById('ic_principal').addEventListener('paste',function(){setTimeout(syncPrincipalFmt,0);});
document.querySelectorAll('input[name="ic_day_mode"]').forEach(function(r){
r.addEventListener('change',function(){
var m=document.querySelector('input[name="ic_day_mode"]:checked').value;
document.getElementById('ic_row_manual').style.display=m==='manual'?'':'none';
document.getElementById('ic_row_range').style.display=m==='range'?'':'none';
document.getElementById('ic_row_manual').hidden=m!=='manual';
document.getElementById('ic_row_range').hidden=m!=='range';
});
});
function syncRangeLabel(){
@@ -210,7 +231,13 @@ declare(strict_types=1);
document.getElementById('ic_d1').addEventListener('change',function(){ if(this.value) document.getElementById('ic_days').value=''; });
document.getElementById('ic_d2').addEventListener('change',function(){ if(this.value) document.getElementById('ic_days').value=''; });
document.getElementById('ic_calc').addEventListener('click',calc);
document.getElementById('ic_copy').addEventListener('click',copyTxt);
document.getElementById('ic_copy').addEventListener('click',function(){ if(!window._ic_last){ alert('请先计算'); return; } copyText(window._ic_last.text); });
document.getElementById('ic_copy_side').addEventListener('click',function(){ if(!window._ic_last){ alert('请先计算'); return; } copyText(window._ic_last.text); });
document.getElementById('ic_caps_copy').addEventListener('click',function(){
var t=document.getElementById('ic_out_cap').textContent;
if(!t||t==='—'){ alert('请先计算'); return; }
copyText(t);
});
document.getElementById('ic_reset').addEventListener('click',resetAll);
})();
</script>
+5 -5
View File
@@ -61,10 +61,10 @@ function fusionQueryTabs(string $current): void
'query_external_guarantee' => '对外担保',
'repayment_history' => '历史还款',
];
echo '<div class="seg query-tabs" role="tablist" aria-label="统计口径">';
echo '<div class="seg tools-tabs" role="tablist" aria-label="统计口径">';
foreach ($tabs as $act => $label) {
$active = $current === $act ? ' data-active' : '';
echo '<a class="btn btn--sm" role="tab" href="index.php?action=' . e($act) . '"' . ($active ? ' data-active style="background:var(--surface-2);box-shadow:var(--shadow-seg);font-weight:600;color:var(--text)"' : ' style="color:var(--text-2)"') . '>' . e($label) . '</a>';
$on = $current === $act;
echo '<a role="tab" href="index.php?action=' . e($act) . '"' . ($on ? ' data-active' : '') . '>' . e($label) . '</a>';
}
echo '</div>';
}
@@ -75,10 +75,10 @@ function fusionToolsTabs(string $current): void
'interest_calculator' => '利息计算器',
'acceptance_discount_calculator' => '承兑贴现计算器',
];
echo '<div class="seg head-switch" role="tablist" aria-label="计算工具">';
echo '<div class="seg tools-tabs" role="tablist" aria-label="计算工具">';
foreach ($tabs as $act => $label) {
$on = $current === $act;
echo '<a role="tab" href="index.php?action=' . e($act) . '"' . ($on ? ' data-active' : '') . ' class="btn btn--sm" style="' . ($on ? 'background:var(--surface-2);box-shadow:var(--shadow-seg);font-weight:600' : 'color:var(--text-2)') . '">' . e($label) . '</a>';
echo '<a role="tab" href="index.php?action=' . e($act) . '"' . ($on ? ' data-active' : '') . '>' . e($label) . '</a>';
}
echo '</div>';
}
+25 -16
View File
@@ -212,8 +212,8 @@ html[data-boot-theme="night"] .v-fusion {
.v-fusion .search input::placeholder { color: var(--text-3); }
/* 面包屑返回:字号沿用 page-sub 体系 */
.v-fusion .crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-3); margin-bottom: 10px; }
.v-fusion .crumbs button { color: var(--text-2); border-radius: 6px; padding: 1px 4px; transition: background-color 150ms ease, color 150ms ease; }
@media (hover: hover) and (pointer: fine) { .v-fusion .crumbs button:hover { background: var(--hover); color: var(--accent); } }
.v-fusion .crumbs button, .v-fusion .crumbs a { color: var(--text-2); border-radius: 6px; padding: 1px 4px; transition: background-color 150ms ease, color 150ms ease; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .v-fusion .crumbs button:hover, .v-fusion .crumbs a:hover { background: var(--hover); color: var(--accent); } }
/* — Stats(与定版一致;增加可点击入口卡) — */
.v-fusion .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
@@ -242,18 +242,17 @@ html[data-boot-theme="night"] .v-fusion {
/* — Segmented control(与定版一致) — */
.v-fusion .seg { display: inline-flex; padding: 2px; background: var(--fill); border-radius: 9px; }
.v-fusion .seg button {
position: relative; height: 26px; padding: 0 14px; border-radius: 7px;
font-size: 12.5px; color: var(--text-2);
transition: color 150ms ease;
white-space: nowrap;
}
.v-fusion .seg button,
.v-fusion .seg a {
position: relative; height: 26px; padding: 0 14px; border-radius: 7px;
font-size: 12.5px; color: var(--text-2);
display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap;
transition: color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
white-space: nowrap;
display: inline-flex; align-items: center; text-decoration: none;
}
.v-fusion .seg button[data-active],
.v-fusion .seg a[data-active] { color: var(--text); font-weight: 600; background: var(--surface-2); box-shadow: var(--shadow-seg); }
.v-fusion .tools-tabs { margin: 0 0 20px; }
/* — 筛选条:输入几何沿用 .search / 表单控件(34px 控件、9px 圆角、fill 底) — */
.v-fusion .filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
@@ -441,7 +440,7 @@ html[data-boot-theme="night"] .v-fusion {
.v-fusion .plan-kind { font-weight: 600; }
.v-fusion .plan-date { color: var(--text-2); font-size: 12px; }
.v-fusion .plan-amt { margin-left: auto; font-weight: 700; }
.v-fusion .empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 12.5px; border: 1px dashed var(--hairline); border-radius: 10px; }
.v-fusion .empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 12.5px; border: 1px dashed var(--hairline); border-radius: 10px; min-height: 88px; display: flex; align-items: center; justify-content: center; }
/* 空态操作卡:空结果 + 引导动作 */
.v-fusion .empty-action {
padding: 40px 24px; text-align: center;
@@ -531,8 +530,8 @@ html[data-boot-theme="night"] .v-fusion {
.v-fusion .file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-fusion .file-meta { font-size: 11px; color: var(--text-3); }
.v-fusion .file-act { margin-left: auto; display: flex; gap: 4px; }
.v-fusion .file-act button { font-size: 11.5px; color: var(--text-2); padding: 3px 7px; border-radius: 6px; transition: background-color 150ms ease, color 150ms ease; }
@media (hover: hover) and (pointer: fine) { .v-fusion .file-act button:hover { background: var(--hover); color: var(--accent); } }
.v-fusion .file-act button, .v-fusion .file-act a { font-size: 11.5px; color: var(--text-2); padding: 3px 7px; border-radius: 6px; transition: background-color 150ms ease, color 150ms ease; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .v-fusion .file-act button:hover, .v-fusion .file-act a:hover { background: var(--hover); color: var(--accent); } }
/* 还款计划时间线:行几何沿用 plan-row,状态点复用 pill 色 */
.v-fusion .timeline { position: relative; padding-left: 18px; }
.v-fusion .timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 1px; background: var(--hairline); }
@@ -567,12 +566,14 @@ html[data-boot-theme="night"] .v-fusion {
position: sticky; top: 34px;
background: var(--surface); border: 1px solid var(--gold-line); border-radius: 14px;
padding: 16px 18px;
min-height: 420px;
}
.v-fusion .summary-card::before {
content: ""; display: block; height: 2px; margin: -16px -18px 14px;
border-radius: 14px 14px 0 0; background: linear-gradient(90deg, var(--gold), var(--gold-bright));
}
.v-fusion .summary-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 7px 0; border-top: 1px solid var(--hairline); color: var(--text-2); }
.v-fusion .summary-row[hidden] { display: none !important; }
.v-fusion .summary-row b { color: var(--text); font-weight: 650; }
.v-fusion .summary-row b.gold { color: var(--gold); font-weight: 700; }
.v-fusion .form-foot {
@@ -667,7 +668,7 @@ html[data-boot-theme="night"] .v-fusion {
.v-fusion .dir-acts button { font-size: 11.5px; color: var(--text-3); padding: 2px 6px; border-radius: 5px; transition: background-color 120ms ease, color 120ms ease; }
@media (hover: hover) and (pointer: fine) { .v-fusion .dir-acts button:hover { background: var(--hover); color: var(--accent); } }
.v-fusion .dir-rename { height: 24px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--focus-ring); background: var(--surface); font-size: 12.5px; outline: none; max-width: 150px; }
.v-fusion .dir-empty { padding: 26px 14px; text-align: center; font-size: 12px; color: var(--text-3); }
.v-fusion .dir-empty { padding: 26px 14px; text-align: center; font-size: 12px; color: var(--text-3); min-height: 120px; display: flex; align-items: center; justify-content: center; }
/* — ② 工作台快捷工具坞:统一线性图标 + 紧凑卡片 — */
.v-fusion .quick-dock { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 14px; }
@@ -730,7 +731,12 @@ html[data-boot-theme="night"] .v-fusion {
/* 计算器输入区:紧凑「标签列 + 控件列」,行边界清晰,标签与控件视线距离短 */
.v-fusion .cr-group + .cr-group { margin-top: 14px; }
.v-fusion .cr { display: flex; align-items: flex-start; gap: 14px; padding: 8px 0; border-top: 1px solid var(--hairline); }
.v-fusion .cr[hidden] { display: none; }
.v-fusion .cr[hidden] { display: none !important; }
.v-fusion .visually-hidden {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.v-fusion .switch[disabled], .v-fusion .switch[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.v-fusion .cr:first-of-type { border-top: 0; }
.v-fusion .cr > label, .v-fusion .cr > .cr-label {
flex: 0 0 118px; padding-top: 8px;
@@ -748,6 +754,8 @@ html[data-boot-theme="night"] .v-fusion {
border-color: var(--focus-ring); box-shadow: 0 0 0 3px var(--focus-glow);
}
.v-fusion .cr-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 34px; }
.v-fusion .cr-pair { display: inline-flex; align-items: center; gap: 8px; }
.v-fusion .cr-pair[hidden] { display: none !important; }
.v-fusion .cr-hint { margin-top: 5px; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }
.v-fusion .cr-hint b { color: var(--gold); font-weight: 650; }
.v-fusion .cr-static { display: flex; align-items: center; min-height: 34px; font-size: 13px; color: var(--text-2); }
@@ -960,8 +968,9 @@ html[data-boot-theme="night"] .v-fusion {
.v-fusion a.btn { text-decoration: none; }
.v-fusion .num { font-variant-numeric: tabular-nums; }
.v-fusion .muted, .v-fusion .small { color: var(--text-3); font-size: 12px; }
.v-fusion .content a:not(.btn):not(.nav-item):not(.qd-item):not(.stat) { color: var(--accent); text-decoration: none; }
.v-fusion .content a:not(.btn):not(.nav-item):hover { text-decoration: underline; }
.v-fusion .content a:not(.btn):not(.nav-item):not(.qd-item):not(.stat):not(.seg a):not(.dir-name):not(.file-act a):not(.crumbs a) { color: var(--accent); text-decoration: none; }
.v-fusion .content a:not(.btn):not(.nav-item):not(.seg a):not(.dir-name):not(.file-act a):not(.crumbs a):hover { text-decoration: underline; }
.v-fusion .content .seg a:hover, .v-fusion .content .dir-name:hover, .v-fusion .content .file-act a:hover, .v-fusion .content .crumbs a:hover { text-decoration: none; }
.v-fusion .content input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.v-fusion .content select,
+11
View File
@@ -36,6 +36,17 @@
if (btn) {
e.preventDefault();
window.setFusionTheme(btn.getAttribute("data-theme-btn"), true);
return;
}
var sw = e.target.closest("[data-switch]");
if (sw && !sw.disabled && sw.getAttribute("aria-disabled") !== "true") {
var on = sw.getAttribute("aria-checked") !== "true";
sw.setAttribute("aria-checked", on ? "true" : "false");
var bind = sw.getAttribute("data-bind-check");
if (bind) {
var cb = document.getElementById(bind);
if (cb) cb.checked = on;
}
}
});
+105 -91
View File
@@ -1877,7 +1877,7 @@ if ($action === 'delete_approvals') {
</tr>
<?php endforeach; ?>
<?php if (empty($approvals)): ?>
<tr><td colspan="8" class="muted">暂无符合条件的审核记录</td></tr>
<tr><td colspan="8"><div class="empty-action"><div class="ea-title">暂无符合条件的审核记录</div>调整筛选条件,或等待新的删除申请</div></td></tr>
<?php endif; ?>
</tbody>
</table></div>
@@ -2058,98 +2058,90 @@ if ($action === 'archive_detail') {
$files = $pdo->prepare('SELECT * FROM files WHERE archive_id=:a ORDER BY id DESC');
$files->execute([':a' => $id]);
pageHeader($me); ?>
<div class="crumbs"><a href="index.php?action=home">档案库</a> / 详情</div>
<div class="crumbs"><a href="index.php?action=home">档案库</a><span>/</span><span><?= e($a['name']) ?></span></div>
<div class="page-head">
<div>
<h1 class="page-title"><?= e($a['name']) ?></h1>
<div class="page-sub"><?= e((string)$a['dir_name']) ?> · <?= e(archiveKindLabel($detailKind)) ?> · <?= fusionStatusPill($status) ?></div>
<h1 class="page-title"><?= e((string)$a['borrower']) ?></h1>
<div class="page-sub"><?= e(archiveKindLabel($detailKind)) ?> · <?= e($a['name']) ?> · <?= e((string)$a['dir_name']) ?> <?= fusionStatusPill($status) ?></div>
</div>
<div style="display:flex;gap:10px;flex-wrap:wrap">
<?php if (isAdmin()): ?>
<a class="btn btn--plain" href="index.php?action=archive_form&id=<?= $id ?>">编辑</a>
<a class="btn btn--primary" href="index.php?action=archive_form&id=<?= $id ?>">编辑档案</a>
<?php endif; ?>
<a class="btn btn--plain" href="index.php?action=home">返回列表</a>
</div>
</div>
<div class="amount-bar">
<div><div class="ab-label">当前应付</div><div class="ab-value"><?= e(amount($interestPayable)) ?></div></div>
<div><div class="ab-label">结息日应付</div><div class="ab-value"><?= $detailKind === ARCHIVE_KIND_BANK_LOAN ? e(amount($settlementInterestPayable)) : '—' ?></div></div>
<div><div class="ab-label">剩余额度</div><div class="ab-value"><?= e(amount($a['remaining_limit'] !== null ? (float)$a['remaining_limit'] : null)) ?></div></div>
<div><div class="ab-label">逾期利息</div><div class="ab-value" style="<?= $status === '逾期中' ? 'color:var(--red)' : '' ?>"><?= $status === '逾期中' ? e(amount($interestPayable)) : '0.00' ?></div></div>
</div>
<?php
$remainAmt = $a['remaining_limit'] !== null ? (float)$a['remaining_limit'] : 0.0;
$creditAmt = $a['credit_limit'] !== null ? (float)$a['credit_limit'] : 0.0;
$paidPct = $creditAmt > 0 ? (int)round((($creditAmt - $remainAmt) / $creditAmt) * 100) : 0;
$rateTxt = $detailKind === ARCHIVE_KIND_EXTERNAL_GUARANTEE ? '—' : ($a['annual_rate'] === null ? '' : ((string)$a['annual_rate'] . '%'));
$settleMode = $financeCfg['interest_mode'] === 'quarterly' ? '按季计息' : ($financeCfg['interest_mode'] === 'bullet' ? '到期一次性付清' : '按月计息');
$rule = (string)$financeCfg['settlement_rule'];
if ($rule === 'quarterly_day') {
$settleDayTxt = '每季' . (string)$financeCfg['settlement_day'] . '日';
} elseif ($rule === 'maturity_once') {
$settleDayTxt = '到期一次性付息';
} else {
$settleDayTxt = '每月' . (string)$financeCfg['settlement_day'] . '日';
}
?>
<div class="detail-grid">
<div>
<div class="card">
<table>
<tr><th><?= $detailKind === ARCHIVE_KIND_EXTERNAL_GUARANTEE ? '债权人' : '贷款机构' ?></th><td><?= e((string)$a['loan_institution']) ?></td><th>借款主体</th><td><?= e((string)$a['borrower']) ?></td></tr>
<tr><th>授信额度</th><td><?= e(amount($a['credit_limit'] !== null ? (float)$a['credit_limit'] : null)) ?></td><th>剩余额度</th><td><?= e(amount($a['remaining_limit'] !== null ? (float)$a['remaining_limit'] : null)) ?></td></tr>
<tr><th>起止日</th><td><?= e((string)$a['start_date']) ?></td><th>到期日</th><td><?= e((string)$a['end_date']) ?></td></tr>
<tr><th>年利率</th><td><?= $detailKind === ARCHIVE_KIND_EXTERNAL_GUARANTEE ? '<span class="muted">—</span>' : e($a['annual_rate'] === null ? '' : ((string)$a['annual_rate'] . '%')) ?></td><th>担保类型</th><td><?= e((string)$a['guarantee_type']) ?></td></tr>
<tr><th>担保人</th><td colspan="3"><?= e((string)$a['guarantor']) ?></td></tr>
<tr>
<th>结息方式</th>
<td><?= e($financeCfg['interest_mode'] === 'quarterly' ? '按季计息' : ($financeCfg['interest_mode'] === 'bullet' ? '到期一次性付清' : '按月计息')) ?></td>
<th>结息日</th>
<td>
<?php
$rule = (string)$financeCfg['settlement_rule'];
if ($rule === 'quarterly_day') {
echo '每季' . e((string)$financeCfg['settlement_day']) . '日';
} elseif ($rule === 'maturity_once') {
echo '到期一次性付息';
} else {
echo '每月' . e((string)$financeCfg['settlement_day']) . '日';
}
?>
</td>
</tr>
<tr><th>逾期利率上浮</th><td><?= e(amount((float)$financeCfg['overdue_float_pct'])) ?>%</td><th>当前应付利息</th><td><?= e(amount($interestPayable)) ?> 元</td></tr>
<?php if ($detailKind === ARCHIVE_KIND_BANK_LOAN): ?>
<tr><th>结息日应付利息</th><td colspan="3"><?= e(amount($settlementInterestPayable)) ?> 元 <span class="muted small">(本结息周期整段)</span></td></tr>
<?php endif; ?>
<?php $detailRemark = trim((string)($financeCfg['remark'] ?? '')); ?>
<?php if ($detailRemark !== ''): ?>
<tr><th>备注</th><td colspan="3" style="white-space:pre-wrap"><?= e($detailRemark) ?></td></tr>
<?php endif; ?>
</table>
</div>
<div class="card" style="margin-top:12px">
<h3>分期还款计划</h3>
<?php if (!($planCfg['enabled'] ?? false)): ?>
<p class="muted">该档案未启用分期还款计划</p>
<?php else: ?>
<table>
<tr><th>还款日期</th><th>还款金额</th><th>状态</th></tr>
<?php foreach ($repaymentPlans as $p): ?>
<tr>
<td><?= e((string)$p['due_date']) ?></td>
<td><?= e(amount((float)($p['amount'] ?? 0))) ?></td>
<td>
<?php
$st = (string)($p['status'] ?? 'pending');
if ($st === 'paid') {
echo '<span class="badge b1">已还款</span>';
} elseif ($st === 'delayed') {
echo '<span class="badge b2">已延期</span>';
} elseif ($st === 'overdue') {
echo '<span class="badge b4">已逾期</span>';
} else {
echo '<span class="badge b3">待处理</span>';
}
?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php if (isAdmin()): ?><p class="small muted">还款计划状态和延期调整请在“编辑档案”页面操作。</p><?php endif; ?>
<?php endif; ?>
</div>
<div class="hero-amount"<?= $remainAmt <= 0 ? ' data-zero' : '' ?>>
<div>
<div class="ha-label">剩余额度</div>
<div class="ha-value num"><?= e(amount($a['remaining_limit'] !== null ? (float)$a['remaining_limit'] : null)) ?></div>
</div>
<div class="ha-side">授信额度 <b class="num"><?= e(amount($a['credit_limit'] !== null ? (float)$a['credit_limit'] : null)) ?></b><br>已还 <b class="num"><?= (int)$paidPct ?>%</b> · 年利率 <b class="num"><?= e($rateTxt) ?></b></div>
</div>
<div class="section-title" style="margin-top:0;">概要</div>
<div class="field-grid">
<div class="field"><label><?= $detailKind === ARCHIVE_KIND_EXTERNAL_GUARANTEE ? '债权人' : '贷款机构' ?></label><div class="val"><?= e((string)$a['loan_institution']) ?></div></div>
<div class="field"><label>业务类型</label><div class="val"><?= e(archiveKindLabel($detailKind)) ?></div></div>
<div class="field"><label>起始日 / 到期日</label><div class="val num"><?= e((string)$a['start_date']) ?> — <?= e((string)$a['end_date']) ?></div></div>
<div class="field"><label>结息方式</label><div class="val"><?= e($settleMode) ?>(<?= e($settleDayTxt) ?>)</div></div>
<div class="field"><label>当前应付利息</label><div class="val num" style="color:var(--gold);"><?= e(amount($interestPayable)) ?></div></div>
<div class="field"><label>结息日应付利息</label><div class="val num"><?= $detailKind === ARCHIVE_KIND_BANK_LOAN ? e(amount($settlementInterestPayable)) : '—' ?></div></div>
<div class="field"><label>逾期利率上浮</label><div class="val num"><?= e(amount((float)$financeCfg['overdue_float_pct'])) ?>%</div></div>
<div class="field"><label>担保人</label><div class="val"><?= e((string)$a['guarantor']) ?></div></div>
</div>
<?php $detailRemark = trim((string)($financeCfg['remark'] ?? '')); ?>
<?php if ($detailRemark !== ''): ?>
<div class="field" style="margin-top:16px;"><label>备注</label><div class="val" style="font-weight:500;font-size:13px;line-height:1.7;white-space:pre-wrap"><?= e($detailRemark) ?></div></div>
<?php endif; ?>
<div class="section-title">还款计划</div>
<?php if (!($planCfg['enabled'] ?? false) || empty($repaymentPlans)): ?>
<div class="empty">暂无分期还款计划</div>
<?php else: ?>
<div class="timeline">
<?php foreach ($repaymentPlans as $p):
$st = (string)($p['status'] ?? 'pending');
$tl = $st === 'paid' ? 'paid' : (($st === 'overdue') ? 'over' : 'due');
$kind = (string)($p['kind'] ?? '分期');
?>
<div class="plan-row" data-tl="<?= e($tl) ?>">
<span class="plan-kind"><?= e($kind) ?></span>
<span class="plan-date num"><?= e((string)($p['due_date'] ?? '')) ?></span>
<?php
if ($st === 'paid') echo fusionStatusPill('已还款');
elseif ($st === 'delayed') echo fusionStatusPill('已延期');
elseif ($st === 'overdue') echo fusionStatusPill('已逾期');
else echo fusionStatusPill('待处理');
?>
<span class="plan-amt num"><?= e(amount((float)($p['amount'] ?? 0))) ?></span>
</div>
<?php endforeach; ?>
</div>
<?php if (isAdmin()): ?><p class="small muted">还款计划状态和延期调整请在「编辑档案」页面操作。</p><?php endif; ?>
<?php endif; ?>
</div>
<aside class="side-panel">
<div class="section-title" style="margin-top:0">附件</div>
<?php
<div class="section-title" style="margin:0 0 12px;">附件(<?php
$fileRows = is_array($files) ? $files : $files->fetchAll();
if (!$fileRows): ?>
echo count($fileRows);
?>)</div>
<?php if (!$fileRows): ?>
<div class="empty">暂无附件</div>
<?php else: foreach ($fileRows as $f):
$ext = strtoupper((string)$f['file_ext']);
@@ -2166,6 +2158,20 @@ if ($action === 'archive_detail') {
</div>
</div>
<?php endforeach; endif; ?>
<?php if (isAdmin()): ?>
<a class="btn btn--plain" style="width:100%;margin-top:4px;box-sizing:border-box;justify-content:center;" href="index.php?action=archive_form&id=<?= $id ?>">+ 上传附件</a>
<?php endif; ?>
<div class="section-title">提醒</div>
<div class="setting-row" style="border-top:0; padding-top:0;">
<div>到期与还款提醒<div class="hint">原系统无独立提醒开关,任务中心按到期日自动列出</div></div>
<button type="button" class="switch" role="switch" aria-checked="true" aria-disabled="true" aria-label="到期与还款提醒(只读占位)"></button>
</div>
<?php if (isAdmin()): ?>
<div class="section-title">危险操作</div>
<button type="button" class="hold-btn" data-hold-href="index.php?action=request_delete_archive&id=<?= $id ?>" aria-label="按住以申请删除">
<span class="fill" aria-hidden="true"></span><span class="lbl">按住申请删除(双管理员审批)</span>
</button>
<?php endif; ?>
</aside>
</div>
<?php pageFooter(); exit;
@@ -2217,6 +2223,7 @@ if ($action === 'archive_form') {
$editFiles = $fs->fetchAll();
}
pageHeader($me); ?>
<div class="crumbs"><a href="index.php?action=home">档案库</a><span>/</span><span><?= $editing ? '编辑档案' : '新建档案' ?></span></div>
<div class="page-head">
<div>
<h1 class="page-title"><?= $editing ? '编辑档案' : '新建档案' ?></h1>
@@ -2862,6 +2869,10 @@ if ($action === 'profile') {
<button type="button" data-theme-btn="night">夜间</button>
</div>
</div>
<div class="setting-row">
<div>到期与还款提醒<div class="hint">原系统无独立提醒开关,任务中心按到期日自动列出;此处仅保持版面,不写入设置。</div></div>
<button type="button" class="switch" role="switch" aria-checked="true" aria-disabled="true" aria-label="到期与还款提醒(只读占位)"></button>
</div>
</div>
<div class="editor-card">
<div class="section-title" style="margin-top:0;">会话</div>
@@ -2882,9 +2893,9 @@ if ($action === 'quick_queries') {
<div>
<h1 class="page-title">统计查询</h1>
<div class="page-sub">口径说明;统计语义与原系统一致</div>
<?php fusionQueryTabs('query_totals'); ?>
</div>
</div>
<?php fusionQueryTabs('query_totals'); ?>
<div class="card">
<div class="section-title" style="margin-top:0">便捷查询说明</div>
<?= quickQueryMenuHtml() ?>
@@ -2911,9 +2922,9 @@ if ($action === 'repayment_history') {
<div>
<h1 class="page-title">统计查询</h1>
<div class="page-sub">分期已还款与已完成档案本金规模</div>
<?php fusionQueryTabs('repayment_history'); ?>
</div>
</div>
<?php fusionQueryTabs('repayment_history'); ?>
<div class="card">
<div class="section-title" style="margin-top:0">汇总</div>
<div class="table-wrap">
@@ -2953,7 +2964,7 @@ if ($action === 'repayment_history') {
<td><?php if ((int)$pr['archive_id'] > 0): ?><a class="icon-btn" href="index.php?action=archive_detail&id=<?= (int)$pr['archive_id'] ?>">查看</a><?php else: ?>—<?php endif; ?></td>
</tr>
<?php endforeach; ?>
<?php if (empty($planRows)): ?><tr><td colspan="8" class="muted">暂无已标记还款的分期计划</td></tr><?php endif; ?>
<?php if (empty($planRows)): ?><tr><td colspan="8"><div class="empty-action"><div class="ea-title">暂无已标记还款的分期计划</div>已还款记录将按机构与档案汇总在此</div></td></tr><?php endif; ?>
</table>
</div>
</div>
@@ -2993,9 +3004,9 @@ if ($action === 'query_totals') {
<div>
<h1 class="page-title">统计查询</h1>
<div class="page-sub">四口径汇总,统计语义与原系统一致</div>
<?php fusionQueryTabs('query_totals'); ?>
</div>
</div>
<?php fusionQueryTabs('query_totals'); ?>
<div class="card">
<form method="get" class="toolbar-left" style="flex-wrap:wrap;gap:10px;align-items:flex-end">
<input type="hidden" name="action" value="query_totals">
@@ -3078,10 +3089,10 @@ if ($action === 'query_payable_interest') {
<div>
<h1 class="page-title">统计查询</h1>
<div class="page-sub">履行中及逾期中银行贷款利息与当月还款计划</div>
<?php fusionQueryTabs('query_payable_interest'); ?>
</div>
<a class="btn btn--plain" href="index.php?action=query_payable_interest&format=xlsx">导出xlsx</a>
</div>
<?php fusionQueryTabs('query_payable_interest'); ?>
<div class="card">
<div class="section-title" style="margin-top:0">一、银行贷款机构利息统计(履行中及逾期中)</div>
<div class="table-wrap"><table>
@@ -3105,7 +3116,7 @@ if ($action === 'query_payable_interest') {
}
?>
<tr><td><strong>合计</strong></td><td>-</td><td><strong><?= e(amount($sumCur)) ?></strong></td><td>-</td><td><strong><?= e(amount($sumSettle)) ?></strong></td></tr>
<?php else: ?><tr><td colspan="5" class="muted">暂无数据</td></tr><?php endif; ?>
<?php else: ?><tr><td colspan="5"><div class="empty-action"><div class="ea-title">暂无应付利息数据</div>履行中及逾期中的银行贷款将在此汇总</div></td></tr><?php endif; ?>
</table></div>
</div>
<div class="card" style="margin-top:12px">
@@ -3124,7 +3135,7 @@ if ($action === 'query_payable_interest') {
</tr>
<?php endforeach; ?>
<?php if (!empty($planRows)): ?><tr><td><strong>合计</strong></td><td colspan="3">-</td><td><strong><?= e(amount($planTotal)) ?></strong></td><td>-</td></tr><?php endif; ?>
<?php if (empty($planRows)): ?><tr><td colspan="6" class="muted">暂无当月还款计划</td></tr><?php endif; ?>
<?php if (empty($planRows)): ?><tr><td colspan="6"><div class="empty-action"><div class="ea-title">暂无当月还款计划</div>当月到期的本金 / 利息计划会列在这里</div></td></tr><?php endif; ?>
</table>
</div>
</div>
@@ -3169,9 +3180,9 @@ if ($action === 'query_external_guarantee') {
<div>
<h1 class="page-title">统计查询</h1>
<div class="page-sub">按担保人检索履行中及逾期中档案</div>
<?php fusionQueryTabs('query_external_guarantee'); ?>
</div>
</div>
<?php fusionQueryTabs('query_external_guarantee'); ?>
<div class="card">
<form method="get" class="toolbar-left">
<input type="hidden" name="action" value="query_external_guarantee">
@@ -3198,7 +3209,7 @@ if ($action === 'query_external_guarantee') {
<td><?= e($st) ?></td>
</tr>
<?php endforeach; ?>
<?php if (empty($resultRows)): ?><tr><td colspan="9" class="muted"><?= $kw === '' ? '请输入主体名称后查询' : '未命中履行中或逾期中的相关档案(已完成等已排除)' ?></td></tr><?php endif; ?>
<?php if (empty($resultRows)): ?><tr><td colspan="9"><div class="empty-action"><div class="ea-title"><?= $kw === '' ? '请输入主体名称后查询' : '未命中履行中或逾期中的相关档案' ?></div><?= $kw === '' ? '按担保人检索对外担保与相关银行贷款' : '已完成等状态已排除' ?></div></td></tr><?php endif; ?>
</table></div>
</div>
<?php pageFooter(); exit;
@@ -3609,7 +3620,7 @@ if ($action === 'pending_updates') {
</tr>
<?php endforeach; ?>
<?php if (empty($pendingUpdateRows)): ?>
<tr><td colspan="7" class="muted">暂无待更新项</td></tr>
<tr><td colspan="7"><div class="empty-action"><div class="ea-title">暂无待更新项</div>已到结息日、待经办确认的档案会列在这里</div></td></tr>
<?php endif; ?>
</tbody>
</table></div>
@@ -3744,7 +3755,7 @@ if ($action === 'reminders') {
</tr>
<?php endforeach; ?>
<?php if (empty($rows)): ?>
<tr><td colspan="7" class="muted">暂无提醒内容</td></tr>
<tr><td colspan="7"><div class="empty-action"><div class="ea-title">暂无提醒内容</div>到期、还款计划与逾期项会按类型列在这里</div></td></tr>
<?php endif; ?>
</tbody>
</table></div>
@@ -3800,6 +3811,9 @@ if ($action === 'dashboard') {
<div style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
<?php if (isAdmin()): ?>
<button type="button" class="btn btn--plain" data-open-modal="import">导入</button>
<?php endif; ?>
<a class="btn btn--plain" href="index.php?action=export&mode=all&format=xlsx&kind=all">导出</a>
<?php if (isAdmin()): ?>
<a class="btn btn--primary" href="index.php?action=archive_form">+ 新建档案</a>
<?php endif; ?>
</div>
@@ -3976,7 +3990,7 @@ if ($listView === 'dirs'):
<thead><tr><th>档案名称</th><th>借款主体</th><th>机构</th><th class="cell-right">剩余额度</th><th>状态</th></tr></thead>
<tbody>
<?php if (!$previewRows): ?>
<tr><td colspan="5" class="muted">该目录下暂无档案</td></tr>
<tr><td colspan="5"><div class="empty-action"><div class="ea-title">该目录下暂无档案</div>选择其他目录,或到档案列表查看全部档案</div></td></tr>
<?php else: foreach ($previewRows as $a):
$st = archiveStatusWithConfig($a['end_date'], getArchiveFinanceConfig($financeAllGlobal, (int)$a['id'])); ?>
<tr>