index.vue 8.0 KB

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