237 lines
9.6 KiB
HTML
237 lines
9.6 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
|
layout:decorate="~{layout/layout}">
|
|
|
|
<section layout:fragment="content">
|
|
<form autocomplete="off" method="get" name="reqForm" th:action="@{/communication/notices}"
|
|
th:object="${reqVO}">
|
|
|
|
<input name="page" th:field="*{page}" type="hidden"/>
|
|
<input name="size" th:field="*{size}" type="hidden"/>
|
|
|
|
<input name="userRole" th:value="${userRole}" type="hidden"/>
|
|
<input name="userRegionMainCode" th:value="${userRegionMainCode}" type="hidden"/>
|
|
|
|
<div class="content-inner">
|
|
<!-- 필터 영역 -->
|
|
<section class="filter-wrap">
|
|
<div class="form-area">
|
|
<!-- 검색필드 -->
|
|
<div class="input-group">
|
|
<div class="input-label">
|
|
<p class="label-txt">
|
|
검색필드
|
|
</p>
|
|
</div>
|
|
<div class="component-select">
|
|
<select class="select-list" th:field="*{searchField}" id="searchField">
|
|
<option value="all" selected>전체</option>
|
|
<option value="title">제목</option>
|
|
<option value="updatedBy">작성자</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="input-group">
|
|
<div class="input-label">
|
|
<p class="label-txt">
|
|
검색필드
|
|
</p>
|
|
</div>
|
|
<div class="component-input">
|
|
<div class="input-field">
|
|
<input type="text" id="searchValue" th:field="*{searchValue}" placeholder="검색어를 입력하세요.">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="input-group">
|
|
<div class="input-label">
|
|
<p class="label-txt">
|
|
검색필드
|
|
</p>
|
|
</div>
|
|
<div class="component-select">
|
|
<select class="select-list" th:field="*{searchOpen}" id="searchOpen">
|
|
<option value="" selected>전체</option>
|
|
<option value="true">Y</option>
|
|
<option value="false">N</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 버튼 그룹 -->
|
|
<div class="component-btns">
|
|
<div class="btns-row">
|
|
<button type="button" class="btn" onclick="location.href = location.pathname">
|
|
<span class="btn-txt">초기화</span>
|
|
</button>
|
|
<button type="submit" class="btn btn-primary">
|
|
<span class="btn-txt">검색</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<p class="input-label" style="font-size: 16px;">총 <span id="totalElements">0</span>건</p>
|
|
<!-- 테이블 영역 -->
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th style="width:50px">
|
|
<div class="component-input">
|
|
<label class="checkbox-inner">
|
|
<input type="checkbox" id="temp_checkbox_0003" name="temp_checkbox_0001">
|
|
</label>
|
|
</div>
|
|
</th>
|
|
<th>제목</th>
|
|
<th style="width:120px">게시일</th>
|
|
<th>게시기간</th>
|
|
<th style="width:80px">노출<br>여부</th>
|
|
<th style="width:250px">최종수정자</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="listTBody">
|
|
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<!-- 페이지네이션 -->
|
|
<div class="row paging"></div>
|
|
|
|
<div class="component-btns bottom-btn-group">
|
|
<div class="btns-row align-right">
|
|
<!-- 관리자만 노출 -->
|
|
<button type="button" class="btn btn-danger" th:if="${userRole == 'ROLE_ADMIN'}" onclick="goRemove()">
|
|
<span class="btn-txt">삭제 </span>
|
|
</button>
|
|
|
|
<button type="button" class="btn" th:if="${userRole == 'ROLE_ADMIN'}"
|
|
onclick="location.href='/communication/notices/create'">
|
|
<span class="btn-txt">등록 </span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
</section>
|
|
|
|
<section layout:fragment="script">
|
|
<script th:inline="javascript">
|
|
// 임가 목록 조회
|
|
const getHouseholds = (pageNo) => {
|
|
const f = document.reqForm;
|
|
f.page.value = pageNo;
|
|
|
|
let dataOj = $(f).serializeObject();
|
|
|
|
ajaxUtil._ajaxMethod(
|
|
'/api/communication/notices',
|
|
dataOj,
|
|
function(response) { // 성공
|
|
console.log("response", response);
|
|
|
|
$('#totalElements').text(response.totalElements);
|
|
|
|
const tbody = $('#listTBody');
|
|
tbody.empty();
|
|
|
|
$(response.content).each((idx, ct) => {
|
|
tbody.append(
|
|
`
|
|
<tr>
|
|
<td>
|
|
<div class="component-input">
|
|
<label class="checkbox-inner">
|
|
<input type="checkbox" name="selectIds" value="${ct.id}">
|
|
</label>
|
|
</div>
|
|
</td>
|
|
<td class="underline"><a href="/communication/notices/${ct.id}">${ct.title}</a></td>
|
|
<td>${uiUtil.isoStrToDateOnly(ct.createdAt)}</td>
|
|
<td>${uiUtil.isoStrToReadable(ct.startDate)} ~ ${uiUtil.isoStrToReadable(ct.endDate)}</td>
|
|
<td>${ct.visible ? 'Y' : 'N'}</td>
|
|
<td>${ct.updatedBy}(${uiUtil.isoStrToReadable(ct.updatedAt)})</td>
|
|
|
|
</tr>
|
|
`
|
|
);
|
|
});
|
|
|
|
// nodata 처리
|
|
if (!$(response.content).length) {
|
|
tbody.append(`
|
|
<tr>
|
|
<td colspan="6" class="text-center text-muted">공지사항이 존재하지 않습니다.</td>
|
|
</tr>
|
|
`);
|
|
}
|
|
|
|
// Pagination 구성하기
|
|
const paging = $('.paging');
|
|
paging.empty();
|
|
paging.append(
|
|
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
|
|
(movePageNo) => {
|
|
f.page.value = movePageNo;
|
|
goSearch();
|
|
}));
|
|
},
|
|
function (code, rstData) { // 실패
|
|
console.log("error : ", code);
|
|
},
|
|
'get',
|
|
'json'
|
|
);
|
|
}
|
|
|
|
// 최초 리스트 로드
|
|
getHouseholds(document.reqForm.page.value);
|
|
</script>
|
|
|
|
<script th:inline="javascript">
|
|
const goSearch = () => {
|
|
const f = document.reqForm;
|
|
f.method = 'GET';
|
|
f.submit();
|
|
}
|
|
function goRemove() {
|
|
if (!$('input[name=selectIds]').is(':checked')) {
|
|
alert(/*[[#{operation.common.remove.choose}]]*/);
|
|
return;
|
|
}
|
|
|
|
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
|
|
const f = document.reqForm;
|
|
const data = $(f).serializeObject();
|
|
|
|
$.ajax({
|
|
'method': 'DELETE',
|
|
'url': '/api/communication/notices/remove',
|
|
'data': {
|
|
'selectIds': data.selectIds
|
|
},
|
|
beforeSend: function (xhr) {
|
|
xhr.setRequestHeader(
|
|
$("meta[name='_csrf_header']").attr("content"),
|
|
$("meta[name='_csrf']").attr("content"));
|
|
},
|
|
success(res){
|
|
alert('선택한 아이템이 삭제되었습니다.');
|
|
f.method = 'GET';
|
|
f.submit();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
</section>
|
|
|
|
</html> |