| | |
| | | getPreMonthDays(amount, dateObj) { |
| | | const result = [] |
| | | for (let i = amount - 1; i >= 0; i--) { |
| | | const month = dateObj.month - 1 |
| | | const month = dateObj.month > 1 ? dateObj.month -1 : 12 |
| | | const year = month === 12 ? dateObj.year - 1 : dateObj.year |
| | | const date = new Date(year,month,-i).getDate() |
| | | const fullDate = `${year}-${addZero(month)}-${addZero(date)}` |
| | | let multiples = this.multipleStatus.data |
| | | let multiplesStatus = -1 |
| | | if (this.range && multiples) { |
| | | multiplesStatus = multiples.findIndex((item) => { |
| | | return this.dateEqual(item, fullDate) |
| | | }) |
| | | } |
| | | const checked = multiplesStatus !== -1 |
| | | // 获取打点信息 |
| | | const extraInfo = this.selected && this.selected.find((item) => { |
| | | if (this.dateEqual(fullDate, item.date)) { |
| | | return item |
| | | } |
| | | }) |
| | | result.push({ |
| | | date: new Date(dateObj.year, month, -i).getDate(), |
| | | fullDate, |
| | | year, |
| | | month, |
| | | disable: true |
| | | date, |
| | | multiple: this.range ? checked : false, |
| | | beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), |
| | | afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), |
| | | disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), |
| | | isToday: fullDate === this.date.fullDate, |
| | | userChecked: false, |
| | | extraInfo |
| | | }) |
| | | } |
| | | return result |
| | |
| | | const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}` |
| | | const isToday = fullDate === currentDate |
| | | // 获取打点信息 |
| | | const info = this.selected && this.selected.find((item) => { |
| | | const extraInfo = this.selected && this.selected.find((item) => { |
| | | if (this.dateEqual(currentDate, item.date)) { |
| | | return item |
| | | } |
| | |
| | | result.push({ |
| | | fullDate: currentDate, |
| | | year: dateObj.year, |
| | | month: dateObj.month, |
| | | date: i, |
| | | multiple: this.range ? checked : false, |
| | | beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after), |
| | | afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after), |
| | | month: dateObj.month, |
| | | disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)), |
| | | isToday, |
| | | userChecked: false, |
| | | extraInfo: info |
| | | extraInfo |
| | | }) |
| | | } |
| | | return result |
| | |
| | | const result = [] |
| | | const month = dateObj.month + 1 |
| | | for (let i = 1; i <= amount; i++) { |
| | | const month = dateObj.month === 12 ? 1 : dateObj.month*1 + 1 |
| | | const year = month === 1 ? dateObj.year + 1 : dateObj.year |
| | | const fullDate = `${year}-${addZero(month)}-${addZero(i)}` |
| | | let multiples = this.multipleStatus.data |
| | | let multiplesStatus = -1 |
| | | if (this.range && multiples) { |
| | | multiplesStatus = multiples.findIndex((item) => { |
| | | return this.dateEqual(item, fullDate) |
| | | }) |
| | | } |
| | | const checked = multiplesStatus !== -1 |
| | | // 获取打点信息 |
| | | const extraInfo = this.selected && this.selected.find((item) => { |
| | | if (this.dateEqual(fullDate, item.date)) { |
| | | return item |
| | | } |
| | | }) |
| | | result.push({ |
| | | fullDate, |
| | | year, |
| | | date: i, |
| | | month, |
| | | disable: true |
| | | multiple: this.range ? checked : false, |
| | | beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), |
| | | afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), |
| | | disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), |
| | | isToday: fullDate === this.date.fullDate, |
| | | userChecked: false, |
| | | extraInfo |
| | | }) |
| | | } |
| | | return result |
| | |
| | | return date.match(dateReg) |
| | | } |
| | | |
| | | const dateTimeReg = /^\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])( [0-5][0-9]:[0-5][0-9]:[0-5][0-9])?$/ |
| | | const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9]:[0-5]?[0-9])?$/ |
| | | function fixIosDateFormat(value) { |
| | | if (typeof value === 'string' && dateTimeReg.test(value)) { |
| | | value = value.replace(/-/g, '/') |