select박스 동적 처리

jiHyung 2022-11-03 12:35:59 +09:00
parent aba6c6cbbf
commit fe7da0d847
4 changed files with 73 additions and 40 deletions

View File

@ -28,6 +28,30 @@ $(document).on('click', '.tr', function (){
getIcaViewModal($(this).data('key'));
});
$(document).on('change', 'select[name="organ"]', function (){
$('select[name="department"]').empty();
const parent_organ = $(this).val();
let department = '';
organConfigList.forEach(function (organConfig) {
if (organConfig.parentOrgan != null && organConfig.organType != 'OGC002' && organConfig.parentOrgan == parent_organ) {
department += '<option value="' + organConfig.organCd + '">' + organConfig.organNm + '</option>';
}
});
$('select[name="department"]').append('<option value="">경찰서 선택</option>' + department);
});
$(document).on('change', 'select[name="crimeType"]', function (){
$('select[name="violationType"]').empty();
let violationType = '';
let code = $(this).val();
commonCode[code].forEach(function (item) {
violationType += '<option value="' + item.itemCd + '">' + item.itemValue + '</option>';
});
$('select[name="violationType"]').append('<option value="">선택</option>' + violationType);
});
$(document).on('change', '#crimeForm', function (){
$('#crimeFormDiv').next().remove();
@ -125,7 +149,7 @@ $(document).on('change', '#crimeType', function (){
smugglingAmount += '<option value="'+ item.itemCd +'">' + item.itemValue +'</option>';
})
if ($(this).val() == 'CTH002') {
if ($(this).val() == 'CTH2') {
makeArrestAreaDiv('장소');
$('#smugglingAmountDiv').append(
'<label class="col-sm-2 col-form-label text-center">밀수입출 품목</label>'
@ -162,7 +186,7 @@ $(document).on('change', '#violationType', function (){
$('.entryVisa').remove();
$('#violationAmountDiv').remove();
if ($(this).val() == 'VLT001') {
if ($(this).val() == 'CTH101') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('밀입국');
@ -171,7 +195,7 @@ $(document).on('change', '#violationType', function (){
makeDestinationDiv('밀입국 출발지(국가)');
}
if ($(this).val() == 'VLT002') {
if ($(this).val() == 'CTH102') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('도외이탈');
@ -179,7 +203,7 @@ $(document).on('change', '#violationType', function (){
makePurposeDiv('도외이탈');
}
if ($(this).val() == 'VLT003') {
if ($(this).val() == 'CTH103') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('밀출국');
@ -188,7 +212,7 @@ $(document).on('change', '#violationType', function (){
makeDestinationDiv('밀출국 행선지(도착예정지)');
}
if ($(this).val() == 'VLT004') {
if ($(this).val() == 'CTH104') {
makeSpiInfoDiv('피의자 정보');
makeArrestAreaDiv('지역');
makeSeaAreaDiv('밀항');
@ -197,15 +221,18 @@ $(document).on('change', '#violationType', function (){
makeDestinationDiv('밀항 행선지(도착예정지)');
}
if ($(this).val() == 'VLT005') {
if ($(this).val() == 'CTH105') {
makeSpiInfoDiv('불법체류 및 취업');
makeEntryVisaDiv();
}
if ($(this).val() == 'VLT301') {
if ($(this).val() == 'CTH401') {
makeViolationAmountDiv();
}
if ($(this).val() == 'CTH201' || $(this).val() == 'CTH202' || $(this).val() == 'CTH203' || $(this).val() == 'CTH204') {
makeArrestAreaDiv('장소');
}
});
$(document).on('change', '#smugglingAmount', function (){
@ -321,7 +348,7 @@ function makeArrestAreaDiv(name) {
function makeMeansDiv(name, code) {
let means = '';
if (code == 'VLT001') {
if (code == 'CTH101') {
commonCode.MS1.forEach(function (item){
means += '<option value="'+ item.itemCd +'">' + item.itemValue +'</option>';
})
@ -500,10 +527,6 @@ function saveInternationalCrimeArrest(contentState){
function contentCheck(){
let flag = true;
if(!$('select[name="organ"]').val()){
alert("지방청을 선택해주세요.")
flag = false;
}
return flag;
}

View File

@ -7,6 +7,7 @@
<script th:inline="javascript">
const internationalCrimeArrest = [[${internationalCrimeArrest}]];
const commonCode = [[${session.commonCode}]];
const organConfigList = [[${organConfigList}]];
</script>
<script type="text/javascript" th:src="@{/js/faStatistics/internationalCrimeArrest.js}"></script>
</th:block>
@ -44,7 +45,7 @@
</th:block>
</select>
</div>
<div class="col-auto">
<div class="col-auto" id="departmentDiv">
<select class="form-select form-select-sm" name="department">
<option value="">경찰서 선택</option>
<th:block th:each="organConfig:${organConfigList}">
@ -63,10 +64,12 @@
</select>
</div>
<div class="col-auto">
<select class="form-select form-select-sm" name="violationType">
<option value="">위반유형</option>
<th:block th:each="commonCode:${session.commonCode.get('VLT')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd eq searchParams.violationType}"></option>
<select class="form-select form-select-sm" name="violationType" id="violationType">
<option value="">위반유형 선택</option>
<th:block th:each="num : ${#numbers.sequence(1,#lists.size(session.commonCode.get('CTH')))}">
<th:block th:each="commonCode:${session.commonCode.get('CTH'+num)}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${internationalCrimeArrest.violationType eq commonCode.itemCd}"></option>
</th:block>
</th:block>
</select>
</div>
@ -138,12 +141,14 @@
<th:block th:each="commonCode:${session.commonCode.get('CTH')}">
<td th:if="${internationalCrimeArrest.crimeType eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<th:block th:each="num : ${#numbers.sequence(1,#lists.size(session.commonCode.get('CTH')))}">
<th:block th:each="commonCode:${session.commonCode.get('CTH'+num)}">
<td th:if="${internationalCrimeArrest.violationType eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
</th:block>
<th:block th:if="${internationalCrimeArrest.violationType eq null || internationalCrimeArrest.violationType eq ''}">
<td></td>
</th:block>
<th:block th:each="commonCode:${session.commonCode.get('VLT')}">
<td th:if="${internationalCrimeArrest.violationType eq commonCode.itemCd}" th:text="${commonCode.itemValue}"></td>
</th:block>
<td th:text="${internationalCrimeArrest.crimeName}"></td>
<td th:text="${internationalCrimeArrest.occurTable}"></td>
<td th:text="${internationalCrimeArrest.arrestTable}"></td>

View File

@ -33,14 +33,14 @@
</select>
</div>
<label class="col-sm-2 col-form-label text-center">관할서</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="department">
<option value="">선택</option>
<th:block th:each="organConfig:${organConfigList}">
<th:block th:if="${organConfig.parentOrgan ne null && organConfig.organType ne 'OGC002'}">
<option th:value="${organConfig.organCd}" th:text="${organConfig.organNm}" th:selected="${organConfig.organCd eq internationalCrimeArrest.department}"></option>
</th:block>
</th:block>
<div class="col-sm-2" id="departmentDiv">
<select class="form-select form-select-sm" name="department">
<option value="">선택</option>
<th:block th:each="organConfig:${organConfigList}">
<th:block th:if="${organConfig.parentOrgan ne null && organConfig.organType ne 'OGC002'}">
<option th:value="${organConfig.organCd}" th:text="${organConfig.organNm}" th:selected="${organConfig.organCd eq internationalCrimeArrest.department}"></option>
</th:block>
</th:block>
</select>
</div>
<div class="col-sm-4 row" id="crimeNameDiv">
@ -65,9 +65,10 @@
<div class="col-sm-2">
<select class="form-select form-select-sm" name="violationType" id="violationType">
<option value="">선택</option>
<th:block th:each="commonCode:${session.commonCode.get('VLT')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
th:selected="${commonCode.itemCd eq internationalCrimeArrest.violationType}"></option>
<th:block th:each="num : ${#numbers.sequence(1,#lists.size(session.commonCode.get('CTH')))}">
<th:block th:if="${'CTH'+num == internationalCrimeArrest.crimeType}" th:each="commonCode:${session.commonCode.get('CTH'+num)}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${internationalCrimeArrest.violationType eq commonCode.itemCd}"></option>
</th:block>
</th:block>
</select>
</div>

View File

@ -33,11 +33,14 @@
</div>
<label class="col-sm-2 col-form-label text-center">관할서</label>
<div class="col-sm-2">
<th:block th:each="organConfig:${organConfigList}">
<th:block th:if="${organConfig.parentOrgan ne null && organConfig.organType ne 'OGC002'}">
<div th:utext="${organConfig.organCd eq internationalCrimeArrest.department ? organConfig.organNm : ''}"></div>
<select class="form-select form-select-sm" name="department" disabled>
<option value="">선택</option>
<th:block th:each="organConfig:${organConfigList}">
<th:block th:if="${organConfig.parentOrgan ne null && organConfig.organType ne 'OGC002'}">
<option th:value="${organConfig.organCd}" th:text="${organConfig.organNm}" th:selected="${organConfig.organCd eq internationalCrimeArrest.department}"></option>
</th:block>
</th:block>
</th:block>
</select>
</div>
<th:block th:if="${internationalCrimeArrest.crimeType ne 'CTH002'}">
<div class="col-sm-4 row" id="crimeNameDiv">
@ -52,7 +55,7 @@
<label class="col-sm-2 col-form-label text-center">범죄테마</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="crimeType" id="crimeType" disabled>
<option value="">범죄테마</option>
<option value="">선택</option>
<th:block th:each="commonCode:${session.commonCode.get('CTH')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
th:selected="${commonCode.itemCd eq internationalCrimeArrest.crimeType}"></option>
@ -62,10 +65,11 @@
<label class="col-sm-2 col-form-label text-center">위반유형</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="violationType" id="violationType" disabled>
<option value="">위반유형</option>
<th:block th:each="commonCode:${session.commonCode.get('VLT')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"
th:selected="${commonCode.itemCd eq internationalCrimeArrest.violationType}"></option>
<option value="">선택</option>
<th:block th:each="num : ${#numbers.sequence(1,#lists.size(session.commonCode.get('CTH')))}">
<th:block th:if="${'CTH'+num == internationalCrimeArrest.crimeType}" th:each="commonCode:${session.commonCode.get('CTH'+num)}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${internationalCrimeArrest.violationType eq commonCode.itemCd}"></option>
</th:block>
</th:block>
</select>
</div>