1
Showing
1 changed file
with
77 additions
and
112 deletions
... | @@ -105,7 +105,14 @@ export default { | ... | @@ -105,7 +105,14 @@ export default { |
105 | // 公历假期,缺少复活节,缺少聖誕節後第一個周日 | 105 | // 公历假期,缺少复活节,缺少聖誕節後第一個周日 |
106 | gl: [[1, 1], [4, 10], [4, 11], [4, 30], [5, 1], [7, 1], [10, 1], [10, 2], [12, 25]], | 106 | gl: [[1, 1], [4, 10], [4, 11], [4, 30], [5, 1], [7, 1], [10, 1], [10, 2], [12, 25]], |
107 | // 农历假期,缺少清明节 | 107 | // 农历假期,缺少清明节 |
108 | nl: [[1, 1], [1, 2], [1, 3], [5, 5], [8, 15], [9, 9]] | 108 | nl: [[1, 1], [1, 2], [1, 3], [5, 5], [8, 15], [9, 9]], |
109 | // 清明节 | ||
110 | qm: [ | ||
111 | // 4月4号 | ||
112 | ["2020", "2021", "2024", "2025", "2028", "2029", "2032", "2033", "2036", "2037"], | ||
113 | // 4月5号 | ||
114 | ["2022", "2023", "2026", "2027", "2030", "2031", "2034", "2035", "2038", "2039"] | ||
115 | ] | ||
109 | }, | 116 | }, |
110 | // 节假日,key是月份,value是日期列表 | 117 | // 节假日,key是月份,value是日期列表 |
111 | // holiday: { | 118 | // holiday: { |
... | @@ -115,66 +122,71 @@ export default { | ... | @@ -115,66 +122,71 @@ export default { |
115 | }, | 122 | }, |
116 | components: {}, | 123 | components: {}, |
117 | computed: { | 124 | computed: { |
118 | holiday(){ | 125 | holiday() { |
119 | // 计算新历 | 126 | // 计算新历 |
120 | let result = {}; | 127 | let result = {}; |
121 | let year = this.year; | 128 | let year = this.year; |
122 | if (!year) { | 129 | if (!year) { |
123 | return; | 130 | return; |
124 | } | 131 | } |
125 | let hkHolidayDefine = this.hkHolidayDefine; | 132 | let hkHolidayDefine = this.hkHolidayDefine; |
126 | for (let index = 0; index < hkHolidayDefine.gl.length; index++) { | ||
127 | let m = hkHolidayDefine.gl[index][0]; | ||
128 | let d = hkHolidayDefine.gl[index][1]; | ||
129 | 133 | ||
130 | // 如果是周六/周日,顺延到下周一 | ||
131 | let date = Date.parse(`${year}.${m}.${d}`); | ||
132 | if (date.getDay() == 6) { | ||
133 | // 周六 | ||
134 | date.addDays(2); | ||
135 | } else if (date.getDay() == 0) { | ||
136 | date.addDays(1); | ||
137 | } | ||
138 | m = date.getMonth() + 1; | ||
139 | d = date.getDate(); | ||
140 | 134 | ||
141 | let list = result[m]; | 135 | // 加入清明节 |
142 | if (!list) { | 136 | if (hkHolidayDefine.qm[0].indexOf(year + "") >= 0) { |
143 | result[m] = []; | 137 | // 如果是周六/周日,顺延到下周一 |
144 | list = result[m]; | 138 | let vals = this.checkWeeken(4, 4); |
145 | } | 139 | let m = vals[0]; |
146 | list.push(d); | 140 | let d = vals[1]; |
141 | result[m] = [d]; | ||
142 | } else if (hkHolidayDefine.qm[1].indexOf(year + "") >= 0) { | ||
143 | // 如果是周六/周日,顺延到下周一 | ||
144 | let vals = this.checkWeeken(4, 5); | ||
145 | let m = vals[0]; | ||
146 | let d = vals[1]; | ||
147 | result[m] = [d]; | ||
148 | } | ||
149 | |||
150 | for (let index = 0; index < hkHolidayDefine.gl.length; index++) { | ||
151 | let m = hkHolidayDefine.gl[index][0]; | ||
152 | let d = hkHolidayDefine.gl[index][1]; | ||
153 | |||
154 | // 如果是周六/周日,顺延到下周一 | ||
155 | let vals = this.checkWeeken(m, d); | ||
156 | m = vals[0]; | ||
157 | d = vals[1]; | ||
158 | |||
159 | let list = result[m]; | ||
160 | if (!list) { | ||
161 | result[m] = []; | ||
162 | list = result[m]; | ||
147 | } | 163 | } |
164 | list.push(d); | ||
165 | } | ||
148 | 166 | ||
149 | 167 | ||
150 | for (let index = 0; index < hkHolidayDefine.nl.length; index++) { | 168 | for (let index = 0; index < hkHolidayDefine.nl.length; index++) { |
151 | let m = hkHolidayDefine.nl[index][0]; | 169 | let m = hkHolidayDefine.nl[index][0]; |
152 | let d = hkHolidayDefine.nl[index][1]; | 170 | let d = hkHolidayDefine.nl[index][1]; |
153 | let gl = toSolar(year, m, d); | 171 | let gl = toSolar(year, m, d); |
154 | 172 | ||
155 | m = gl[1]; | 173 | m = gl[1]; |
156 | d = gl[2]; | 174 | d = gl[2]; |
157 | 175 | ||
158 | // 如果是周六/周日,顺延到下周一 | ||
159 | let date = Date.parse(`${year}.${m}.${d}`); | ||
160 | 176 | ||
161 | if (date.getDay() == 6) { | 177 | // 如果是周六/周日,顺延到下周一 |
162 | // 周六 | 178 | let vals = this.checkWeeken(m, d); |
163 | date.addDays(2); | 179 | m = vals[0]; |
164 | } else if (date.getDay() == 0) { | 180 | d = vals[1]; |
165 | date.addDays(1); | ||
166 | } | ||
167 | m = date.getMonth() + 1; | ||
168 | d = date.getDate(); | ||
169 | 181 | ||
170 | let list = result[m]; | 182 | let list = result[m]; |
171 | if (!list) { | 183 | if (!list) { |
172 | result[m] = []; | 184 | result[m] = []; |
173 | list = result[m]; | 185 | list = result[m]; |
174 | } | ||
175 | list.push(d); | ||
176 | } | 186 | } |
177 | return result; | 187 | list.push(d); |
188 | } | ||
189 | return result; | ||
178 | }, | 190 | }, |
179 | locale() { | 191 | locale() { |
180 | return this.$i18n.locale || 'tc'; | 192 | return this.$i18n.locale || 'tc'; |
... | @@ -278,7 +290,7 @@ export default { | ... | @@ -278,7 +290,7 @@ export default { |
278 | if (isWeekend) { | 290 | if (isWeekend) { |
279 | disable = true; | 291 | disable = true; |
280 | } else { | 292 | } else { |
281 | let holidayCandidates = this.holiday[month+""]; | 293 | let holidayCandidates = this.holiday[month + ""]; |
282 | if (holidayCandidates && holidayCandidates.indexOf(date) != -1) { | 294 | if (holidayCandidates && holidayCandidates.indexOf(date) != -1) { |
283 | disable = true; | 295 | disable = true; |
284 | } | 296 | } |
... | @@ -595,68 +607,21 @@ export default { | ... | @@ -595,68 +607,21 @@ export default { |
595 | 607 | ||
596 | }, | 608 | }, |
597 | calculateHolidays() { | 609 | calculateHolidays() { |
598 | // 计算新历 | 610 | |
599 | let result = {}; | 611 | }, |
612 | checkWeeken(m, d) { | ||
600 | let year = this.year; | 613 | let year = this.year; |
601 | if (!year) { | 614 | let date = Date.parse(`${year}.${m}.${d}`); |
602 | return; | 615 | // if (date.getDay() == 6) { |
603 | } | 616 | // // 周六 |
604 | let hkHolidayDefine = this.hkHolidayDefine; | 617 | // date.addDays(2); |
605 | for (let index = 0; index < hkHolidayDefine.gl.length; index++) { | 618 | // } else |
606 | let m = hkHolidayDefine.gl[index][0]; | 619 | if (date.getDay() == 0) { |
607 | let d = hkHolidayDefine.gl[index][1]; | 620 | date.addDays(1); |
608 | |||
609 | // 如果是周六/周日,顺延到下周一 | ||
610 | let date = Date.parse(`${year}.${m}.${d}`); | ||
611 | if (date.getDay() == 6) { | ||
612 | // 周六 | ||
613 | date.addDays(2); | ||
614 | } else if (date.getDay() == 0) { | ||
615 | date.addDays(1); | ||
616 | } | ||
617 | m = date.getMonth() + 1; | ||
618 | d = date.getDate(); | ||
619 | |||
620 | let list = result[m]; | ||
621 | if (!list) { | ||
622 | result[m] = []; | ||
623 | list = result[m]; | ||
624 | } | ||
625 | list.push(d); | ||
626 | } | ||
627 | |||
628 | |||
629 | for (let index = 0; index < hkHolidayDefine.nl.length; index++) { | ||
630 | let m = hkHolidayDefine.nl[index][0]; | ||
631 | let d = hkHolidayDefine.nl[index][1]; | ||
632 | let gl = toSolar(year, m, d); | ||
633 | |||
634 | m = gl[1]; | ||
635 | d = gl[2]; | ||
636 | |||
637 | // 如果是周六/周日,顺延到下周一 | ||
638 | let date = Date.parse(`${year}.${m}.${d}`); | ||
639 | |||
640 | if (date.getDay() == 6) { | ||
641 | // 周六 | ||
642 | date.addDays(2); | ||
643 | } else if (date.getDay() == 0) { | ||
644 | date.addDays(1); | ||
645 | } | ||
646 | m = date.getMonth() + 1; | ||
647 | d = date.getDate(); | ||
648 | |||
649 | let list = result[m]; | ||
650 | if (!list) { | ||
651 | result[m] = []; | ||
652 | list = result[m]; | ||
653 | } | ||
654 | list.push(d); | ||
655 | } | 621 | } |
656 | 622 | m = date.getMonth() + 1; | |
657 | this.holiday = result; | 623 | d = date.getDate(); |
658 | console.log(JSON.stringify(this.holiday)); | 624 | return [m, d]; |
659 | |||
660 | } | 625 | } |
661 | }, | 626 | }, |
662 | mounted() { }, | 627 | mounted() { }, | ... | ... |
-
Please register or sign in to post a comment