• 日历封装


    getManthDate (year, month) {
            this.year = parseInt(year)
            this.month = parseInt(month)
            if (month === 13) {
              month = 1
              this.month = 1
              year += 1
              this.year += 1
            }
            if (month === 0) {
              month = 12
              this.month = 12
              year -= 1
              this.year -= 1
            }
            var tempArray = []
            var ret = []
            if (!year || !month) {
              var today = new Date()
              year = today.getFullYear()
              month = today.getMonth() + 1
              this.year = year
              this.month = month
            }
            var firstDay = new Date(year, month - 1, 1)
            var firstWeekDay = firstDay.getDay()
            firstWeekDay = firstWeekDay === 0 ? 7 : firstWeekDay
            var lastDayofLastMonth = new Date(year, month - 1, 0)
            var lastDateOfLastMonth = lastDayofLastMonth.getDate()
            var preMonthDayCount = firstWeekDay - 1
            var lastDay = new Date(year, month, 0)
            console.log('lastDay', lastDay)
            var lastDate = lastDay.getDate()
            for (let i = 0; i < 6 * 7; i++) {
              var date = i + 1 - preMonthDayCount
              var isActiveMonth = 1
              var showDate = date
              var thisMonth = month
              if (date <= 0) {
                isActiveMonth = 0
                thisMonth = month - 1
                showDate = lastDateOfLastMonth + date
              } else if (date > lastDate) {
                isActiveMonth = 2
                thisMonth = month + 1
                showDate = showDate - lastDate
              }
              thisMonth = thisMonth === 0 ? 12 : thisMonth
              thisMonth = thisMonth === 13 ? 1 : thisMonth
              tempArray.push({
                isAct: isActiveMonth,
                month: thisMonth,
                date: date,
                showDate: showDate
              })
            }
            for (let j = 0; j < tempArray.length; j += 7) {
              ret.push(tempArray.slice(j, j + 7))
            }
            this.days = ret
            if (!this.dateString) {
              this.selectedDate = new Date().getDate()
            } else {
              this.selectedDate = parseInt(this.dateString.split('-')[2])
            }
            console.log(this.days, 'days')
            console.log('selectedDate', this.selectedDate)
            console.log('year', this.year)
            console.log('month', this.month)
          }
    
  • 相关阅读:
    CRM 安装过程 AD+SQL+CRM
    CRM系统新思维
    美团点评前端无痕埋点实践
    大数据平台的技术演化之路 诸葛io平台设计实例
    Dynamics 365 for Team Members Description
    Integrating SharePoint 2013 with ADFS and Shibboleth
    CRM 安全证书到期操作命令
    cmseasy CmsEasy_5.6_20151009 无限制报错注入(parse_str()的坑)
    Mlecms Getshell
    Discuz 5.x 6.x 7.x 前台SQL注入漏洞
  • 原文地址:https://www.cnblogs.com/langqq/p/9132090.html
Copyright © 2020-2023  润新知