uni-calendar-item.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. @click="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 === '初一'?weeks.lunar.IMonthCn: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. // +----------------------------------------------------------------------
  44. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  45. // +----------------------------------------------------------------------
  46. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  47. // +----------------------------------------------------------------------
  48. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  49. // +----------------------------------------------------------------------
  50. // | Author: CRMEB Team <admin@crmeb.com>
  51. // +----------------------------------------------------------------------
  52. export default {
  53. props: {
  54. weeks: {
  55. type: Object,
  56. default () {
  57. return {}
  58. }
  59. },
  60. calendar: {
  61. type: Object,
  62. default: () => {
  63. return {}
  64. }
  65. },
  66. selected: {
  67. type: Array,
  68. default: () => {
  69. return []
  70. }
  71. },
  72. lunar: {
  73. type: Boolean,
  74. default: false
  75. }
  76. },
  77. methods: {
  78. choiceDate(weeks) {
  79. this.$emit('change', weeks)
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .uni-calendar-item__weeks-box {
  86. flex: 1;
  87. /* #ifndef APP-NVUE */
  88. display: flex;
  89. /* #endif */
  90. flex-direction: column;
  91. justify-content: center;
  92. align-items: center;
  93. }
  94. .uni-calendar-item__weeks-box-text {
  95. font-size: $uni-font-size-base;
  96. color: $uni-text-color;
  97. }
  98. .uni-calendar-item__weeks-lunar-text {
  99. font-size: $uni-font-size-sm;
  100. color: $uni-text-color;
  101. }
  102. .uni-calendar-item__weeks-box-item {
  103. position: relative;
  104. /* #ifndef APP-NVUE */
  105. display: flex;
  106. /* #endif */
  107. flex-direction: column;
  108. justify-content: center;
  109. align-items: center;
  110. width: 100rpx;
  111. height: 100rpx;
  112. }
  113. .uni-calendar-item__weeks-box-circle {
  114. position: absolute;
  115. top: 5px;
  116. right: 5px;
  117. width: 8px;
  118. height: 8px;
  119. border-radius: 8px;
  120. background-color: $uni-color-error;
  121. }
  122. .uni-calendar-item--disable {
  123. background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  124. color: $uni-text-color-disable;
  125. }
  126. .uni-calendar-item--isDay-text {
  127. color: $uni-color-primary;
  128. }
  129. .uni-calendar-item--isDay {
  130. background-color: $uni-color-primary;
  131. opacity: 0.8;
  132. color: #fff;
  133. }
  134. .uni-calendar-item--extra {
  135. color: $uni-color-error;
  136. opacity: 0.8;
  137. }
  138. .uni-calendar-item--checked {
  139. background-color: $uni-color-primary;
  140. color: #fff;
  141. opacity: 0.8;
  142. }
  143. .uni-calendar-item--multiple {
  144. background-color: $uni-color-primary;
  145. color: #fff;
  146. opacity: 0.8;
  147. }
  148. </style>