Files
korea-research/admin/src/main/resources/templates/admin/adminUpdateForm.html
2025-07-14 14:57:47 +09:00

254 lines
12 KiB
HTML

<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form
method="post"
th:action="${'/settings/admins/update/' + bindingVO.id}"
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="roleId">권한<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td>
<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>
<tr>
<th><label for="id">ID<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td>
<div class="component-input">
<div class="input-field">
<input id="id" readonly="readonly" th:field="*{id}"/>
</div>
</div>
</td>
<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="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>
<span>총 5자 / 숫자 + 특수문자 1개 이상 (!,@,#,$,%,_,-)</span>
</div>
</td>
</tr>
<tr class="researcherArea"
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">
<div class="input-field">
<input id="name" type="text" name="name"
th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
th:field="*{name}" maxlength="10" />
<div class="invalid-feedback fw-bold"
th:if="${#fields.hasErrors('name')}">
에러 메세지
</div>
</div>
</div>
</td>
<th><label for="name">전화번호<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td>
<div class="d-flex">
<div class="component-select">
<select class="select-list" required>
<option value="value1" selected>010</option>
</select>
</div>
<div class="component-input">
<div class="input-field">
<input type="number" id="phone1" name="phone1" placeholder="" maxlength="4"
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="" maxlength="4"
th:value="${bindingVO.phone2 != null ? bindingVO.phone2 : ''}">
</div>
</div>
<div class="invalid-feedback fw-bold"
th:if="${#fields.hasErrors('phone2')}">
에러 메세지
</div>
</div>
</td>
</tr>
<tr class="regionMainCodeArea"
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">
<select class="select-list" id="regionMainCode" name="regionMainCode"
th:classappend="${#fields.hasErrors('regionMainCode')} ? 'is-invalid'"
th:field="*{regionMainCode}">
<option value="">선택</option>
<option th:each="code : ${regionMainCode}"
th:value="${code.id}"
th:text="${code.codeText}">
</option>
</select>
</div>
<div class="invalid-feedback fw-bold" th:errors="*{regionMainCode}"
th:if="${#fields.hasErrors('regionMainCode')}">
에러 메세지
</div>
</td>
</tr>
<tr>
<th> <label>사용 여부<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
<td class="radio-group">
<div class="component-input">
<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>
</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>
</label>
</div>
<div class="invalid-feedback fw-bold" th:errors="*{accountDisabled}"
th:if="${#fields.hasErrors('accountDisabled')}">
에러 메세지
</div>
</td>
</tr>
</tbody>
</table>
<!-- <div th:replace="common/components :: auditArea"></div>-->
<div class="component-btns bottom-btn-group">
<div class="btns-row">
<button type="button" class="btn btn-secondary" onclick="gotoList();return false;">
<span class="btn-txt">목록</span>
</button>
<button type="button" class="btn btn-primary" onclick="updateAdmin();">
<span class="btn-txt">저장</span>
</button>
</div>
</div>
</div>
</form>
<!-- 이전 목록페이지의 검색 및 정렬조건 폼 -->
<th:block th:if="${listStatus != null}">
<form method="get" name="prevAdminParamForm"
th:action="@{/settings/admins}"
th:object="${listStatus}">
<input th:field="*{searchField}" type="hidden">
<input th:field="*{searchValue}" type="hidden">
<input th:field="*{searchRole}" type="hidden">
<th:block th:if="${pageable != null}">
<input name="page" th:value="${pageable.page}" type="hidden"/>
<input name="sort" th:value="${pageable.sort}" type="hidden"/>
</th:block>
</form>
</th:block>
<th:block layout:fragment="script">
<script th:inline="javascript">
function gotoList() {
location.href = '/settings/admins';
}
$(document).ready(() => {
// 초기 로드 시 roleId에 따라 regionMainCodeArea 표시/숨김
const roleSelect = document.getElementById('roleId');
if (roleSelect) {
onRoleChange(roleSelect);
}
/* $('form').on('submit', function() {
const phone1 = $('#phone1').val();
const phone2 = $('#phone2').val();
if (phone1 && phone2) {
$('#phone').val('010-' + phone1 + "-" + phone2);
} else {
$('#phone').val('');
}
});*/
});
const onRoleChange = (el) => {
const isAdmin = el.value === 'ROLE_ADMIN' || !el.value;
const idResearcher = el.value === 'ROLE_RESEARCHER' || !el.value;
$('.regionMainCodeArea').toggle(!isAdmin);
$('.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>
</section>
</html>