|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+import {
|
|
|
2
|
+ getPortrait,
|
|
|
3
|
+ getModuleMetrics,
|
|
|
4
|
+ getGrowthPortrait,
|
|
|
5
|
+ getOverview,
|
|
|
6
|
+ getUserProfile,
|
|
|
7
|
+ getCollaborationProfile,
|
|
|
8
|
+ getDetailProfile,
|
|
|
9
|
+ getSiteStatistics,
|
|
|
10
|
+ getAttendanceStatistics,
|
|
|
11
|
+ getDeptProfile,
|
|
|
12
|
+ getSiteProfile
|
|
|
13
|
+} from '@/api/eikonStatistics/eikonStatistics';
|
|
|
14
|
+import { getUserInfoById, getDeptUserTree } from '@/api/system/user';
|
|
|
15
|
+const eikonLevel = {
|
|
|
16
|
+ namespaced: true,
|
|
|
17
|
+ state: () => ({
|
|
|
18
|
+ currentLevel: '',
|
|
|
19
|
+ currentLevelId: '',
|
|
|
20
|
+ oldLevel: '',
|
|
|
21
|
+ oldLevelId: '',
|
|
|
22
|
+ allData: {},
|
|
|
23
|
+ systemData: {},
|
|
|
24
|
+ attendanceData: {},
|
|
|
25
|
+ itemData: {},
|
|
|
26
|
+ portraitData: {},
|
|
|
27
|
+ growthPortraitData: {},
|
|
|
28
|
+ overviewData: {},
|
|
|
29
|
+ profileData: {},
|
|
|
30
|
+ collaborationData: {},
|
|
|
31
|
+ detailData: {},
|
|
|
32
|
+ stationSiteData: [],
|
|
|
33
|
+ stationAttendanceData: [],
|
|
|
34
|
+ // 新增角色状态
|
|
|
35
|
+ isPersonal: false,
|
|
|
36
|
+ isZhanZhang: false,
|
|
|
37
|
+ isKeZhang: false,
|
|
|
38
|
+ isBanZuZhang: false,
|
|
|
39
|
+ // 新增部门树数据
|
|
|
40
|
+ departmentTree: [],
|
|
|
41
|
+ // 当前部门的完整路径
|
|
|
42
|
+ currentDepartmentPath: '',
|
|
|
43
|
+ // 当前levelId在组织中管理的人数
|
|
|
44
|
+ currentLevelUserCount: 0
|
|
|
45
|
+ }),
|
|
|
46
|
+ mutations: {
|
|
|
47
|
+ SET_CURRENT_LEVEL: (state, level) => {
|
|
|
48
|
+ state.currentLevel = level
|
|
|
49
|
+ },
|
|
|
50
|
+ SET_CURRENT_LEVEL_ID: (state, levelId) => {
|
|
|
51
|
+ state.currentLevelId = levelId
|
|
|
52
|
+ },
|
|
|
53
|
+ SET_OLD_LEVEL: (state, level) => {
|
|
|
54
|
+ state.oldLevel = level
|
|
|
55
|
+ },
|
|
|
56
|
+ SET_OLD_LEVEL_ID: (state, levelId) => {
|
|
|
57
|
+ state.oldLevelId = levelId
|
|
|
58
|
+ },
|
|
|
59
|
+ SET_ALL_DATA: (state, data) => {
|
|
|
60
|
+ state.allData = data
|
|
|
61
|
+ },
|
|
|
62
|
+ SET_SYSTEM_DATA: (state, data) => {
|
|
|
63
|
+ state.systemData = data
|
|
|
64
|
+ },
|
|
|
65
|
+ SET_ATTENDANCE_DATA: (state, data) => {
|
|
|
66
|
+ state.attendanceData = data
|
|
|
67
|
+ },
|
|
|
68
|
+ SET_ITEM_DATA: (state, data) => {
|
|
|
69
|
+ state.itemData = data
|
|
|
70
|
+ },
|
|
|
71
|
+ SET_PORTRAIT_DATA: (state, data) => {
|
|
|
72
|
+ state.portraitData = data
|
|
|
73
|
+ },
|
|
|
74
|
+ SET_GROWTH_PORTRAIT_DATA: (state, data) => {
|
|
|
75
|
+ state.growthPortraitData = data
|
|
|
76
|
+ },
|
|
|
77
|
+ // 新增角色状态mutations
|
|
|
78
|
+ SET_ROLE_STATES: (state, { isPersonal, isZhanZhang, isKeZhang, isBanZuZhang }) => {
|
|
|
79
|
+ state.isPersonal = isPersonal
|
|
|
80
|
+ state.isZhanZhang = isZhanZhang
|
|
|
81
|
+ state.isKeZhang = isKeZhang
|
|
|
82
|
+ state.isBanZuZhang = isBanZuZhang
|
|
|
83
|
+ },
|
|
|
84
|
+ SET_OVERVIEW_DATA: (state, data) => {
|
|
|
85
|
+ state.overviewData = data
|
|
|
86
|
+ },
|
|
|
87
|
+ SET_PROFILE_DATA: (state, data) => {
|
|
|
88
|
+ state.profileData = data
|
|
|
89
|
+ },
|
|
|
90
|
+ SET_COLLABORATION_DATA: (state, data) => {
|
|
|
91
|
+ state.collaborationData = data
|
|
|
92
|
+ },
|
|
|
93
|
+ SET_DETAIL_DATA: (state, data) => {
|
|
|
94
|
+ state.detailData = data
|
|
|
95
|
+ },
|
|
|
96
|
+ // 新增部门树相关mutations
|
|
|
97
|
+ SET_DEPARTMENT_TREE: (state, treeData) => {
|
|
|
98
|
+ state.departmentTree = treeData
|
|
|
99
|
+ },
|
|
|
100
|
+ SET_CURRENT_DEPARTMENT_PATH: (state, path) => {
|
|
|
101
|
+ state.currentDepartmentPath = path
|
|
|
102
|
+ },
|
|
|
103
|
+ SET_CURRENT_LEVEL_USER_COUNT: (state, count) => {
|
|
|
104
|
+ state.currentLevelUserCount = count
|
|
|
105
|
+ },
|
|
|
106
|
+ // 新增站点统计相关mutations
|
|
|
107
|
+ SET_STATION_SITE_DATA: (state, data) => {
|
|
|
108
|
+ state.stationSiteData = data
|
|
|
109
|
+ },
|
|
|
110
|
+ SET_STATION_ATTENDANCE_DATA: (state, data) => {
|
|
|
111
|
+ state.stationAttendanceData = data
|
|
|
112
|
+ }
|
|
|
113
|
+ },
|
|
|
114
|
+ actions: {
|
|
|
115
|
+ // 加载数据
|
|
|
116
|
+ async loadData({ commit, state, rootState, dispatch, getters }) {
|
|
|
117
|
+ // 清空所有数据变量
|
|
|
118
|
+ commit('SET_ALL_DATA', null)
|
|
|
119
|
+ commit('SET_SYSTEM_DATA', null)
|
|
|
120
|
+ commit('SET_ATTENDANCE_DATA', null)
|
|
|
121
|
+ commit('SET_ITEM_DATA', null)
|
|
|
122
|
+ commit('SET_PORTRAIT_DATA', null)
|
|
|
123
|
+ commit('SET_GROWTH_PORTRAIT_DATA', null)
|
|
|
124
|
+ commit('SET_OVERVIEW_DATA', null)
|
|
|
125
|
+ commit('SET_PROFILE_DATA', null)
|
|
|
126
|
+ commit('SET_COLLABORATION_DATA', null)
|
|
|
127
|
+ commit('SET_DETAIL_DATA', null)
|
|
|
128
|
+ commit('SET_STATION_SITE_DATA', null)
|
|
|
129
|
+ commit('SET_STATION_ATTENDANCE_DATA', null)
|
|
|
130
|
+
|
|
|
131
|
+ // let params = {
|
|
|
132
|
+ // userId: rootState.user.id || '',
|
|
|
133
|
+ // userTypeStr: state.currentLevel
|
|
|
134
|
+ // }
|
|
|
135
|
+ let portraitParams = {};
|
|
|
136
|
+ let overviewParams = {};
|
|
|
137
|
+ let detailParams = {};
|
|
|
138
|
+ let growthParams = {};
|
|
|
139
|
+
|
|
|
140
|
+ if (getters.isPersonal) {
|
|
|
141
|
+ portraitParams = {
|
|
|
142
|
+ checkedUserId: state.currentLevelId
|
|
|
143
|
+ }
|
|
|
144
|
+ overviewParams = {
|
|
|
145
|
+ userId: state.currentLevelId
|
|
|
146
|
+ }
|
|
|
147
|
+ detailParams = {
|
|
|
148
|
+ userId: state.currentLevelId
|
|
|
149
|
+ }
|
|
|
150
|
+ growthParams = {
|
|
|
151
|
+ userId: state.currentLevelId
|
|
|
152
|
+ }
|
|
|
153
|
+ }
|
|
|
154
|
+ if (getters.isBanZuZhang) {
|
|
|
155
|
+ portraitParams = {
|
|
|
156
|
+ checkedTeamId: state.currentLevelId
|
|
|
157
|
+ }
|
|
|
158
|
+ overviewParams = {
|
|
|
159
|
+ deptId: state.currentLevelId
|
|
|
160
|
+ }
|
|
|
161
|
+ detailParams = {
|
|
|
162
|
+ deptId: state.currentLevelId
|
|
|
163
|
+ }
|
|
|
164
|
+ growthParams = {
|
|
|
165
|
+ teamId: state.currentLevelId
|
|
|
166
|
+ }
|
|
|
167
|
+ }
|
|
|
168
|
+ if (getters.isKeZhang) {
|
|
|
169
|
+ portraitParams = {
|
|
|
170
|
+ checkedDepartmentId: state.currentLevelId
|
|
|
171
|
+ }
|
|
|
172
|
+ overviewParams = {
|
|
|
173
|
+ deptId: state.currentLevelId
|
|
|
174
|
+ }
|
|
|
175
|
+ detailParams = {
|
|
|
176
|
+ deptId: state.currentLevelId
|
|
|
177
|
+ }
|
|
|
178
|
+ growthParams = {
|
|
|
179
|
+ departmentId: state.currentLevelId
|
|
|
180
|
+ }
|
|
|
181
|
+ }
|
|
|
182
|
+ if (getters.isZhanZhang) {
|
|
|
183
|
+ portraitParams = {
|
|
|
184
|
+ checkedSiteId: state.currentLevelId
|
|
|
185
|
+ }
|
|
|
186
|
+ overviewParams = {
|
|
|
187
|
+ siteId: state.currentLevelId
|
|
|
188
|
+ }
|
|
|
189
|
+ detailParams = {
|
|
|
190
|
+ deptId: state.currentLevelId
|
|
|
191
|
+ }
|
|
|
192
|
+ }
|
|
|
193
|
+
|
|
|
194
|
+ try {
|
|
|
195
|
+ //总体概览
|
|
|
196
|
+ const overviewRes = await getOverview(detailParams)
|
|
|
197
|
+ //资质能力
|
|
|
198
|
+ const res = await getModuleMetrics({ ...detailParams, userTypeStr: state.currentLevel })
|
|
|
199
|
+ //巡检
|
|
|
200
|
+ const portraitRes = await getPortrait(portraitParams)
|
|
|
201
|
+ //学习成长
|
|
|
202
|
+ const growthPortraitRes = await getGrowthPortrait(growthParams)
|
|
|
203
|
+ //测试
|
|
|
204
|
+ let profileRes = {}
|
|
|
205
|
+ if (getters.isKeZhang) {
|
|
|
206
|
+ profileRes = await getDeptProfile(overviewParams)
|
|
|
207
|
+ } else if (getters.isZhanZhang) {
|
|
|
208
|
+ profileRes = await getSiteProfile(overviewParams)
|
|
|
209
|
+ } else {
|
|
|
210
|
+ profileRes = await getUserProfile(overviewParams)
|
|
|
211
|
+ }
|
|
|
212
|
+
|
|
|
213
|
+ //协同配合
|
|
|
214
|
+ let collaborationRes = {}
|
|
|
215
|
+ if (getters.isPersonal) {
|
|
|
216
|
+ collaborationRes = await getUserInfoById(state.currentLevelId)
|
|
|
217
|
+ } else {
|
|
|
218
|
+ collaborationRes = await getCollaborationProfile({ deptId: state.currentLevelId })
|
|
|
219
|
+ }
|
|
|
220
|
+ //能力画像-明细
|
|
|
221
|
+
|
|
|
222
|
+ if (!getters.isPersonal) {
|
|
|
223
|
+ const detailRes = await getDetailProfile(detailParams)
|
|
|
224
|
+ commit('SET_DETAIL_DATA', detailRes.data)
|
|
|
225
|
+ }
|
|
|
226
|
+
|
|
|
227
|
+ // 只有当state.currentLevel为station的时候请求这俩接口
|
|
|
228
|
+ if (getters.isZhanZhang) {
|
|
|
229
|
+ const siteStatisticsRes = await getSiteStatistics({ deptId: state.currentLevelId })
|
|
|
230
|
+ const attendanceStatisticsRes = await getAttendanceStatistics({ deptId: state.currentLevelId })
|
|
|
231
|
+ console.log(siteStatisticsRes, attendanceStatisticsRes)
|
|
|
232
|
+
|
|
|
233
|
+ commit('SET_STATION_SITE_DATA', siteStatisticsRes.data)
|
|
|
234
|
+ commit('SET_STATION_ATTENDANCE_DATA', attendanceStatisticsRes)
|
|
|
235
|
+ }
|
|
|
236
|
+
|
|
|
237
|
+ commit('SET_COLLABORATION_DATA', collaborationRes.data)
|
|
|
238
|
+
|
|
|
239
|
+
|
|
|
240
|
+ commit('SET_OVERVIEW_DATA', overviewRes.data)
|
|
|
241
|
+ commit('SET_PROFILE_DATA', profileRes.data)
|
|
|
242
|
+ commit('SET_PORTRAIT_DATA', portraitRes.data)
|
|
|
243
|
+ commit('SET_GROWTH_PORTRAIT_DATA', growthPortraitRes.data)
|
|
|
244
|
+ let result = res.data && res.data.moduleResults;
|
|
|
245
|
+ commit('SET_ALL_DATA', result)
|
|
|
246
|
+ commit('SET_SYSTEM_DATA', result && result.system || {})
|
|
|
247
|
+ commit('SET_ATTENDANCE_DATA', result && result.attendance || {})
|
|
|
248
|
+ commit('SET_ITEM_DATA', result && result.item || {})
|
|
|
249
|
+
|
|
|
250
|
+ return result
|
|
|
251
|
+ } catch (error) {
|
|
|
252
|
+ console.error('加载数据失败:', error);
|
|
|
253
|
+ throw error
|
|
|
254
|
+ }
|
|
|
255
|
+ },
|
|
|
256
|
+ // 保存所有数据
|
|
|
257
|
+ saveAllData({ commit }, data = {}) {
|
|
|
258
|
+ commit('SET_ALL_DATA', data)
|
|
|
259
|
+ commit('SET_SYSTEM_DATA', data.system || {})
|
|
|
260
|
+ commit('SET_ATTENDANCE_DATA', data.attendance || {})
|
|
|
261
|
+ commit('SET_ITEM_DATA', data.item || {})
|
|
|
262
|
+ },
|
|
|
263
|
+ // 切换级别
|
|
|
264
|
+ async initLevel({ commit, dispatch }, { level = '', levelId = '' } = {}) {
|
|
|
265
|
+ // 清空旧的级别信息
|
|
|
266
|
+ commit('SET_OLD_LEVEL', '')
|
|
|
267
|
+ commit('SET_OLD_LEVEL_ID', '')
|
|
|
268
|
+
|
|
|
269
|
+ commit('SET_CURRENT_LEVEL', level)
|
|
|
270
|
+ commit('SET_CURRENT_LEVEL_ID', levelId)
|
|
|
271
|
+
|
|
|
272
|
+ // 根据当前级别更新角色状态
|
|
|
273
|
+ const roleStates = {
|
|
|
274
|
+ isPersonal: level === 'personal',
|
|
|
275
|
+ isBanZuZhang: level === 'team',
|
|
|
276
|
+ isKeZhang: level === 'department',
|
|
|
277
|
+ isZhanZhang: level === 'station' || level === 'zhijianke',
|
|
|
278
|
+ }
|
|
|
279
|
+ commit('SET_ROLE_STATES', roleStates)
|
|
|
280
|
+
|
|
|
281
|
+ // 确保部门树数据已加载,然后更新当前部门路径
|
|
|
282
|
+ await dispatch('loadDepartmentTree')
|
|
|
283
|
+ dispatch('updateCurrentDepartmentPath', { level, levelId })
|
|
|
284
|
+ },
|
|
|
285
|
+ // 切换级别
|
|
|
286
|
+ async changeLevel({ commit, state, dispatch }, { level = '', levelId = '' } = {}) {
|
|
|
287
|
+ // 保存旧的级别信息
|
|
|
288
|
+ commit('SET_OLD_LEVEL', state.currentLevel)
|
|
|
289
|
+ commit('SET_OLD_LEVEL_ID', state.currentLevelId)
|
|
|
290
|
+
|
|
|
291
|
+ commit('SET_CURRENT_LEVEL', level)
|
|
|
292
|
+ commit('SET_CURRENT_LEVEL_ID', levelId)
|
|
|
293
|
+
|
|
|
294
|
+ // 根据当前级别更新角色状态
|
|
|
295
|
+ const roleStates = {
|
|
|
296
|
+ isPersonal: level === 'personal',
|
|
|
297
|
+ isBanZuZhang: level === 'team',
|
|
|
298
|
+ isKeZhang: level === 'department',
|
|
|
299
|
+ isZhanZhang: level === 'station' || level === 'zhijianke',
|
|
|
300
|
+ }
|
|
|
301
|
+ commit('SET_ROLE_STATES', roleStates)
|
|
|
302
|
+
|
|
|
303
|
+ // 确保部门树数据已加载,然后更新当前部门路径
|
|
|
304
|
+ await dispatch('loadDepartmentTree')
|
|
|
305
|
+ dispatch('updateCurrentDepartmentPath', { level, levelId })
|
|
|
306
|
+ },
|
|
|
307
|
+ // 重置级别状态
|
|
|
308
|
+ resetLevel({ commit }) {
|
|
|
309
|
+ commit('SET_CURRENT_LEVEL', '')
|
|
|
310
|
+ commit('SET_CURRENT_LEVEL_ID', '')
|
|
|
311
|
+ commit('SET_ROLE_STATES', {
|
|
|
312
|
+ isPersonal: false,
|
|
|
313
|
+ isZhanZhang: false,
|
|
|
314
|
+ isKeZhang: false,
|
|
|
315
|
+ isBanZuZhang: false
|
|
|
316
|
+ })
|
|
|
317
|
+ },
|
|
|
318
|
+ // 更新角色状态
|
|
|
319
|
+ updateRoleStates({ commit }, roleStates) {
|
|
|
320
|
+ commit('SET_ROLE_STATES', roleStates)
|
|
|
321
|
+ },
|
|
|
322
|
+ // 获取部门树数据
|
|
|
323
|
+ async loadDepartmentTree({ commit, rootState }) {
|
|
|
324
|
+ try {
|
|
|
325
|
+ const res = await getDeptUserTree({})
|
|
|
326
|
+ commit('SET_DEPARTMENT_TREE', res.data)
|
|
|
327
|
+ return res.data
|
|
|
328
|
+ } catch (error) {
|
|
|
329
|
+ console.error('获取部门树数据失败:', error)
|
|
|
330
|
+ throw error
|
|
|
331
|
+ }
|
|
|
332
|
+ },
|
|
|
333
|
+ // 根据ID获取部门完整路径
|
|
|
334
|
+ getDepartmentPathById({ state }, nodeId) {
|
|
|
335
|
+
|
|
|
336
|
+ if (!nodeId || !state.departmentTree.length) {
|
|
|
337
|
+ return []
|
|
|
338
|
+ }
|
|
|
339
|
+
|
|
|
340
|
+ const findNodePath = (treeNodes, targetId, path = []) => {
|
|
|
341
|
+ for (const treeNode of treeNodes) {
|
|
|
342
|
+ // 如果找到目标节点,返回包含本级 label 的路径
|
|
|
343
|
+ if (treeNode.id === targetId) {
|
|
|
344
|
+ return [...path, treeNode.label]
|
|
|
345
|
+ }
|
|
|
346
|
+
|
|
|
347
|
+ // 如果有子节点,递归查找
|
|
|
348
|
+ if (treeNode.children && treeNode.children.length > 0) {
|
|
|
349
|
+ const newPath = [...path, treeNode.label]
|
|
|
350
|
+ const result = findNodePath(treeNode.children, targetId, newPath)
|
|
|
351
|
+ if (result) {
|
|
|
352
|
+ return result
|
|
|
353
|
+ }
|
|
|
354
|
+ }
|
|
|
355
|
+ }
|
|
|
356
|
+ return null
|
|
|
357
|
+ }
|
|
|
358
|
+
|
|
|
359
|
+ const fullPath = findNodePath(state.departmentTree, nodeId)
|
|
|
360
|
+ return fullPath || []
|
|
|
361
|
+ },
|
|
|
362
|
+ // 根据ID获取本级别的label
|
|
|
363
|
+ getDepartmentLabelById({ state }, nodeId) {
|
|
|
364
|
+ if (!nodeId || !state.departmentTree.length) {
|
|
|
365
|
+ return ''
|
|
|
366
|
+ }
|
|
|
367
|
+
|
|
|
368
|
+ const findNode = (treeNodes, targetId) => {
|
|
|
369
|
+ for (const treeNode of treeNodes) {
|
|
|
370
|
+ // 如果找到目标节点,返回本级的label
|
|
|
371
|
+ if (treeNode.id === targetId) {
|
|
|
372
|
+ return treeNode.label
|
|
|
373
|
+ }
|
|
|
374
|
+
|
|
|
375
|
+ // 如果有子节点,递归查找
|
|
|
376
|
+ if (treeNode.children && treeNode.children.length > 0) {
|
|
|
377
|
+ const result = findNode(treeNode.children, targetId)
|
|
|
378
|
+ if (result) {
|
|
|
379
|
+ return result
|
|
|
380
|
+ }
|
|
|
381
|
+ }
|
|
|
382
|
+ }
|
|
|
383
|
+ return null
|
|
|
384
|
+ }
|
|
|
385
|
+
|
|
|
386
|
+ const label = findNode(state.departmentTree, nodeId)
|
|
|
387
|
+ return label || ''
|
|
|
388
|
+ },
|
|
|
389
|
+ // 获取指定节点所有子级中nodeType为"user"的节点个数
|
|
|
390
|
+ getUserCountByLevelId({ state }, levelId) {
|
|
|
391
|
+ if (!levelId || !state.departmentTree || !state.departmentTree.length) {
|
|
|
392
|
+ return 0
|
|
|
393
|
+ }
|
|
|
394
|
+
|
|
|
395
|
+ // 查找目标节点
|
|
|
396
|
+ const findTargetNode = (treeNodes, targetId) => {
|
|
|
397
|
+ for (const treeNode of treeNodes) {
|
|
|
398
|
+ if (treeNode.id === targetId) {
|
|
|
399
|
+ return treeNode
|
|
|
400
|
+ }
|
|
|
401
|
+ if (treeNode.children && treeNode.children.length > 0) {
|
|
|
402
|
+ const result = findTargetNode(treeNode.children, targetId)
|
|
|
403
|
+ if (result) {
|
|
|
404
|
+ return result
|
|
|
405
|
+ }
|
|
|
406
|
+ }
|
|
|
407
|
+ }
|
|
|
408
|
+ return null
|
|
|
409
|
+ }
|
|
|
410
|
+
|
|
|
411
|
+ // 递归统计所有子级中nodeType为"user"的节点个数
|
|
|
412
|
+ const countUserNodes = (node) => {
|
|
|
413
|
+ let count = 0
|
|
|
414
|
+
|
|
|
415
|
+ // 如果当前节点是用户节点,计数加1
|
|
|
416
|
+ if (node.nodeType === 'user') {
|
|
|
417
|
+ count++
|
|
|
418
|
+ }
|
|
|
419
|
+
|
|
|
420
|
+ // 递归统计所有子节点
|
|
|
421
|
+ if (node.children && node.children.length > 0) {
|
|
|
422
|
+ for (const child of node.children) {
|
|
|
423
|
+ count += countUserNodes(child)
|
|
|
424
|
+ }
|
|
|
425
|
+ }
|
|
|
426
|
+
|
|
|
427
|
+ return count
|
|
|
428
|
+ }
|
|
|
429
|
+
|
|
|
430
|
+ const targetNode = findTargetNode(state.departmentTree, levelId)
|
|
|
431
|
+ if (!targetNode) {
|
|
|
432
|
+ return 0
|
|
|
433
|
+ }
|
|
|
434
|
+
|
|
|
435
|
+ // 统计目标节点所有子级中的用户节点个数
|
|
|
436
|
+ return countUserNodes(targetNode)
|
|
|
437
|
+ },
|
|
|
438
|
+ // 更新当前部门路径
|
|
|
439
|
+ async updateCurrentDepartmentPath({ commit, dispatch, state, rootState }, { level, levelId }) {
|
|
|
440
|
+
|
|
|
441
|
+ // 根据级别获取对应的部门路径
|
|
|
442
|
+ const path = await dispatch('getDepartmentPathById', levelId)
|
|
|
443
|
+
|
|
|
444
|
+ if (level === 'personal') {
|
|
|
445
|
+ // 个人模式:去掉数组里的最后一个元素
|
|
|
446
|
+ const personalPath = path.slice(0, -1)
|
|
|
447
|
+ const pathString = personalPath.join(' / ')
|
|
|
448
|
+ commit('SET_CURRENT_DEPARTMENT_PATH', pathString)
|
|
|
449
|
+ // 个人模式下管理人数为1(自己)
|
|
|
450
|
+ commit('SET_CURRENT_LEVEL_USER_COUNT', 1)
|
|
|
451
|
+ } else {
|
|
|
452
|
+ // 其他模式:使用完整路径
|
|
|
453
|
+ const pathString = path.join(' / ')
|
|
|
454
|
+ commit('SET_CURRENT_DEPARTMENT_PATH', pathString)
|
|
|
455
|
+ // 获取当前levelId在组织中管理的人数
|
|
|
456
|
+ const userCount = await dispatch('getUserCountByLevelId', levelId)
|
|
|
457
|
+ commit('SET_CURRENT_LEVEL_USER_COUNT', userCount)
|
|
|
458
|
+ }
|
|
|
459
|
+ }
|
|
|
460
|
+ },
|
|
|
461
|
+
|
|
|
462
|
+ getters: {
|
|
|
463
|
+ currentLevel: state => state.currentLevel,
|
|
|
464
|
+ currentLevelId: state => state.currentLevelId,
|
|
|
465
|
+ oldLevel: state => state.oldLevel,
|
|
|
466
|
+ oldLevelId: state => state.oldLevelId,
|
|
|
467
|
+ allData: state => state.allData,
|
|
|
468
|
+ // 新增角色状态getters
|
|
|
469
|
+ isPersonal: state => state.isPersonal,
|
|
|
470
|
+ isZhanZhang: state => state.isZhanZhang,
|
|
|
471
|
+ isKeZhang: state => state.isKeZhang,
|
|
|
472
|
+ isBanZuZhang: state => state.isBanZuZhang
|
|
|
473
|
+ }
|
|
|
474
|
+}
|
|
|
475
|
+
|
|
|
476
|
+export default eikonLevel
|