Commit 4ffe89c8 by Jony.L

大屏数据:API请求趋势、订单管理、服务能力、用户管理真实数据

parent 84548daa
...@@ -39,3 +39,9 @@ export const getOverallSituation = async () => { ...@@ -39,3 +39,9 @@ export const getOverallSituation = async () => {
}) })
} }
export const getAllDashboardData = async () => {
return await request.get({
url: `/index/count/getAllDashboardData`
})
}
...@@ -23,7 +23,6 @@ export interface ResourceSpu { ...@@ -23,7 +23,6 @@ export interface ResourceSpu {
source?: string; // 算力来源 source?: string; // 算力来源
picUrl?: string; // 商品封面图 picUrl?: string; // 商品封面图
sliderPicUrls?: string; // 商品轮播图地址,以逗号分隔,最多15张 sliderPicUrls?: string; // 商品轮播图地址,以逗号分隔,最多15张
stock?: number; // 总库存数量
sales?: number; // 商品销量 sales?: number; // 商品销量
status?: number; // 状态(0 下架,1 上架,2 回收) status?: number; // 状态(0 下架,1 上架,2 回收)
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<script setup> <script setup>
import { ref, watch, onMounted, onBeforeUnmount, inject } from 'vue' import { ref, watch, onMounted, onBeforeUnmount, inject } from 'vue'
import { DICT_TYPE, getDictLabel } from '@/utils/dict'
import * as echarts from 'echarts/core' import * as echarts from 'echarts/core'
import { TitleComponent, TooltipComponent, LegendComponent } from 'echarts/components' import { TitleComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import { PieChart } from 'echarts/charts' import { PieChart } from 'echarts/charts'
...@@ -36,7 +37,11 @@ const datasets = ref({ ...@@ -36,7 +37,11 @@ const datasets = ref({
const fetchComputeDistribution = () => { const fetchComputeDistribution = () => {
const data = dashboardData.value.computeDistribution || { gpu: [], source: [], resource: [] } const data = dashboardData.value.computeDistribution || { gpu: [], source: [], resource: [] }
datasets.value.gpu = data.gpu || [] datasets.value.gpu = data.gpu || []
datasets.value.source = data.source || [] // 转换算力来源key为中文标签
datasets.value.source = (data.source || []).map(item => ({
name: getDictLabel(DICT_TYPE.COMPUTE_RESOURCE_SOURCE, item.name) || item.name,
value: item.value
}))
datasets.value.resource = data.resource || [] datasets.value.resource = data.resource || []
} }
......
...@@ -230,29 +230,45 @@ const fetchAllMockData = async () => { ...@@ -230,29 +230,45 @@ const fetchAllMockData = async () => {
// 获取真实数据 // 获取真实数据
const fetchRealData = async () => { const fetchRealData = async () => {
try { try {
// 并行调用所有真实数据接口 // 调用统一接口获取所有数据
const [overallRes, apiCallsRes, usersRes] = await Promise.all([ const res = await IndexCountApi.getAllDashboardData()
IndexCountApi.getOverallSituation(),
IndexCountApi.getApiCallsData('m'),
IndexCountApi.getUsersData('d')
])
if (res) {
// 总体态势数据 // 总体态势数据
if (overallRes) { if (res.overallSituation) {
dashboardData.value.overallSituation = overallRes dashboardData.value.overallSituation = res.overallSituation
} }
// API 调用趋势 // API 调用趋势(Map格式,包含d/m/y三个维度)
if (Array.isArray(apiCallsRes)) { if (res.apiCalls) {
dashboardData.value.apiCalls = apiCallsRes dashboardData.value.apiCalls = res.apiCalls
} }
// 用户数据 // 算力资源分布
if (Array.isArray(usersRes)) { if (res.computeDistribution) {
dashboardData.value.users = usersRes dashboardData.value.computeDistribution = res.computeDistribution
} }
// TODO: 算力分布和服务能力数据的真实接口待实现 // 用户数据(Map格式,包含d/m/y三个维度)
if (res.users) {
dashboardData.value.users = res.users
}
// 订单数据(Map格式,包含d/m/y三个维度)
if (res.orders) {
dashboardData.value.orders = res.orders
}
// 服务能力数据
if (res.serviceCapability) {
dashboardData.value.serviceCapability = res.serviceCapability
}
// 轮播数据
if (res.carouselItems) {
dashboardData.value.carouselItems = res.carouselItems
}
}
} catch (error) { } catch (error) {
console.error('获取真实数据失败:', error) console.error('获取真实数据失败:', error)
} }
......
...@@ -128,14 +128,8 @@ const getChartData = () => { ...@@ -128,14 +128,8 @@ const getChartData = () => {
return { x: [], y: [] } return { x: [], y: [] }
} }
// 根据数据格式转换为图表数据 // 直接使用后端返回的 countDate
// apiCalls[d/m/y] 格式: [{countDate: "2025-01-01", callsCount: 1202}, ...] const x = data.map(item => item.countDate)
const x = data.map(item => {
const date = new Date(item.countDate)
const m = String(date.getMonth() + 1).padStart(2, '0')
const d = String(date.getDate()).padStart(2, '0')
return `${m}-${d}`
})
const y = data.map(item => item.callsCount) const y = data.map(item => item.callsCount)
return { x, y } return { x, y }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment