index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div class="log-list">
  3. <el-calendar ref="calendar" v-model="thisMonth">
  4. <template #header="{ date }">
  5. <div class="title">
  6. <div class="check-btn" @click="checkMonth('prev')">
  7. <el-icon><ArrowLeft /></el-icon>
  8. </div>
  9. <div class="show-month">{{ date }}</div>
  10. <div class="check-btn" @click="checkMonth('next')">
  11. <el-icon><ArrowRight /></el-icon>
  12. </div>
  13. </div>
  14. </template>
  15. <template #date-cell="{ data }">
  16. <!-- 仅工作日显示角标 -->
  17. <div>
  18. <div class="date-type">
  19. <div
  20. class="icon-box"
  21. :style="{ backgroundColor: backgroundColorObj[iconType(data.day)] }"
  22. >
  23. <el-icon>
  24. <Check v-if="iconType(data.day) == '已填'" />
  25. <Close v-if="iconType(data.day) == '未填'" />
  26. <EditPen v-if="iconType(data.day) == '当天'" />
  27. <!-- <More v-if="iconType(data.day) == '未到'" /> -->
  28. </el-icon>
  29. </div>
  30. </div>
  31. <div>{{ moment(data.day).format('DD') }}</div>
  32. </div>
  33. </template>
  34. </el-calendar>
  35. </div>
  36. </template>
  37. <script lang="ts" setup>
  38. /**
  39. * @description 首页日志概况
  40. */
  41. import moment from 'moment'
  42. import { http } from '../weekly/service'
  43. import PubsubService from '@/utils/PubsubService'
  44. const { push } = useRouter()
  45. const message = useMessage()
  46. // 本月日期
  47. const thisMonth = ref<any>(moment())
  48. // 日志填报列表
  49. const logObj = ref<any>({})
  50. // 获取工作日列表
  51. onMounted(async () => {
  52. const logList = await http.getLogList('daily')
  53. logList.map((item: any) => {
  54. const date = item.reportStartDate
  55. const dateKey = moment(date).format('YYYY-MM-DD')
  56. logObj.value[dateKey] = item
  57. })
  58. // 订阅点击更多事件
  59. PubsubService.subscribe('homepage-click-weeklyAndDaily-more', () => {
  60. // 跳转到日志填报页面
  61. push('oaSystem/PersonalCenter/dailyCenter')
  62. })
  63. })
  64. // 仅能查看近三个月的
  65. const checkMonth = (type: 'prev' | 'next') => {
  66. if (
  67. type == 'prev' &&
  68. moment(thisMonth.value).format('YYYY-MM') == moment().subtract(2, 'month').format('YYYY-MM')
  69. ) {
  70. message.info('仅能查看近三个月的周报,点击更多以查看全部!')
  71. return
  72. }
  73. if (type == 'next' && moment(thisMonth.value).format('YYYY-MM') == moment().format('YYYY-MM')) {
  74. message.info('还未到下个月!')
  75. return
  76. }
  77. if (type == 'prev') {
  78. thisMonth.value = moment(thisMonth.value).subtract(1, 'month')
  79. } else {
  80. thisMonth.value = moment(thisMonth.value).add(1, 'month')
  81. }
  82. }
  83. const iconType = (date) => {
  84. const formatDate = moment(date).format('YYYY-MM-DD')
  85. let text = ''
  86. if (!logObj.value[formatDate]) {
  87. text = '未填'
  88. }
  89. if (moment(formatDate).isAfter(moment())) {
  90. text = '未到'
  91. }
  92. if (formatDate == moment().format('YYYY-MM-DD')) {
  93. text = '当天'
  94. }
  95. if (logObj.value[formatDate]) {
  96. text = '已填'
  97. }
  98. return text
  99. }
  100. const backgroundColorObj = {
  101. 未填: '#F85638',
  102. 当天: '#1B80EB',
  103. 已填: '#0ACE9D',
  104. 未到: ''
  105. // 未到: '#BDC7CE'
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .log-list {
  110. .title {
  111. width: 100%;
  112. height: 48px;
  113. line-height: 48px;
  114. background: #f3f6fa;
  115. border-radius: 40px 40px 40px 40px;
  116. display: flex;
  117. justify-content: space-between;
  118. align-items: center;
  119. .show-month {
  120. }
  121. .check-btn {
  122. width: 30px;
  123. height: 30px;
  124. background-color: #fff;
  125. border-radius: 50%;
  126. line-height: 30px;
  127. text-align: center;
  128. font-size: 18px;
  129. margin: 0 10px;
  130. color: #5b656f;
  131. }
  132. }
  133. :deep(.el-calendar-table tr td) {
  134. border: 0;
  135. }
  136. :deep(.el-calendar-day) {
  137. padding: 0;
  138. text-align: center;
  139. height: 40px;
  140. .date-type {
  141. font-size: 12px;
  142. display: flex;
  143. justify-content: right;
  144. }
  145. }
  146. .icon-box {
  147. width: 16px;
  148. height: 16px;
  149. border-radius: 50%;
  150. display: flex;
  151. justify-content: center;
  152. align-items: center;
  153. font-size: 12px;
  154. color: #fff;
  155. font-weight: bold;
  156. }
  157. }
  158. </style>