custom-content.vue 1.3 KB

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