calendar.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view>
  3. <back :text="'打卡详情'"></back>
  4. <view class="card-box">
  5. <view class="card-item" v-if="topInfo === false">
  6. <view class="total">
  7. <view class="total-title">本月打卡</view>
  8. <view class="total-content">
  9. <view class="number-box">
  10. <view class="number" style="color: #4169E1;">{{calendar.isAttendNum}}</view>
  11. <view class="number-detail">打卡次数</view>
  12. </view>
  13. <view class="number-box">
  14. <view class="number" style="color: #ff5959;">{{calendar.noAttendNum}}</view>
  15. <view class="number-detail">缺卡次数</view>
  16. </view>
  17. <view class="number-box">
  18. <text class="number"
  19. :style="{color: monthAttendQuality==='优秀'?'#4169E1':(monthAttendQuality === '良好'?'#f9c752':'#3B4144')}">{{monthAttendQuality}}</text>
  20. <view class="number-detail">出勤质量</view>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- <view class="flex" style="justify-content: center;" >
  25. <view class="image" :style="{backgroundImage:`url(${image})`}"></view>
  26. </view> -->
  27. </view>
  28. <view class="card-item">
  29. <view class="calendar_container">
  30. <zsyCalendar :sundayIndex="6" @chooseDate="chooseDate" @change="change" />
  31. </view>
  32. <view class="state-box">
  33. <view class="state"
  34. :style="{backgroundColor: attendance==='已打卡'?'#4169E1':(attendance === '未打卡'?'#f9c752':'#bebebe')}">
  35. <view class="state-text">{{attendance}}</view>
  36. </view>
  37. <view class="msg-box">
  38. <view class="flex">
  39. <text class="msg-text" style="font-weight: normal;font-size: 28rpx;">打卡时间:</text>
  40. <text class="msg-text">{{attendanceTime}}</text>
  41. </view>
  42. <view class="flex">
  43. <text class="msg-text" style="font-weight: normal;font-size: 28rpx;">出勤效率:</text>
  44. <text class="msg-text"
  45. :style="{color: attendanceQuality==='优秀'?'#4169E1':(attendanceQuality === '良好'?'#f9c752':'#3B4144')}">{{attendanceQuality}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. mapState,
  56. } from 'vuex'
  57. import zsyCalendar from '@/subpkg/z-calendar/zsy-calendar.vue'
  58. export default {
  59. name: 'Calendar',
  60. components: {
  61. zsyCalendar
  62. },
  63. computed: {
  64. ...mapState('m_children', ['records', 'calendar']),
  65. },
  66. data() {
  67. return {
  68. // image: 'https://image.meiye.art/pic_1632658822816Dw1wc8QoTOnItNvJI76v6',
  69. topInfo: false,
  70. //当日打卡信息
  71. attendance: '',
  72. attendanceTime: '',
  73. attendanceQuality: '',
  74. //当月天数
  75. // monthDates: '',
  76. monthAttendQuality: '',
  77. //当月
  78. month: '',
  79. };
  80. },
  81. onLoad(options) {
  82. this.getTodayAttendance()
  83. this.getMonthAttendQuality()
  84. },
  85. methods: {
  86. //选中日期改变回调
  87. change(e) {
  88. if(e.month != this.month){
  89. this.topInfo = true
  90. }else{
  91. this.topInfo = false
  92. }
  93. },
  94. //今日打卡
  95. getTodayAttendance() {
  96. //获取当月
  97. this.month = new Date().getMonth() + 1
  98. //获得当前时间时间戳
  99. let timeNow = (new Date()).format("yyyy-M-dd")
  100. let timeArr = timeNow.split("-")
  101. let info = this.records.filter(x => x.year == timeArr[0] && x.month == timeArr[1] && x.date == timeArr[2])
  102. if (info.length === 0) {
  103. //出勤状况
  104. this.attendance = '未打卡',
  105. //打卡时间
  106. this.attendanceTime = '未记录',
  107. //出勤质量
  108. this.attendanceQuality = '未记录'
  109. } else {
  110. this.attendance = '已打卡'
  111. this.attendanceTime = info[0].time
  112. this.attendanceQuality = info[0].time <= '08:15' ? '优秀' : (info[0].time <= '08:25' ? '良好' : '较差')
  113. }
  114. },
  115. //判断本月出勤质量
  116. getMonthAttendQuality() {
  117. this.monthAttendQuality = this.calendar.noAttendNum <= 3 ? '优秀' : (this.calendar.noAttendNum <= 6 ? '良好' :
  118. '较差')
  119. },
  120. //选择日期
  121. chooseDate(dateInfo, dateIndex) {
  122. // console.log(dateInfo);
  123. if (dateInfo.isAttend === 1) {
  124. this.attendance = '已打卡'
  125. this.attendanceTime = this.records.filter(x => x.date === dateInfo.date && x.month === dateInfo
  126. .month && x.year === x.year)[0].time
  127. // console.log(info);
  128. this.attendanceQuality = this.attendanceTime <= '08:15' ? '优秀' : (this.attendanceTime <= '08:25' ?
  129. '良好' : '较差')
  130. }
  131. if (dateInfo.isAttend === 0) {
  132. this.attendance = '未打卡'
  133. this.attendanceTime = '未记录'
  134. this.attendanceQuality = '未记录'
  135. }
  136. if (dateInfo.isAttend === -1) {
  137. this.attendance = '未到日期'
  138. this.attendanceTime = '未记录'
  139. this.attendanceQuality = '未记录'
  140. }
  141. },
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. .card-box {
  147. display: flex;
  148. flex-flow: column wrap;
  149. margin: 0 20rpx 0 20rpx;
  150. justify-content: space-between;
  151. .card-item {
  152. margin: 2% 0;
  153. width: 100%;
  154. height: auto;
  155. display: flex;
  156. flex-direction: column;
  157. justify-content: space-around;
  158. background-color: #FFF;
  159. border-radius: $card-border-radius;
  160. //日历组件
  161. .calendar_container {
  162. height: 100%;
  163. width: 100%;
  164. background-color: #FFF;
  165. margin: 0 auto;
  166. box-sizing: border-box;
  167. border-radius: $card-border-radius;
  168. }
  169. }
  170. }
  171. .total {
  172. height: 250rpx;
  173. width: 100%;
  174. .total-title {
  175. font-size: 32rpx;
  176. font-weight: bold;
  177. color: $color-title;
  178. margin: 30rpx 30rpx 0rpx 30rpx;
  179. }
  180. .total-content {
  181. display: flex;
  182. align-items: center;
  183. justify-content: space-around;
  184. height: 175rpx;
  185. .number-box {
  186. display: flex;
  187. flex-direction: column;
  188. align-items: center;
  189. .number {
  190. font-size: 46rpx;
  191. font-weight: bold;
  192. color: $color-title;
  193. }
  194. .number-detail {
  195. margin-top: 10rpx;
  196. font-size: 28rpx;
  197. color: #afafaf;
  198. }
  199. }
  200. }
  201. }
  202. .state-box {
  203. display: flex;
  204. align-items: center;
  205. height: 200rpx;
  206. width: 100%;
  207. .state {
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. border-radius: 100%;
  212. margin: 20rpx;
  213. height: 150rpx;
  214. width: 150rpx;
  215. .state-text {
  216. font-size: 32rpx;
  217. font-weight: bold;
  218. color: #FFF;
  219. }
  220. }
  221. .msg-box {
  222. display: flex;
  223. flex-direction: column;
  224. justify-content: space-around;
  225. height: 150rpx;
  226. width: auto;
  227. .msg-text {
  228. color: $color-title;
  229. font-weight: bold;
  230. font-size: 36rpx;
  231. margin-left: 20rpx;
  232. }
  233. }
  234. }
  235. .flex {
  236. display: flex;
  237. align-items: center;
  238. }
  239. .image {
  240. width: 45%;
  241. height: 250rpx;
  242. border-radius: $card-border-radius;
  243. background-size: 100%;
  244. background-repeat: no-repeat;
  245. }
  246. </style>