123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <template>
- <div class="OaCalendar">
- <div class="selectBox">
- <el-icon class="icon1" @click="lastClick"><ArrowLeftBold /></el-icon>
- <p>{{ moment(nowTime).format('YYYY年MM月') }}</p>
- <el-icon class="icon1" @click="nextClick"><ArrowRightBold /></el-icon>
- </div>
- <div class="contentBox">
- <div class="ulBox">
- <ul>
- <li v-for="(item, index) in daysList" :key="index" :style="{ width: item.w }">
- <div class="topBox" :class="item.week == 0 || item.week == 6 ? 'topBoxPa' : 'topBox'">
- <p>{{ item.d }}</p>
- </div>
- <div class="bomBox">
- <img :src="imgBoxInit(item, index)" />
- </div>
- </li>
- </ul>
- </div>
- <div class="infoBox">
- <span>已填写 (天)</span>
- <p>15</p>
- </div>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { getAssetURL } from '@/utils/auth'
- import moment from 'moment'
- const daysList: any = ref([])
- const nowTime: any = ref(moment().format('YYYY-MM'))
- const initDates = async () => {
- let curDays: any = moment(nowTime.value).daysInMonth() // 当前天数
- let currentM: any = nowTime.value // 当前月
- let dateList: any = []
- for (let i = 0; i < curDays; i++) {
- let days = i + 1
- dateList.push({
- w: `calc(100% / ${curDays})`,
- d: days,
- m: currentM,
- dm: currentM + '-' + days,
- week: moment(currentM + '-' + days).day()
- })
- }
- daysList.value = dateList
- }
- const imgBoxInit = (item: any, index: any) => {
- let icon1 = getAssetURL('kq/1')
- let icon2 = getAssetURL('kq/2')
- let icon3 = getAssetURL('kq/3')
- if (item.week == 0 || item.week == 6) {
- return ''
- } else {
- if (index % 2 == 0) {
- return icon2
- } else {
- if (index % 3 == 0) {
- return icon3
- } else {
- return icon1
- }
- }
- }
- }
- const lastClick = () => {
- let time: any = moment(nowTime.value).subtract(1, 'months').format('YYYY-MM')
- nowTime.value = moment(time).format('YYYY-MM')
- initDates()
- }
- const nextClick = () => {
- let time: any = moment(nowTime.value).add(1, 'months').format('YYYY-MM')
- nowTime.value = moment(time).format('YYYY-MM')
- initDates()
- }
- onMounted(() => {
- initDates()
- })
- </script>
- <style lang="scss" scoped>
- .OaCalendar {
- width: 100%;
- .selectBox {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- .icon1 {
- cursor: pointer;
- }
- p {
- font-weight: 600;
- color: #2d333c;
- margin: 0 10px;
- user-select: none;
- cursor: pointer;
- }
- }
- .contentBox {
- width: 100%;
- height: 80px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- border: 1px solid #dee0e3;
- .ulBox {
- width: calc(100% - 120px);
- height: 100%;
- ul {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- li {
- height: 100%;
- .topBox {
- width: 100%;
- height: 50%;
- border: 1px solid #dee0e3;
- display: flex;
- align-items: center;
- justify-content: center;
- border-right: 0;
- border-top: 0;
- background-color: #f7f8fa;
- cursor: pointer;
- p {
- color: #121518;
- user-select: none;
- }
- }
- .topBoxPa {
- p {
- color: #b9c3c9;
- }
- }
- .topBox:hover {
- p {
- color: #1b80eb;
- }
- }
- .bomBox {
- width: 100%;
- height: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- img {
- user-select: none;
- }
- }
- }
- li:first-child {
- .topBox {
- border-left: 0;
- }
- }
- li:last-child {
- .topBox {
- border-right: 0;
- }
- }
- }
- .infoBox {
- width: 120px;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- flex-wrap: wrap;
- background-color: #edf0f4;
- border-left: 1px solid #dee0e3;
- span {
- display: block;
- width: 100%;
- text-align: center;
- font-size: 14px;
- }
- p {
- width: 100%;
- text-align: center;
- font-size: 18px;
- }
- }
- }
- }
- </style>
|