계정 관리 삭제 기능 수정

- 삭제(비활성화) 후 목록에서 즉시 숨겨지도록 수정 (기본값: 활성 계정만 표시)
- "비활성 계정 포함" 체크박스 추가 — 필요 시 비활성 계정도 확인 가능
- delUser 에러 처리 추가 (try/catch + alert)
- 삭제 확인 메시지 개선

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
byun
2026-05-31 19:05:49 +09:00
parent 16f7ee651b
commit 7ab8a5065e

View File

@@ -52,11 +52,15 @@
</div> </div>
<div class="card"> <div class="card">
<div style="display:flex;gap:10px;margin-bottom:14px;"> <div style="display:flex;gap:10px;margin-bottom:14px;align-items:center;flex-wrap:wrap;">
<select id="fRole" onchange="load()" style="width:auto"> <select id="fRole" onchange="load()" style="width:auto">
<option value="">전체</option><option value="mechanic">정비사</option> <option value="">전체</option><option value="mechanic">정비사</option>
<option value="manufacturer">제조사</option><option value="admin">관리자</option> <option value="manufacturer">제조사</option><option value="admin">관리자</option>
</select> </select>
<label style="display:flex;align-items:center;gap:6px;font-size:13px;cursor:pointer;">
<input type="checkbox" id="chkInactive" onchange="load()" style="width:14px;height:14px;">
비활성 계정 포함
</label>
</div> </div>
<div class="tbl-wrap"><table> <div class="tbl-wrap"><table>
<thead><tr> <thead><tr>
@@ -169,10 +173,12 @@ async function rejectUser(id, name) {
async function load() { async function load() {
const role = document.getElementById('fRole').value; const role = document.getElementById('fRole').value;
const showInactive = document.getElementById('chkInactive').checked;
const users = await API.get('/accounts'+(role?'?role='+role:'')); const users = await API.get('/accounts'+(role?'?role='+role:''));
document.getElementById('chkAll').checked = false; document.getElementById('chkAll').checked = false;
updateDeleteBtn(); updateDeleteBtn();
document.getElementById('tbody').innerHTML = users.filter(u => !u.is_pending).map(u=>` const filtered = users.filter(u => !u.is_pending && (showInactive || u.is_active));
document.getElementById('tbody').innerHTML = filtered.map(u=>`
<tr> <tr>
<td class="cb-cell" onclick="event.stopPropagation()"> <td class="cb-cell" onclick="event.stopPropagation()">
<input type="checkbox" class="row-chk" data-id="${u.id}" <input type="checkbox" class="row-chk" data-id="${u.id}"
@@ -182,7 +188,7 @@ async function load() {
<td>${u.name}</td><td>${u.company||'-'}</td><td>${u.phone||'-'}</td> <td>${u.name}</td><td>${u.company||'-'}</td><td>${u.phone||'-'}</td>
<td><span class="badge ${u.is_active?'s-done':'s-waiting'}">${u.is_active?'활성':'비활성'}</span></td> <td><span class="badge ${u.is_active?'s-done':'s-waiting'}">${u.is_active?'활성':'비활성'}</span></td>
<td><button class="btn btn-outline btn-sm" onclick="editUser(${u.id})">수정</button> <td><button class="btn btn-outline btn-sm" onclick="editUser(${u.id})">수정</button>
<button class="btn btn-danger btn-sm" onclick="delUser(${u.id})">삭제</button></td> ${u.is_active ? `<button class="btn btn-danger btn-sm" onclick="delUser(${u.id})">삭제</button>` : ''}</td>
</tr>`).join(''); </tr>`).join('');
} }
function openModal() { document.getElementById('modal').classList.remove('hidden'); document.getElementById('eId').value=''; document.getElementById('eUsername').disabled=false; document.getElementById('pwReq').style.display='inline'; } function openModal() { document.getElementById('modal').classList.remove('hidden'); document.getElementById('eId').value=''; document.getElementById('eUsername').disabled=false; document.getElementById('pwReq').style.display='inline'; }
@@ -221,7 +227,11 @@ async function save() {
closeModal(); load(); closeModal(); load();
} catch(e) { const el=document.getElementById('modalErr'); el.textContent=e.message; el.style.display='block'; } } catch(e) { const el=document.getElementById('modalErr'); el.textContent=e.message; el.style.display='block'; }
} }
async function delUser(id) { if(!confirm('비활성 처리하시겠습니까?')) return; await API.delete('/accounts/'+id); load(); } async function delUser(id) {
if (!confirm('계정을 삭제하시겠습니까?\n(처리 이력이 있는 계정은 비활성 처리됩니다.)')) return;
try { await API.delete('/accounts/'+id); load(); }
catch(e) { alert('오류: ' + e.message); }
}
loadPending(); loadPending();
load(); load();
</script></body></html> </script></body></html>