瀏覽代碼

fix(attendance): 修复考勤组件打卡状态判断逻辑

修正多个组件中关于打卡状态的判断条件,确保在已打卡下班后不能再次打卡或维护信息。同时调整考勤信息初始化逻辑,根据可打卡类型显示不同的时间信息。
huoyi 4 月之前
父節點
當前提交
0bde108793

+ 8 - 1
src/pages/attendance/components/AddAttendancePersonnelModal.vue

@@ -136,7 +136,11 @@ export default {
136 136
     selectedMember: {
137 137
       type: Array,
138 138
       default: () => []
139
-    }
139
+    },
140
+    attendanceInfo: { // 考勤信息
141
+      type: Object,
142
+      default: () => ({})
143
+    },
140 144
   },
141 145
   data() {
142 146
     return {
@@ -280,6 +284,9 @@ export default {
280 284
     },
281 285
     openModal() {
282 286
       if (this.disabled || (this.selectedMember.length === 0 && this.notkezhang)) return
287
+      if ((!this.attendanceInfo.checkInTime || (this.attendanceInfo.checkInTime && this.attendanceInfo.checkOutTime))) {
288
+        return;
289
+      }
283 290
       this.show = true
284 291
     },
285 292
     close() {

+ 2 - 2
src/pages/attendance/components/AttendanceControl.vue

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <view>
3 3
     <view class="attendance-control">
4
-      <view class="control-btn" :class="{ disable: !result || checkAbleType != '1' }" @click="clockIn(1)">
4
+      <view class="control-btn" :class="{ disable:!result || checkAbleType != '1' }" @click="clockIn(1)">
5 5
         <text class="control-btn-text">上班打卡</text>
6 6
       </view>
7 7
       <view class="attendance-info">
@@ -24,7 +24,7 @@
24 24
           </view>
25 25
         </view>
26 26
       </view>
27
-      <view class="control-btn" :class="{ disable: !result || checkAbleType != '2' }" @click="clockIn(2)">
27
+      <view class="control-btn" :class="{ disable:!result || checkAbleType != '2' }" @click="clockIn(2)">
28 28
         <text class="control-btn-text">下班打卡</text>
29 29
       </view>
30 30
     </view>

+ 2 - 2
src/pages/attendance/components/MaintainAreaOrMemberModal.vue

@@ -21,7 +21,7 @@
21 21
                     </view>
22 22
                 </view>
23 23
             </view>
24
-            <view v-else :class="{ 'custom-btn': true, 'disabled': !attendanceInfo.checkInTime }" @click="openModal">
24
+            <view v-else :class="{ 'custom-btn': true, 'disabled': (!attendanceInfo.checkInTime||(attendanceInfo.checkInTime && attendanceInfo.checkOutTime)) }" @click="openModal">
25 25
                 维护工作区域/班组成员</view>
26 26
         </view>
27 27
         <u-popup :show="show" mode="center" :round="8">
@@ -368,7 +368,7 @@ export default {
368 368
             })
369 369
         },
370 370
         openModal() {
371
-            if (!this.attendanceInfo.checkInTime) {
371
+            if ((!this.attendanceInfo.checkInTime||(this.attendanceInfo.checkInTime && this.attendanceInfo.checkOutTime))) {
372 372
                 return;
373 373
             }
374 374
             this.show = true;

+ 8 - 5
src/pages/attendance/components/WorkingGroup.vue

@@ -31,7 +31,8 @@
31 31
             v-if="!notkezhang">
32 32
             <text class="content-cell-label">负责区域</text>
33 33
             <!-- <text class="content-cell-value">{{ info.regionalName || info.regionalCode || '--' }}</text> -->
34
-            <view class="selected-areas" v-if="getHandleAreaData(data) && getHandleAreaData(data).length && !notkezhang">
34
+            <view class="selected-areas"
35
+              v-if="getHandleAreaData(data) && getHandleAreaData(data).length && !notkezhang">
35 36
               <view class="area-item" v-for="area in getHandleAreaData(data)" :key="area.code">
36 37
                 <view class="area-label">{{ area.label }}</view>
37 38
                 <text-tag :showClose="false" :tags="area.children" :labelColumn="'regionalName'" />
@@ -51,10 +52,10 @@
51 52
       <!-- {{ selectedMember.length === 0 }}{{ !userInfo.roles.includes('kezhang') }}{{ !attendanceInfo.checkInTime }} -->
52 53
       <!-- :disabled="!attendanceInfo.checkInTime || checkOutStatus" -->
53 54
       <AddAttendancePersonnelModal v-if="index === 0" :disabled="checkOutStatus" :notkezhang="notkezhang"
54
-        :userInfo="userInfo" @updateRecord="invokerGetPostRecordList" :selectedMember="selectedMember">
55
+        :userInfo="userInfo" @updateRecord="invokerGetPostRecordList" :selectedMember="selectedMember" :attendanceInfo="attendanceInfo">
55 56
         <!-- :class="{ disabled: !attendanceInfo.checkInTime }"   没有选人不可以上通道 -->
56 57
         <view v-if="authority" class="custom-btn" @click="openModal"
57
-          :class="{ disabled: selectedMember.length === 0 && !userInfo.roles.includes('kezhang') || (!attendanceInfo.checkInTime && attendanceInfo.checkOutTime) }">
58
+          :class="{ disabled: selectedMember.length === 0 && !userInfo.roles.includes('kezhang') || (!attendanceInfo.checkInTime || (attendanceInfo.checkInTime && attendanceInfo.checkOutTime)) }">
58 59
           {{ checkOutStatus ? '下通道' : '上通道' }}
59 60
         </view>
60 61
       </AddAttendancePersonnelModal>
@@ -112,7 +113,7 @@ export default {
112 113
       currentTime: undefined,
113 114
       workingGroupId: '',
114 115
       historyList: [], //班组工作记录 todo 现在只能做科长
115
-   
116
+
116 117
     }
117 118
   },
118 119
   computed: {
@@ -131,6 +132,8 @@ export default {
131 132
       if (!this.checkOutStatus) {
132 133
         return;
133 134
       }
135
+  
136
+      
134 137
       this.currentTime = formatTime(new Date())
135 138
       this.checkOutWork = true
136 139
     },
@@ -198,7 +201,7 @@ export default {
198 201
 
199 202
 
200 203
 
201
-        
204
+
202 205
 
203 206
           this.checkOutStatus = this.isCheckOutJobs(this.curUserWorkingGroupData)
204 207
 

+ 14 - 7
src/pages/attendance/index.vue

@@ -26,7 +26,7 @@
26 26
         @attendanceHandler="handleCheckIn" />
27 27
       <!-- 工作区域/班组成员 -->
28 28
       <MaintainAreaOrMemberModal ref="maintainAreaOrMemberModal" v-if="showMaintain" :userInfo="userInfoAndRoles"
29
-        @update-member="updateMember" :attendanceInfo="attendanceInfo"/>
29
+        @update-member="updateMember" :attendanceInfo="attendanceInfo" />
30 30
       <!-- 新界面工作组状态 -->
31 31
       <WorkingGroup ref="workingGroup" style="margin: 16px 0 24px 0" :attendanceInfo="attendanceInfo"
32 32
         :loadUserInfoOver="loadUserInfoOver" :userInfo="userInfoAndRoles" :selectedMember="selectedMember" />
@@ -42,7 +42,7 @@ import WorkingGroup from './components/WorkingGroup'
42 42
 import { addAttendance, areaList } from "@/api/attendance/attendance"
43 43
 import { getInfo } from "@/api/login"
44 44
 import { formatTime as formatTimehandler } from '@/utils/formatUtils'
45
-import { getAttendanceList } from "@/api/attendance/attendance"
45
+import { getAttendanceList, queryClickAble } from "@/api/attendance/attendance"
46 46
 import { isInRangeOptimized, wgs84ToGcj02 } from '@/utils/handler'
47 47
 
48 48
 export default {
@@ -108,7 +108,7 @@ export default {
108 108
 
109 109
     // app 在前台时获取位置信息
110 110
     uni.onLocationChange((res) => {
111
-      this.result = {latitude:res.latitude, longitude:res.longitude}
111
+      this.result = { latitude: res.latitude, longitude: res.longitude }
112 112
     });
113 113
   },
114 114
   async onLoad() {
@@ -196,7 +196,9 @@ export default {
196 196
         checkInDate: today,
197 197
         userId: this.$store.state.user.id
198 198
       });
199
-
199
+      let res = await queryClickAble()
200
+      let checkAbleType = res.data;
201
+   
200 202
       // new
201 203
       if (Array.isArray(data) && data.length) {
202 204
         const items = data[0]
@@ -206,12 +208,17 @@ export default {
206 208
         const latestCheckOutTime = items.items.filter(item => item.checkInType === 'CLOCK_OUT').sort((a, b) => {
207 209
           return new Date(b.checkInTime) - new Date(a.checkInTime).getTime()
208 210
         })[0] || {}
209
-        
211
+        console.log(firstCheckOnTime,"firstCheckOnTime")
212
+
210 213
         this.attendanceInfo = {
211 214
           ...items,
212
-          checkInTime: formatTimehandler(firstCheckOnTime.checkInTime, 'hh:mm:ss', { defaultResult: '' }),
213
-          checkOutTime: formatTimehandler(latestCheckOutTime.checkInTime, 'hh:mm:ss', { defaultResult: '' })
215
+          ...(checkAbleType == '1'? {checkInTime: '', checkOutTime: ''}: {}),
216
+          ...(checkAbleType == '2'? {checkInTime: formatTimehandler(firstCheckOnTime.checkInTime, 'hh:mm:ss', { defaultResult: '' }), checkOutTime: ''}:{}),
217
+          // checkInTime: checkAbleType == 1 ? '' : formatTimehandler(firstCheckOnTime.checkInTime, 'hh:mm:ss', { defaultResult: '' }),
218
+          // checkOutTime: checkAbleType == 1 ? '' : formatTimehandler(latestCheckOutTime.checkInTime, 'hh:mm:ss', { defaultResult: '' })
214 219
         }
220
+        console.log(this.attendanceInfo,"this.attendanceInfo")
221
+        
215 222
       }
216 223
 
217 224
       // 接口 data 可能是多条(按天),我们取第一条里的 items