Blame view

src/components/date-picker/date-picker.js 17.8 KB
simon committed
1 2 3 4 5 6 7
import api from '@/api/api'
import {
	httpGet,
	httpPost
} from '@/api/fetch-api.js'

import Date from '@/utils/date.js';
1  
joe committed
8
import { toSolar } from '@/utils/lunar.js';
simon committed
9

simon committed
10 11 12 13
import {
	ddMMyyyy2yyyyMMdd
} from '@utils/utils.js';

simon committed
14
export default {
simon committed
15
	inheritAttrs: false,
simon committed
16
	props: {
simon committed
17 18 19 20
		value: {
			type: String,
			default: ""
		},
simon committed
21 22 23 24 25
		// 日期格式 默认yyyy-MM-dd
		formatter: {
			type: String,
			default: "yyyy-MM-dd"
		},
simon committed
26
		// 周末是否可选
simon committed
27 28 29 30
		weekend: {
			type: Boolean,
			default: false
		},
joe committed
31 32 33 34 35
		// 过滤类型,含这些模型
		// history : 历史不可选择
		// future : 未来不可选择
		// weekend : 周末不可选择
		// today : 当日不可选择
1  
joe committed
36
		// holiday : 节假日不可选择
joe committed
37 38
		filtModel: {
			type: Array,
1  
joe committed
39
			default() {
joe committed
40 41 42
				return ["history", "weekend", "today"]
			}
		},
43
		// 需要过滤的日期列表 格式 ["yyyy-MM-dd","yyyy-MM-dd"]
simon committed
44 45
		filterDates: {
			type: Array,
1  
joe committed
46
			default() {
simon committed
47
				return [] // ["2019-11-26", "2019-11-28"]
simon committed
48
			}
49 50 51 52 53 54 55 56 57 58
		},
		/**
		 * 占位符
		 * 1.默认空格字符串 " " 即视觉上无内容
		 * 2.空字符串 ""  使用默认国际化
		 * 3.自定义传值
		 */
		placeholder: {
			type: String,
			default: " "
simon committed
59 60 61 62 63 64 65 66
		},
		/**
		 * input框 是否只读
		 * ture为输入框不可编辑
		 */
		readonly: {
			type: Boolean,
			default: false
simon committed
67 68 69 70 71 72
		},
		// 校验日期是否合法
		check: {
			type: Function,
			default: null
		},
joe committed
73 74
		cusStyle: {
			type: Object,
1  
joe committed
75
			default() {
joe committed
76 77
				return {};
			}
joe committed
78
		},
simon committed
79 80 81 82 83
		// 选择完日后触发
		datePickComplete: {
			type: Function,
			default: null
		},
1  
joe committed
84 85 86 87 88
		// 打开或关闭插件
		pluginActivity: {
			type: Function,
			default: null
		}
simon committed
89 90 91
	},
	data() {
		return {
simon committed
92 93
			dateValue: "", // 日期value yyyy-MM-dd
			dateType: 1, // 选择显示类型 1.日 2.月 3.年
simon committed
94 95 96 97
			year: 1970,
			month: 1, // (1~12)
			date: 1, // (1~31)
			day: 0, // (0~6)
simon committed
98 99 100
			yearPage: 1,
			yearList: [],
			yearRange: "", // 年份范围
simon committed
101 102
			// 用户渲染的数据
			fortmatMonthData: [],
simon committed
103
			visible: false,
1  
joe committed
104 105
			hkHolidayDefine: {
				// 公历假期,缺少复活节,缺少聖誕節後第一個周日
joe committed
106
				gl: [[1, 1], [5, 1], [7, 1], [10, 1], [10, 2], [12, 25]],
1  
joe committed
107
				// 农历假期,缺少清明节
1  
joe committed
108 109 110 111 112 113 114
				nl: [[1, 1], [1, 2], [1, 3], [5, 5], [8, 15], [9, 9]],
				// 清明节
				qm: [
					// 4月4号
					["2020", "2021", "2024", "2025", "2028", "2029", "2032", "2033", "2036", "2037"],
					// 4月5号
					["2022", "2023", "2026", "2027", "2030", "2031", "2034", "2035", "2038", "2039"]
joe committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
				],
				pub: {
					2020: [[4, 10], [4, 11], [4, 12], [4, 13], [4, 30]],
					2021: [[4, 2], [4, 3], [4, 4], [4, 5], [5, 19]],
					2022: [[4, 15], [4, 16], [4, 17], [4, 18], [5, 8]],
					2023: [[4, 7], [4, 8], [4, 9], [4, 10], [5, 26]],
					2024: [[3, 29], [3, 30], [3, 31], [4, 1], [5, 15]],
					2025: [[4, 18], [4, 19], [4, 20], [4, 21], [5, 5]],
					2026: [[4, 3], [4, 4], [4, 5], [4, 6], [5, 24]],
					2027: [[3, 26], [3, 27], [3, 28], [3, 29], [5, 13]],
					2028: [[4, 14], [4, 15], [4, 16], [4, 17], [5, 2]],
					2029: [[3, 30], [3, 31], [4, 1], [4, 2], [5, 20]],
					2030: [[4, 19], [4, 20], [4, 21], [4, 22], [5, 9]],
					2031: [[4, 11], [4, 12], [4, 13], [4, 14], [5, 28]],
					2032: [[3, 26], [3, 27], [3, 28], [3, 29], [5, 16]],
					2033: [[4, 15], [4, 16], [4, 17], [4, 18], [5, 6]],
					2034: [[4, 7], [4, 8], [4, 9], [4, 10], [5, 25]],
					2035: [[3, 23], [3, 24], [3, 25], [3, 26], [5, 15]],
					2036: [[4, 11], [4, 12], [4, 13], [4, 14], [5, 3]],
					2037: [[4, 3], [4, 4], [4, 5], [4, 6], [5, 22]],
					2038: [[4, 23], [4, 24], [4, 25], [4, 26], [5, 11]],
					2039: [[4, 8], [4, 9], [4, 10], [4, 11], [4, 30]],
					2040: [[3, 30], [3, 31], [4, 1], [4, 2], [5, 18]],
					2041: [[4, 19], [4, 20], [4, 21], [4, 22], [5, 7]],
					2042: [[4, 4], [4, 5], [4, 6], [4, 7], [5, 26]],
					2043: [[3, 27], [3, 28], [3, 29], [3, 30], [5, 16]],
					2044: [[4, 15], [4, 16], [4, 17], [4, 18], [5, 5]],
					2045: [[4, 7], [4, 8], [4, 9], [4, 10], [5, 24]],
					2046: [[3, 23], [3, 24], [3, 25], [3, 26], [5, 13]],
					2047: [[4, 12], [4, 13], [4, 14], [4, 15], [5, 2]],
					2048: [[4, 3], [4, 4], [4, 5], [4, 6], [5, 20]],
					2049: [[4, 16], [4, 17], [4, 18], [4, 19], [5, 9]],
					2050: [[4, 8], [4, 9], [4, 10], [4, 11], [5, 28]]
				}
1  
joe committed
149 150
			},
			// 节假日,key是月份,value是日期列表
simon committed
151
			// holiday: {
1  
joe committed
152

simon committed
153
			// }
simon committed
154 155 156
		}
	},
	components: {},
157
	computed: {
1  
joe committed
158 159 160 161 162 163 164 165
		holiday() {
			// 计算新历
			let result = {};
			let year = this.year;
			if (!year) {
				return;
			}
			let hkHolidayDefine = this.hkHolidayDefine;
simon committed
166 167


1  
joe committed
168 169 170 171 172 173 174 175 176 177 178 179 180
			// 加入清明节
			if (hkHolidayDefine.qm[0].indexOf(year + "") >= 0) {
				// 如果是周六/周日,顺延到下周一
				let vals = this.checkWeeken(4, 4);
				let m = vals[0];
				let d = vals[1];
				result[m] = [d];
			} else if (hkHolidayDefine.qm[1].indexOf(year + "") >= 0) {
				// 如果是周六/周日,顺延到下周一
				let vals = this.checkWeeken(4, 5);
				let m = vals[0];
				let d = vals[1];
				result[m] = [d];
1  
joe committed
181 182 183 184 185 186 187
			} else {
				let mod = year % 4;
				let d = mod == 0 || mod == 1 ? 4 : 5;
				let vals = this.checkWeeken(4, d);
				let m = vals[0];
				d = vals[1];
				result[m] = [d];
1  
joe committed
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
			}

			for (let index = 0; index < hkHolidayDefine.gl.length; index++) {
				let m = hkHolidayDefine.gl[index][0];
				let d = hkHolidayDefine.gl[index][1];

				// 如果是周六/周日,顺延到下周一
				let vals = this.checkWeeken(m, d);
				m = vals[0];
				d = vals[1];

				let list = result[m];
				if (!list) {
					result[m] = [];
					list = result[m];
simon committed
203
				}
1  
joe committed
204 205
				list.push(d);
			}
simon committed
206

joe committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
			// 不能通过计算的公历
			let pubData = this.hkHolidayDefine.pub[year + ""];
			if (pubData) {
				for (let index = 0; index < pubData.length; index++) {
					let m = pubData[index][0];
					let d = pubData[index][1];

					// 如果是周六/周日,顺延到下周一
					let vals = this.checkWeeken(m, d);
					m = vals[0];
					d = vals[1];

					let list = result[m];
					if (!list) {
						result[m] = [];
						list = result[m];
					}
					list.push(d);
				}
			}

simon committed
228

1  
joe committed
229 230 231 232
			for (let index = 0; index < hkHolidayDefine.nl.length; index++) {
				let m = hkHolidayDefine.nl[index][0];
				let d = hkHolidayDefine.nl[index][1];
				let gl = toSolar(year, m, d);
simon committed
233

1  
joe committed
234 235
				m = gl[1];
				d = gl[2];
simon committed
236 237


1  
joe committed
238 239 240 241
				// 如果是周六/周日,顺延到下周一
				let vals = this.checkWeeken(m, d);
				m = vals[0];
				d = vals[1];
simon committed
242

1  
joe committed
243 244 245 246
				let list = result[m];
				if (!list) {
					result[m] = [];
					list = result[m];
simon committed
247
				}
1  
joe committed
248 249 250
				list.push(d);
			}
			return result;
simon committed
251
		},
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
		locale() {
			return this.$i18n.locale || 'tc';
		},
		i18n() {
			return this.$i18n.messages && this.$i18n.locale ? this.$i18n.messages[this.$i18n.locale] : {};
		},
		getDayList() {
			if (this.locale == 'en') {
				return ["Sun", "Mon", "Tue", "Wen", "Thu", "Fri", "Sat"]
			} else {
				return ["日", "一", "二", "三", "四", "五", "六"]
			}
		},
		getMonthList() {
			if (this.locale == 'en') {
				return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
			} else {
				return ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
			}
		},
		// 年月
		getDateType1() {
			if (this.locale == 'en') {
				let date = Date.parse(`${this.month}/${this.date}/${this.year}`);
				return date.toString('MMM , yyyy');
			} else {
				return `${this.year}${this.month}月`
			}
		},
		// 年
		getDateType2() {
			if (this.locale == 'en') {
				return `${this.year}`
			} else {
				return `${this.year}年`
			}
		}
	},
simon committed
290
	methods: {
joe committed
291
		activity(item) {
simon committed
292 293 294 295 296 297 298
			let year = item.year;
			let month = item.month > 9 ? item.month : "0" + item.month;
			let date = item.date > 9 ? item.date : "0" + item.date;
			let ymd = `${year}-${month}-${date}`;
			if (this.formatter == "dd-MM-yyyy") {
				ymd = `${date}-${month}-${year}`;
			}
joe committed
299 300
			return ymd == this.dateValue;
		},
simon committed
301 302 303 304 305 306 307 308 309 310 311
		/**
		 * 画月历图
		 * 所需数据
		 * 		year  	年
		 * 		month 	月 (1~12)
		 * 		date		日  (1~31)
		 * 		day		星期几  (0-6)
		 *
		 * 输出数据
		 * 		fortmatMonthData 用于渲染日历的数据
		 */
simon committed
312
		formatDate() {
simon committed
313
			// console.log("qqq:",this.holiday);
simon committed
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
			let result = [];
			let year = this.year;
			let month = this.month;

			// 获取当月天数
			let dayNum = Date.getDaysInMonth(year, month - 1);

			/**
			 * 排布出当月号码
			 * 组装数据
			 */
			for (let index = 0; index < dayNum; index++) {
				let curData = {}
				curData.standards = 0;
				let date = index + 1;
joe committed
329
				let buildDate = Date.parse(`${year}.${month}.${date}`);
simon committed
330
				if (buildDate) {
1  
joe committed
331 332 333 334 335
					let now = new Date();
					let y = now.getFullYear();
					let m = now.getMonth() + 1;
					let d = now.getDate();
					let nowDate = Date.parse(`${y}.${m}.${d}`);
simon committed
336 337 338 339 340
					let day = buildDate.getDay();
					let isWeekend = day == 0 || day == 6;
					let disable = false; // 判断是否不可选
					if (this.filtModel.indexOf("weekend") >= 0) {
						disable = isWeekend;
simon committed
341
					}
simon committed
342
					if (!disable && this.filtModel.indexOf("future") >= 0) {
1  
joe committed
343
						// buildDate.setHours(23, 59, 59, 999);
simon committed
344 345 346 347 348 349
						disable = buildDate.getTime() > nowDate.getTime()
					}
					if (!disable && this.filtModel.indexOf("today") >= 0) {
						nowDate.setHours(0, 0, 0, 0);
						disable = buildDate.getTime() == nowDate.getTime();
					}
1  
joe committed
350 351 352 353
					if (!disable && this.filtModel.indexOf("holiday") >= 0) {
						if (isWeekend) {
							disable = true;
						} else {
1  
joe committed
354
							let holidayCandidates = this.holiday[month + ""];
simon committed
355
							if (holidayCandidates && holidayCandidates.indexOf(date) != -1) {
1  
joe committed
356 357 358 359
								disable = true;
							}
						}
					}
1  
joe committed
360 361 362 363
					if (!disable && this.filtModel.indexOf("history") >= 0) {
						buildDate.setHours(23, 59, 59, 999);
						disable = buildDate.getTime() < nowDate.getTime()
					}
simon committed
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
					// disable = isWeekend && !this.weekend; // 判断周末不可选
					let filterDates = this.filterDates;
					filterDates.forEach(element => {
						let curDate = `${year}-${month}-${date}`;
						if (element == curDate) {
							disable = true;
						}
					});
					curData = Object.assign({
						year: year,
						month: month,
						date: date, // (1~31)
						day: day,
						isWeekend: isWeekend,
						disable: disable,
					}, curData);
					result.push(curData);
				}
simon committed
382 383 384 385
			}

			// 当月1号星期几 0-6 往前塞值
			let dateStr = month + '.' + '1' + '.' + year;
simon committed
386 387 388
			let firstDate = Date.parse(dateStr);
			if (firstDate) {
				let firstDay = Date.parse(dateStr).getDay();
simon committed
389

simon committed
390 391 392 393 394
				// 根据星期几在前面补空格 星期日0格子,星期一1格子,星期六6格子
				for (let index = 0; index < firstDay; index++) {
					result.unshift(null);
				}
				this.fortmatMonthData = result;
simon committed
395
			}
simon committed
396

simon committed
397 398 399 400 401 402 403 404
		},
		// 加/减 月份
		addMonths(value) {
			let dateStr = this.month + '.' + this.date + '.' + this.year;
			let targetDate = Date.parse(dateStr).addMonths(value);
			this.year = targetDate.getFullYear();
			this.month = targetDate.getMonth() + 1;
			this.date = targetDate.getDate();
simon committed
405
			this.formatDate();
simon committed
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
		},
		// 上一个月
		prevMonth() {
			this.addMonths(-1);
		},
		// 下一个月
		nextMonth() {
			this.addMonths(1);
		},
		// 加/减 年份
		addYear(value) {
			let dateStr = this.month + '.' + this.date + '.' + this.year;
			let targetDate = Date.parse(dateStr).addYears(value);
			this.year = targetDate.getFullYear();
			this.month = targetDate.getMonth() + 1;
simon committed
421
			this.formatDate();
simon committed
422 423 424 425 426 427 428 429 430
		},
		// 上一年
		prevYear() {
			this.addYear(-1);
		},
		// 下一年
		nextYear() {
			this.addYear(1);
		},
simon committed
431
		// 选择日期
simon committed
432 433 434
		selectDay(item) {
			if (!item) return;
			let curData = item;
simon committed
435 436 437 438 439 440 441
			let curDate = curData.date;
			this.date = curDate;
			let {
				year,
				month,
				date
			} = this;
simon committed
442 443
			// this.dateValue = `${year}-${month}-${date}`;
			this.formatDateValue(year, month, date);
simon committed
444
			this.showCalendar();
1  
joe committed
445
			if (this.datePickComplete) {
simon committed
446 447
				this.datePickComplete();
			}
simon committed
448 449 450 451 452 453 454 455 456 457 458 459
		},
		// 选择月份
		selectMonth(item) {
			if (!item) return;
			this.dateType = 1;
			this.month = item;
			this.formatDate();
			let {
				year,
				month,
				date
			} = this;
simon committed
460 461
			// this.dateValue = `${year}-${month}-${date}`;
			this.formatDateValue(year, month, date);
simon committed
462 463 464 465 466 467 468 469 470 471 472 473 474
		},
		// 选择年份
		selectYear(item) {
			if (!item) return;
			this.dateType = 2;
			let curData = item;
			let curYear = curData.year;
			this.year = curYear;
			let {
				year,
				month,
				date,
			} = this;
simon committed
475 476
			// this.dateValue = `${year}-${month}-${date}`;
			this.formatDateValue(year, month, date);
simon committed
477 478 479 480 481 482 483 484 485
		},

		// 计算year渲染列表
		refreshYearList() {
			let yearPage = this.yearPage;
			if (yearPage <= 0) return;
			let yearList = [];
			for (let index = 0; index < 12; index++) {
				yearList.push({
simon committed
486
					year: yearPage * 10 + index,
simon committed
487 488
					// disable: index == 0 || index == 11,
					// gray: index == 0 || index == 11,
joe committed
489 490 491 492
					// disable: index >= 10,
					// gray: index >= 10,
					disable: false,
					gray: false,
simon committed
493 494
				});
			}
joe committed
495
			this.yearRange = `${yearPage * 10 + 0}-${yearPage * 10 + 9}`
simon committed
496 497 498 499 500 501 502 503 504 505
			this.yearList = yearList;
		},
		// 显示日历
		showCalendar(boo) {
			this.visible = boo;
			this.dateType = 1;
			let year = this.year;
			let yearPage = Math.floor(year / 10);
			this.yearPage = yearPage;
			this.refreshYearList();
1  
joe committed
506 507 508 509 510 511 512 513

			if (this.pluginActivity) {
				let _this = this;
				let type = boo ? "show" : "close";
				setTimeout(function () {
					_this.pluginActivity({ type: type });
				}, 100);
			}
simon committed
514
		},
515 516 517 518
		getMonthByIndex(index) {
			let monthList = this.getMonthList;
			return monthList[index - 1];
		},
simon committed
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561
		// 选择类型 年/月/日
		onTypeHandler() {
			let dateType = this.dateType;
			if (dateType == 1) {
				this.dateType = 2;
				return;
			}
			if (dateType == 2) {
				this.dateType = 3;
				this.refreshYearList();
				return;
			}
		},
		// 上下按钮
		onPrevHandler() {
			if (this.dateType == 1) {
				this.prevMonth();
				return;
			}
			if (this.dateType == 2) {
				this.prevYear();
				return;
			}
			if (this.dateType == 3) {
				this.yearPage--;
				this.refreshYearList();
				return;
			}
		},
		onNextHandler() {
			if (this.dateType == 1) {
				this.nextMonth();
				return;
			}
			if (this.dateType == 2) {
				this.nextYear();
				return;
			}
			if (this.dateType == 3) {
				this.yearPage++;
				this.refreshYearList();
				return;
			}
simon committed
562
		},
simon committed
563
		formatDateValue(year, month, date) {
simon committed
564 565 566
			// console.log("year:", year);
			// console.log("month:", month);
			// console.log("date:", date);
simon committed
567 568 569 570 571 572
			if (month < 10) {
				month = "0" + month
			}
			if (date < 10) {
				date = "0" + date
			}
simon committed
573 574 575
			// this.dateValue = `${year}-${month}-${date}`;
			this.dateValue = Date.parse(`${year}.${month}.${date}`).toString(this.formatter);
			// console.log("this.dateValue:", this.dateValue);
simon committed
576
		},
simon committed
577 578 579 580 581 582 583 584 585 586 587 588 589
		/**
		 * 校验并返回日期
		 * {
		 *	dateValue:yyyy-MM-dd,
		 *  disable:boolean  true:不可用 , false,当前日期可用
		 * }
		 */
		checkDateValue() {
			if (this.check) {
				let disable = false;
				let dateValue = this.dateValue;
				let fortmatMonthData = this.fortmatMonthData;
				fortmatMonthData.forEach((element, idx) => {
simon committed
590 591
					if (element) {
						let curDate = `${element.year}-${element.month}-${element.date}`;
simon committed
592
						curDate = Date.parse(curDate).toString(this.formatter); //转成yyyy-MM-dd
simon committed
593 594 595
						if (curDate == dateValue && element.disable == true) {
							disable = true;
						}
simon committed
596 597
					}
				});
simon committed
598
				if (!disable) {
simon committed
599 600 601
					let reDateValue = dateValue;
					if (this.formatter == "dd-MM-yyyy") {
						reDateValue = ddMMyyyy2yyyyMMdd(reDateValue);
simon committed
602
					}
simon committed
603
					disable = !/^((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)$/.test(reDateValue);
joe committed
604
				}
simon committed
605 606 607 608 609 610 611
				let result = {
					dateValue: this.dateValue,
					disable: disable
				}
				this.check(result);
			}
		},
joe committed
612 613 614 615
		initData() {
			// 设置今天日期
			let isInit = false;
			if (this.value) {
simon committed
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
				// console.log("this.value:", this.value);
				// let ymd = this.value.split("-");
				// if (ymd.length == 3) {
				// 	try {
				// 		this.year = Number(ymd[0]);
				// 		this.month = Number(ymd[1]);
				// 		this.date = Number(ymd[2]);
				// 		isInit = true;
				// 	} catch (e) {}
				// }
				try {
					let dateStr = this.value;
					if (this.formatter == "dd-MM-yyyy") {
						// dateStr = this.value.replace(/-/g, '').replace(/^(\d{2})(\d{2})(\d{4})$/, "$3-$2-$1");
						dateStr = ddMMyyyy2yyyyMMdd(this.value);

					}
					let curDate = Date.parse(dateStr);
					this.year = curDate.getFullYear();
					this.month = curDate.getMonth() + 1;
					this.date = curDate.getDate();
					isInit = true;
1  
joe committed
638
				} catch (error) { }
joe committed
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667
			}
			if (!isInit) {
				let today = Date.today();
				try {
					if (this.filtModel.indexOf("today") >= 0) {
						if (this.filtModel.indexOf("future") >= 0) {
							today.setDate(today.getDate() - 1);
							if (this.filtModel.indexOf("weekend") >= 0) {
								let day = today.getDay();
								let m = day == 0 ? -2 : day == 6 ? -1 : 0;
								today.setDate(today.getDate() + m);
							}
						} else if (this.filtModel.indexOf("history") >= 0) {
							today.setDate(today.getDate() + 1);
							if (this.filtModel.indexOf("weekend") >= 0) {
								let day = today.getDay();
								let m = day == 0 ? 1 : day == 6 ? 2 : 0;
								today.setDate(today.getDate() + m);
							}
						}
					}
				} catch (e) {
					console.error(e);
				}
				this.year = today.getFullYear();
				this.month = today.getMonth() + 1;
				this.date = today.getDate();
			}
			this.formatDate();
668
		},
simon committed
669 670
		judgeLastDateValidate(val) {

1  
joe committed
671 672
		},
		calculateHolidays() {
1  
joe committed
673

1  
joe committed
674 675
		},
		checkWeeken(m, d) {
1  
joe committed
676
			let year = this.year;
1  
joe committed
677 678 679 680 681 682 683
			let date = Date.parse(`${year}.${m}.${d}`);
			// if (date.getDay() == 6) {
			// 	// 周六
			// 	date.addDays(2);
			// } else 
			if (date.getDay() == 0) {
				date.addDays(1);
1  
joe committed
684
			}
1  
joe committed
685 686 687
			m = date.getMonth() + 1;
			d = date.getDate();
			return [m, d];
joe committed
688 689
		}
	},
1  
joe committed
690
	mounted() { },
simon committed
691
	created() {
joe committed
692
		this.initData();
simon committed
693 694 695 696
	},
	watch: {
		value(val) {
			this.dateValue = val;
joe committed
697
			this.initData();
simon committed
698
		},
simon committed
699 700 701
		dateValue(val, oldVal) {
			this.checkDateValue();
			this.$emit('input', val);
1  
joe committed
702 703
		},
		year() {
simon committed
704
			// this.calculateHolidays();
simon committed
705
		}
simon committed
706 707
	}
}