index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="OaCalendar">
  3. <div class="selectBox">
  4. <el-icon class="icon1" @click="lastClick"><ArrowLeftBold /></el-icon>
  5. <p>{{ moment(nowTime).format('YYYY年MM月') }}</p>
  6. <el-icon class="icon1" @click="nextClick"><ArrowRightBold /></el-icon>
  7. </div>
  8. <div class="contentBox">
  9. <div class="ulBox">
  10. <ul>
  11. <li v-for="(item, index) in daysList" :key="index" :style="{ width: item.w }">
  12. <div class="topBox" :class="item.week == 0 || item.week == 6 ? 'topBoxPa' : 'topBox'">
  13. <p>{{ item.d }}</p>
  14. </div>
  15. <div class="bomBox">
  16. <img :src="imgBoxInit(item, index)" />
  17. </div>
  18. </li>
  19. </ul>
  20. </div>
  21. <div class="infoBox">
  22. <span>已填写&nbsp;(天)</span>
  23. <p>15</p>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script setup lang="ts">
  29. import { getAssetURL } from '@/utils/auth'
  30. import moment from 'moment'
  31. const daysList: any = ref([])
  32. const nowTime: any = ref(moment().format('YYYY-MM'))
  33. const initDates = async () => {
  34. let curDays: any = moment(nowTime.value).daysInMonth() // 当前天数
  35. let currentM: any = nowTime.value // 当前月
  36. let dateList: any = []
  37. for (let i = 0; i < curDays; i++) {
  38. let days = i + 1
  39. dateList.push({
  40. w: `calc(100% / ${curDays})`,
  41. d: days,
  42. m: currentM,
  43. dm: currentM + '-' + days,
  44. week: moment(currentM + '-' + days).day()
  45. })
  46. }
  47. daysList.value = dateList
  48. }
  49. const imgBoxInit = (item: any, index: any) => {
  50. let icon1 = getAssetURL('kq/1')
  51. let icon2 = getAssetURL('kq/2')
  52. let icon3 = getAssetURL('kq/3')
  53. if (item.week == 0 || item.week == 6) {
  54. return ''
  55. } else {
  56. if (index % 2 == 0) {
  57. return icon2
  58. } else {
  59. if (index % 3 == 0) {
  60. return icon3
  61. } else {
  62. return icon1
  63. }
  64. }
  65. }
  66. }
  67. const lastClick = () => {
  68. let time: any = moment(nowTime.value).subtract(1, 'months').format('YYYY-MM')
  69. nowTime.value = moment(time).format('YYYY-MM')
  70. initDates()
  71. }
  72. const nextClick = () => {
  73. let time: any = moment(nowTime.value).add(1, 'months').format('YYYY-MM')
  74. nowTime.value = moment(time).format('YYYY-MM')
  75. initDates()
  76. }
  77. onMounted(() => {
  78. initDates()
  79. })
  80. </script>
  81. <style lang="scss" scoped>
  82. .OaCalendar {
  83. width: 100%;
  84. .selectBox {
  85. display: flex;
  86. align-items: center;
  87. margin-bottom: 10px;
  88. .icon1 {
  89. cursor: pointer;
  90. }
  91. p {
  92. font-weight: 600;
  93. color: #2d333c;
  94. margin: 0 10px;
  95. user-select: none;
  96. cursor: pointer;
  97. }
  98. }
  99. .contentBox {
  100. width: 100%;
  101. height: 80px;
  102. display: flex;
  103. align-items: center;
  104. justify-content: space-between;
  105. border: 1px solid #dee0e3;
  106. .ulBox {
  107. width: calc(100% - 120px);
  108. height: 100%;
  109. ul {
  110. width: 100%;
  111. height: 100%;
  112. display: flex;
  113. align-items: center;
  114. justify-content: space-between;
  115. }
  116. li {
  117. height: 100%;
  118. .topBox {
  119. width: 100%;
  120. height: 50%;
  121. border: 1px solid #dee0e3;
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. border-right: 0;
  126. border-top: 0;
  127. background-color: #f7f8fa;
  128. cursor: pointer;
  129. p {
  130. color: #121518;
  131. user-select: none;
  132. }
  133. }
  134. .topBoxPa {
  135. p {
  136. color: #b9c3c9;
  137. }
  138. }
  139. .topBox:hover {
  140. p {
  141. color: #1b80eb;
  142. }
  143. }
  144. .bomBox {
  145. width: 100%;
  146. height: 50%;
  147. display: flex;
  148. align-items: center;
  149. justify-content: center;
  150. img {
  151. user-select: none;
  152. }
  153. }
  154. }
  155. li:first-child {
  156. .topBox {
  157. border-left: 0;
  158. }
  159. }
  160. li:last-child {
  161. .topBox {
  162. border-right: 0;
  163. }
  164. }
  165. }
  166. .infoBox {
  167. width: 120px;
  168. height: 100%;
  169. display: flex;
  170. align-items: center;
  171. justify-content: space-between;
  172. flex-wrap: wrap;
  173. background-color: #edf0f4;
  174. border-left: 1px solid #dee0e3;
  175. span {
  176. display: block;
  177. width: 100%;
  178. text-align: center;
  179. font-size: 14px;
  180. }
  181. p {
  182. width: 100%;
  183. text-align: center;
  184. font-size: 18px;
  185. }
  186. }
  187. }
  188. }
  189. </style>