ソースを参照

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

- 在eikonLevel模块中添加isJingLi状态及相关处理逻辑
- 支持BRIGADE部门类型的初始化处理
- 优化workProfile中的部门选择逻辑,支持递归查找
- 修复seizedReportedVoice中的位置信息处理逻辑
huoyi 3 ヶ月 前
コミット
1f93f1a4f0
共有4 個のファイルを変更した105 個の追加43 個の削除を含む
  1. 3 0
      src/pages/eikonStatistics/index.vue
  2. 38 26
      src/pages/seizedReportedVoice/index.vue
  3. 39 12
      src/pages/workProfile/index.vue
  4. 25 5
      src/store/modules/eikonLevel.js

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

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

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

@@ -460,10 +460,10 @@ export default {
460
             createBy: user?.userName || '',
460
             createBy: user?.userName || '',
461
             seizureTime: data.createTime || '',
461
             seizureTime: data.createTime || '',
462
             inspectUserRoleName: user?.roles[0]?.roleName || '',
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
             reportTeam: data.teamId || '',
465
             reportTeam: data.teamId || '',
466
-            // securityLocation: data.channelId,
466
+            securityLocation: data.channelId || '',
467
             forbiddenName: data.name || '',
467
             forbiddenName: data.name || '',
468
             isActiveConcealment: '0',
468
             isActiveConcealment: '0',
469
             handlingMethod: 'ABANDON',
469
             handlingMethod: 'ABANDON',
@@ -478,8 +478,19 @@ export default {
478
             partType: data.checkPointId,
478
             partType: data.checkPointId,
479
             partTypeText: data.checkPointName
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
         } else {
496
         } else {
@@ -907,47 +918,47 @@ export default {
907
         const curUserInfo = (res.data || []).find(item => {
918
         const curUserInfo = (res.data || []).find(item => {
908
           return item.userId === this.currentUser.id && (!item.checkOutTime || item.checkOutTime === '2000-01-01 00:00:00')
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
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
933
         if (curUserInfo.attendanceStationName && curUserInfo.attendanceDepartmentName) {
917
           this.formData.teamName = `${curUserInfo.attendanceStationName} / ${curUserInfo.attendanceDepartmentName} / ${curUserInfo.attendanceTeamName}`
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
         console.log(this.formData);
937
         console.log(this.formData);
921
         const locationResult = this.getParentLocation(this.formData.securityLocation)
938
         const locationResult = this.getParentLocation(this.formData.securityLocation)
922
         // 安全地处理可能为null的结果
939
         // 安全地处理可能为null的结果
923
         if (locationResult) {
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
     //根据securityLocation,从this.position_options中向上找到前两级别的父级对象和当前级别对象
950
     //根据securityLocation,从this.position_options中向上找到前两级别的父级对象和当前级别对象
942
-    getParentLocation(securityLocation) {
951
+    getParentLocation(securityLocation, value) {
952
+
943
       if (!securityLocation || !this.position_options || !this.position_options.length) {
953
       if (!securityLocation || !this.position_options || !this.position_options.length) {
944
         return null;
954
         return null;
945
       }
955
       }
956
+      const getValue = value || 'value';
946
 
957
 
947
       // 递归查找节点及其父级
958
       // 递归查找节点及其父级
948
       const findNodeAndParents = (nodes, targetValue, parents = []) => {
959
       const findNodeAndParents = (nodes, targetValue, parents = []) => {
949
         for (const node of nodes) {
960
         for (const node of nodes) {
950
-          if (node.value === targetValue) {
961
+          if (node[getValue] === targetValue) {
951
             return { node, parents };
962
             return { node, parents };
952
           }
963
           }
953
 
964
 
@@ -1023,6 +1034,7 @@ export default {
1023
           list.map(node => ({
1034
           list.map(node => ({
1024
             text: node.label,
1035
             text: node.label,
1025
             value: node.code,
1036
             value: node.code,
1037
+            id: node.id,
1026
             children: node.children ? convertTree(node.children) : null
1038
             children: node.children ? convertTree(node.children) : null
1027
           }))
1039
           }))
1028
 
1040
 

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

@@ -10,7 +10,7 @@
10
             </div>
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
                 <h2 class="section-title">总体概览</h2>
14
                 <h2 class="section-title">总体概览</h2>
15
                 <div class="overview-cards">
15
                 <div class="overview-cards">
16
                     <!-- 组织支撑 -->
16
                     <!-- 组织支撑 -->
@@ -163,9 +163,31 @@ export default {
163
 
163
 
164
     methods: {
164
     methods: {
165
         handleLevelChange(value) {
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
             this.loadData()
191
             this.loadData()
170
         },
192
         },
171
         loadData() {
193
         loadData() {
@@ -191,11 +213,11 @@ export default {
191
         },
213
         },
192
         //获取抽问抽答完成率
214
         //获取抽问抽答完成率
193
         getLevelRateData() {
215
         getLevelRateData() {
194
-            let params = {}
216
+            let params = {};
195
             let api = this.selectedLevelType == 'station' ? getStationLevelRate : getDepartmentLevelRate
217
             let api = this.selectedLevelType == 'station' ? getStationLevelRate : getDepartmentLevelRate
196
             if (this.selectedLevelType == 'station') {
218
             if (this.selectedLevelType == 'station') {
197
                 params.siteId = this.selectedLevelId
219
                 params.siteId = this.selectedLevelId
198
-            } else if (this.selectedLevelType == 'department') {
220
+            } else if (this.selectedLevelType == 'department' || this.selectedLevelType == 'brigade') {
199
                 params.deptId = this.selectedLevelId
221
                 params.deptId = this.selectedLevelId
200
             }
222
             }
201
             api(params).then(res => {
223
             api(params).then(res => {
@@ -203,7 +225,7 @@ export default {
203
             })
225
             })
204
         },
226
         },
205
         async getDept() {
227
         async getDept() {
206
-            if (this.isSpecialUser) {
228
+            if (this.isSpecialUser || this.isKeZhang) {
207
                 getDeptList().then(res => {
229
                 getDeptList().then(res => {
208
                     const { data } = res
230
                     const { data } = res
209
                     let targetObj = data.find(item => item.id == '100' || item.label == '安检站');
231
                     let targetObj = data.find(item => item.id == '100' || item.label == '安检站');
@@ -221,11 +243,11 @@ export default {
221
                         this.selectedLevel = arr[0].id
243
                         this.selectedLevel = arr[0].id
222
                         this.handleLevelChange(arr[0].id)
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
             let otherparams = {
302
             let otherparams = {
281
                 deptId: this.selectedLevelId || ''
303
                 deptId: this.selectedLevelId || ''
282
             }
304
             }
305
+            console.log("params===", params, this.selectedLevelType)
283
             if (this.selectedLevelType == 'station') {
306
             if (this.selectedLevelType == 'station') {
284
                 params.checkedSiteId = this.selectedLevelId
307
                 params.checkedSiteId = this.selectedLevelId
285
-            } else if (this.selectedLevelType == 'department') {
308
+            } 
309
+            if (this.selectedLevelType == 'department') {
286
                 params.checkedDepartmentId = this.selectedLevelId
310
                 params.checkedDepartmentId = this.selectedLevelId
287
             }
311
             }
312
+            if (this.selectedLevelType == 'brigade') {
313
+                params.checkedBrigadeId = this.selectedLevelId
314
+            }
288
             getPortrait(params).then(res => {
315
             getPortrait(params).then(res => {
289
                 this.portraitData = res.data || {};
316
                 this.portraitData = res.data || {};
290
             })
317
             })

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

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