CardItemFive copy 2.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="FiveDetailBox">
  3. <el-calendar ref="calendar">
  4. <template #header="{ date }">
  5. <div class="calendarHeader">
  6. <el-icon class="icon1" @click="selectDate('prev-month')"><ArrowLeftBold /></el-icon>
  7. <span class="title">{{ date }}</span>
  8. <el-icon class="icon1" @click="selectDate('next-month')"><ArrowRightBold /></el-icon>
  9. </div>
  10. </template>
  11. <template #date-cell="{ data }">
  12. <p :class="`isSelected_${mockData[data.day] ? mockData[data.day]['s'] : '0'}`">
  13. {{ data.day.split('-').slice(1)[1] }}
  14. </p>
  15. </template>
  16. </el-calendar>
  17. </div>
  18. </template>
  19. <script setup lang="ts">
  20. import type { CalendarDateType, CalendarInstance } from 'element-plus'
  21. const calendar = ref<CalendarInstance>()
  22. const selectDate = (val: CalendarDateType) => {
  23. if (!calendar.value) return
  24. calendar.value.selectDate(val)
  25. }
  26. const mockData = ref({
  27. '2023-11-01': {
  28. s: 1 //1 未填 2 已填 3 请假
  29. },
  30. '2023-11-02': {
  31. s: 2 //1 未填 2 已填 3 请假
  32. },
  33. '2023-11-03': {
  34. s: 2 //1 未填 2 已填 3 请假
  35. }
  36. })
  37. </script>
  38. <style lang="scss" scoped>
  39. @import '../common.scss';
  40. .FiveDetailBox {
  41. height: 100%;
  42. .calendarHeader {
  43. width: 100%;
  44. display: flex;
  45. align-items: center;
  46. justify-content: space-between;
  47. .title {
  48. font-size: 18px;
  49. font-weight: bold;
  50. }
  51. padding: 20px 20px 0px 20px;
  52. .icon1 {
  53. cursor: pointer;
  54. color: #8b969c;
  55. }
  56. }
  57. ::v-deep {
  58. .el-calendar {
  59. .el-calendar__header {
  60. border: 0px;
  61. }
  62. .el-calendar__body {
  63. padding-bottom: 15px;
  64. }
  65. .el-calendar-table {
  66. td {
  67. border: 0px;
  68. }
  69. .el-calendar-day {
  70. height: auto;
  71. text-align: center;
  72. border: 0px;
  73. background: none;
  74. margin: auto;
  75. &:hover,
  76. &:active {
  77. background: none;
  78. }
  79. }
  80. .is-selected {
  81. background: none;
  82. }
  83. .is-today {
  84. &.is-selected {
  85. background: none;
  86. }
  87. .el-calendar-day {
  88. border-radius: 50%;
  89. background: none;
  90. color: #303133;
  91. }
  92. }
  93. }
  94. }
  95. }
  96. //控制不同状态的颜色
  97. .isSelected_1 {
  98. border: 1px solid #f83535;
  99. display: inline-block;
  100. padding: 3px 8px;
  101. border-radius: 2px;
  102. color: #f83535;
  103. position: relative;
  104. &:hover {
  105. &::after {
  106. display: block;
  107. content: '补填';
  108. position: absolute;
  109. top: 0px;
  110. padding: 3px 0px;
  111. bottom: 0px;
  112. left: 0px;
  113. right: 0px;
  114. text-align: center;
  115. margin: auto;
  116. font-size: 14px;
  117. background-color: #fff;
  118. }
  119. }
  120. }
  121. .isSelected_2 {
  122. color: #2e77e6;
  123. }
  124. }
  125. </style>