index.vue 9.1 KB

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