feat: 运维管理 仪表盘 新增empty状态

This commit is contained in:
jackhoo_98 2023-03-01 17:08:32 +08:00
parent 4e75bf94c6
commit 1230ea3d90
4 changed files with 28 additions and 11 deletions

View File

@ -60,6 +60,7 @@ const iconKeys = [
'RedoOutlined', 'RedoOutlined',
'VideoCameraOutlined', 'VideoCameraOutlined',
'HistoryOutlined', 'HistoryOutlined',
'CalendarOutlined',
] ]
const Icon = (props: {type: string}) => { const Icon = (props: {type: string}) => {

View File

@ -10,7 +10,9 @@
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
v-model="data.time" v-model="data.time"
> >
<template #suffixIcon><a-icon type="calendar" /></template> <template #suffixIcon
><AIcon type="CalendarOutlined"
/></template>
<template #renderExtraFooter> <template #renderExtraFooter>
<a-radio-group <a-radio-group
default-value="a" default-value="a"
@ -31,7 +33,8 @@
> >
</a-range-picker> </a-range-picker>
</div> </div>
<div ref="chartRef" style="width: 100%; height: 300px"></div> <a-empty v-if="empty" class="empty" />
<div v-else ref="chartRef" style="width: 100%; height: 300px"></div>
</div> </div>
</a-spin> </a-spin>
</template> </template>
@ -50,8 +53,8 @@ import {
} from './tool.ts'; } from './tool.ts';
const chartRef = ref<Record<string, any>>({}); const chartRef = ref<Record<string, any>>({});
const loading = ref(false); const loading = ref(false);
const empty = ref(false);
const data = ref({ const data = ref({
type: 'hour', type: 'hour',
time: [null, null], time: [null, null],
@ -140,6 +143,7 @@ const handleCpuOptions = (optionsData, xAxis) => {
: typeDataLine, : typeDataLine,
}; };
myChart.setOption(options); myChart.setOption(options);
xAxis.length === 0 && (empty.value = true);
window.addEventListener('resize', function () { window.addEventListener('resize', function () {
myChart.resize(); myChart.resize();
}); });
@ -186,4 +190,7 @@ watch(
margin-top: 8px; margin-top: 8px;
} }
} }
.empty {
height: 300px;
}
</style> </style>

View File

@ -10,7 +10,9 @@
format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
v-model="data.time" v-model="data.time"
> >
<template #suffixIcon><a-icon type="calendar" /></template> <template #suffixIcon
><AIcon type="CalendarOutlined"
/></template>
<template #renderExtraFooter> <template #renderExtraFooter>
<a-radio-group <a-radio-group
default-value="a" default-value="a"
@ -31,7 +33,8 @@
> >
</a-range-picker> </a-range-picker>
</div> </div>
<div ref="chartRef" style="width: 100%; height: 300px"></div> <a-empty v-if="empty" class="empty" />
<div v-else ref="chartRef" style="width: 100%; height: 300px"></div>
</div> </div>
</a-spin> </a-spin>
</template> </template>
@ -50,7 +53,7 @@ import {
} from './tool.ts'; } from './tool.ts';
const chartRef = ref<Record<string, any>>({}); const chartRef = ref<Record<string, any>>({});
const empty = ref(false);
const loading = ref(false); const loading = ref(false);
const data = ref({ const data = ref({
type: 'hour', type: 'hour',
@ -144,6 +147,7 @@ const handleJVMOptions = (optionsData, xAxis) => {
: typeDataLine, : typeDataLine,
}; };
myChart.setOption(options); myChart.setOption(options);
xAxis.length === 0 && (empty.value = true);
window.addEventListener('resize', function () { window.addEventListener('resize', function () {
myChart.resize(); myChart.resize();
}); });
@ -190,4 +194,7 @@ watch(
margin-top: 8px; margin-top: 8px;
} }
} }
.empty {
height: 300px;
}
</style> </style>

View File

@ -43,12 +43,12 @@
</div> </div>
</div> </div>
<div> <div>
<a-empty v-if="empty" class="empty" />
<div <div
v-else
ref="chartRef" ref="chartRef"
v-if="flag"
style="width: 100%; height: 350px" style="width: 100%; height: 350px"
></div> ></div>
<a-empty v-else style="height: 300px; margin-top: 120px" />
</div> </div>
</div> </div>
</a-spin> </a-spin>
@ -67,10 +67,8 @@ import moment from 'moment';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
const chartRef = ref<Record<string, any>>({}); const chartRef = ref<Record<string, any>>({});
const empty = ref(false);
const flag = ref(true);
const loading = ref(false); const loading = ref(false);
const myChart = ref(null);
const data = ref({ const data = ref({
type: 'bytesRead', type: 'bytesRead',
time: { time: {
@ -163,6 +161,7 @@ const handleNetworkOptions = (optionsData, xAxis) => {
: typeDataLine, : typeDataLine,
}; };
myChart.setOption(options); myChart.setOption(options);
// xAxis.length === 0 && (empty.value = true);
window.addEventListener('resize', function () { window.addEventListener('resize', function () {
myChart.resize(); myChart.resize();
}); });
@ -216,4 +215,7 @@ watch(
display: flex; display: flex;
align-items: center; align-items: center;
} }
.empty {
height: 300px;
}
</style> </style>