[BO] 공통코드 지역/세부지역, 업종대분류/업종중분류 - 계층형으로 일괄 변경

This commit is contained in:
kangsunlee
2025-06-27 21:43:49 +09:00
parent 549bbee654
commit b16b56513c
18 changed files with 228 additions and 109 deletions

View File

@@ -89,7 +89,7 @@
join researcher_has_household rhh ON h.seq = rhh.household_seq and rhh.is_deleted = false
left join uicode rm ON rm.parent_id = 'code.region.main' AND rm.id = h.region_main_code
left join uicode rs ON rs.parent_id = 'code.region.sub' AND rs.id = h.region_sub_code
left join uicode rd ON rd.parent_id = 'code.region.detail' AND rd.id = h.region_detail_code
left join uicode rd ON rd.id = h.region_detail_code
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 1=1

View File

@@ -470,3 +470,50 @@ const limitMaxLength = (el) => {
el.value = el.value.replace(/\D/g, '').slice(0, maxLength);
}
/**
* 공통코드 기반의 2단계 셀렉트박스(부모/자식) UI를 구성하는 함수
*
* @param {Object} codeList - 공통코드 리스트 객체
* @param {string} parentSelector - 부모 셀렉트박스 셀렉터 (ex. '#regionSubCode')
* @param {string} childSelector - 자식 셀렉트박스 셀렉터 (ex. '#regionDetailCode')
* @param {string} selectedParentCode - 초기 선택할 부모 코드값 (ex. 'code.region.sub.31')
* @param {string} selectedChildCode - 초기 선택할 자식 코드값 (ex. 'code.region.detail.9')
*/
const setSelectBoxUiCode = ({
codeList,
parentSelector,
childSelector,
selectedParentCode = '',
selectedChildCode = ''
}) => {
const $parent = $(parentSelector);
const $child = $(childSelector);
if (!codeList?.nodes || !$parent.length || !$child.length) return;
const renderOptions = ($el, list, selected) => {
$el.html('<option value="">전체</option>');
list.forEach(item => {
const val = item.id.split('.').pop();
const isSelected = item.id === selected ? 'selected' : '';
$el.append(`<option value="${item.id}" ${isSelected}>${val}. ${item.codeText}</option>`);
});
};
const loadChildren = (parentId, selectedChild = '') => {
$child.html('<option value="">전체</option>');
if (!parentId) return;
const parent = codeList.nodes.find(n => n.id === parentId);
if (!parent?.nodes) return;
renderOptions($child, parent.nodes, selectedChild);
};
renderOptions($parent, codeList.nodes, selectedParentCode);
if (selectedParentCode) loadChildren(selectedParentCode, selectedChildCode);
$parent.on('change', function () {
loadChildren($(this).val());
});
};

View File

@@ -49,7 +49,6 @@
</div>
<select class="select-list" id="regionSubCode" name="regionSubCode">
<option value="" selected>전체</option>
<option th:each="region : ${regionSubList}" th:value="${region.id}" th:text="${region.codeText}"></option>
</select>
</div>
<div class="component-select">
@@ -58,7 +57,6 @@
</div>
<select class="select-list" id="regionDetailCode" name="regionDetailCode">
<option value="" selected>전체</option>
<option th:each="subRegion : ${regionDetailList}" th:value="${subRegion.id}" th:text="${subRegion.codeText}"></option>
</select>
</div>
</div>
@@ -142,6 +140,10 @@
</div>
</div>
<script th:inline="javascript">
const regionList = [[${regionSubList}]];
</script>
<script th:inline="javascript">
const showHouseholdModal = (button) => {
const regionMainCode = button.getAttribute('data-region-main-code') || '';
@@ -154,6 +156,13 @@
existingModal.remove();
}
// 지역, 세부지역 셀렉트박스 세팅
setSelectBoxUiCode({
codeList: regionList,
parentSelector: '#regionSubCode',
childSelector: '#regionDetailCode',
});
document.querySelector(".modal01").ui.open();
// 초기 데이터 조회

View File

@@ -131,22 +131,16 @@
<th>지역<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
<td>
<div class="component-select">
<select class="select-list" name="regionSubCode" required>
<select class="select-list" name="regionSubCode" id="regionSubCode" required>
<option value="">전체</option>
<option th:each="item : ${regionSubList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
</td>
<th>세부 지역<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
<td>
<div class="component-select">
<select class="select-list" name="regionDetailCode" required>
<select class="select-list" name="regionDetailCode" id="regionDetailCode" required>
<option value="">전체</option>
<option th:each="item : ${regionDetailList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
</td>
@@ -165,22 +159,16 @@
<th>업종 대분류</th>
<td>
<div class="component-select">
<select class="select-list" name="industryLargeCode">
<select class="select-list" name="industryLargeCode" id="industryLargeCode">
<option value="">전체</option>
<option th:each="item : ${industryLargeList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
</td>
<th>업종 중분류1</th>
<td>
<div class="component-select">
<select class="select-list" name="industryMiddleCode">
<option value="">전체</option>
<option th:each="item : ${industryMiddleList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
<select class="select-list" name="industryMiddleCode" id="industryMiddleCode">
<option value="">전체</option>>
</select>
</div>
</td>
@@ -269,6 +257,27 @@
</section>
<section layout:fragment="script">
<script th:inline="javascript">
const regionList = [[${regionSubList}]];
const industryLargeList = [[${industryLargeList}]];
$(document).ready(function () {
// 지역, 세부지역 셀렉트박스 세팅
setSelectBoxUiCode({
codeList: regionList,
parentSelector: '#regionSubCode',
childSelector: '#regionDetailCode'
});
// 업종 대분류, 중분류 셀렉트박스 세팅
setSelectBoxUiCode({
codeList: industryLargeList,
parentSelector: '#industryLargeCode',
childSelector: '#industryMiddleCode',
});
});
</script>
<script th:inline="javascript">
// 임가번호 중복확인 변수
let checkDuplicate = false;

View File

@@ -78,11 +78,8 @@
지역
</p>
</div>
<select class="select-list" name="regionSubCode" th:field="*{regionSubCode}">
<select class="select-list" name="regionSubCode" id="regionSubCode" th:field="*{regionSubCode}">
<option value="">전체</option>
<option th:each="item : ${regionSubList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
<div class="component-select">
@@ -91,11 +88,8 @@
세부지역
</p>
</div>
<select class="select-list" name="regionDetailCode" th:field="*{regionDetailCode}">
<select class="select-list" name="regionDetailCode" id="regionDetailCode" th:field="*{regionDetailCode}">
<option value="">전체</option>
<option th:each="item : ${regionDetailList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
</div>
@@ -109,11 +103,8 @@
업종 대분류
</p>
</div>
<select class="select-list" name="industryLargeCode" th:field="*{industryLargeCode}">
<select class="select-list" name="industryLargeCode" id="industryLargeCode" th:field="*{industryLargeCode}">
<option value="">전체</option>
<option th:each="item : ${industryLargeList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
<div class="component-select">
@@ -122,11 +113,8 @@
업종 중분류
</p>
</div>
<select class="select-list" name="industryMiddleCode" th:field="*{industryMiddleCode}">
<select class="select-list" name="industryMiddleCode" id="industryMiddleCode" th:field="*{industryMiddleCode}">
<option value="">전체</option>
<option th:each="item : ${industryMiddleList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}">
</select>
</div>
</div>
@@ -309,6 +297,36 @@
</section>
<section layout:fragment="script">
<script th:inline="javascript">
const regionList = [[${regionSubList}]];
const selectedRegionSubCode = /*[[${reqVO.regionSubCode}]]*/ '';
const selectedRegionDetailCode = /*[[${reqVO.regionDetailCode}]]*/ '';
const industryLargeList = [[${industryLargeList}]];
const selectedIndustryLargeCode = /*[[${reqVO.industryLargeCode}]]*/ '';
const selectedIndustryMiddleCode= /*[[${reqVO.industryMiddleCode}]]*/ '';
$(document).ready(function () {
// 지역, 세부지역 셀렉트박스 세팅
setSelectBoxUiCode({
codeList: regionList,
parentSelector: '#regionSubCode',
childSelector: '#regionDetailCode',
selectedParentCode: selectedRegionSubCode,
selectedChildCode: selectedRegionDetailCode
});
// 업종 대분류, 중분류 셀렉트박스 세팅
setSelectBoxUiCode({
codeList: industryLargeList,
parentSelector: '#industryLargeCode',
childSelector: '#industryMiddleCode',
selectedParentCode: selectedIndustryLargeCode,
selectedChildCode: selectedIndustryMiddleCode
});
});
</script>
<script th:inline="javascript">
// 임가 목록 조회
const getHouseholds = (pageNo) => {

View File

@@ -141,24 +141,16 @@
<th>지역<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
<td>
<div class="component-select">
<select class="select-list" name="regionSubCode" required>
<select class="select-list" name="regionSubCode" id="regionSubCode" required>
<option value="">전체</option>
<option th:each="item : ${regionSubList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}"
th:selected="${item.id == householdInfo.regionSubCode}">
</select>
</div>
</td>
<th>세부 지역<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
<td>
<div class="component-select">
<select class="select-list" name="regionDetailCode" required>
<select class="select-list" name="regionDetailCode" id="regionDetailCode" required>
<option value="">전체</option>
<option th:each="item : ${regionDetailList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}"
th:selected="${item.id == householdInfo.regionDetailCode}">
</select>
</div>
</td>
@@ -178,24 +170,16 @@
<th>업종 대분류</th>
<td>
<div class="component-select">
<select class="select-list" name="industryLargeCode">
<option value="">전체</option>
<option th:each="item : ${industryLargeList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}"
th:selected="${item.id == householdInfo.industryLargeCode}">
<select class="select-list" name="industryLargeCode" id="industryLargeCode">
<option value="">전체</option>>
</select>
</div>
</td>
<th>업종 중분류1</th>
<td>
<div class="component-select">
<select class="select-list" name="industryMiddleCode">
<select class="select-list" name="industryMiddleCode" id="industryMiddleCode">
<option value="">전체</option>
<option th:each="item : ${industryMiddleList}"
th:value="${item.id}"
th:text="${item.codeValue + '. ' + item.codeText}"
th:selected="${item.id == householdInfo.industryMiddleCode}">
</select>
</div>
</td>
@@ -296,6 +280,36 @@
</section>
<section layout:fragment="script">
<script th:inline="javascript">
const regionList = [[${regionSubList}]];
const selectedRegionSubCode = /*[[${householdInfo.regionSubCode}]]*/ '';
const selectedRegionDetailCode = /*[[${householdInfo.regionDetailCode}]]*/ '';
const industryLargeList = [[${industryLargeList}]];
const selectedIndustryLargeCode = /*[[${householdInfo.industryLargeCode}]]*/ '';
const selectedIndustryMiddleCode= /*[[${householdInfo.industryMiddleCode}]]*/ '';
$(document).ready(function () {
// 지역, 세부지역 셀렉트박스 세팅
setSelectBoxUiCode({
codeList: regionList,
parentSelector: '#regionSubCode',
childSelector: '#regionDetailCode',
selectedParentCode: selectedRegionSubCode,
selectedChildCode: selectedRegionDetailCode
});
// 업종 대분류, 중분류 셀렉트박스 세팅
setSelectBoxUiCode({
codeList: industryLargeList,
parentSelector: '#industryLargeCode',
childSelector: '#industryMiddleCode',
selectedParentCode: selectedIndustryLargeCode,
selectedChildCode: selectedIndustryMiddleCode
});
});
</script>
<script th:inline="javascript">
// 임가 수정
const updateHousehold= () => {