2021-10-30 21:39:11 +08:00
|
|
|
<template>
|
|
|
|
<div class="demo-date-picker">
|
|
|
|
<el-date-picker
|
|
|
|
v-model="value"
|
|
|
|
type="date"
|
|
|
|
placeholder="Pick a day"
|
|
|
|
format="YYYY/MM/DD"
|
|
|
|
value-format="YYYY-MM-DD"
|
|
|
|
>
|
|
|
|
<template #default="cell">
|
|
|
|
<div class="cell" :class="{ current: cell.isCurrent }">
|
|
|
|
<span class="text">{{ cell.text }}</span>
|
|
|
|
<span v-if="isHoliday(cell)" class="holiday"></span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</el-date-picker>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ref } from 'vue'
|
2021-10-30 21:39:11 +08:00
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
const value = ref('2021-10-29')
|
|
|
|
const holidays = [
|
|
|
|
'2021-10-01',
|
|
|
|
'2021-10-02',
|
|
|
|
'2021-10-03',
|
|
|
|
'2021-10-04',
|
|
|
|
'2021-10-05',
|
|
|
|
'2021-10-06',
|
|
|
|
'2021-10-07',
|
|
|
|
]
|
2021-10-30 21:39:11 +08:00
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
const isHoliday = ({ dayjs }) => {
|
|
|
|
return holidays.includes(dayjs.format('YYYY-MM-DD'))
|
|
|
|
}
|
2021-10-30 21:39:11 +08:00
|
|
|
</script>
|
|
|
|
|
2021-12-21 15:51:33 +08:00
|
|
|
<style scoped>
|
2021-10-30 21:39:11 +08:00
|
|
|
.cell {
|
|
|
|
height: 30px;
|
|
|
|
padding: 3px 0;
|
|
|
|
box-sizing: border-box;
|
2021-12-21 15:51:33 +08:00
|
|
|
}
|
|
|
|
.cell .text {
|
|
|
|
width: 24px;
|
|
|
|
height: 24px;
|
|
|
|
display: block;
|
|
|
|
margin: 0 auto;
|
|
|
|
line-height: 24px;
|
|
|
|
position: absolute;
|
|
|
|
left: 50%;
|
|
|
|
transform: translateX(-50%);
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
.cell.current .text {
|
|
|
|
background: purple;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
.cell .holiday {
|
|
|
|
position: absolute;
|
|
|
|
width: 6px;
|
|
|
|
height: 6px;
|
|
|
|
background: red;
|
|
|
|
border-radius: 50%;
|
|
|
|
bottom: 0px;
|
|
|
|
left: 50%;
|
|
|
|
transform: translateX(-50%);
|
2021-10-30 21:39:11 +08:00
|
|
|
}
|
|
|
|
</style>
|