계정 관리 삭제 기능 수정
- 삭제(비활성화) 후 목록에서 즉시 숨겨지도록 수정 (기본값: 활성 계정만 표시) - "비활성 계정 포함" 체크박스 추가 — 필요 시 비활성 계정도 확인 가능 - delUser 에러 처리 추가 (try/catch + alert) - 삭제 확인 메시지 개선 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -52,11 +52,15 @@
|
||||
</div>
|
||||
|
||||
<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">
|
||||
<option value="">전체</option><option value="mechanic">정비사</option>
|
||||
<option value="manufacturer">제조사</option><option value="admin">관리자</option>
|
||||
</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 class="tbl-wrap"><table>
|
||||
<thead><tr>
|
||||
@@ -169,10 +173,12 @@ async function rejectUser(id, name) {
|
||||
|
||||
async function load() {
|
||||
const role = document.getElementById('fRole').value;
|
||||
const showInactive = document.getElementById('chkInactive').checked;
|
||||
const users = await API.get('/accounts'+(role?'?role='+role:''));
|
||||
document.getElementById('chkAll').checked = false;
|
||||
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>
|
||||
<td class="cb-cell" onclick="event.stopPropagation()">
|
||||
<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><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>
|
||||
<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('');
|
||||
}
|
||||
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();
|
||||
} 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();
|
||||
load();
|
||||
</script></body></html>
|
||||
|
||||
Reference in New Issue
Block a user