From 783792ecbaaf996a124c42e55c2bb0dc547d2f35 Mon Sep 17 00:00:00 2001 From: jiHyung Date: Thu, 3 Nov 2022 14:25:44 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8F=99=EC=A0=81=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EA=B3=B5=ED=86=B5=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/js/common.js | 24 +++++++++++++++++++ .../faStatistics/internationalCrimeArrest.js | 20 ++-------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index 6154c7c3..023b650d 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -186,4 +186,28 @@ function fileCheck(flag, files){ flag = false; } return flag; +} + +function dynamicOption(targetTagName, code) { + $(targetTagName).empty(); + let option = ''; + + if (code) { + commonCode[code].forEach(function (item) { + option += ''; + }); + } + + $(targetTagName).append('' + option); +} + +function departmentDynamicOption(targetTagName, code, defaultOptionName='') { + $(targetTagName).empty(); + let option = ''; + organConfigList.forEach(function (organConfig) { + if (organConfig.parentOrgan != null && organConfig.organType != 'OGC002' && organConfig.parentOrgan == code) { + option += ''; + } + }); + $(targetTagName).append('' + option); } \ No newline at end of file diff --git a/src/main/resources/static/js/faStatistics/internationalCrimeArrest.js b/src/main/resources/static/js/faStatistics/internationalCrimeArrest.js index 00553ccd..023de1ce 100644 --- a/src/main/resources/static/js/faStatistics/internationalCrimeArrest.js +++ b/src/main/resources/static/js/faStatistics/internationalCrimeArrest.js @@ -29,27 +29,11 @@ $(document).on('click', '.tr', function (){ }); $(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 += ''; - } - }); - - $('select[name="department"]').append('' + department); + departmentDynamicOption('select[name="department"]', $(this).val()); }); $(document).on('change', 'select[name="crimeType"]', function (){ - $('select[name="violationType"]').empty(); - let violationType = ''; - let code = $(this).val(); - commonCode[code].forEach(function (item) { - violationType += ''; - }); - - $('select[name="violationType"]').append('' + violationType); + dynamicOption('select[name="violationType"]', $(this).val()); });