Ver código fonte

update 2024-10-11

junggilpark 9 meses atrás
pai
commit
1bd99614d9

+ 9 - 0
src/main/java/com/its/web/service/common/CommonService.java

@@ -157,4 +157,13 @@ public class CommonService {
     }
 
     public List<YearDto> getYearList() { return this.mapper.getYearList(); }
+//    public List<YearDto> getYearList() {
+//        List<YearDto> list = new ArrayList<>();
+//        for (int ii = 2023; ii <= 2024; ii++) {
+//            YearDto dto = new YearDto();
+//            dto.setRate(String.valueOf(ii));
+//            list.add(dto);
+//        }
+//        return list;
+//    }
 }

+ 3 - 3
src/main/resources/static/js/traffic/traffic.js

@@ -203,16 +203,16 @@ $(()=>{
         for (let ii = 0; ii < $list.length; ii++) {
             const li = $list.eq(ii);
             if ($(this).val().length === 0) {
-                li.css('display', 'block');
+                li.css('display', 'flex');
             }
             else {
                 let text = li.text().toLowerCase();
                 const liId = li.attr('id');
                 if (showIdArr.includes(liId)){
-                    li.css('display', 'block');
+                    li.css('display', 'flex');
                 }
                 else if (text.includes(searchText.toLowerCase())) {
-                    li.css('display', 'block');
+                    li.css('display', 'flex');
                 }
                 else {
                     li.css('display', 'none');

+ 18 - 10
src/main/resources/templates/admin/conn-statistics.html

@@ -25,7 +25,7 @@
                     <option value="_month">월별</option>
                     <option value="_year">년별</option>
                 </select>
-                <select name="year_from" title="연별 시작년" class="_year from_year">
+                <select name="year_from" title="연별 시작년" class="_year from_year" onchange="setMonthOption(this, 'from')">
                     <option th:each="year : ${yearList}" th:unless="${year.rate} == ${#calendars.format(#calendars.createNow(), 'yyyy')}" th:value="${year.rate}" th:title="${year.rate + '년'}" th:text="${year.rate + '년'}"></option>
                     <option th:each="year : ${yearList}" th:if="${year.rate} == ${#calendars.format(#calendars.createNow(), 'yyyy')}"
                             th:value="${year.rate}" th:title="${year.rate + '년'}" th:text="${year.rate + '년'}" selected></option>
@@ -35,7 +35,7 @@
                     <option th:each="num : ${#numbers.sequence(1, month)}" th:if="${month} == ${num}" selected th:value="${num}" th:title="${num + '월'}" th:text="${num + '월'}"></option>
                 </select>
                 <div class="wave">&nbsp;~&nbsp;</div>
-                <select name="year_to" title="연별 종료년" class="_year to_year">
+                <select name="year_to" title="연별 종료년" class="_year to_year" onchange="setMonthOption(this, 'to')">
                     <option th:each="year : ${yearList}" th:unless="${year.rate} == ${#calendars.format(#calendars.createNow(), 'yyyy')}" th:value="${year.rate}" th:title="${year.rate + '년'}" th:text="${year.rate + '년'}"></option>
                     <option th:each="year : ${yearList}" th:if="${year.rate} == ${#calendars.format(#calendars.createNow(), 'yyyy')}"
                             th:value="${year.rate}" th:title="${year.rate + '년'}" th:text="${year.rate + '년'}" selected></option>
@@ -325,14 +325,22 @@
         }
     });
 
-    $('.year_from').on('change', function() {
-        if ($(this).val() === new Date().getFullYear()) {
-
-        }
-        else {
-
-        }
-    })
+   function setMonthOption(el, type) {
+       const yearVal = $(el).val();
+       const now = new Date();
+       let monthLimit = 12;
+       if (yearVal === now.getFullYear().toString()) {
+           monthLimit = now.getMonth() + 1;
+       }
+       let str = '';
+       const target = $('.' + type + '_month');
+       const selected = target.val();
+       for (let ii = 1; ii <= monthLimit; ii++) {
+           str += `<option value="${ii}" title="${ii}월" >${ii}월</option>`;
+       }
+       target.empty().html(str);
+       target.val(selected);
+   }
 
     function getDateFormat(date) {
         const year = date.getFullYear();