king
2020-12-17 a4ef35bb323b5f8300f15a4eb604d61ff39a194a
src/tabviews/zshare/calendar/index.jsx
@@ -92,8 +92,17 @@
    const { calendar } = this.props
    let datalist = []
    let levels = { red: 1, orange: 2, yellow: 3, green: 4, cyan: 5, blue: 6, purple: 7, gray: 8 }
    let colors = { red: '#d0021b', orange: '#f5a623', yellow: '#f8e71c', green: '#7ed321', cyan: '#50e3c2', blue: '#1890ff', purple: '#bd10e0', gray: '#9b9b9b' }
    let colors = {
      transparent: 'rgba(0, 0, 0, 0)',
      red: 'rgba(208, 2, 27, 1)',
      orange: 'rgba(245, 166, 35, 1)',
      yellow: 'rgba(248, 231, 28, 1)',
      green: 'rgba(126, 211, 33, 1)',
      cyan: 'rgba(80, 227, 194, 1)',
      blue: 'rgba(24, 144, 255, 1)',
      purple: 'rgba(189, 16, 224, 1)',
      gray: 'rgba(155, 155, 155, 1)'
    }
    data && data.forEach(item => {
      let startTime = item[calendar.startfield]
@@ -107,8 +116,7 @@
      let equal = endTime.substr(0, 4) === startTime.substr(0, 4)
      datalist.push({
        color: colors[color] || '',
        level: color && levels[color] ? levels[color] : 100,
        color: colors[color] || color,
        remark: item[calendar.remarkfield],
        startMonth: startTime.substr(0, 4) + startTime.substr(5, 2),
        endMonth: endTime.substr(0, 4) + endTime.substr(5, 2),
@@ -119,21 +127,6 @@
      })
    })
    if (datalist.length > 0) {
      datalist.sort((a, b) => a.level - b.level)
    }
    let styles = [
      {background: '#d0021b', color: '#ffffff'},
      {background: '#f5a623', color: '#ffffff'},
      {background: '#f8e71c', color: '#ffffff'},
      {background: '#7ed321', color: '#ffffff'},
      {background: '#50e3c2', color: '#ffffff'},
      {background: '#1890ff', color: '#ffffff'},
      {background: '#bd10e0', color: '#ffffff'},
      {background: '#9b9b9b', color: '#ffffff'},
    ]
    return datelist.map(month => {
      month.subData = []
      datalist.forEach(item => {
@@ -141,9 +134,7 @@
          month.subData.push(item)
        }
      })
      if (month.subData[0]) {
        month.style = styles[month.subData[0].level - 1] || null
      }
      month.style = this.getStyle(month.subData[0])
      month.sublist = month.sublist.map(week => {
        week.sublist = week.sublist.map(day => {
          if (!day) return null
@@ -154,16 +145,29 @@
              day.subData.push(item)
            }
          })
          if (day.subData[0]) {
            day.style = styles[day.subData[0].level - 1] || null
          }
          day.style = this.getStyle(day.subData[0])
          return day
        })
        return week
      })
      return month
    })
  }
  getStyle = (item ) => {
    if (!item || !item.color) return null
    let style = {background: item.color}
    if (/rgb/ig.test(item.color)) {
      try {
        let colors = item.color.match(/\d+/g)
        if ((colors[0] * 0.299 + colors[1] * 0.578 + colors[2] * 0.114) * colors[3] < 192) {
          style.color = '#ffffff'
        }
      } catch {}
    }
    return style
  }
  getDateList = (selectYear) => {
@@ -309,7 +313,7 @@
                      <tr key={cell.week}>
                        {cell.sublist.map((d, i) => (
                          <td key={i}>
                            {d ? <div className={'day-wrap ' + d.class} style={d.style || null} onClick={() => this.triggerDay(d)}>
                            {d ? <div className="day-wrap" style={d.style || null} onClick={() => this.triggerDay(d)}>
                              {d.subData.length > 0 ? <Popover mouseEnterDelay={0.3} overlayClassName="calendar-day-pop" content={
                                <div>
                                  {d.subData.map((data, index) => (