Explorar el Código

feat(角色权限): 添加经理角色支持并优化部门选择逻辑

- 在eikonLevel模块中添加isJingLi状态及相关处理逻辑
- 支持BRIGADE部门类型的初始化处理
- 优化workProfile中的部门选择逻辑,支持递归查找
- 修复seizedReportedVoice中的位置信息处理逻辑
huoyi hace 3 meses
padre
commit
1f93f1a4f0

+ 3 - 0
src/pages/eikonStatistics/index.vue

@@ -195,6 +195,9 @@ export default {
195 195
       if (deptType == 'TEAMS') {
196 196
         this.initLevel({ level: 'team', levelId: selectedDepartment.id })
197 197
       }
198
+      if (deptType == 'BRIGADE') {
199
+        this.initLevel({ level: 'brigade', levelId: selectedDepartment.id })
200
+      }
198 201
       if (!deptType) {
199 202
         this.initLevel({ level: 'personal', levelId: selectedDepartment.id })
200 203
       }

+ 38 - 26
src/pages/seizedReportedVoice/index.vue

@@ -460,10 +460,10 @@ export default {
460 460
             createBy: user?.userName || '',
461 461
             seizureTime: data.createTime || '',
462 462
             inspectUserRoleName: user?.roles[0]?.roleName || '',
463
-            checkMethod: data.positionId === 0 ? '' : data.positionId || '',
464
-            checkMethodText: data.positionName == '未知岗位' ? '' : data.positionName,
463
+            checkMethod: data.postDictCode == 0 ? '' : data.postDictCode || '',
464
+            checkMethodText: data.postLabel == '未知岗位' ? '' : data.postLabel,
465 465
             reportTeam: data.teamId || '',
466
-            // securityLocation: data.channelId,
466
+            securityLocation: data.channelId || '',
467 467
             forbiddenName: data.name || '',
468 468
             isActiveConcealment: '0',
469 469
             handlingMethod: 'ABANDON',
@@ -478,8 +478,19 @@ export default {
478 478
             partType: data.checkPointId,
479 479
             partTypeText: data.checkPointName
480 480
           };
481
+          const locationResult = this.getParentLocation(data.channelId, 'id')
482
+          // 安全地处理可能为null的结果
483
+          if (locationResult) {
484
+            this.formData.terminlName = locationResult.grandParent?.text;
485
+            this.formData.terminlCode = locationResult.grandParent?.value;
486
+            this.formData.regionalName = locationResult.parent?.text;
487
+            this.formData.regionalCode = locationResult.parent?.value;
488
+            this.formData.channelName = locationResult.current?.text;
489
+            this.formData.channelCode = locationResult.current?.value;
490
+            this.formData.securityLocation = locationResult.current?.value;
491
+          }
481 492
 
482
-          console.log(this.formData, "parentNode")
493
+  
483 494
 
484 495
 
485 496
         } else {
@@ -907,47 +918,47 @@ export default {
907 918
         const curUserInfo = (res.data || []).find(item => {
908 919
           return item.userId === this.currentUser.id && (!item.checkOutTime || item.checkOutTime === '2000-01-01 00:00:00')
909 920
         }) || {}
910
-        console.log(curUserInfo, "curUserInfo")
911
-        this.formData.securityLocation = curUserInfo.channelCode || curUserInfo.regionalCode
912
-        this.formData.securityLocationText = curUserInfo.channelName || curUserInfo.regionalName
921
+        console.log(curUserInfo, "curUserInfo", this.formData)
922
+        // 修复:只有当打卡数据确实存在时才覆盖securityLocation
923
+        if (curUserInfo.channelCode) {
924
+
925
+          this.formData.securityLocation = curUserInfo.channelCode;
926
+          this.formData.securityLocationText = `${curUserInfo?.terminlName}/${curUserInfo?.regionalName}/${curUserInfo?.channelName}`;
927
+        }
928
+        console.log(this.formData.securityLocation, "this.formData.securityLocation");
913 929
 
914
-        this.formData.team = curUserInfo.attendanceTeamId
915
-        this.formData.reportTeam = curUserInfo.attendanceTeamId
930
+        this.formData.team = curUserInfo.attendanceTeamId;
931
+        //打卡的优先于语音,所以后请求打卡的数据,先请求语音的,但是如果打卡的数据没有,就不清空语音的数据
932
+        this.formData.reportTeam = curUserInfo.attendanceTeamId ?? this.formData.reportTeam;
916 933
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
917 934
           this.formData.teamName = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
918
-          this.formData.reportTeamText = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
935
+          this.formData.reportTeamText = curUserInfo.attendanceTeamName ? `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}` : this.formData.reportTeamText
919 936
         }
920 937
         console.log(this.formData);
921 938
         const locationResult = this.getParentLocation(this.formData.securityLocation)
922 939
         // 安全地处理可能为null的结果
923 940
         if (locationResult) {
924
-          this.formData.terminlName = locationResult.grandParent?.text || '';
925
-          this.formData.terminlCode = locationResult.grandParent?.value || '';
926
-          this.formData.regionalName = locationResult.parent?.text || '';
927
-          this.formData.regionalCode = locationResult.parent?.value || '';
928
-          this.formData.channelName = locationResult.current?.text || '';
929
-          this.formData.channelCode = locationResult.current?.value || '';
930
-        } else {
931
-          // 如果找不到位置信息,清空相关字段
932
-          this.formData.terminlName = '';
933
-          this.formData.terminlCode = '';
934
-          this.formData.regionalName = '';
935
-          this.formData.regionalCode = '';
936
-          this.formData.channelName = '';
937
-          this.formData.channelCode = '';
941
+          this.formData.terminlName = locationResult.grandParent?.text;
942
+          this.formData.terminlCode = locationResult.grandParent?.value;
943
+          this.formData.regionalName = locationResult.parent?.text;
944
+          this.formData.regionalCode = locationResult.parent?.value;
945
+          this.formData.channelName = locationResult.current?.text;
946
+          this.formData.channelCode = locationResult.current?.value;
938 947
         }
939 948
       })
940 949
     },
941 950
     //根据securityLocation,从this.position_options中向上找到前两级别的父级对象和当前级别对象
942
-    getParentLocation(securityLocation) {
951
+    getParentLocation(securityLocation, value) {
952
+
943 953
       if (!securityLocation || !this.position_options || !this.position_options.length) {
944 954
         return null;
945 955
       }
956
+      const getValue = value || 'value';
946 957
 
947 958
       // 递归查找节点及其父级
948 959
       const findNodeAndParents = (nodes, targetValue, parents = []) => {
949 960
         for (const node of nodes) {
950
-          if (node.value === targetValue) {
961
+          if (node[getValue] === targetValue) {
951 962
             return { node, parents };
952 963
           }
953 964
 
@@ -1023,6 +1034,7 @@ export default {
1023 1034
           list.map(node => ({
1024 1035
             text: node.label,
1025 1036
             value: node.code,
1037
+            id: node.id,
1026 1038
             children: node.children ? convertTree(node.children) : null
1027 1039
           }))
1028 1040
 

+ 39 - 12
src/pages/workProfile/index.vue

@@ -10,7 +10,7 @@
10 10
             </div>
11 11
 
12 12
             <!-- 总体概览 -->
13
-            <div class="overview-section" :style="{ marginTop:isSpecialUser || isJingLi? '80rpx':'0rpx' }">
13
+            <div class="overview-section" :style="{ marginTop: isSpecialUser || isJingLi ? '80rpx' : '0rpx' }">
14 14
                 <h2 class="section-title">总体概览</h2>
15 15
                 <div class="overview-cards">
16 16
                     <!-- 组织支撑 -->
@@ -163,9 +163,31 @@ export default {
163 163
 
164 164
     methods: {
165 165
         handleLevelChange(value) {
166
-            let targetObj = this.levelOptions.find(item => item.value == value)
167
-            this.selectedLevelId = targetObj.value
168
-            this.selectedLevelType = targetObj.deptType == 'STATION' ? 'station' : 'department'
166
+            console.log("value===", value, this.levelOptions)
167
+            let targetObj = {}
168
+            // 递归查找函数
169
+            const findInTree = (items, id) => {
170
+                for (let item of items) {
171
+                    if (item.id == id) {
172
+                        return item;
173
+                    }
174
+                    if (item.children && item.children.length > 0) {
175
+                        const found = findInTree(item.children, id);
176
+                        if (found) return found;
177
+                    }
178
+                }
179
+                return null;
180
+            };
181
+
182
+            targetObj = findInTree(this.levelOptions, value);
183
+            if (!targetObj) {
184
+                console.warn('未找到匹配的部门对象,id:', value);
185
+                return;
186
+            }
187
+            console.log("targetObj===", targetObj)
188
+
189
+            this.selectedLevelId = targetObj.id;
190
+            this.selectedLevelType = targetObj.deptType == 'STATION' ? 'station' : targetObj.deptType == 'BRIGADE' ? 'brigade' : 'department'
169 191
             this.loadData()
170 192
         },
171 193
         loadData() {
@@ -191,11 +213,11 @@ export default {
191 213
         },
192 214
         //获取抽问抽答完成率
193 215
         getLevelRateData() {
194
-            let params = {}
216
+            let params = {};
195 217
             let api = this.selectedLevelType == 'station' ? getStationLevelRate : getDepartmentLevelRate
196 218
             if (this.selectedLevelType == 'station') {
197 219
                 params.siteId = this.selectedLevelId
198
-            } else if (this.selectedLevelType == 'department') {
220
+            } else if (this.selectedLevelType == 'department' || this.selectedLevelType == 'brigade') {
199 221
                 params.deptId = this.selectedLevelId
200 222
             }
201 223
             api(params).then(res => {
@@ -203,7 +225,7 @@ export default {
203 225
             })
204 226
         },
205 227
         async getDept() {
206
-            if (this.isSpecialUser) {
228
+            if (this.isSpecialUser || this.isKeZhang) {
207 229
                 getDeptList().then(res => {
208 230
                     const { data } = res
209 231
                     let targetObj = data.find(item => item.id == '100' || item.label == '安检站');
@@ -221,11 +243,11 @@ export default {
221 243
                         this.selectedLevel = arr[0].id
222 244
                         this.handleLevelChange(arr[0].id)
223 245
                     }
224
-                    // if (this.isKeZhang) {
246
+                    if (this.isKeZhang) {
225 247
 
226
-                    //     this.selectedLevel = this.userInfo.departmentId
227
-                    //     this.handleLevelChange(this.userInfo.departmentId)
228
-                    // }
248
+                        this.selectedLevel = this.userInfo.departmentId
249
+                        this.handleLevelChange(this.userInfo.departmentId)
250
+                    }
229 251
 
230 252
                 })
231 253
             }
@@ -280,11 +302,16 @@ export default {
280 302
             let otherparams = {
281 303
                 deptId: this.selectedLevelId || ''
282 304
             }
305
+            console.log("params===", params, this.selectedLevelType)
283 306
             if (this.selectedLevelType == 'station') {
284 307
                 params.checkedSiteId = this.selectedLevelId
285
-            } else if (this.selectedLevelType == 'department') {
308
+            } 
309
+            if (this.selectedLevelType == 'department') {
286 310
                 params.checkedDepartmentId = this.selectedLevelId
287 311
             }
312
+            if (this.selectedLevelType == 'brigade') {
313
+                params.checkedBrigadeId = this.selectedLevelId
314
+            }
288 315
             getPortrait(params).then(res => {
289 316
                 this.portraitData = res.data || {};
290 317
             })

+ 25 - 5
src/store/modules/eikonLevel.js

@@ -36,6 +36,7 @@ const eikonLevel = {
36 36
     isZhanZhang: false,
37 37
     isKeZhang: false,
38 38
     isBanZuZhang: false,
39
+    isJingLi: false,
39 40
     // 新增部门树数据
40 41
     departmentTree: [],
41 42
     // 当前部门的完整路径
@@ -75,11 +76,12 @@ const eikonLevel = {
75 76
       state.growthPortraitData = data
76 77
     },
77 78
     // 新增角色状态mutations
78
-    SET_ROLE_STATES: (state, { isPersonal, isZhanZhang, isKeZhang, isBanZuZhang }) => {
79
+    SET_ROLE_STATES: (state, { isPersonal, isZhanZhang, isKeZhang, isBanZuZhang, isJingLi }) => {
79 80
       state.isPersonal = isPersonal
80 81
       state.isZhanZhang = isZhanZhang
81 82
       state.isKeZhang = isKeZhang
82 83
       state.isBanZuZhang = isBanZuZhang
84
+      state.isJingLi = isJingLi
83 85
     },
84 86
     SET_OVERVIEW_DATA: (state, data) => {
85 87
       state.overviewData = data
@@ -190,6 +192,20 @@ const eikonLevel = {
190 192
           deptId: state.currentLevelId
191 193
         }
192 194
       }
195
+      if (getters.isJingLi) {
196
+        portraitParams = {
197
+          checkedBrigadeId: state.currentLevelId
198
+        }
199
+        detailParams = {
200
+          deptId: state.currentLevelId
201
+        }
202
+        growthParams = {
203
+          brigadeId: state.currentLevelId
204
+        }
205
+        overviewParams = {
206
+          deptId: state.currentLevelId
207
+        }
208
+      }
193 209
 
194 210
       try {
195 211
         //总体概览
@@ -210,7 +226,7 @@ const eikonLevel = {
210 226
         commit('SET_GROWTH_PORTRAIT_DATA', growthPortraitRes.data)
211 227
         //测试
212 228
         let profileRes = {}
213
-        if (getters.isKeZhang) {
229
+        if (getters.isKeZhang || getters.isJingLi) {
214 230
           profileRes = await getDeptProfile(overviewParams)
215 231
         } else if (getters.isZhanZhang) {
216 232
           profileRes = await getSiteProfile(overviewParams)
@@ -242,7 +258,7 @@ const eikonLevel = {
242 258
           commit('SET_STATION_ATTENDANCE_DATA', attendanceStatisticsRes)
243 259
         }
244 260
 
245
-    
261
+
246 262
       } catch (error) {
247 263
         console.error('加载数据失败:', error);
248 264
         throw error
@@ -270,6 +286,7 @@ const eikonLevel = {
270 286
         isBanZuZhang: level === 'team',
271 287
         isKeZhang: level === 'department',
272 288
         isZhanZhang: level === 'station' || level === 'zhijianke',
289
+        isJingLi: level === 'brigade'
273 290
       }
274 291
       commit('SET_ROLE_STATES', roleStates)
275 292
 
@@ -292,6 +309,7 @@ const eikonLevel = {
292 309
         isBanZuZhang: level === 'team',
293 310
         isKeZhang: level === 'department',
294 311
         isZhanZhang: level === 'station' || level === 'zhijianke',
312
+        isJingLi: level === 'brigade'
295 313
       }
296 314
       commit('SET_ROLE_STATES', roleStates)
297 315
 
@@ -307,7 +325,8 @@ const eikonLevel = {
307 325
         isPersonal: false,
308 326
         isZhanZhang: false,
309 327
         isKeZhang: false,
310
-        isBanZuZhang: false
328
+        isBanZuZhang: false,
329
+        isJingLi: false
311 330
       })
312 331
     },
313 332
     // 更新角色状态
@@ -464,7 +483,8 @@ const eikonLevel = {
464 483
     isPersonal: state => state.isPersonal,
465 484
     isZhanZhang: state => state.isZhanZhang,
466 485
     isKeZhang: state => state.isKeZhang,
467
-    isBanZuZhang: state => state.isBanZuZhang
486
+    isBanZuZhang: state => state.isBanZuZhang,
487
+    isJingLi: state => state.isJingLi
468 488
   }
469 489
 }
470 490