custom-content.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <div class="demo-date-picker">
  3. <el-date-picker v-model="value" type="date" placeholder="Pick a day" format="YYYY/MM/DD" value-format="YYYY-MM-DD">
  4. <template #default="cell">
  5. <div class="cell" :class="{ current: cell.isCurrent }">
  6. <span class="text">{{ cell.text }}</span>
  7. <span v-if="isHoliday(cell)" class="holiday" />
  8. </div>
  9. </template>
  10. </el-date-picker>
  11. </div>
  12. </template>
  13. <script lang="ts" setup>
  14. import { ref } from 'vue'
  15. const value = ref('2021-10-29')
  16. const holidays = ['2021-10-01', '2021-10-02', '2021-10-03', '2021-10-04', '2021-10-05', '2021-10-06', '2021-10-07']
  17. const isHoliday = ({ dayjs }) => {
  18. return holidays.includes(dayjs.format('YYYY-MM-DD'))
  19. }
  20. </script>
  21. <style scoped>
  22. .cell {
  23. height: 30px;
  24. padding: 3px 0;
  25. box-sizing: border-box;
  26. }
  27. .cell .text {
  28. width: 24px;
  29. height: 24px;
  30. display: block;
  31. margin: 0 auto;
  32. line-height: 24px;
  33. position: absolute;
  34. left: 50%;
  35. transform: translateX(-50%);
  36. border-radius: 50%;
  37. }
  38. .cell.current .text {
  39. background: #626aef;
  40. color: #fff;
  41. }
  42. .cell .holiday {
  43. position: absolute;
  44. width: 6px;
  45. height: 6px;
  46. background: var(--el-color-danger);
  47. border-radius: 50%;
  48. bottom: 0px;
  49. left: 50%;
  50. transform: translateX(-50%);
  51. }
  52. </style>