|
@@ -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"> ~ </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();
|