Sfoglia il codice sorgente

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

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

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

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

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

@@ -1,7 +1,7 @@
1
 <template>
1
 <template>
2
   <view>
2
   <view>
3
     <view class="attendance-control">
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
         <text class="control-btn-text">上班打卡</text>
5
         <text class="control-btn-text">上班打卡</text>
6
       </view>
6
       </view>
7
       <view class="attendance-info">
7
       <view class="attendance-info">
@@ -24,7 +24,7 @@
24
           </view>
24
           </view>
25
         </view>
25
         </view>
26
       </view>
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
         <text class="control-btn-text">下班打卡</text>
28
         <text class="control-btn-text">下班打卡</text>
29
       </view>
29
       </view>
30
     </view>
30
     </view>

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

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

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

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

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

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