You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
clean-parking/src/main/webapp/WEB-INF/views/biz/minwon/init/init.jsp

249 lines
10 KiB
Plaintext

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- Main body -->
<div class="main_body">
<section id="section8" class="main_bars">
<div class="bgs-main">
<section id="section5">
<div class="sub_title"></div>
<button type="button" onclick="location.href='<c:url value='/template/noticeSample/register.do'/>'" class="newbtn bg1">등록</button>
</section>
</div>
</section>
<div class="contants_body">
<div class="gs_b_top">
<ul class="lef">
<li class="th">검색구분</li>
<li>
<select id="searchCondition" name="searchCondition" class="input">
<option value="">검색구분</option>
<option value="title" <c:if test="${paramVO.searchCondition eq 'title'}">selected</c:if>>제목</option>
<option value="contents" <c:if test="${paramVO.searchCondition eq 'contents'}">selected</c:if>>내용</option>
<option value="writer" <c:if test="${paramVO.searchCondition eq 'writer'}">selected</c:if>>수정자명</option>
</select>
</li>
<li class="th">검색어</li>
<li><input type="text" id="searchKeyword" name="searchKeyword" class="input" value="${param.searchKeyword}"/></li>
<li class="th">담당자지정</li>
<li><input type="text" id="worker" name="worker" class="input" value=""/></li>
<li class="th">사용여부</li>
<li>
<select id="searchUseYn" name="searchUseYn" class="input">
<option value="">전체</option>
<option value="Y" <c:if test="${param.searchUseYn eq 'Y'}">selected</c:if>>사용</option>
<option value="N" <c:if test="${param.searchUseYn eq 'N'}">selected</c:if>>미사용</option>
</select>
</li>
<li class="th">접수일자 지정</li>
<li>
<input type="text" id="searchStartDt" name="searchStartDt" class="input calender datepicker bottom" value="${param.searchStartDt}" /> ~
<input type="text" id="searchEndDt" name="searchEndDt" class="input calender datepicker" value="${param.searchEndDt}" />
</li>
<li>
<button type="button" id="search_btn" class="newbtnss bg1">검색</button>
</li>
</ul>
<ul class="rig2">
<li>
<select id="perPageSelect" class="input">
<option value="10" <c:if test="${param.perPage eq '10'}">selected</c:if>>페이지당 10</option>
<option value="30" <c:if test="${empty param.perPage or param.perPage eq '30'}">selected</c:if>>페이지당 30</option>
<option value="100" <c:if test="${param.perPage eq '100'}">selected</c:if>>페이지당 100</option>
</select>
<span class="page_number"><span id="currentPage"></span><span class="bar">/</span><sapn id="totalPages"></sapn> Pages</span>
</li>
</ul>
</div>
<div class="gs_booking">
<div class="row">
<div class="col-sm-12">
<div class="box_column">
<div class="containers">
<div id="grid"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /Main body -->
<script type="text/javascript">
let GRID = null;
let INIT_POPUP = null;
let SEARCH_COND = {};
let perPage = parseInt($('#perPageSelect').val() || 10, 10);
// 검색정보 셋팅
let setSearchCond = function() {
let searchCondition = $.trim(nvl($("#searchCondition").val(), ""));
let searchKeyword = $.trim(nvl($("#searchKeyword").val(), ""));
let searchUseYn = $.trim(nvl($("#searchUseYn").val(), ""));
let searchStartDt = $.trim(nvl($("#searchStartDt").val(), ""));
let searchEndDt = $.trim(nvl($("#searchEndDt").val(), ""));
SEARCH_COND.searchCondition = searchCondition;
SEARCH_COND.searchKeyword = searchKeyword;
SEARCH_COND.searchUseYn = searchUseYn;
SEARCH_COND.searchStartDt = searchStartDt;
SEARCH_COND.searchEndDt = searchEndDt;
};
const fnBiz = {
init: () => {
initGrid();
},
eventListener: () => {
// 검색 버튼 클릭 이벤트
$('#search_btn').on('click', function() {
// 등록일 from~to 유효성 검사
let startDate = $("#searchStartDt").val();
let endDate = $("#searchEndDt").val();
// 시작일과 종료일 중 하나만 입력된 경우 체크
if ((startDate && !endDate) || (!startDate && endDate)) {
alert("등록일 검색 시 시작일과 종료일을 모두 입력해주세요.");
return;
}
// 시작일과 종료일이 모두 입력된 경우 유효성 검사
if (startDate && endDate) {
if (!isDate(startDate) || !isDate(endDate)) {
alert("유효한 날짜 형식이 아닙니다. (YYYY-MM-DD)");
return;
}
// 시작일이 종료일보다 늦은 경우 체크
let startDateObj = new Date(startDate);
let endDateObj = new Date(endDate);
if (startDateObj > endDateObj) {
alert("시작일은 종료일보다 이후일 수 없습니다.");
return;
}
}
// 페이지를 1로 리셋
$("#page").val(1);
// 그리드 데이터 리로드
TuiGrid.instance.readData(1);
});
// 검색어 입력 필드에서 엔터키 이벤트 처리
$('#searchKeyword').on('keypress', function(e) {
if (e.which === 13) { // 엔터키 코드는 13
e.preventDefault(); // 기본 이벤트 방지
$('#search_btn').trigger('click'); // 검색 버튼 클릭 이벤트 트리거
}
});
// perPage 변경 이벤트 추가
$('#perPageSelect').on('change', () => {
const pagination = TuiGrid.instance.getPagination();
if (!pagination) return;
pagination.setItemsPerPage($('#perPageSelect').val());
pagination.reset(TuiGrid.instance.getRowCount());
pagination.movePageTo(1);
});
}
}
/** tui-grid Set */
const initGrid = () => {
const gridColumns = [
{header: '등록구분', name: 'mmDlgb', sortable: true, width: 50,},
{header: '목록번호', name: 'asBbsNo', sortable: true, width: 70,},
{header: '신고자', name: 'mmSgnm', sortable: true, width: 100,},
{header: '담당자', name: 'mmSgtel', sortable: true, width: 100,},
{header: '전화번호', name: 'asTel', width: 150,},
{header: '접수일자', name: 'asJsdate', sortable: true, width: 70,},
{header: '처리기한', name: 'asLimitDt', sortable: true, width: 70,},
{header: '위반일자', name: 'mmDate', sortable: true, width: 150,},
{header: '첨부', name: 'mmImagegb', width: 150,},
{header: '사진갯수', name: 'mmImagecnt', width: 50,},
{header: '위반내용', name: 'mmSgcont', width: 250,},
{header: '접수번호', name: 'asJsno', sortable: true, width: 150,},
{header: '차량번호', name: 'mmCarno', sortable: true, width: 150,},
{header: 'mmCode', name: 'mmCode', sortable: true, width: 150, align: 'center', hidden: true}
];
const gridDatasource = {
api: {
readData: {
url: '<c:url value="/minwon/init/list.ajax"/>',
method: 'POST',
contentType: 'application/x-www-form-urlencoded',
processData: true
}
},
initialRequest: true, //초기화시 조회
serializer: function (params) {
setSearchCond();
SEARCH_COND.perPage = params.perPage;
SEARCH_COND.page = params.page;
return $.param(SEARCH_COND);
}
}
const gridOptions = {
el: 'grid',
rowHeaders: ['checkbox'],
columns: gridColumns,
noData: "처리 할 초기자료가 없습니다.",
pageOptions: {
useClient: true, // 클라이언트 페이징 여부(false: 서버 페이징)
perPage: perPage,
},
};
GRID = TuiGrid.of(gridOptions, gridDatasource, (res) => {
GRID.on("dblclick", (e) => {
var popUrl = '/minwon/init/init_popup.do';
var popTitle = "initPopup";
var popOption = "width=1400px, height=900px, resizable=yes, scrollbars=yes, location=no, top=100px, left=100px";
// 1) localStorage에 저장
console.log(e)
let cursor = e.instance.getValue(e.rowKey, 'mmCode');
let mmCodes = e.instance.getData().map(row => row.mmCode);
const state = { cursor, mmCodes, savedAt: Date.now() };
localStorage.setItem('TOTAL_INFO_STATE', JSON.stringify(state));
// 2) 팝업이 없거나 닫혀 있으면 새로 열기
if (!INIT_POPUP || INIT_POPUP.closed) {
INIT_POPUP = window.open(popUrl, popTitle, popOption);
} else {
// 이미 떠 있으면 새로 안 만들고, 그 창에 포커스만 줌
INIT_POPUP.focus();
INIT_POPUP.INIT_POP_API.search();
}
});
});
};
// 레디펑션
$(function () {
fnBiz.init();
fnBiz.eventListener();
});
</script>