云链智安app
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

uni-calendar-item.vue 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view
  3. class="uni-calendar-item__weeks-box"
  4. :class="{
  5. 'uni-calendar-item--disable': weeks.disable,
  6. 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
  7. 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
  8. 'uni-calendar-item--before-checked': weeks.beforeMultiple,
  9. 'uni-calendar-item--multiple': weeks.multiple,
  10. 'uni-calendar-item--after-checked': weeks.afterMultiple,
  11. }"
  12. @click="choiceDate(weeks)"
  13. >
  14. <view class="uni-calendar-item__weeks-box-item">
  15. <!-- 右上角打点 -->
  16. <text
  17. v-if="selected && weeks.extraInfo"
  18. class="uni-calendar-item__weeks-box-circle"
  19. :class="{
  20. 'uni-calendar-item--workday-dot': weeks.extraInfo.info === '工作日',
  21. 'uni-calendar-item--restday-dot': weeks.extraInfo.info === '休息日',
  22. }"
  23. ></text>
  24. <!-- 日期文字 -->
  25. <text
  26. class="uni-calendar-item__weeks-box-text"
  27. :class="{
  28. 'uni-calendar-item--isDay-text': weeks.isDay,
  29. 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
  30. 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
  31. 'uni-calendar-item--before-checked': weeks.beforeMultiple,
  32. 'uni-calendar-item--multiple': weeks.multiple,
  33. 'uni-calendar-item--after-checked': weeks.afterMultiple,
  34. 'uni-calendar-item--disable': weeks.disable,
  35. 'uni-calendar-item--workday-text': weeks.extraInfo && weeks.extraInfo.info === '工作日',
  36. 'uni-calendar-item--restday-text': weeks.extraInfo && weeks.extraInfo.info === '休息日',
  37. }"
  38. >{{ weeks.date }}</text>
  39. <!-- 农历或今日文字 -->
  40. <text
  41. v-if="!lunar && !weeks.extraInfo && weeks.isDay"
  42. class="uni-calendar-item__weeks-lunar-text"
  43. :class="{
  44. 'uni-calendar-item--isDay-text': weeks.isDay,
  45. 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
  46. 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
  47. 'uni-calendar-item--before-checked': weeks.beforeMultiple,
  48. 'uni-calendar-item--multiple': weeks.multiple,
  49. 'uni-calendar-item--after-checked': weeks.afterMultiple,
  50. }"
  51. >{{ todayText }}</text>
  52. <!-- 农历文字 -->
  53. <text
  54. v-if="lunar && !weeks.extraInfo"
  55. class="uni-calendar-item__weeks-lunar-text"
  56. :class="{
  57. 'uni-calendar-item--isDay-text': weeks.isDay,
  58. 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
  59. 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
  60. 'uni-calendar-item--before-checked': weeks.beforeMultiple,
  61. 'uni-calendar-item--multiple': weeks.multiple,
  62. 'uni-calendar-item--after-checked': weeks.afterMultiple,
  63. 'uni-calendar-item--disable': weeks.disable,
  64. }"
  65. >{{ weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一' ? weeks.lunar.IMonthCn : weeks.lunar.IDayCn) }}</text>
  66. <!-- 额外信息 -->
  67. <text
  68. v-if="weeks.extraInfo && weeks.extraInfo.info"
  69. class="uni-calendar-item__weeks-lunar-text"
  70. :class="{
  71. 'uni-calendar-item--extra': weeks.extraInfo.info,
  72. 'uni-calendar-item--isDay-text': weeks.isDay,
  73. 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
  74. 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
  75. 'uni-calendar-item--before-checked': weeks.beforeMultiple,
  76. 'uni-calendar-item--multiple': weeks.multiple,
  77. 'uni-calendar-item--after-checked': weeks.afterMultiple,
  78. 'uni-calendar-item--disable': weeks.disable,
  79. 'uni-calendar-item--workday-texts': weeks.extraInfo && weeks.extraInfo.info === '工作日',
  80. 'uni-calendar-item--restday-texts': weeks.extraInfo && weeks.extraInfo.info === '休息日'
  81. }"
  82. >{{ weeks.extraInfo.info }}</text>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import { initVueI18n } from '@dcloudio/uni-i18n';
  88. import i18nMessages from './i18n/index.js';
  89. const { t } = initVueI18n(i18nMessages);
  90. export default {
  91. emits: ['change'],
  92. props: {
  93. weeks: {
  94. type: Object,
  95. default() {
  96. return {};
  97. },
  98. },
  99. calendar: {
  100. type: Object,
  101. default: () => {
  102. return {};
  103. },
  104. },
  105. selected: {
  106. type: Array,
  107. default: () => {
  108. return [];
  109. },
  110. },
  111. lunar: {
  112. type: Boolean,
  113. default: false,
  114. },
  115. },
  116. computed: {
  117. todayText() {
  118. return t('uni-calender.today');
  119. },
  120. },
  121. methods: {
  122. choiceDate(weeks) {
  123. this.$emit('change', weeks);
  124. },
  125. },
  126. };
  127. </script>
  128. <style lang="scss" scoped>
  129. $uni-font-size-base: 14px;
  130. $uni-text-color: #333;
  131. $uni-font-size-sm: 12px;
  132. $uni-color-error: #e43d33;
  133. $uni-opacity-disabled: 0.3;
  134. $uni-text-color-disable: #c0c0c0;
  135. $uni-primary: #2979ff !default;
  136. $uni-workday-color: #007545; // 工作日字体颜色
  137. $uni-restday-color: #e43d33; // 休息日字体颜色
  138. $uni-workday-dot: #007545; // 工作日打点颜色
  139. $uni-restday-dot: #e43d33; // 休息日打点颜色
  140. .uni-calendar-item__weeks-box {
  141. flex: 1;
  142. /* #ifndef APP-NVUE */
  143. display: flex;
  144. /* #endif */
  145. flex-direction: column;
  146. justify-content: center;
  147. align-items: center;
  148. }
  149. .uni-calendar-item__weeks-box-text {
  150. font-size: $uni-font-size-base;
  151. color: $uni-text-color;
  152. }
  153. .uni-calendar-item__weeks-lunar-text {
  154. font-size: $uni-font-size-sm;
  155. color: $uni-text-color;
  156. }
  157. .uni-calendar-item__weeks-box-item {
  158. position: relative;
  159. /* #ifndef APP-NVUE */
  160. display: flex;
  161. /* #endif */
  162. flex-direction: column;
  163. justify-content: center;
  164. align-items: center;
  165. width: 100rpx;
  166. height: 100rpx;
  167. }
  168. .uni-calendar-item__weeks-box-circle {
  169. position: absolute;
  170. top: 5px;
  171. right: 5px;
  172. width: 8px;
  173. height: 8px;
  174. border-radius: 8px;
  175. }
  176. .uni-calendar-item--workday-dot {
  177. background-color: $uni-workday-dot; // 工作日打点颜色
  178. }
  179. .uni-calendar-item--restday-dot {
  180. background-color: $uni-restday-dot; // 休息日打点颜色
  181. }
  182. .uni-calendar-item--disable {
  183. color: $uni-text-color-disable;
  184. }
  185. .uni-calendar-item--isDay-text {
  186. color: $uni-primary;
  187. }
  188. .uni-calendar-item--isDay {
  189. // color: #fff;
  190. color: #2979ff;
  191. }
  192. .uni-calendar-item--checked {
  193. // color: #e96900 !important;
  194. }
  195. .uni-calendar-item--multiple {
  196. color: #fff;
  197. }
  198. .uni-calendar-item--before-checked {
  199. color: #fff;
  200. }
  201. .uni-calendar-item--after-checked {
  202. color: #fff;
  203. }
  204. .uni-calendar-item--workday-text {
  205. color: $uni-workday-color; // 工作日字体颜色
  206. }
  207. .uni-calendar-item--restday-text {
  208. color: $uni-restday-color; // 休息日字体颜色
  209. }
  210. .uni-calendar-item--workday-texts {
  211. color: $uni-text-color-disable; // 工作日字体颜色
  212. }
  213. .uni-calendar-item--restday-texts {
  214. color: $uni-text-color-disable; // 休息日字体颜色
  215. }
  216. </style>