index.vue 7.7 KB

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