zhuoyuan.wang
2024-06-19 15ebe96f28cadec6a726c5324593a40bbf56205f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
  <div class="dashborad-calendar">
    <div class="header">
      <div>日历</div>
      <el-select
        class="select"
        v-model="value"
        size="small"
      >
        <el-option
          v-for="item in windowList"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
    </div>
    <div class="content">
      <el-calendar>
        <template #date-cell="{ data }">
          <p :class="isExistDate(data.day) ? 'is-selected' : ''">
            {{ data.day.split('-').slice(2).join('-') }}
          </p>
        </template>
      </el-calendar>
    </div>
  </div>
</template>
 
<script setup>
import moment from 'moment';
 
const value = ref('销量预测')
const windowList = [
  {
    value: '销量预测',
    label: '销量预测',
  },
  {
    value: '销量预估',
    label: '销量预估',
  },
  {
    value: '销量上报',
    label: '销量上报',
  },
];
 
const dateRange = [{cycleId: '202403', startData: '2024-03-01', endDate: '2024-03-25'}];
 
const isExistDate = (date) => {
  const dateStr = moment(date, 'YYYY-MM-DD').format('YYYYMM');
  const curDate = dateRange.find(e => e.cycleId === dateStr);
  if (curDate) {
    return moment(date).isBetween(curDate.startData, curDate.endDate);
  }
  return false;
};
 
</script>
 
<style scoped lang="scss">
.dashborad-calendar {
  border-top: 3px solid var(--el-color-primary);
  background: #fff;
  box-sizing: border-box;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
  border-radius: 6px;
  width: 100%;
  height: 328px;
 
  .header {
    padding: 8px 13px;
    background-color: #fff;
    border-bottom: 1px solid #e7e7e7;
    font-size: 14px;
    color: #303133;
    font-weight: 500;
    position: relative;
 
    .select {
      position: absolute;
      right: 10px;
      width: 100px;
      top: 6px;
    }
  }
 
  .content {
    .is-selected {
      color: #1989fa;
      border-radius: 3px;
      border: solid 1px var(--el-color-primary);
    }
  }
}
</style>
 
<style lang="scss">
.dashborad-calendar {
  .el-calendar__body {
    padding: 5px;
  }
 
  .el-calendar-table thead th {
    padding: 0 0 5px 0;
  }
 
  .el-calendar {
    height: 35px;
    text-align: center;
  }
 
  .el-calendar-day {
    padding: 9px;
    height: 35px;
  }
 
  .el-calendar__header {
    font-size: 13px;
    padding: 5px 8px;
 
    .el-button {
      font-size: 12px;
      padding: 6px 9px;
    }
  }
}
</style>