관리자 목록 수정

This commit is contained in:
주수현
2025-06-25 15:54:34 +09:00
parent b2357e91f4
commit 93d8219b3c
14 changed files with 154 additions and 129 deletions

View File

@@ -235,19 +235,18 @@
ajaxUtil._ajaxMethod(
'/api/settings/admin/create',
JSON.stringify(dataOj),
function(response) { // 성공
alert("등록이 완료되었습니다.");
location.href = '/settings/admins';
function(response) {
},
function (code, rstData) {
if(code == 422) alert(rstData.responseText);
if(code == 200 ){
if(code === 422) alert(rstData.responseText);
if(code === 200 ){
alert("등록이 완료되었습니다.");
location.href = '/settings/admins';
}
},
'post',
'json'
'json',
{ handle422Type: 'alert' }
);
}
</script>

View File

@@ -96,13 +96,12 @@
<label><input class="form-check-input" onchange="toggleCheckbox(this);"
type="checkbox"/></label>
</th>
<th scope="col"><a class="order-able" data-sort-field="id" href="#">아이디</a></th>
<th scope="col"><a class="order-able" data-sort-field="id" href="#">이름</a></th>
<th class="text-secondary" scope="col">권한</th></th>
<th scope="col"><a class="order-able" data-sort-field="id" href="#">실사</a></th>
<th scope="col"><a class="order-able" data-sort-field="accountDisabled" href="#">계정사용여부</a></th>
<th scope="col"><a class="order-able" data-sort-field="createdAt" href="#">생성일</a>
</th>
<th scope="col">아이디</th>
<th scope="col">이름</th>
<th scope="col">권한</th>
<th scope="col">실사</th>
<th scope="col">계정사용여부</th>
<th scope="col">생성일</th>
</tr>
</thead>
<tbody>
@@ -166,12 +165,9 @@
f.searchDisabled.value = '';
}
// 수정페이지 이동
function goUpdate(adminId) {
const f = document.adminParamForm;
f.action = '/settings/admins/update/' + adminId;
f.method = 'get';
f.submit();
location.href = '/settings/admins/update/' + adminId; // 쿼리 파라미터 없이 이동
}
// 체크박스 선택/해제

View File

@@ -6,28 +6,34 @@
<form
method="post"
th:action="${'/settings/admins/update/' + bindingVO.id}"
th:object="${bindingVO}">
th:object="${bindingVO}"
name="adminUpdateForm"
onsubmit="event.preventDefault(); updateAdmin(); return false;">
<div class="content-inner">
<input type="hidden" name="seq" th:field="*{seq}"/>
<table class="type-form">
<tbody>
<tr>
<th> <label for="roleIds">권한<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<th> <label for="roleId">권한<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td>
<div class="component-select">
<select class="select-list" id="roleIds"
th:classappend="${#fields.hasErrors('roleIds')} ? 'is-invalid'"
th:field="*{roleIds}"
onchange="onRoleChange(this);">
<option value="">선택</option>
<option th:each="role : ${roles}" th:text="${role.description}"
th:value="${role.id}"></option>
</select>
</div>
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
th:if="${#fields.hasErrors('roleIds')}">
에러 메세지
<div class="d-flex">
<div class="component-input">
<div class="component-select">
<select class="select-list" id="roleId"
th:classappend="${#fields.hasErrors('roleId')} ? 'is-invalid'"
th:field="*{roleId}"
onchange="onRoleChange(this);">
<option value="">선택</option>
<option th:each="role : ${roles}" th:text="${role.description}"
th:value="${role.id}"></option>
</select>
</div>
<div class="invalid-feedback fw-bold" th:errors="*{roleId}"
th:if="${#fields.hasErrors('roleId')}">
에러 메세지
</div>
</div>
</div>
</td>
</tr>
@@ -40,24 +46,25 @@
</div>
</div>
</td>
<th><label for="password">비밀번호<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<th><label for="updatePassword">비밀번호<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td>
<div class="component-input">
<div class="input-field">
<input id="password" placeholder="암호를 변경하고 싶다면 입력하세요"
<input id="updatePassword" placeholder="암호를 변경하고 싶다면 입력하세요"
th:classappend="${#fields.hasErrors('updatePassword')} ? 'is-invalid'"
th:field="*{updatePassword}"
type="password"/>
<div class="invalid-feedback fw-bold" th:errors="*{updatePassword}"
th:if="${#fields.hasErrors('updatePassword')}">
에러 메세지
</div>
</div>
<div class="invalid-feedback fw-bold" th:errors="*{updatePassword}"
th:if="${#fields.hasErrors('updatePassword')}">
에러 메세지
</div>
<span>총 5자 / 숫자 + 특수문자 1개 이상 (!,@,#,$,%,_,-)</span>
</div>
</td>
</tr>
<tr class="researcherArea"
th:classappend="${#lists.isEmpty(bindingVO.roleIds) or #lists.contains(bindingVO.roleIds, 'ROLE_LOCAL_INSPECTOR')} ? 'd-none'">
th:classappend="${#lists.isEmpty(bindingVO.roleId) or #lists.contains(bindingVO.roleId, 'ROLE_LOCAL_INSPECTOR')} ? 'd-none'">
<th><label for="name">이름<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td>
<div class="component-input">
@@ -83,25 +90,28 @@
<div class="component-input">
<div class="input-field">
<input type="number" id="phone1" name="phone1" placeholder=""
th:value="${bindingVO.phone != null ? bindingVO.phone.substring(4, 8) : ''}">
th:value="${bindingVO.phone1 != null ? bindingVO.phone1 : ''}">
</div>
</div>
<div class="invalid-feedback fw-bold"
th:if="${#fields.hasErrors('phone1')}">
에러 메세지
</div>
<div class="component-input">
<div class="input-field">
<input type="number" id="phone2" name="phone2" placeholder=""
th:value="${bindingVO.phone != null ? bindingVO.phone.substring(9, 13) : ''}">
th:value="${bindingVO.phone2 != null ? bindingVO.phone2 : ''}">
</div>
</div>
<div class="invalid-feedback fw-bold"
th:if="${#fields.hasErrors('phone2')}">
에러 메세지
</div>
</div>
<div class="invalid-feedback fw-bold"
th:if="${#fields.hasErrors('phone')}">
에러 메세지
</div>
<input type="hidden" name="phone" id="phone" th:field="*{phone}"/>
</td>
</tr>
<tr class="regionMainCodeArea"
th:classappend="${#lists.isEmpty(bindingVO.roleIds) or #lists.contains(bindingVO.roleIds, 'ROLE_ADMIN')} ? 'd-none'">
th:classappend="${#lists.isEmpty(bindingVO.roleId) or #lists.contains(bindingVO.roleId, 'ROLE_ADMIN')} ? 'd-none'">
<th><label for="regionMainCode">실사<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td>
<div class="component-select">
@@ -128,16 +138,16 @@
<label for="inlineRadio1" class="radio-inner">
<input id="inlineRadio1" th:field="*{accountDisabled}" type="radio" value="true">
<span class="radio-item">
<span class="radio-txt">미사용</span>
</span>
<span class="radio-txt">미사용</span>
</span>
</label>
</div>
<div class="component-input">
<label for="inlineRadio2" class="radio-inner">
<input id="inlineRadio2" th:field="*{accountDisabled}" type="radio" value="false">
<span class="radio-item">
<span class="radio-txt">사용</span>
</span>
<span class="radio-txt">사용</span>
</span>
</label>
</div>
<div class="invalid-feedback fw-bold" th:errors="*{accountDisabled}"
@@ -148,6 +158,7 @@
</tr>
</tbody>
</table>
<!-- <div th:replace="common/components :: auditArea"></div>-->
<div class="component-btns bottom-btn-group">
@@ -155,12 +166,13 @@
<button type="button" class="btn btn-secondary" onclick="gotoList();return false;">
<span class="btn-txt">목록</span>
</button>
<button type="submit" class="btn btn-primary">
<button type="button" class="btn btn-primary" onclick="updateAdmin();">
<span class="btn-txt">저장</span>
</button>
</div>
</div>
</div>
</form>
<!-- 이전 목록페이지의 검색 및 정렬조건 폼 -->
@@ -185,18 +197,14 @@
}
$(document).ready(() => {
showAudit([[${bindingVO.id}]], [[${bindingVO.createdBy}]],
[[${#temporals.format(bindingVO.createdAt, "yyyy-MM-dd'T'HH:mm:ss")}]],
[[${bindingVO.updatedBy}]],
[[${#temporals.format(bindingVO.updatedAt, "yyyy-MM-dd'T'HH:mm:ss")}]]);
// 초기 로드 시 roleIds에 따라 regionMainCodeArea 표시/숨김
const roleSelect = document.getElementById('roleIds');
// 초기 로드 시 roleId에 따라 regionMainCodeArea 표시/숨김
const roleSelect = document.getElementById('roleId');
if (roleSelect) {
onRoleChange(roleSelect);
}
$('form').on('submit', function() {
/* $('form').on('submit', function() {
const phone1 = $('#phone1').val();
const phone2 = $('#phone2').val();
if (phone1 && phone2) {
@@ -204,7 +212,7 @@
} else {
$('#phone').val('');
}
});
});*/
});
@@ -215,6 +223,29 @@
$('.researcherArea').toggle(idResearcher);
};
const updateAdmin = () => {
const f = document.adminUpdateForm;
let dataOj = $(f).serializeObject();
ajaxUtil._ajaxMethod(
'/api/settings/admin/update',
JSON.stringify(dataOj),
function(response) {
},
function (code, rstData) {
if(code === 422) alert(rstData.responseText);
if(code === 200 ){
alert("수정이 완료되었습니다.");
location.href = '/settings/admins';
}
},
'post',
'json',
{ handle422Type: 'alert' }
);
}
</script>
</th:block>