feat:添加漫游式引导

This commit is contained in:
zhongzm
2024-11-08 18:25:11 +08:00
parent 3561a5dc39
commit d7990a6ee5

View File

@@ -6,13 +6,47 @@ import { LineChart, BarChart } from 'echarts/charts';
import { CanvasRenderer } from 'echarts/renderers'; import { CanvasRenderer } from 'echarts/renderers';
import { getKPITitle, listKPIData } from '@/api/perfManage/goldTarget'; import { getKPITitle, listKPIData } from '@/api/perfManage/goldTarget';
import useI18n from '@/hooks/useI18n'; import useI18n from '@/hooks/useI18n';
import { message } from 'ant-design-vue'; import { message, TourProps } from 'ant-design-vue';
import { RESULT_CODE_ERROR, RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { RESULT_CODE_ERROR, RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import type { Dayjs } from 'dayjs'; import type { Dayjs } from 'dayjs';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { OptionsType, WS } from '@/plugins/ws-websocket'; import { OptionsType, WS } from '@/plugins/ws-websocket';
import { generateColorRGBA } from '@/utils/generate-utils'; import { generateColorRGBA } from '@/utils/generate-utils';
import { BarChartOutlined, LineChartOutlined, UnorderedListOutlined, DownOutlined, MoreOutlined } from '@ant-design/icons-vue'; import { BarChartOutlined, LineChartOutlined, UnorderedListOutlined, MoreOutlined } from '@ant-design/icons-vue';
//配置漫游引导变量
const open = ref<boolean>(false);
const handleOpen = (val: boolean): void => {
open.value = val;
};
const ref1=ref<any>(null);
const ref2=ref<any>(null);
const ref3=ref<any>(null);
const ref4=ref<any>(null);
const steps: TourProps['steps']=[
{
title:'日期范围选择器',
description: '选择要查看数据的时间范围建议范围一个小时',
target: () => ref1.value && ref1.value.$el,
},
{
title:'选择指标按钮',
description: '在这里勾选想要查看的指标',
target: () => ref2.value && ref2.value.$el,
},
{
title:'切换图表类型',
description: '点击切换另一种图表查看数据概览',
target: () => ref3.value && ref3.value.$el,
},
{
title:'实时数据开关',
description: '打开开关观看实时数据',
target: () => ref4.value && ref4.value.$el,
},
]
//定义KPI接口 //定义KPI接口
interface KPIBase{ interface KPIBase{
@@ -311,27 +345,17 @@ const updateChart = () => {
}, },
xAxis: { xAxis: {
// 指定x轴类型为类目轴适用于离散的类目数据 // 指定x轴类型为类目轴适用于离散的类目数据
//type: 'category', type: 'category',
// boundaryGap 控制坐标轴两边留白 //控制坐标轴两边留白
// 当为折线图时(isLine为true)时不留白,柱状图时留白 // 当为折线图时(isLine为true)时不留白,柱状图时留白
// 这样可以让折线图从原点开始,柱状图有合适的间距 // 这样可以让折线图从原点开始,柱状图有合适的间距
//boundaryGap: isLine, boundaryGap: isLine,
// 设置x轴的数据 // 设置x轴的数据
// 将时间戳转换为格式化的时间字符串 // 将时间戳转换为格式化的时间字符串
data:chartData.value.map(item=> data:chartData.value.map(item=>
dayjs(Number(item.date)).format('YYYY-MM-DD HH:mm:ss') dayjs(Number(item.date)).format('YYYY-MM-DD HH:mm:ss')
), ),
// 设置坐标轴刻度标签的样式 //设置坐标轴刻度标签的样式
// axisLabel: {
// // 格式化函数,这里直接返回原值
// formatter: (value: string) => value,
// // 刻度标签旋转角度0表示不旋转
// rotate: 0,
// // 自动计算标签显示的间隔,防止标签重叠
// interval: 'auto', // 自动计算显示间隔
// // 刻度标签对齐方式,右对齐
// align: 'right',
// },
}, },
yAxis: { yAxis: {
// y轴配置 // y轴配置
@@ -375,6 +399,7 @@ const updateChart = () => {
//钩子函数 //钩子函数
onMounted(async () => { onMounted(async () => {
open.value=true;
try { try {
// 获取所有网元的指标 // 获取所有网元的指标
await fetchSpecificKPI(); await fetchSpecificKPI();
@@ -415,6 +440,7 @@ const originalSelectedKPIs = ref<string[]>([]);
// 打开对话框的方法 // 打开对话框的方法
const showKPISelector = () => { const showKPISelector = () => {
// 保存当前的选择状态 // 保存当前的选择状态
originalSelectedKPIs.value = [...selectedKPIs.value]; originalSelectedKPIs.value = [...selectedKPIs.value];
@@ -442,6 +468,7 @@ const handleModalCancel = () => {
// 确认按钮的处理方法 // 确认按钮的处理方法
const handleModalOk = () => { const handleModalOk = () => {
// 获取主要指标列表 // 获取主要指标列表
const primaryKPIs = Object.values(TARGET_KPI_IDS).flat(); const primaryKPIs = Object.values(TARGET_KPI_IDS).flat();
@@ -545,7 +572,7 @@ onUnmounted(() => {
chart.dispose(); chart.dispose();
chart = null; chart = null;
} }
// 可选在组件卸载时保存选择 // 可选:在组件卸载时保存选择
saveSelectedKPIs(); saveSelectedKPIs();
}); });
@@ -615,14 +642,15 @@ const secondaryKPIs = computed(() => {
const primaryIds = TARGET_KPI_IDS[neType]; const primaryIds = TARGET_KPI_IDS[neType];
// 从所有指标中筛选出当前网元其他指标 // 从所有指标中筛选出当前网元其他指标
groups[neType] = kpiColumns.value.filter(kpi => { groups[neType] = kpiColumns.value.filter(kpi => {
return kpi.neType === neType && !primaryIds.includes(kpi.kpiId);
// 检查是否不在主要指标列表中 // 检查是否不在主要指标列表中
const isNotPrimary = !primaryIds.includes(kpi.kpiId); // const isNotPrimary = !primaryIds.includes(kpi.kpiId);
//
// 检查是否属于当前网元类型 // // 检查是否属于当前网元类型
// 使用 getKPITitle API 返回的原始数据中的网元类型信息 // // 使用 getKPITitle API 返回的原始数据中的网元类型信息
const isCurrentNeType = kpi.neType === neType; // const isCurrentNeType = kpi.neType === neType;
//
return isCurrentNeType && isNotPrimary; // return isCurrentNeType && isNotPrimary;
}); });
}); });
return groups; return groups;
@@ -645,6 +673,7 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
<div class="kpi-overview"> <div class="kpi-overview">
<div class="controls"> <div class="controls">
<a-range-picker <a-range-picker
ref="ref1"
v-model:value="dateRange" v-model:value="dateRange"
:show-time="{ format: 'HH:mm:ss' }" :show-time="{ format: 'HH:mm:ss' }"
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
@@ -652,13 +681,13 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
:disabled="isRealtime" :disabled="isRealtime"
@change="handleDateChange" @change="handleDateChange"
/> />
<a-button @click="showKPISelector"> <a-button ref="ref2" @click="showKPISelector">
<template #icon> <template #icon>
<unordered-list-outlined /> <unordered-list-outlined />
</template> </template>
{{ t('views.perfManage.kpiOverView.chooseMetrics') }} {{ t('views.perfManage.kpiOverView.chooseMetrics') }}
</a-button> </a-button>
<a-button @click="toggleChartType"> <a-button ref="ref3" @click="toggleChartType">
<template #icon> <template #icon>
<bar-chart-outlined v-if="chartType === 'line'" /> <bar-chart-outlined v-if="chartType === 'line'" />
<line-chart-outlined v-else /> <line-chart-outlined v-else />
@@ -676,8 +705,13 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
: t('views.dashboard.cdr.realTimeDataStart') : t('views.dashboard.cdr.realTimeDataStart')
" "
> >
<a-switch v-model:checked="isRealtime" @change="toggleRealtime" /> <a-switch ref="ref4" v-model:checked="isRealtime" @change="toggleRealtime" />
</a-form-item> </a-form-item>
<a-tour :open="open" :steps="steps" @close="handleOpen(false)">
<template #indicatorsRender="{ current, total }">
<span>{{ current + 1 }} / {{ total }}</span>
</template>
</a-tour>
</div> </div>
<div id="chartContainer" class="chart-container"></div> <div id="chartContainer" class="chart-container"></div>
<a-modal <a-modal
@@ -688,7 +722,7 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
width="800px" width="800px"
:bodyStyle="{ maxHeight: '600px', overflow: 'auto' }" :bodyStyle="{ maxHeight: '600px', overflow: 'auto' }"
> >
<a-checkbox-group v-model:value="selectedKPIs"> <a-checkbox-group v-model:value="selectedKPIs" >
<div class="kpi-checkbox-list"> <div class="kpi-checkbox-list">
<a-card <a-card
v-for="neType in ALL_NE_TYPES" v-for="neType in ALL_NE_TYPES"
@@ -696,6 +730,7 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
class="ne-type-card" class="ne-type-card"
:bordered="false" :bordered="false"
> >
{{neType.toUpperCase()}}
<template #title> <template #title>
<span class="card-title">{{ neType.toUpperCase() }}</span> <span class="card-title">{{ neType.toUpperCase() }}</span>
</template> </template>
@@ -722,7 +757,7 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
</div> </div>
</div> </div>
</template> </template>
<a-button type="link" size="small" class="more-metrics-btn"> <a-button type="link" size="small" class="more-metrics-btn" ref="ref6">
<more-outlined /> <more-outlined />
<span class="secondary-count">({{ secondaryKPIs[neType].length }})</span> <span class="secondary-count">({{ secondaryKPIs[neType].length }})</span>
</a-button> </a-button>
@@ -758,7 +793,7 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
} }
.chart-container { .chart-container {
height: calc(100vh - 160px); height: calc(100vh - 210px);/*调整图表大小*/
width: 100%; width: 100%;
} }
/* 网元指标列表样式 */ /* 网元指标列表样式 */
@@ -874,5 +909,4 @@ const handleSecondaryKPIChange = (kpiId: string, checked: boolean) => {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
</style> </style>