index.vue 7.2 KB

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