feat: 引入v-chart,重要系统健康状态组件

master
LCJ-MinYa 11 months ago
parent 09453ae877
commit 146ec24afb

@ -43,6 +43,7 @@
"responsive-storage": "^2.2.0",
"sortablejs": "^1.15.2",
"vue": "^3.4.38",
"vue-echarts": "^7.0.3",
"vue-router": "^4.4.3",
"vue-tippy": "^6.4.4",
"vue-types": "^5.1.3"

@ -74,6 +74,9 @@ importers:
vue:
specifier: ^3.4.38
version: 3.4.38(typescript@5.5.4)
vue-echarts:
specifier: ^7.0.3
version: 7.0.3(@vue/runtime-core@3.4.38)(echarts@5.5.1)(vue@3.4.38(typescript@5.5.4))
vue-router:
specifier: ^4.4.3
version: 4.4.3(vue@3.4.38(typescript@5.5.4))
@ -3459,6 +3462,17 @@ packages:
vscode-uri@3.0.8:
resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==}
vue-demi@0.13.11:
resolution: {integrity: sha512-IR8HoEEGM65YY3ZJYAjMlKygDQn25D5ajNFNoKh9RSDMQtlzCxtfQjdQgv9jjK+m3377SsJXY8ysq8kLCZL25A==}
engines: {node: '>=12'}
hasBin: true
peerDependencies:
'@vue/composition-api': ^1.0.0-rc.1
vue: ^3.0.0-0 || ^2.6.0
peerDependenciesMeta:
'@vue/composition-api':
optional: true
vue-demi@0.14.10:
resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
engines: {node: '>=12'}
@ -3470,6 +3484,16 @@ packages:
'@vue/composition-api':
optional: true
vue-echarts@7.0.3:
resolution: {integrity: sha512-/jSxNwOsw5+dYAUcwSfkLwKPuzTQ0Cepz1LxCOpj2QcHrrmUa/Ql0eQqMmc1rTPQVrh2JQ29n2dhq75ZcHvRDw==}
peerDependencies:
'@vue/runtime-core': ^3.0.0
echarts: ^5.5.1
vue: ^2.7.0 || ^3.1.1
peerDependenciesMeta:
'@vue/runtime-core':
optional: true
vue-eslint-parser@9.4.3:
resolution: {integrity: sha512-2rYRLWlIpaiN8xbPiDyXZXRgLGOtWxERV7ND5fFAv5qo1D2N9Fu9MNajBNc6o13lZ+24DAWCkQCvj4klgmcITg==}
engines: {node: ^14.17.0 || >=16.0.0}
@ -6950,10 +6974,24 @@ snapshots:
vscode-uri@3.0.8: {}
vue-demi@0.13.11(vue@3.4.38(typescript@5.5.4)):
dependencies:
vue: 3.4.38(typescript@5.5.4)
vue-demi@0.14.10(vue@3.4.38(typescript@5.5.4)):
dependencies:
vue: 3.4.38(typescript@5.5.4)
vue-echarts@7.0.3(@vue/runtime-core@3.4.38)(echarts@5.5.1)(vue@3.4.38(typescript@5.5.4)):
dependencies:
echarts: 5.5.1
vue: 3.4.38(typescript@5.5.4)
vue-demi: 0.13.11(vue@3.4.38(typescript@5.5.4))
optionalDependencies:
'@vue/runtime-core': 3.4.38
transitivePeerDependencies:
- '@vue/composition-api'
vue-eslint-parser@9.4.3(eslint@9.9.0(jiti@1.21.6)):
dependencies:
debug: 4.3.6

@ -3,7 +3,7 @@ import router from './router';
import { setupStore } from '@/store';
import { getPlatformConfig } from './config';
import { MotionPlugin } from '@vueuse/motion';
// import { useEcharts } from "@/plugins/echarts";
import { registerVueEcharts } from '@/plugins/echarts';
import { createApp, type Directive } from 'vue';
import { useElementPlus } from '@/plugins/elementPlus';
import { injectResponsiveStorage } from '@/utils/responsive';
@ -56,6 +56,6 @@ getPlatformConfig(app).then(async (config) => {
injectResponsiveStorage(app, config);
app.use(MotionPlugin).use(useElementPlus).use(useAutoImport).use(Table);
// .use(PureDescriptions)
// .use(useEcharts);
registerVueEcharts(app);
app.mount('#app');
});

@ -1,7 +1,7 @@
import type { App } from "vue";
import * as echarts from "echarts/core";
import { PieChart, BarChart, LineChart } from "echarts/charts";
import { CanvasRenderer, SVGRenderer } from "echarts/renderers";
import type { App } from 'vue';
import * as echarts from 'echarts/core';
import { PieChart, BarChart, LineChart, ScatterChart, GaugeChart } from 'echarts/charts';
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers';
import {
GridComponent,
TitleComponent,
@ -11,12 +11,16 @@ import {
ToolboxComponent,
TooltipComponent,
DataZoomComponent,
VisualMapComponent
} from "echarts/components";
VisualMapComponent,
MarkPointComponent,
} from 'echarts/components';
import VueEcharts from 'vue-echarts';
const { use } = echarts;
use([
GaugeChart,
ScatterChart,
PieChart,
BarChart,
LineChart,
@ -30,7 +34,8 @@ use([
ToolboxComponent,
TooltipComponent,
DataZoomComponent,
VisualMapComponent
VisualMapComponent,
MarkPointComponent,
]);
/**
@ -41,4 +46,8 @@ export function useEcharts(app: App) {
app.config.globalProperties.$echarts = echarts;
}
export const registerVueEcharts = (app: App) => {
app.component('v-chart', VueEcharts);
};
export default echarts;

@ -0,0 +1,177 @@
<template>
<ul class="system-health-ul">
<li
v-for="item in list"
:key="item.name"
>
<v-chart
v-if="JSON.stringify(item.option) != '{}'"
:option="item.option"
/>
</li>
</ul>
</template>
<script setup>
import { ref } from 'vue';
import { cptColor } from '../config';
const list = ref();
const setOptions = () => {
list.value.forEach((item) => {
item.option = {
series: [
/*仪表盘图,做中间刻度线*/
{
type: 'gauge',
radius: '100%',
startAngle: '0',
endAngle: '-359.99',
splitNumber: '60',
pointer: {
show: false,
},
title: {
show: false,
},
detail: {
show: false,
},
axisLine: {
lineStyle: {
width: 15,
opacity: 0,
},
},
axisTick: {
show: false,
},
splitLine: {
show: true,
length: 10,
lineStyle: {
color: cptColor(item.value, 0.5),
width: 2,
type: 'solid',
},
},
axisLabel: {
show: false,
},
},
/*内心原型图,展示整体数据概览*/
{
name: item.name,
type: 'pie',
clockwise: true,
startAngle: 90,
radius: ['55%', '65%'],
emphasis: {
scale: false,
},
center: ['50%', '50%'],
data: [
{
value: item.value,
label: {
formatter: (params) => {
return `{title|${params.seriesName}}\n{value|${params.value}%}`;
},
position: 'center',
show: true,
rich: {
title: {
fontSize: 18,
fontWeight: 'normal',
color: 'rgba(255,255,255,.6)',
fontFamily: 'xxx字体',
},
value: {
color: '#fff',
fontSize: 36,
fontWeight: 'bold',
fontFamily: 'xxx字体',
padding: [8, 0, 0, 0],
},
},
},
itemStyle: {
color: cptColor(item.value),
},
},
{
value: 100 - item.value,
itemStyle: {
color: 'rgba(42,42,42,1)', //
label: {
show: false,
},
labelLine: {
show: false,
},
},
emphasis: {
color: 'rgba(42,42,42,1)', //
},
},
],
labelLine: { show: false },
label: { show: false },
},
],
};
});
};
const getMajorSystemHealthStatusData = () => {
console.log('执行请求MajorSystemHealthStatus');
return new Promise((resolve) => {
setTimeout(() => {
resolve([
{
name: '重要系统',
value: 55,
},
{
name: '核心平台',
value: 75,
},
{
name: '关键网络',
value: 85,
},
{
name: '基础设置',
value: 95,
},
]);
}, 1000);
});
};
const initFN = () => {
getMajorSystemHealthStatusData().then((res) => {
list.value = res;
setOptions();
});
};
defineExpose({
name: 'MajorSystemHealthStatus',
init: initFN,
});
</script>
<style lang="scss" scoped>
.system-health-ul {
display: flex;
flex-wrap: wrap;
height: calc(100% - 20px);
li {
width: 50%;
height: 50%;
}
}
</style>

@ -0,0 +1,55 @@
const colorEnum = {
critical: {
R: 255,
G: 87,
B: 77,
A: 1,
},
warning: {
R: 254,
G: 138,
B: 55,
A: 1,
},
major: {
R: 67,
G: 128,
B: 229,
A: 1,
},
info: {
R: 85,
G: 251,
B: 170,
A: 1,
},
};
const getColor = (key: string = 'info', alpha: number = 1) => {
return `rgba(${colorEnum[key].R}, ${colorEnum[key].G}, ${colorEnum[key].B}, ${alpha || colorEnum[key].A})`;
};
const cptColor = (value: number, alpha: number = 1) => {
let color = '';
switch (true) {
case value < 70:
color = getColor('critical', alpha);
break;
case value >= 70 && value < 80:
color = getColor('warning', alpha);
break;
case value >= 80 && value < 90:
color = getColor('major', alpha);
break;
case value >= 90:
color = getColor('info', alpha);
break;
}
return color;
};
const keyColor = (value, alpha = 1) => {
return getColor(value, alpha);
};
export { colorEnum, getColor, cptColor, keyColor };

@ -45,6 +45,7 @@ import ScaleScreen from './components/common/scale-screen';
import Headers from './components/Headers.vue';
import ItemWrap from './components/common/item-wrap';
import AccessStatus from './components/AccessStatus.vue';
import MajorSystemHealthStatus from './components/MajorSystemHealthStatus.vue';
/** 机构切换配置 */
const orgList = ref([
@ -82,6 +83,9 @@ const getComponent = (componentName) => {
case 'AccessStatus':
component = shallowRef(AccessStatus);
break;
case 'MajorSystemHealthStatus':
component = shallowRef(MajorSystemHealthStatus);
break;
}
return component;
};
@ -91,6 +95,9 @@ const getComponentClass = computed(() => (componentName) => {
case 'AccessStatus':
className = 'content_kb-item';
break;
case 'MajorSystemHealthStatus':
className = 'content_lb-item';
break;
}
return className;
});
@ -102,14 +109,20 @@ const getLayout = (id) => {
switch (id) {
case 'all':
layoutDataValue = {
left: [{ title: '综合看板', componentName: 'AccessStatus' }],
left: [
{ title: '综合看板', componentName: 'AccessStatus' },
{ title: '重要系统健康状态', componentName: 'MajorSystemHealthStatus' },
],
center: [],
right: [],
};
break;
case 'org1':
layoutDataValue = {
left: [{ title: '综合看板', componentName: 'AccessStatus' }],
left: [
{ title: '综合看板', componentName: 'AccessStatus' },
{ title: '重要系统健康状态', componentName: 'MajorSystemHealthStatus' },
],
center: [],
right: [],
};
@ -147,7 +160,7 @@ let timer = null;
const setTimer = () => {
timer = setInterval(() => {
refreshRequest();
});
}, 60000);
};
const clearTimer = () => {
clearInterval(timer);

Loading…
Cancel
Save