index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="tabPage" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='统计' :showback="false"></cus-header>
  4. <div class="card">
  5. <div class="c_top">
  6. <div class="ct_left" @tap="show=true">{{currentDay}}</div>
  7. <div class="ct_right">统计截至{{currentTime}}</div>
  8. </div>
  9. <div class="c_nums">
  10. <div class="cn_pre">
  11. <p>{{clockDays}}</p>
  12. <p class="text">出勤天数</p>
  13. </div>
  14. <div class="cn_pre">
  15. <p>{{workHours}}</p>
  16. <p class="text">总工时</p>
  17. </div>
  18. <div class="cn_pre">
  19. <p>{{mealTimes}}</p>
  20. <p class="text">餐补次数</p>
  21. </div>
  22. </div>
  23. <div class="c_calendar">
  24. <Calendar ref="calendarRef" @selectDay="selectDay" @selectInfo="selectInfo"></Calendar>
  25. </div>
  26. <div class="c_tip">当日班次:{{'固定上下班'}} 班次 {{'08:30-17:30'}}</div>
  27. <div class="c_tip">出勤统计:打卡{{info.clockTimes||0}}次,工时{{info.workHours||0}}小时</div>
  28. <div class="c_time" v-if="info&&info.status==1">
  29. <image :src="imgBase+'clockingin/time_line.png'"></image>
  30. <div class="ct_info">
  31. <div class="cti_pre" v-if="info.sbTime">
  32. <div class="ctip_left">上班 {{info.sbTime}}</div>
  33. <div class="ctip_right">
  34. <image :src="imgBase+'clockingin/location_inactive.png'"></image>
  35. <span>{{'谷锐特设备自动化有限公司'}}</span>
  36. </div>
  37. </div>
  38. <div class="cti_pre" v-else>
  39. <div class="ctip_left">未打卡</div>
  40. </div>
  41. <div class="cti_pre" v-if="info.xbTime">
  42. <div class="ctip_left">下班 {{info.xbTime}}</div>
  43. <div class="ctip_right">
  44. <image :src="imgBase+'clockingin/location_inactive.png'"></image>
  45. <span>{{'谷锐特设备自动化有限公司'}}</span>
  46. </div>
  47. </div>
  48. <div class="cti_pre" v-else>
  49. <div class="ctip_left">未打卡</div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <u-datetime-picker :itemHeight="88" :show="show" v-model="yearMonth" mode="year-month" @confirm="confirm" @cancel="show=false" :immediateChange="true" :minDate="minDate" :maxDate="maxDate"></u-datetime-picker>
  55. <Tabbar :tabbarIndex="1"></Tabbar>
  56. </view>
  57. </template>
  58. <script>
  59. import Calendar from '@/components/CusCalendar/index.vue'
  60. import Tabbar from '@/components/CusTabbar/clock.vue'
  61. export default {
  62. components:{ Calendar,Tabbar },
  63. data(){
  64. return {
  65. currentDay:'',
  66. currentTime:'',
  67. clockDays:'',
  68. workHours:'',
  69. mealTimes:'',
  70. show:false,
  71. yearMonth:new Date().Format('yyyy-MM'),
  72. minDate:'',
  73. maxDate:'',
  74. userInfo:null,
  75. list:[],
  76. info:null
  77. }
  78. },
  79. onLoad() {
  80. this.currentDay = new Date().Format('yyyy MM.dd');
  81. this.currentTime = new Date().Format('yyyy-MM-dd hh:mm');
  82. if(uni.getStorageSync('userInfo')){
  83. this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  84. }
  85. this.getUserMonthClock(new Date().getFullYear(),new Date().getMonth()+1);
  86. },
  87. mounted() {
  88. let d = new Date();
  89. this.minDate = new Date(d.getFullYear()-1,d.getMonth()+1,d.getDate()).getTime();
  90. this.maxDate = new Date().getTime();
  91. },
  92. methods:{
  93. getUserMonthClock(year,month){
  94. this.$api.get('/wms/outsourced/attendance/listByUserId',{
  95. outUserId:this.userInfo.id,
  96. queryMoth:this.yearMonth
  97. }).then(res=>{
  98. if(res.data.code!==0) return this.$showToast(res.data.msg)
  99. this.clockDays = res.data.data.filter(d=>d.isLeave!=3)?.length;
  100. this.workHours = res.data.data.reduce((a,b)=>a+Number(b.workingHours),0);
  101. this.mealTimes = res.data.data.reduce((a,b)=>a+Number(b.mealTimes),0);
  102. this.$refs.calendarRef.clockList = res.data.data||[];
  103. this.$refs.calendarRef.getDataByMonth(year,month);
  104. })
  105. },
  106. async selectDay(obj){
  107. this.currentDay = new Date(obj.year,obj.month-1,1).Format('yyyy MM.dd');
  108. this.$refs.calendarRef.year = obj.year;
  109. this.$refs.calendarRef.month = obj.month;
  110. this.yearMonth = new Date(obj.year,obj.month-1,1).Format('yyyy-MM');
  111. this.getUserMonthClock(obj.year,obj.month);
  112. // let idx = this.$refs.calendarList.findIndex(c=>c.month==obj.month);
  113. // this.$set(this.$refs.calendarList[idx],'select',true);
  114. },
  115. selectInfo(info){
  116. this.info = info;
  117. },
  118. confirm(e){
  119. this.currentDay = new Date(e.value).Format('yyyy MM.dd');
  120. let year = new Date(e.value).Format('yyyy');
  121. let month = Number(new Date(e.value).Format('MM'));
  122. this.$refs.calendarRef.year = year;
  123. this.$refs.calendarRef.month = month;
  124. this.yearMonth = new Date(e.value).Format('yyyy-MM');
  125. this.getUserMonthClock(year,month);
  126. this.info = {status:0}
  127. this.show = false;
  128. },
  129. }
  130. }
  131. </script>
  132. <style scoped lang="less">
  133. .tabPage{
  134. padding: 0 24rpx 188rpx;
  135. background: #F4F8FB;
  136. .card{
  137. background: #FFFFFF;
  138. border-radius: 16rpx;
  139. padding: 40rpx 30rpx;
  140. margin-top: 20rpx;
  141. .c_top{
  142. display: flex;
  143. align-items: center;
  144. justify-content: space-between;
  145. .ct_left{
  146. font-family: PingFang-SC, PingFang-SC;
  147. font-weight: bold;
  148. font-size: 32rpx;
  149. color: #1D2129;
  150. line-height: 45rpx;
  151. }
  152. .ct_right{
  153. font-family: PingFangSC, PingFang SC;
  154. font-weight: 400;
  155. font-size: 24rpx;
  156. color: #86909C;
  157. line-height: 33rpx;
  158. text-align: right;
  159. }
  160. }
  161. .c_nums{
  162. display: flex;
  163. margin-top: 54rpx;
  164. .cn_pre{
  165. width: calc(100% / 3);
  166. display: flex;
  167. flex-direction: column;
  168. align-items: center;
  169. p{
  170. font-family: PingFang-SC, PingFang-SC;
  171. font-weight: bold;
  172. font-size: 36rpx;
  173. color: #1D2129;
  174. line-height: 36rpx;
  175. text-align: center;
  176. &.text{
  177. font-weight: 400;
  178. font-size: 24rpx;
  179. color: #86909C;
  180. line-height: 24rpx;
  181. margin-top: 16rpx;
  182. }
  183. }
  184. }
  185. }
  186. .c_calendar{
  187. border-top: 1rpx solid #EFEFEF;
  188. border-bottom: 1rpx solid #EFEFEF;
  189. margin-top: 36rpx;
  190. padding: 20rpx 0;
  191. }
  192. .c_tip{
  193. font-family: PingFangSC, PingFang SC;
  194. font-weight: 400;
  195. font-size: 24rpx;
  196. color: #86909C;
  197. line-height: 24rpx;
  198. text-align: left;
  199. margin-top: 24rpx;
  200. }
  201. .c_time{
  202. margin-top: 40rpx;
  203. display: flex;
  204. align-items: center;
  205. &>image{
  206. width: 10rpx;
  207. height: 82rpx;
  208. }
  209. .ct_info{
  210. margin-left: 10rpx;
  211. .cti_pre{
  212. display: flex;
  213. align-items: center;
  214. &:last-child{
  215. margin-top: 48rpx;
  216. }
  217. .ctip_left{
  218. font-family: PingFang-SC, PingFang-SC;
  219. font-weight: bold;
  220. font-size: 24rpx;
  221. color: #1D2129;
  222. line-height: 24rpx;
  223. }
  224. .ctip_right{
  225. display: flex;
  226. align-items: center;
  227. margin-left: 20rpx;
  228. image{
  229. width: 24rpx;
  230. height: 24rpx;
  231. }
  232. span{
  233. font-family: PingFangSC, PingFang SC;
  234. font-weight: 400;
  235. font-size: 24rpx;
  236. color: #86909C;
  237. line-height: 24rpx;
  238. margin-left: 8rpx;
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. }
  246. </style>