66761cf1 by joe

1

1 parent 3f03b9c8
...@@ -5,6 +5,7 @@ import { ...@@ -5,6 +5,7 @@ import {
5 } from '@/api/fetch-api.js' 5 } from '@/api/fetch-api.js'
6 6
7 import Date from '@/utils/date.js'; 7 import Date from '@/utils/date.js';
8 import { toSolar } from '@/utils/lunar.js';
8 9
9 import { 10 import {
10 ddMMyyyy2yyyyMMdd 11 ddMMyyyy2yyyyMMdd
...@@ -100,6 +101,16 @@ export default { ...@@ -100,6 +101,16 @@ export default {
100 // 用户渲染的数据 101 // 用户渲染的数据
101 fortmatMonthData: [], 102 fortmatMonthData: [],
102 visible: false, 103 visible: false,
104 hkHolidayDefine: {
105 // 公历假期,缺少复活节,缺少聖誕節後第一個周日
106 gl: [[1, 1], [4, 10], [4, 11], [4, 30], [5, 1], [7, 1], [10, 1], [10, 2], [12, 25]],
107 // 农历假期,缺少清明节
108 nl: [[1, 1], [1, 2], [1, 3], [5, 5], [8, 15], [9, 9]]
109 },
110 // 节假日,key是月份,value是日期列表
111 holiday: {
112
113 }
103 } 114 }
104 }, 115 },
105 components: {}, 116 components: {},
...@@ -201,6 +212,16 @@ export default { ...@@ -201,6 +212,16 @@ export default {
201 nowDate.setHours(0, 0, 0, 0); 212 nowDate.setHours(0, 0, 0, 0);
202 disable = buildDate.getTime() == nowDate.getTime(); 213 disable = buildDate.getTime() == nowDate.getTime();
203 } 214 }
215 if (!disable && this.filtModel.indexOf("holiday") >= 0) {
216 if (isWeekend) {
217 disable = true;
218 } else {
219 let holidayCandidates = this.holiday[month+""];
220 if (holidayCandidates && holidayCandidates.indexOf(d) >= 0) {
221 disable = true;
222 }
223 }
224 }
204 if (!disable && this.filtModel.indexOf("history") >= 0) { 225 if (!disable && this.filtModel.indexOf("history") >= 0) {
205 buildDate.setHours(23, 59, 59, 999); 226 buildDate.setHours(23, 59, 59, 999);
206 disable = buildDate.getTime() < nowDate.getTime() 227 disable = buildDate.getTime() < nowDate.getTime()
...@@ -510,6 +531,70 @@ export default { ...@@ -510,6 +531,70 @@ export default {
510 }, 531 },
511 judgeLastDateValidate(val) { 532 judgeLastDateValidate(val) {
512 533
534 },
535 calculateHolidays() {
536 // 计算新历
537 let result = {};
538 let year = this.year;
539 if (!year) {
540 return;
541 }
542 let hkHolidayDefine = this.hkHolidayDefine;
543 for (let index = 0; index < hkHolidayDefine.gl.length; index++) {
544 let m = hkHolidayDefine.gl[index][0];
545 let d = hkHolidayDefine.gl[index][1];
546
547 // 如果是周六/周日,顺延到下周一
548 let date = Date.parse(`${year}.${m}.${d}`);
549 if (date.getDay() == 6) {
550 // 周六
551 date.addDays(2);
552 } else if (date.getDay() == 0) {
553 date.addDays(1);
554 }
555 m = date.getMonth() + 1;
556 d = date.getDate();
557
558 let list = result[m];
559 if (!list) {
560 result[m] = [];
561 list = result[m];
562 }
563 list.push(d);
564 }
565
566
567 for (let index = 0; index < hkHolidayDefine.nl.length; index++) {
568 let m = hkHolidayDefine.nl[index][0];
569 let d = hkHolidayDefine.nl[index][1];
570 let gl = toSolar(year, m, d);
571
572 m = gl[1];
573 d = gl[2];
574
575 // 如果是周六/周日,顺延到下周一
576 let date = Date.parse(`${year}.${m}.${d}`);
577
578 if (date.getDay() == 6) {
579 // 周六
580 date.addDays(2);
581 } else if (date.getDay() == 0) {
582 date.addDays(1);
583 }
584 m = date.getMonth() + 1;
585 d = date.getDate();
586
587 let list = result[m];
588 if (!list) {
589 result[m] = [];
590 list = result[m];
591 }
592 list.push(d);
593 }
594
595 this.holiday = result;
596 console.log(JSON.stringify(this.holiday));
597
513 } 598 }
514 }, 599 },
515 mounted() { }, 600 mounted() { },
...@@ -524,6 +609,9 @@ export default { ...@@ -524,6 +609,9 @@ export default {
524 dateValue(val, oldVal) { 609 dateValue(val, oldVal) {
525 this.checkDateValue(); 610 this.checkDateValue();
526 this.$emit('input', val); 611 this.$emit('input', val);
612 },
613 year() {
614 this.calculateHolidays();
527 } 615 }
528 } 616 }
529 } 617 }
......
...@@ -95,6 +95,7 @@ export default { ...@@ -95,6 +95,7 @@ export default {
95 } 95 }
96 }, 96 },
97 logoutHandler() { 97 logoutHandler() {
98 this.clearCache();
98 httpPost({ 99 httpPost({
99 url: api.logout 100 url: api.logout
100 }).then(() => { 101 }).then(() => {
...@@ -102,6 +103,12 @@ export default { ...@@ -102,6 +103,12 @@ export default {
102 this.showLogoutTip(); 103 this.showLogoutTip();
103 }); 104 });
104 }, 105 },
106 clearCache() {
107 for (let index = 0; index < sessionStorage.length; index++) {
108 let key = sessionStorage.key(index);
109 sessionStorage.removeItem(key);
110 }
111 },
105 // 点击item 112 // 点击item
106 onChangeHandler(evt) { 113 onChangeHandler(evt) {
107 this.activeIndex = evt; 114 this.activeIndex = evt;
......
...@@ -233,7 +233,6 @@ export default { ...@@ -233,7 +233,6 @@ export default {
233 }, 233 },
234 234
235 created() { 235 created() {
236
237 } 236 }
238 237
239 } 238 }
......
...@@ -122,6 +122,9 @@ export default { ...@@ -122,6 +122,9 @@ export default {
122 initData() { 122 initData() {
123 httpPost({ url: api.profile, sid: true }).then(content => { 123 httpPost({ url: api.profile, sid: true }).then(content => {
124 if (content) { 124 if (content) {
125 if (content.birthDate.indexOf(" ") > 0) {
126 content.birthDate = content.birthDate.split(" ")[0];
127 }
125 this.information = content; 128 this.information = content;
126 if (content && content.birthDate) { 129 if (content && content.birthDate) {
127 this.birthDate = content.birthDate; 130 this.birthDate = content.birthDate;
......