1
Showing
1 changed file
with
43 additions
and
78 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,7 +122,7 @@ export default { | ... | @@ -115,7 +122,7 @@ 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; |
... | @@ -123,20 +130,31 @@ export default { | ... | @@ -123,20 +130,31 @@ export default { |
123 | return; | 130 | return; |
124 | } | 131 | } |
125 | let hkHolidayDefine = this.hkHolidayDefine; | 132 | let hkHolidayDefine = this.hkHolidayDefine; |
133 | |||
134 | |||
135 | // 加入清明节 | ||
136 | if (hkHolidayDefine.qm[0].indexOf(year + "") >= 0) { | ||
137 | // 如果是周六/周日,顺延到下周一 | ||
138 | let vals = this.checkWeeken(4, 4); | ||
139 | let m = vals[0]; | ||
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 | |||
126 | for (let index = 0; index < hkHolidayDefine.gl.length; index++) { | 150 | for (let index = 0; index < hkHolidayDefine.gl.length; index++) { |
127 | let m = hkHolidayDefine.gl[index][0]; | 151 | let m = hkHolidayDefine.gl[index][0]; |
128 | let d = hkHolidayDefine.gl[index][1]; | 152 | let d = hkHolidayDefine.gl[index][1]; |
129 | 153 | ||
130 | // 如果是周六/周日,顺延到下周一 | 154 | // 如果是周六/周日,顺延到下周一 |
131 | let date = Date.parse(`${year}.${m}.${d}`); | 155 | let vals = this.checkWeeken(m, d); |
132 | if (date.getDay() == 6) { | 156 | m = vals[0]; |
133 | // 周六 | 157 | d = vals[1]; |
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 | 158 | ||
141 | let list = result[m]; | 159 | let list = result[m]; |
142 | if (!list) { | 160 | if (!list) { |
... | @@ -155,17 +173,11 @@ export default { | ... | @@ -155,17 +173,11 @@ export default { |
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) { |
... | @@ -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 | // 计算新历 | ||
599 | let result = {}; | ||
600 | let year = this.year; | ||
601 | if (!year) { | ||
602 | return; | ||
603 | } | ||
604 | let hkHolidayDefine = this.hkHolidayDefine; | ||
605 | for (let index = 0; index < hkHolidayDefine.gl.length; index++) { | ||
606 | let m = hkHolidayDefine.gl[index][0]; | ||
607 | let d = hkHolidayDefine.gl[index][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 | 610 | ||
620 | let list = result[m]; | 611 | }, |
621 | if (!list) { | 612 | checkWeeken(m, d) { |
622 | result[m] = []; | 613 | let year = this.year; |
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}`); | 614 | let date = Date.parse(`${year}.${m}.${d}`); |
639 | 615 | // if (date.getDay() == 6) { | |
640 | if (date.getDay() == 6) { | 616 | // // 周六 |
641 | // 周六 | 617 | // date.addDays(2); |
642 | date.addDays(2); | 618 | // } else |
643 | } else if (date.getDay() == 0) { | 619 | if (date.getDay() == 0) { |
644 | date.addDays(1); | 620 | date.addDays(1); |
645 | } | 621 | } |
646 | m = date.getMonth() + 1; | 622 | m = date.getMonth() + 1; |
647 | d = date.getDate(); | 623 | d = date.getDate(); |
648 | 624 | return [m, d]; | |
649 | let list = result[m]; | ||
650 | if (!list) { | ||
651 | result[m] = []; | ||
652 | list = result[m]; | ||
653 | } | ||
654 | list.push(d); | ||
655 | } | ||
656 | |||
657 | this.holiday = result; | ||
658 | console.log(JSON.stringify(this.holiday)); | ||
659 | |||
660 | } | 625 | } |
661 | }, | 626 | }, |
662 | mounted() { }, | 627 | mounted() { }, | ... | ... |
-
Please register or sign in to post a comment