Browse Source

移除不再使用的 getTeamStatistics API,更新 DashboardView 以使用 averageCommissionRate 替代 commissionRate,优化团队统计数据加载逻辑。

wuyi 2 months ago
parent
commit
6b662f4d96
2 changed files with 12 additions and 7 deletions
  1. 5 4
      src/services/api.js
  2. 7 3
      src/views/DashboardView.vue

+ 5 - 4
src/services/api.js

@@ -320,10 +320,11 @@ export const getAllTeamStatistics = async () => {
   return response.data
 }
 
-export const getTeamStatistics = async () => {
-  const response = await api.get('/teams/statistics/team')
-  return response.data
-}
+// 单个团队统计数据-废弃
+// export const getTeamStatistics = async () => {
+//   const response = await api.get('/teams/statistics/team')
+//   return response.data
+// }
 
 
 // 获取所有团队

+ 7 - 3
src/views/DashboardView.vue

@@ -34,7 +34,7 @@
         </div>
         <div class="card">
           <h3>佣金率</h3>
-          <p class="stat-value">{{ formatRate(teamStats?.commissionRate) }}%</p>
+          <p class="stat-value">{{ formatRate(teamStats?.averageCommissionRate) }}%</p>
         </div>
       </div>
     </div>
@@ -84,7 +84,7 @@
 import { ref, onMounted, computed, inject, watch } from 'vue'
 import { useUserStore } from '@/stores/user'
 import { useTeamStore } from '@/stores/team'
-import { getAllTeamStatistics, getTeamStatistics, getIncomeStatistics } from '@/services/api'
+import { getAllTeamStatistics, getIncomeStatistics } from '@/services/api'
 import Chart from 'chart.js/auto'
 import Select from 'primevue/select'
 import DataTable from 'primevue/datatable'
@@ -171,8 +171,12 @@ const loadTeamStats = async () => {
       }
     } else if (isTeam.value) {
       console.log('加载队长团队统计数据')
-      const data = await getTeamStatistics()
+      const data = await getAllTeamStatistics()
       console.log('队长团队统计数据:', data)
+      // 为 team 角色添加团队名称
+      if (data.allTeams && data.allTeams.length > 0) {
+        data.name = data.allTeams[0].name
+      }
       teamStats.value = data
     }
   } catch (error) {