조사원 현황 수정

This commit is contained in:
주수현
2025-06-14 17:43:04 +09:00
parent efe27296bf
commit f061085ce3
9 changed files with 178 additions and 122 deletions

View File

@@ -11,7 +11,7 @@
a.name,
a.phone,
max(u.code_text) AS region_main_code_name,
case a.account_disabled when false then '활성화' when true then '비활성화' end account_disabled_flag
case a.account_disabled when false then '사용' when true then '미사용' end account_disabled_flag
from admin a
join admin_has_role ahr ON a.seq = ahr.admin_seq
left join uicode u ON u.parent_id = 'code.region.main' AND u.id = a.region_main_code
@@ -25,6 +25,9 @@
<if test="searchField == 'phone' and searchValue != null and searchValue != ''">
and a.phone LIKE CONCAT('%', #{searchValue}, '%')
</if>
<if test="searchArea != null and searchArea != ''">
and a.region_main_code = #{searchArea}
</if>
<if test="searchAccountDisabled != null and searchAccountDisabled != ''">
and a.account_disabled = #{searchAccountDisabled}
</if>
@@ -56,7 +59,7 @@
a.name,
a.phone,
u.code_text AS region_main_code_name,
case a.account_disabled when false then '활성화' when true then '비활성화' end account_disabled_flag
case a.account_disabled when false then '사용' when true then '미사용' end account_disabled_flag
from admin a
join admin_has_role ahr ON a.seq = ahr.admin_seq
left join uicode u ON u.parent_id = 'code.region.main' AND u.id = a.region_main_code
@@ -86,8 +89,8 @@
left join uicode il ON il.parent_id = 'code.industry.large' AND il.id = h.industry_large_code
left join uicode im ON im.parent_id = 'code.industry.middle' AND im.id = h.industry_middle_code
where ahr.role_id = 'ROLE_RESEARCHER' and ahr.is_deleted = false
<if test="adminSeq > 0">
and a.seq = #{adminSeq}
<if test="seq > 0">
and ahr.admin_seq = #{seq}
</if>
LIMIT #{size} OFFSET #{page}*#{size}
</select>
@@ -98,8 +101,8 @@
from household h
join admin_has_role ahr ON h.seq = ahr.admin_seq
where ahr.role_id = 'ROLE_RESEARCHER' and ahr.is_deleted = false
<if test="adminSeq > 0">
and a.admin_seq = #{adminSeq}
<if test="seq > 0">
and ahr.admin_seq = #{seq}
</if>
</select>
@@ -108,7 +111,7 @@
select
rhv.id,
rhv.admin_seq,
rhv.household_seq
rhv.household_seq,
h.household_num,
h.owner_name,
rhv.visit_date,
@@ -119,8 +122,11 @@
join household h on rhv.household_seq = h.seq
join admin a on a.seq = rhv.admin_seq
where rhv.is_deleted = false
<if test="adminSeq > 0">
and rhv.admin_seq = #{adminSeq}
<if test="seq > 0">
and rhv.admin_seq = #{seq}
</if>
<if test="searchMonth != null and searchMonth != ''">
and TO_CHAR(rhv.visit_date ,'YYYYMM')= #{searchMonth}
</if>
LIMIT #{size} OFFSET #{page}*#{size}
</select>
@@ -129,9 +135,23 @@
select count(*)
from researcher_household_visit rhv
where rhv.is_deleted = false
<if test="adminSeq > 0">
and rhv.admin_seq = #{adminSeq}
<if test="seq > 0">
and rhv.admin_seq = #{seq}
</if>
<if test="searchMonth != null and searchMonth != ''">
and TO_CHAR(rhv.visit_date ,'YYYYMM')= #{searchMonth}
</if>
</select>
<update id="visitHouseholdDelete">
update researcher_household_visit
set is_deleted = true,
deleted_at = NOW(),
deleted_by = #{deletedBy}
where id in (
<foreach collection="selectIds" item="item" separator=",">
#{item}
</foreach>)
</update>
</mapper>

View File

@@ -2,7 +2,7 @@
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<th layout:fragment="content">
<section>
<!-- 테이블 영역 -->
<table class="type-form confirm" th:object="${researcherDto}" >
@@ -42,10 +42,20 @@
</div>
</section>
<section>
<form autocomplete="off" method="get" name="householdReqForm" th:object="${reqVO}">
<div class="component-tab" data-active="tab1">
<div class="tab-head">
<button type="button" class="tab-label" data-tab-value="tab1">담당 임가 목록</button>
<button type="button" class="tab-label" data-tab-value="tab2">임가방문정보</button>
<div class="component-select select-date" id="monthTab2" style="display: none;">
<select name="searchMonth" class="select-list search-month-container" onchange="getHouseholdVisitList(0);">
<option th:each="month : ${monthList}"
th:value="${month.value}"
th:text="${month.label}"
th:selected="${month.value == currentMonth}">
</option>
</select>
</div>
</div>
<div class="row">
<div class="col text-start">
@@ -55,27 +65,28 @@
</div>
</div>
<form autocomplete="off" method="get" name="householdReqForm" th:object="${reqVO}">
<!-- hidden parameters -->
<input name="page" th:field="*{page}" type="hidden"/>
<input name="adminSeq" th:field="${researcherDto.seq}" type="hidden"/>
</form>
<!-- hidden parameters -->
<input name="page" th:field="*{page}" type="hidden"/>
<input name="adminSeq" th:field="${researcherDto.seq}" type="hidden"/>
<div class="tab-body">
<div class="tab-content" data-tab-value="tab1">
<div class="content-inner">
<table>
<thead>
<tr>
<th>임가번호</th>
<th>경영주명</th>
<th>휴대폰번호</th>
<th>실사</th>
<th>지역</th>
<th>세부지역</th>
<th>업종 대분류</th>
<th>업종 중분류1</th>
<th>유지여부</th>
</tr>
<tr>
<th>임가번호</th>
<th>경영주명</th>
<th>휴대폰번호</th>
<th>실사</th>
<th>지역</th>
<th>세부지역</th>
<th>업종 대분류</th>
<th>업종 중분류1</th>
<th>유지여부</th>
</tr>
</thead>
<tbody id="household-list">
</tbody>
@@ -84,29 +95,30 @@
</div>
<div class="tab-content" data-tab-value="tab2">
<div class="component-btns bottom-btn-group">
<div class="btns-row two-col">
<div class="btns-row">
<div class="btns-col-1 align-right">
<button type="button" class="btn" onClick="goRemove();">
<span class="btn-txt">삭제 <i class="ico-print" aria-hidden="true"></i></span>
</button>
</div>
</div>
</div>-
</div>
<div class="content-inner">
<table>
<thead>
<tr>
<th>
<input class="form-check-input" onchange="toggleCheckbox(this);" type="checkbox"/>
</th>
<th>임가번호</th>
<th>경영주명</th>
<th>방문일</th>
<th>관리분야</th>
<th>내용</th>
<th>작성일</th>
<th>답례품 전달</th>
</tr>
<tr>
<th>
<input onchange="toggleCheckbox(this);" type="checkbox"/>
</th>
<th>임가번호</th>
<th>경영주명</th>
<th>방문일</th>
<th>관리분야</th>
<th>내용</th>
<th>작성일</th>
<th>답례품 전달</th>
</tr>
</thead>
<tbody id="household-visit-list">
</tbody>
@@ -131,18 +143,39 @@
</button>
</div>
</div>
</div>-
</section>
</div>
</form>
</section>
<th:block layout:fragment="script">
<script th:inline="javascript">
// 탭 클릭 시 함수 호출
document.addEventListener('DOMContentLoaded', function () {
const tabButtons = document.querySelectorAll('.tab-label');
tabButtons.forEach(button => {
button.addEventListener('click', function () {
const tabValue = this.getAttribute('data-tab-value');
const form = document.householdReqForm;
form.page.value = 1; // 페이지 초기화
document.getElementById('monthTab2').style.display = 'block';
if (tabValue === 'tab1') {
getHouseholdList(0);
} else if (tabValue === 'tab2') {
if (!form.searchMonth.value) {
form.searchMonth.value = '[[${currentMonth}]]'; // 기본값 복원
}
getHouseholdVisitList(0);
}
});
});
// 초기 데이터 로드 (tab1)
getHouseholdList(document.householdReqForm.page.value);
});
<section layout:fragment="script">
<script>
// 담당 임가 목록
const getHouseholdList = (pageNo) => {
const f = document.householdReqForm;
f.page.value = pageNo;
let dataOj = $(f).serializeObject();
ajaxUtil._ajaxMethod(
'/researcher/mappingHouseholdList',
dataOj,
@@ -153,6 +186,8 @@
const tbody = $('#household-list');
tbody.empty();
document.getElementById('monthTab2').style.display = 'none';
$(response.content).each((idx, ct) => {
tbody.append(
`
@@ -175,7 +210,7 @@
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="10" class="text-center text-muted">담당임가정보가 존재하지 않습니다.</td>
<td colspan="9" class="text-center text-muted">담당임가정보가 존재하지 않습니다.</td>
</tr>
`);
}
@@ -192,7 +227,6 @@
},
function (code, rstData) {
console.log("왜지 ");
},
'get',
@@ -200,22 +234,21 @@
null
);
}
// 최초 리스트 로드
getHouseholdList(document.householdReqForm.page.value);
</script>
<script th:inline="javascript">
// 임가 방문 정보
const getHouseholdVisitList = (pageNo) => {
const f = document.householdReqForm;
f.page.value = pageNo;
let dataOj = $(f).serializeObject();
let dataObj = {
page: f.page.value,
adminSeq: f.seq.value,
searchMonth: f.searchMonth.value,
};
ajaxUtil._ajaxMethod(
'/researcher/visitHouseholdList',
dataOj,
dataObj,
function (response) {
$('#household-totalElements').text(response.totalElements);
@@ -235,8 +268,8 @@
<td class="underline"><a href="">${ct.householdNum}</a></td>
<td>${ct.ownerName}</td>
<td>${ct.visitDate}</td>
<td>${ct.Memo}</td>
<td>${ct.Memo}</td>
<td>${ct.memo}</td>
<td>${ct.memo}</td>
<td>${ct.createdAt}</td>
<td>${ct.isGiftSentFlag}</td>
</tr>
@@ -247,7 +280,7 @@
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="10" class="text-center text-muted">임가 방문 정보가 존재하지 않습니다.</td>
<td colspan="8" class="text-center text-muted">임가 방문 정보가 존재하지 않습니다.</td>
</tr>
`);
}
@@ -264,7 +297,6 @@
},
function (code, rstData) {
console.log("왜지 ");
},
'get',
@@ -290,8 +322,12 @@
}
function goRemove() {
if (!$('input[name=selectIds]').is(':checked')) {
alert(/*[[#{operation.common.remove.choose}]]*/);
const selectIds = $('input[name=selectIds]:checked').map(function() {
return parseInt(this.value);
}).get();
if (!selectIds.length) {
alert('삭제할 항목을 선택해주세요.');
return;
}
@@ -299,26 +335,31 @@
const f = document.householdReqForm;
const data = $(f).serializeObject();
$.ajax({
'method': 'DELETE',
'url': '/researchers/householdVisit/remove',
'data': {
'selectIds': data.selectIds
ajaxUtil._ajaxMethod(
'/researcher/visitHousehold/remove',
JSON.stringify(selectIds),
function (response) {
console.log("여기있어요");
console.log(response);
if(response > 0){
alert('선택한 임가정보가 삭제되었습니다.');
getHouseholdVisitList(document.householdReqForm.page.value);
} else {
alert('삭제에 실패했습니다.');
}
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
function (code, rstData) {
console.error("Error in goRemove: ", err);
alert('삭제 중 오류가 발생했습니다.');
},
success(res) {
alert('선택한 아이템이 삭제되었습니다.');
f.method = 'GET';
f.submit();
}
});
'delete',
'json',
null
);
}
}
</script>
</section>
</th:block>
</html>

View File

@@ -43,7 +43,7 @@
<option selected value="">전체</option>
<option
th:each="item : ${inspectionArea}"
th:text="${item.codeText}" th:value="${item.codeValue}"></option>
th:text="${item.codeText}" th:value="${item.id}"></option>
</select>
</div>
</div>
@@ -56,8 +56,8 @@
<div class="component-select">
<select class="select-list" required th:field="*{searchAccountDisabled}">
<option selected value="">전체</option>
<option value="0">사용</option>
<option value="1">미사용</option>
<option value="false">사용</option>
<option value="true">미사용</option>
</select>
</div>
</div>
@@ -68,7 +68,7 @@
<span class="btn-txt">초기화</span>
</button>
<button type="button" class="btn btn-primary" onclick="goSearch();" >
<i class="bi bi-search"></i>
<span class="btn-txt">검색</span>
</button>
</div>
</div>
@@ -106,15 +106,6 @@
<button type="button" class="btn" onclick="goExcel();">
<span class="btn-txt">엑셀 다운로드 <i class="ico-download ico-small" aria-hidden="true"></i></span>
</button>
<button type="button" class="btn" onclick="goSave();">
<span class="btn-txt">등록</span>
</button>
<button type="button" class="btn" >
<span class="btn-txt">조사원 매핑</span>
</button>
<button type="button" class="btn" onclick="goRemove();">
<span class="btn-txt">비활성화</span>
</button>
</div>
</div>
</section>
@@ -154,7 +145,7 @@
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="10" class="text-center text-muted">조사원이 존재하지 않습니다.</td>
<td colspan="5" class="text-center text-muted">조사원이 존재하지 않습니다.</td>
</tr>
`);
}
@@ -198,17 +189,6 @@
f.searchArea.value = '';
f.searchAccountDisabled.value = '';
}
// 저장페이지 이동
function goSave() {
location.href = '/board/articles/create';
}
// 수정페이지 이동
function goUpdate(itemId) {
location.href = '/board/articles/' + itemId;
}
// 상세페이지 이동
function goDetail(seq) {
location.href = '/researcher/' + seq;