oa-calendar-item.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="uni-calendar-item__weeks-box" :class="{
  3. 'uni-calendar-item--disable':weeks.disable,
  4. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  5. 'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
  6. 'uni-calendar-item--multiple': weeks.multiple
  7. }"
  8. @tap="choiceDate(weeks)">
  9. <view class="uni-calendar-item__weeks-box-item">
  10. <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
  11. <text class="uni-calendar-item__weeks-box-text" :class="{
  12. 'uni-calendar-item--isDay-text': weeks.isDay,
  13. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  14. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  15. 'uni-calendar-item--multiple': weeks.multiple,
  16. 'uni-calendar-item--disable':weeks.disable,
  17. }">{{weeks.date}}</text>
  18. <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
  19. 'uni-calendar-item--isDay-text':weeks.isDay,
  20. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  21. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  22. 'uni-calendar-item--multiple': weeks.multiple,
  23. }">今天</text>
  24. <text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{
  25. 'uni-calendar-item--isDay-text':weeks.isDay,
  26. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  27. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  28. 'uni-calendar-item--multiple': weeks.multiple,
  29. 'uni-calendar-item--disable':weeks.disable,
  30. }">{{weeks.isDay?'今天': weeks.lunar.IDayCn}}</text>
  31. <text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{
  32. 'uni-calendar-item--extra':weeks.extraInfo.info,
  33. 'uni-calendar-item--isDay-text':weeks.isDay,
  34. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  35. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  36. 'uni-calendar-item--multiple': weeks.multiple,
  37. 'uni-calendar-item--disable':weeks.disable,
  38. }">{{weeks.extraInfo.info}}</text>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. props: {
  45. weeks: {
  46. type: Object,
  47. default () {
  48. return {}
  49. }
  50. },
  51. calendar: {
  52. type: Object,
  53. default: () => {
  54. return {}
  55. }
  56. },
  57. selected: {
  58. type: Array,
  59. default: () => {
  60. return []
  61. }
  62. },
  63. lunar: {
  64. type: Boolean,
  65. default: false
  66. }
  67. },
  68. methods: {
  69. choiceDate(weeks) {
  70. this.$emit('change', weeks)
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .uni-calendar-item__weeks-box {
  77. flex: 1;
  78. /* #ifndef APP-NVUE */
  79. display: flex;
  80. /* #endif */
  81. flex-direction: column;
  82. justify-content: center;
  83. align-items: center;
  84. }
  85. .uni-calendar-item__weeks-box-text {
  86. font-size: $uni-font-size-base - 6rpx;
  87. color: $uni-text-color;
  88. }
  89. .uni-calendar-item__weeks-lunar-text {
  90. font-size: $uni-font-size-sm - 6rpx;
  91. color: $uni-text-color;
  92. }
  93. .uni-calendar-item__weeks-box-item {
  94. position: relative;
  95. /* #ifndef APP-NVUE */
  96. display: flex;
  97. /* #endif */
  98. flex-direction: column;
  99. justify-content: center;
  100. align-items: center;
  101. height: 85rpx;
  102. }
  103. .uni-calendar-item__weeks-box-circle {
  104. position: absolute;
  105. top: 5px;
  106. right: 5px;
  107. width: 8px;
  108. height: 8px;
  109. border-radius: 8px;
  110. background-color: $uni-color-error;
  111. }
  112. .uni-calendar-item--disable {
  113. background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  114. color: $uni-text-color-disable;
  115. }
  116. .uni-calendar-item--isDay-text {
  117. color: $uni-color-primary;
  118. }
  119. .uni-calendar-item--isDay {
  120. background-color: $uni-color-primary;
  121. opacity: 0.8;
  122. color: #fff;
  123. }
  124. .uni-calendar-item--extra {
  125. color: $uni-color-error;
  126. opacity: 0.8;
  127. }
  128. .uni-calendar-item--checked {
  129. background-color: $uni-color-primary;
  130. color: #fff;
  131. opacity: 0.8;
  132. }
  133. .uni-calendar-item--multiple {
  134. background-color: $uni-color-primary;
  135. color: #fff;
  136. opacity: 0.8;
  137. }
  138. </style>