index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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">当日班次:{{'固定上下班'}} 班次 {{workingTime||'08:30'}}-{{offWorkTime||'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. workingTime:'',
  67. offWorkTime:'',
  68. currentDay:'',
  69. currentTime:'',
  70. clockDays:'',
  71. workHours:'',
  72. mealTimes:'',
  73. show:false,
  74. yearMonth:new Date().Format('yyyy-MM'),
  75. minDate:'',
  76. maxDate:'',
  77. userInfo:null,
  78. list:[],
  79. info:null
  80. }
  81. },
  82. onLoad() {
  83. this.currentDay = new Date().Format('yyyy MM.dd');
  84. this.currentTime = new Date().Format('yyyy-MM-dd hh:mm');
  85. if(uni.getStorageSync('userInfo')){
  86. this.userInfo = JSON.parse(uni.getStorageSync('userInfo'));
  87. }
  88. this.getUserMonthClock(new Date().getFullYear(),new Date().getMonth()+1);
  89. },
  90. mounted() {
  91. this.getRules();
  92. let d = new Date();
  93. this.minDate = new Date(d.getFullYear()-1,d.getMonth()+1,d.getDate()).getTime();
  94. this.maxDate = new Date().getTime();
  95. },
  96. methods:{
  97. getRules(){
  98. this.$api.get('/wms/outsourced/attendance/rule').then(res=>{
  99. if(res.data.code!==0) return this.$showToast(res.data.msg)
  100. this.workingTime = res.data.data.workingTime.slice(0,5);
  101. this.offWorkTime = res.data.data.offWorkTime.slice(0,5);
  102. })
  103. },
  104. getUserMonthClock(year,month){
  105. this.$api.get('/wms/outsourced/attendance/listByUserId',{
  106. outUserId:this.userInfo.id,
  107. queryMoth:this.yearMonth
  108. }).then(res=>{
  109. if(res.data.code!==0) return this.$showToast(res.data.msg)
  110. this.clockDays = res.data.data.filter(d=>d.isLeave!=3)?.length;
  111. this.workHours = res.data.data.reduce((a,b)=>a+Number(b.workingHours),0);
  112. this.mealTimes = res.data.data.reduce((a,b)=>a+Number(b.mealTimes),0);
  113. this.$refs.calendarRef.clockList = res.data.data||[];
  114. this.$refs.calendarRef.getDataByMonth(year,month);
  115. })
  116. },
  117. async selectDay(obj){
  118. this.currentDay = new Date(obj.year,obj.month-1,1).Format('yyyy MM.dd');
  119. this.$refs.calendarRef.year = obj.year;
  120. this.$refs.calendarRef.month = obj.month;
  121. this.yearMonth = new Date(obj.year,obj.month-1,1).Format('yyyy-MM');
  122. this.getUserMonthClock(obj.year,obj.month);
  123. // let idx = this.$refs.calendarList.findIndex(c=>c.month==obj.month);
  124. // this.$set(this.$refs.calendarList[idx],'select',true);
  125. },
  126. selectInfo(info){
  127. this.info = info;
  128. },
  129. confirm(e){
  130. this.currentDay = new Date(e.value).Format('yyyy MM.dd');
  131. let year = new Date(e.value).Format('yyyy');
  132. let month = Number(new Date(e.value).Format('MM'));
  133. this.$refs.calendarRef.year = year;
  134. this.$refs.calendarRef.month = month;
  135. this.yearMonth = new Date(e.value).Format('yyyy-MM');
  136. this.getUserMonthClock(year,month);
  137. this.info = {status:0}
  138. this.show = false;
  139. },
  140. }
  141. }
  142. </script>
  143. <style scoped lang="less">
  144. .tabPage{
  145. padding: 0 24rpx 188rpx;
  146. background: #F4F8FB;
  147. .card{
  148. background: #FFFFFF;
  149. border-radius: 16rpx;
  150. padding: 40rpx 30rpx;
  151. margin-top: 20rpx;
  152. .c_top{
  153. display: flex;
  154. align-items: center;
  155. justify-content: space-between;
  156. .ct_left{
  157. font-family: PingFang-SC, PingFang-SC;
  158. font-weight: bold;
  159. font-size: 32rpx;
  160. color: #1D2129;
  161. line-height: 45rpx;
  162. }
  163. .ct_right{
  164. font-family: PingFangSC, PingFang SC;
  165. font-weight: 400;
  166. font-size: 24rpx;
  167. color: #86909C;
  168. line-height: 33rpx;
  169. text-align: right;
  170. }
  171. }
  172. .c_nums{
  173. display: flex;
  174. margin-top: 54rpx;
  175. .cn_pre{
  176. width: calc(100% / 3);
  177. display: flex;
  178. flex-direction: column;
  179. align-items: center;
  180. p{
  181. font-family: PingFang-SC, PingFang-SC;
  182. font-weight: bold;
  183. font-size: 36rpx;
  184. color: #1D2129;
  185. line-height: 36rpx;
  186. text-align: center;
  187. &.text{
  188. font-weight: 400;
  189. font-size: 24rpx;
  190. color: #86909C;
  191. line-height: 24rpx;
  192. margin-top: 16rpx;
  193. }
  194. }
  195. }
  196. }
  197. .c_calendar{
  198. border-top: 1rpx solid #EFEFEF;
  199. border-bottom: 1rpx solid #EFEFEF;
  200. margin-top: 36rpx;
  201. padding: 20rpx 0;
  202. }
  203. .c_tip{
  204. font-family: PingFangSC, PingFang SC;
  205. font-weight: 400;
  206. font-size: 24rpx;
  207. color: #86909C;
  208. line-height: 24rpx;
  209. text-align: left;
  210. margin-top: 24rpx;
  211. }
  212. .c_time{
  213. margin-top: 40rpx;
  214. display: flex;
  215. align-items: center;
  216. &>image{
  217. width: 10rpx;
  218. height: 82rpx;
  219. }
  220. .ct_info{
  221. margin-left: 10rpx;
  222. .cti_pre{
  223. display: flex;
  224. align-items: center;
  225. &:last-child{
  226. margin-top: 48rpx;
  227. }
  228. .ctip_left{
  229. font-family: PingFang-SC, PingFang-SC;
  230. font-weight: bold;
  231. font-size: 24rpx;
  232. color: #1D2129;
  233. line-height: 24rpx;
  234. }
  235. .ctip_right{
  236. display: flex;
  237. align-items: center;
  238. margin-left: 20rpx;
  239. image{
  240. width: 24rpx;
  241. height: 24rpx;
  242. }
  243. span{
  244. font-family: PingFangSC, PingFang SC;
  245. font-weight: 400;
  246. font-size: 24rpx;
  247. color: #86909C;
  248. line-height: 24rpx;
  249. margin-left: 8rpx;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. </style>