Browse Source

fix(employee profile): add deptType prop and adjust department data fetch

1. 为员工档案页面的SearchBar组件传入deptType为'user'参数
2. 新增getDeptUserTree接口调用用于获取用户部门树数据
3. 调整部门数据加载逻辑,区分user类型和其他类型的部门数据获取方式
4. 修复部分代码缩进格式问题
huoyi 3 weeks ago
parent
commit
58a3c64762

+ 9 - 6
src/views/portraitManagement/components/SearchBar.vue

@@ -44,7 +44,7 @@
44
 <script setup>
44
 <script setup>
45
 import { onMounted, onUnmounted } from 'vue'
45
 import { onMounted, onUnmounted } from 'vue'
46
 import { searchPortraitUsers } from '@/api/score/index'
46
 import { searchPortraitUsers } from '@/api/score/index'
47
-import { getDeptList } from '@/api/item/items'
47
+import { getDeptList,getDeptUserTree } from '@/api/item/items'
48
 import { listDept } from '@/api/system/dept'
48
 import { listDept } from '@/api/system/dept'
49
 
49
 
50
 const props = defineProps({
50
 const props = defineProps({
@@ -140,13 +140,13 @@ const handleNodeClick = (node) => {
140
     if (node.deptType === props.deptType) {
140
     if (node.deptType === props.deptType) {
141
       personName.value = node.deptName || node.name || node.label;
141
       personName.value = node.deptName || node.name || node.label;
142
       let obj = {}
142
       let obj = {}
143
-      if(props.deptType === 'BRIGADE') {
143
+      if (props.deptType === 'BRIGADE') {
144
         obj = { deptId: node.deptId || node.id }
144
         obj = { deptId: node.deptId || node.id }
145
-      } 
146
-      if(props.deptType === 'MANAGER') {
145
+      }
146
+      if (props.deptType === 'MANAGER') {
147
         obj = { teamId: node.deptId || node.id }
147
         obj = { teamId: node.deptId || node.id }
148
       }
148
       }
149
-      if(props.deptType === 'TEAMS') {
149
+      if (props.deptType === 'TEAMS') {
150
         obj = { groupId: node.deptId || node.id }
150
         obj = { groupId: node.deptId || node.id }
151
       }
151
       }
152
       searchHandler(obj)
152
       searchHandler(obj)
@@ -177,10 +177,13 @@ const resetStyle = () => {
177
 
177
 
178
 onMounted(async () => {
178
 onMounted(async () => {
179
   setStyle()
179
   setStyle()
180
-  const res = await getDeptList({ deptType: props.deptType })
180
+
181
   if (props.deptType === 'user') {
181
   if (props.deptType === 'user') {
182
+    const res = await getDeptUserTree()
182
     departments.value = res.data
183
     departments.value = res.data
184
+
183
   } else {
185
   } else {
186
+    const res = await getDeptList({ deptType: props.deptType })
184
     departments.value = filterDeptTree(res.data, props.deptType)
187
     departments.value = filterDeptTree(res.data, props.deptType)
185
   }
188
   }
186
 })
189
 })

+ 1 - 1
src/views/portraitManagement/employeeProfile/index.vue

@@ -2,7 +2,7 @@
2
   <Page @click="visible = false" v-loading="loading" element-loading-background="rgba(22, 22, 22, 0.8)">
2
   <Page @click="visible = false" v-loading="loading" element-loading-background="rgba(22, 22, 22, 0.8)">
3
     <div class="content">
3
     <div class="content">
4
       <div class="content-search">
4
       <div class="content-search">
5
-        <SearchBar v-model:visible="visible" @search="searchHandler" />
5
+        <SearchBar v-model:visible="visible" @search="searchHandler" :deptType="'user'" />
6
       </div>
6
       </div>
7
       
7
       
8
         <div v-show="portrait.personName" class="content-info">
8
         <div v-show="portrait.personName" class="content-info">