法院执行本息计算器

录入案件基础信息,持续管理每次还款记录,随时查询最新结果

0.9.3 测试版
注册登录后可录入当事人资料,保存历史案件和还款记录,随时查询并添加最新还款记录;不注册也可直接计算,数据不保存。
剩余本金¥0
累计利息(至今日)¥0
当前应还总额¥0
债务状态:请填写案件基础信息

还款节点明细

序号还款日期天数期初本金本段利息还款金额剩余本金操作
(()=>{let me=null,currentId=null;const api=(u,o={})=>fetch(u,{headers:{'content-type':'application/json'},...o}).then(async r=>{let j=await r.json();if(!r.ok)throw Error(j.error);return j});let style=document.createElement('style');style.textContent='.modalMask{position:fixed;inset:0;background:#0006;display:none;place-items:center;z-index:99}.modalBox{background:#fff;width:min(420px,92vw);padding:24px;border-radius:8px}.modalBox input{width:100%;height:40px;margin:6px 0 12px;padding:0 10px;border:1px solid #cbd5e1}.historyItem{padding:12px;border-bottom:1px solid #eee;cursor:pointer}.accountFields{display:none}';document.head.append(style);document.body.insertAdjacentHTML('beforeend','
');let base=document.querySelector('.base h2');base.insertAdjacentHTML('afterend','
');let tools=document.querySelector('.tools');tools.insertAdjacentHTML('afterbegin','');let mode='login';function open(m){mode=m;authTitle.textContent=m==='login'?'登录':'注册';authNick.style.display=m==='register'?'block':'none';authModal.style.display='grid';authErr.textContent=''}loginBtn.onclick=()=>open('login');registerBtn.onclick=()=>open('register');authClose.onclick=()=>authModal.style.display='none';historyClose.onclick=()=>historyModal.style.display='none';authSubmit.onclick=async()=>{try{if(mode==='register'){await api('/api/register',{method:'POST',body:JSON.stringify({phone:authPhone.value,nickname:authNick.value,password:authPass.value})});alert('注册成功,请登录');open('login')}else{me=await api('/api/login',{method:'POST',body:JSON.stringify({phone:authPhone.value,password:authPass.value})});authModal.style.display='none';logged()}}catch(e){authErr.textContent=e.message}};function logged(){loginBtn.textContent=me.nickname;registerBtn.textContent='退出';registerBtn.onclick=async()=>{await api('/api/logout',{method:'POST'});location.reload()};document.querySelector('.accountFields').style.display='block';saveCase.style.display=historyBtn.style.display='inline-block'}saveCase.onclick=async()=>{if(!me)return open('login');let start=dateValue();if(!principal.value||!validDate(start))return alert('请完整填写案件基础信息');try{let x=await api('/api/cases',{method:'POST',body:JSON.stringify({id:currentId,partyName:partyName.value,idNumber:idNumber.value,principal:+principal.value,start,rate:+rate.value,unit:unit.value,payments:state.nodes})});currentId=x.id;alert('案件已保存')}catch(e){alert(e.message)}};historyBtn.onclick=async()=>{if(!me)return open('login');try{let cs=await api('/api/cases');historyList.innerHTML=cs.length?cs.map((c,i)=>'
'+(c.party_name||'未命名当事人')+'
'+c.interest_start+' 本金 ¥'+Number(c.principal).toLocaleString()+'
').join(''):'暂无历史案件';historyList.onclick=e=>{let x=e.target.closest('[data-i]');if(!x)return;let c=cs[+x.dataset.i];currentId=c.id;partyName.value=c.party_name||'';idNumber.value=c.id_number||'';principal.value=c.principal;let d=String(c.interest_start).slice(0,10).split('-');sy.value=d[0];sm.value=+d[1];sd.value=+d[2];rate.value=c.rate;unit.value=c.rate_unit;state.nodes=c.payments.map(p=>({date:String(p.date).slice(0,10),amount:String(p.amount)}));while(state.nodes.length<5)state.nodes.push({date:'',amount:''});historyModal.style.display='none';render()};historyModal.style.display='grid'}catch(e){alert(e.message)}};saveCase.style.display=historyBtn.style.display='none';api('/api/me').then(x=>{me=x;logged()}).catch(()=>{})})();