Browse Source

增加打卡防抖

htc 3 weeks ago
parent
commit
d218faac56
2 changed files with 11 additions and 2 deletions
  1. 5 1
      pagesClockin/fieldService.vue
  2. 6 1
      pagesClockin/index.vue

+ 5 - 1
pagesClockin/fieldService.vue

@@ -43,7 +43,8 @@
 				nearestBuilding: '正在定位...',
 				address: '正在获取地址...',
 				mapCtx: null,
-				fileList: []
+				fileList: [],
+				canClick:true
 			}
 		},
 		onLoad(option) {
@@ -173,14 +174,17 @@
 				})
 			},
 			confirm() {
+				if(!this.canClick) return
 				if(this.fileList.length===0) return this.$showToast('请先外出签到拍照')
 				let params = { outUserId:this.outUserId };
 				params[this.isSW==1?'checkInTime':'clockOutTime'] = new Date().Format('yyyy-MM-dd hh:mm');
 				params.file = this.fileList[0].url;
 				params.position = this.address;
+				this.canClick = false;
 				this.$api.post(this.url,params).then(res=>{
 					if(res.data.code!==0) return this.$showToast(res.data.msg);
 					this.$showToast('外出签到成功')
+					this.canClick = true;
 					setTimeout(()=>{
 						uni.reLaunch({
 							url:'/pagesClockin/index'

+ 6 - 1
pagesClockin/index.vue

@@ -91,7 +91,8 @@
 					latitude: 31.962084,
 					longitude: 117.020446
 				},
-				userInfo:null
+				userInfo:null,
+				canClick:true
 			}
 		},
 		created() {
@@ -147,6 +148,8 @@
 				this.isSW =  new Date().getHours()>12?false:true;
 			},
 			clock(){
+				if(!this.canClick) return
+				
 				let url = this.isSW?'/wms/outsourced/attendance/checkIn':'/wms/outsourced/attendance/clockOut';
 				let params = {outUserId:this.userInfo?.id};
 				params[this.isSW?'checkInTime':'clockOutTime'] = new Date().Format('yyyy-MM-dd hh:mm');
@@ -156,10 +159,12 @@
 					})
 					return
 				} 
+				this.canClick = false;
 				this.$api.post(url,params).then(res=>{
 					if(res.data.code!==0) return this.$showToast(res.data.msg);
 					this.clockTime = new Date().Format('hh:mm');
 					this.show = true;
+					this.canClick = true;
 				})
 			},
 			close(){