ref: 重构黄金指标数据列表,图表切换显示优化
This commit is contained in:
@@ -82,19 +82,11 @@ export async function listgoldData(query: Record<string, any>) {
|
|||||||
* @param query 查询参数
|
* @param query 查询参数
|
||||||
* @returns object
|
* @returns object
|
||||||
*/
|
*/
|
||||||
export async function goldData(query: Record<string, any>) {
|
export async function listKPIData(query: Record<string, any>) {
|
||||||
const result = await request({
|
const result = await request({
|
||||||
url: `/neData/kpi/data`,
|
url: `/neData/kpi/data`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: query,
|
||||||
neType: query.neType[0],
|
|
||||||
neId: query.neType[1],
|
|
||||||
startTime: query.beginTime,
|
|
||||||
endTime: query.endTime,
|
|
||||||
interval: query.particle,
|
|
||||||
sortField: query.sortField,
|
|
||||||
sortOrder: query.sortOrder,
|
|
||||||
},
|
|
||||||
timeout: 60_000,
|
timeout: 60_000,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -102,14 +94,14 @@ export async function goldData(query: Record<string, any>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询网元可用黄金指标
|
* 查询黄金指标数据kpi.id转换title
|
||||||
* @param neType 网元类型
|
* @param neType 网元类型
|
||||||
* @returns object
|
* @returns object
|
||||||
*/
|
*/
|
||||||
export async function getGoldTitleByNE(neType: string) {
|
export async function getKPITitle(neType: string) {
|
||||||
// 发起请求
|
// 发起请求
|
||||||
const result = await request({
|
const result = await request({
|
||||||
url: `/ne/kpi/title`,
|
url: `/neData/kpi/title`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: { neType },
|
params: { neType },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
newChart.dispose();
|
newChart?.dispose();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -708,14 +708,14 @@ export default {
|
|||||||
value:'Value',
|
value:'Value',
|
||||||
startTime:'Start Time',
|
startTime:'Start Time',
|
||||||
endTime:'End Time',
|
endTime:'End Time',
|
||||||
particle: 'Granularity',
|
interval: 'Granularity',
|
||||||
timeFrame: 'Time Range',
|
timeFrame: 'Time Range',
|
||||||
nullTip:'There are no statistical data within this time range',
|
nullTip:'There are no statistical data within this time range',
|
||||||
kpiTitle:'KPI Statistics Chart',
|
kpiChartTitle:'KPI Statistics Chart',
|
||||||
allData:'Complete Data',
|
kpiTableTitle:'KPI Statistics Data',
|
||||||
makeLine:'Statistical Chart',
|
|
||||||
time:'Time',
|
time:'Time',
|
||||||
exportSure:'Confirm whether to export all statistical data',
|
exportSure:'Confirm whether to export all statistical data',
|
||||||
|
exportEmpty: "Export data is empty",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
traceManage: {
|
traceManage: {
|
||||||
|
|||||||
@@ -708,14 +708,14 @@ export default {
|
|||||||
value:'值',
|
value:'值',
|
||||||
startTime:'开始时间',
|
startTime:'开始时间',
|
||||||
endTime:'结束时间',
|
endTime:'结束时间',
|
||||||
particle:'颗粒度',
|
interval:'颗粒度',
|
||||||
timeFrame:'时间范围',
|
timeFrame:'时间范围',
|
||||||
nullTip:'此时间范围内没有统计数据',
|
nullTip:'此时间范围内没有统计数据',
|
||||||
kpiTitle:'KPI统计图表',
|
kpiChartTitle:'KPI统计图表',
|
||||||
allData:'完整统计数据',
|
kpiTableTitle:'KPI统计数据',
|
||||||
makeLine:'统计图',
|
|
||||||
time:'时间',
|
time:'时间',
|
||||||
exportSure:'确认是否导出全部统计数据',
|
exportSure:'确认是否导出全部统计数据',
|
||||||
|
exportEmpty: "导出数据为空",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
traceManage: {
|
traceManage: {
|
||||||
|
|||||||
@@ -1,35 +1,99 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref, onMounted, toRaw } from 'vue';
|
import * as echarts from 'echarts/core';
|
||||||
|
import {
|
||||||
|
TooltipComponent,
|
||||||
|
TooltipComponentOption,
|
||||||
|
GridComponent,
|
||||||
|
GridComponentOption,
|
||||||
|
LegendComponent,
|
||||||
|
LegendComponentOption,
|
||||||
|
DataZoomComponent,
|
||||||
|
DataZoomComponentOption,
|
||||||
|
} from 'echarts/components';
|
||||||
|
import { LineChart, LineSeriesOption } from 'echarts/charts';
|
||||||
|
import { UniversalTransition } from 'echarts/features';
|
||||||
|
import { CanvasRenderer } from 'echarts/renderers';
|
||||||
|
|
||||||
|
import { reactive, ref, onMounted, toRaw, markRaw, nextTick } from 'vue';
|
||||||
import { PageContainer } from 'antdv-pro-layout';
|
import { PageContainer } from 'antdv-pro-layout';
|
||||||
import { message, Form, Modal } from 'ant-design-vue/lib';
|
import { message, Modal } from 'ant-design-vue/lib';
|
||||||
import { ColumnsType } from 'ant-design-vue/lib/table';
|
import { ColumnsType } from 'ant-design-vue/lib/table';
|
||||||
import { SizeType } from 'ant-design-vue/lib/config-provider';
|
import { SizeType } from 'ant-design-vue/lib/config-provider';
|
||||||
import ChartLine from '@/components/ChartLine/index.vue';
|
|
||||||
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
|
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
|
||||||
import TableColumnsDnd from '@/components/TableColumnsDnd/index.vue';
|
import TableColumnsDnd from '@/components/TableColumnsDnd/index.vue';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import useNeInfoStore from '@/store/modules/neinfo';
|
import useNeInfoStore from '@/store/modules/neinfo';
|
||||||
import useI18n from '@/hooks/useI18n';
|
import useI18n from '@/hooks/useI18n';
|
||||||
import { getGoldTitleByNE, goldData } from '@/api/perfManage/goldTarget';
|
import { getKPITitle, listKPIData } from '@/api/perfManage/goldTarget';
|
||||||
import { parseDateToStr } from '@/utils/date-utils';
|
import { parseDateToStr } from '@/utils/date-utils';
|
||||||
import { writeSheet } from '@/utils/execl-utils';
|
import { writeSheet } from '@/utils/execl-utils';
|
||||||
import saveAs from 'file-saver';
|
import saveAs from 'file-saver';
|
||||||
const neInfoStore = useNeInfoStore();
|
const neInfoStore = useNeInfoStore();
|
||||||
const { t, currentLocale } = useI18n();
|
const { t, currentLocale } = useI18n();
|
||||||
|
|
||||||
|
echarts.use([
|
||||||
|
TooltipComponent,
|
||||||
|
GridComponent,
|
||||||
|
LegendComponent,
|
||||||
|
DataZoomComponent,
|
||||||
|
LineChart,
|
||||||
|
CanvasRenderer,
|
||||||
|
UniversalTransition,
|
||||||
|
]);
|
||||||
|
|
||||||
|
type EChartsOption = echarts.ComposeOption<
|
||||||
|
| TooltipComponentOption
|
||||||
|
| GridComponentOption
|
||||||
|
| LegendComponentOption
|
||||||
|
| DataZoomComponentOption
|
||||||
|
| LineSeriesOption
|
||||||
|
>;
|
||||||
|
|
||||||
|
/**图DOM节点实例对象 */
|
||||||
|
const kpiChartDom = ref<HTMLElement | undefined>(undefined);
|
||||||
|
|
||||||
|
/**图实例对象 */
|
||||||
|
const kpiChart = ref<any>(null);
|
||||||
|
|
||||||
/**网元参数 */
|
/**网元参数 */
|
||||||
let neCascaderOptions = ref<Record<string, any>[]>([]);
|
let neCascaderOptions = ref<Record<string, any>[]>([]);
|
||||||
|
|
||||||
/**记录开始结束时间 */
|
/**记录开始结束时间 */
|
||||||
let queryRangePicker = ref<[string, string]>(['', '']);
|
let queryRangePicker = ref<[string, string]>(['', '']);
|
||||||
|
|
||||||
|
/**表格字段列 */
|
||||||
|
let tableColumns = ref<ColumnsType>([]);
|
||||||
|
|
||||||
/**表格字段列排序 */
|
/**表格字段列排序 */
|
||||||
let tableColumnsDnd = ref<ColumnsType>([]);
|
let tableColumnsDnd = ref<ColumnsType>([]);
|
||||||
|
|
||||||
|
/**表格分页器参数 */
|
||||||
|
let tablePagination = reactive({
|
||||||
|
/**当前页数 */
|
||||||
|
current: 1,
|
||||||
|
/**每页条数 */
|
||||||
|
pageSize: 20,
|
||||||
|
/**默认的每页条数 */
|
||||||
|
defaultPageSize: 20,
|
||||||
|
/**指定每页可以显示多少条 */
|
||||||
|
pageSizeOptions: ['10', '20', '50', '100'],
|
||||||
|
/**只有一页时是否隐藏分页器 */
|
||||||
|
hideOnSinglePage: false,
|
||||||
|
/**是否可以快速跳转至某页 */
|
||||||
|
showQuickJumper: true,
|
||||||
|
/**是否可以改变 pageSize */
|
||||||
|
showSizeChanger: true,
|
||||||
|
/**数据总数 */
|
||||||
|
total: 0,
|
||||||
|
showTotal: (total: number) => t('common.tablePaginationTotal', { total }),
|
||||||
|
onChange: (page: number, pageSize: number) => {
|
||||||
|
tablePagination.current = page;
|
||||||
|
tablePagination.pageSize = pageSize;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
/**表格状态类型 */
|
/**表格状态类型 */
|
||||||
type TabeStateType = {
|
type TabeStateType = {
|
||||||
/**表格列 */
|
|
||||||
tableColumns: object[];
|
|
||||||
/**加载等待 */
|
/**加载等待 */
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
/**紧凑型 */
|
/**紧凑型 */
|
||||||
@@ -37,7 +101,9 @@ type TabeStateType = {
|
|||||||
/**搜索栏 */
|
/**搜索栏 */
|
||||||
seached: boolean;
|
seached: boolean;
|
||||||
/**记录数据 */
|
/**记录数据 */
|
||||||
data: object[];
|
data: Record<string, any>[];
|
||||||
|
/**显示表格 */
|
||||||
|
showTable: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**表格状态 */
|
/**表格状态 */
|
||||||
@@ -47,6 +113,7 @@ let tableState: TabeStateType = reactive({
|
|||||||
size: 'middle',
|
size: 'middle',
|
||||||
seached: true,
|
seached: true,
|
||||||
data: [],
|
data: [],
|
||||||
|
showTable: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**表格紧凑型变更操作 */
|
/**表格紧凑型变更操作 */
|
||||||
@@ -56,295 +123,370 @@ function fnTableSize({ key }: MenuInfo) {
|
|||||||
|
|
||||||
/**查询参数 */
|
/**查询参数 */
|
||||||
let queryParams: any = reactive({
|
let queryParams: any = reactive({
|
||||||
/**卡片切换Flag */
|
/**网元类型 */
|
||||||
cardFlag: 0, //0-显示统计图 1-显示统计表
|
|
||||||
/**告警设备类型 */
|
|
||||||
neType: '',
|
neType: '',
|
||||||
/**告警网元标识 */
|
/**网元标识 */
|
||||||
neId: '',
|
neId: '',
|
||||||
/**颗粒度 */
|
/**颗粒度 */
|
||||||
particle: '15',
|
interval: 900,
|
||||||
beginTime: '',
|
/**开始时间 */
|
||||||
|
startTime: '',
|
||||||
|
/**结束时间 */
|
||||||
endTime: '',
|
endTime: '',
|
||||||
/**排序字段 */
|
/**排序字段 */
|
||||||
sortField: 'timeGroup',
|
sortField: 'timeGroup',
|
||||||
/**排序方式 */
|
/**排序方式 */
|
||||||
sortOrder: 'asc',
|
sortOrder: 'desc',
|
||||||
});
|
});
|
||||||
|
|
||||||
/**表格分页、排序、筛选变化时触发操作, 排序方式,取值为 ascend descend */
|
/**表格分页、排序、筛选变化时触发操作, 排序方式,取值为 ascend descend */
|
||||||
function fnTableChange(pagination: any, filters: any, sorter: any, extra: any) {
|
function fnTableChange(pagination: any, filters: any, sorter: any, extra: any) {
|
||||||
tableState.loading = true;
|
|
||||||
const { columnKey, order } = sorter;
|
const { columnKey, order } = sorter;
|
||||||
|
if (!order) return;
|
||||||
|
if (order.startsWith(queryParams.sortOrder)) return;
|
||||||
|
|
||||||
if (order) {
|
if (order) {
|
||||||
queryParams.sortField = columnKey;
|
queryParams.sortField = columnKey;
|
||||||
queryParams.sortOrder = order.replace('end', '');
|
queryParams.sortOrder = order.replace('end', '');
|
||||||
} else {
|
} else {
|
||||||
queryParams.sortOrder = 'asc';
|
queryParams.sortOrder = 'asc';
|
||||||
}
|
}
|
||||||
fnMakeTable(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**图表显示数据 */
|
fnGetList();
|
||||||
const chartsOption = reactive({
|
}
|
||||||
/**性能指标 */
|
|
||||||
perfChart: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
/**对象信息状态类型 */
|
/**对象信息状态类型 */
|
||||||
type StateType = {
|
type StateType = {
|
||||||
/**网元类型 */
|
/**网元类型 */
|
||||||
neType: string[];
|
neType: string[];
|
||||||
/**制表网元类型 */
|
/**图表配置数据 */
|
||||||
designNeType: string;
|
chartsOption: Record<string, any>;
|
||||||
/**黄金指标集 tree */
|
|
||||||
designTreeData: any[];
|
|
||||||
/**表单数据 */
|
|
||||||
from: Record<string, any>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**对象信息状态 */
|
/**对象信息状态 */
|
||||||
let state: StateType = reactive({
|
let state: StateType = reactive({
|
||||||
neType: [],
|
neType: [],
|
||||||
designNeType: '',
|
chartsOption: {},
|
||||||
designTreeData: [],
|
|
||||||
from: {
|
|
||||||
uploadLoading: false,
|
|
||||||
sendLoading: false,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**网元类型选择对应修改 */
|
function fnChangShowType() {
|
||||||
function fnNeChange(keys: any, _: any) {
|
tableState.showTable = !tableState.showTable;
|
||||||
// 不是同类型时需要重新加载
|
|
||||||
if (state.designNeType !== keys[0]) {
|
|
||||||
state.designTreeData = [];
|
|
||||||
queryParams.cardFlag = 0;
|
|
||||||
fnGetList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**查询可选命令列表 */
|
/**
|
||||||
function fnGetList() {
|
* 数据列表导出
|
||||||
const neType = queryParams.neType[0];
|
*/
|
||||||
state.designNeType = neType;
|
function fnRecordExport() {
|
||||||
|
Modal.confirm({
|
||||||
|
title: 'Tip',
|
||||||
|
content: t('views.perfManage.goldTarget.exportSure'),
|
||||||
|
onOk() {
|
||||||
|
const key = 'exportKPI';
|
||||||
|
message.loading({ content: t('common.loading'), key });
|
||||||
|
|
||||||
|
if (tableState.data.length <= 0) {
|
||||||
|
message.error({
|
||||||
|
content: t('views.perfManage.goldTarget.exportEmpty'),
|
||||||
|
key,
|
||||||
|
duration: 2,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tableColumnsTitleArr: string[] = [];
|
||||||
|
const tableColumnsKeyArr: string[] = [];
|
||||||
|
for (const columns of tableColumnsDnd.value) {
|
||||||
|
tableColumnsTitleArr.push(`${columns.title}`);
|
||||||
|
tableColumnsKeyArr.push(`${columns.key}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const kpiDataArr = [];
|
||||||
|
for (const item of tableState.data) {
|
||||||
|
const kpiData: Record<string, any> = {};
|
||||||
|
const keys = Object.keys(item);
|
||||||
|
for (let i = 0; i <= tableColumnsKeyArr.length; i++) {
|
||||||
|
for (const key of keys) {
|
||||||
|
if (tableColumnsKeyArr[i] === key) {
|
||||||
|
const title = tableColumnsTitleArr[i];
|
||||||
|
kpiData[title] = item[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kpiDataArr.push(kpiData);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeSheet(kpiDataArr, 'KPI', { header: tableColumnsTitleArr })
|
||||||
|
.then(fileBlob => saveAs(fileBlob, `kpi_data_${Date.now()}.xlsx`))
|
||||||
|
.finally(() => {
|
||||||
|
message.success({
|
||||||
|
content: t('common.msgSuccess', { msg: t('common.export') }),
|
||||||
|
key,
|
||||||
|
duration: 2,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**查询数据列表表头 */
|
||||||
|
function fnGetListTitle() {
|
||||||
|
// 当前语言
|
||||||
var language = currentLocale.value.split('_')[0];
|
var language = currentLocale.value.split('_')[0];
|
||||||
if (language === 'zh') language = 'cn';
|
if (language === 'zh') language = 'cn';
|
||||||
getGoldTitleByNE(neType).then(res => {
|
|
||||||
|
// 获取表头文字
|
||||||
|
getKPITitle(state.neType[0])
|
||||||
|
.then(res => {
|
||||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||||
// 构建树结构
|
tableColumns.value = [];
|
||||||
const treeArr: Record<string, any>[] = [];
|
const columns: ColumnsType = [
|
||||||
|
{
|
||||||
|
title: t('views.perfManage.perfData.neName'),
|
||||||
|
dataIndex: 'neName',
|
||||||
|
key: 'neName',
|
||||||
|
align: 'left',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
];
|
||||||
for (const item of res.data) {
|
for (const item of res.data) {
|
||||||
const id = item['id'];
|
|
||||||
const kpiDisplay = item[`${language}Title`];
|
const kpiDisplay = item[`${language}Title`];
|
||||||
const kpiValue = item[`kpiId`];
|
const kpiValue = item[`kpiId`];
|
||||||
treeArr.push({
|
columns.push({
|
||||||
key: kpiValue,
|
|
||||||
title: kpiDisplay,
|
title: kpiDisplay,
|
||||||
|
dataIndex: kpiValue,
|
||||||
|
align: 'left',
|
||||||
|
key: kpiValue,
|
||||||
|
resizable: true,
|
||||||
|
width: 100,
|
||||||
|
minWidth: 150,
|
||||||
|
maxWidth: 300,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
state.designTreeData = treeArr;
|
columns.push({
|
||||||
|
title: t('views.perfManage.goldTarget.time'),
|
||||||
|
dataIndex: 'timeGroup',
|
||||||
|
align: 'left',
|
||||||
|
fixed: 'right',
|
||||||
|
key: 'timeGroup',
|
||||||
|
sorter: true,
|
||||||
|
width: 100,
|
||||||
|
});
|
||||||
|
nextTick(() => {
|
||||||
|
tableColumns.value = columns;
|
||||||
|
});
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
message.warning({
|
message.warning({
|
||||||
content: t('common.getInfoFail'),
|
content: t('common.getInfoFail'),
|
||||||
duration: 2,
|
duration: 2,
|
||||||
});
|
});
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.then(result => {
|
||||||
|
result && fnGetList();
|
||||||
});
|
});
|
||||||
fnDesign();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**根据 key 查找对应的 title */
|
/**查询数据列表 */
|
||||||
function findTitleByKey(key: string): string | undefined {
|
function fnGetList() {
|
||||||
const item = state.designTreeData.find(item => item.key === key);
|
if (tableState.loading) return;
|
||||||
return item ? item.title : key;
|
tableState.loading = true;
|
||||||
}
|
queryParams.neType = state.neType[0];
|
||||||
|
queryParams.neId = state.neType[1];
|
||||||
/**筛选条件进行制图 */
|
queryParams.startTime = queryRangePicker.value[0];
|
||||||
function fnMakeTable(flag: any) {
|
|
||||||
queryParams.cardFlag = flag;
|
|
||||||
fnDesign();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**筛选条件进行制图 */
|
|
||||||
function fnDesign() {
|
|
||||||
//当前界面是表格界面
|
|
||||||
const columnsArr = state.designTreeData.map(item => {
|
|
||||||
return {
|
|
||||||
title: item.title,
|
|
||||||
dataIndex: item.key,
|
|
||||||
align: 'center',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
tableState.tableColumns = columnsArr;
|
|
||||||
tableState.tableColumns.unshift({
|
|
||||||
title: t('views.perfManage.perfData.neName'),
|
|
||||||
dataIndex: 'neName',
|
|
||||||
align: 'center',
|
|
||||||
});
|
|
||||||
tableState.tableColumns.push({
|
|
||||||
title: t('views.perfManage.goldTarget.time'),
|
|
||||||
dataIndex: 'timeGroup',
|
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
|
||||||
key: 'timeGroup',
|
|
||||||
sorter: true,
|
|
||||||
});
|
|
||||||
if (!queryRangePicker.value) {
|
|
||||||
queryRangePicker.value = ['', ''];
|
|
||||||
}
|
|
||||||
queryParams.beginTime = queryRangePicker.value[0];
|
|
||||||
queryParams.endTime = queryRangePicker.value[1];
|
queryParams.endTime = queryRangePicker.value[1];
|
||||||
let goldXDate: any = [];
|
listKPIData(toRaw(queryParams))
|
||||||
let goldYData: any = [];
|
|
||||||
let hideAll: any = {};
|
|
||||||
goldData(queryParams)
|
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
tableState.loading = false;
|
||||||
if (res.data.length > 0) {
|
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||||
console.log(res.data);
|
tablePagination.total = res.data.length;
|
||||||
tableState.data = res.data;
|
tableState.data = res.data;
|
||||||
goldXDate = res.data.map((item: any) => item.timeGroup);
|
return true;
|
||||||
goldYData = Object.keys(res.data[0])
|
}
|
||||||
.filter(key => !['timeGroup', 'neName', 'startIndex'].includes(key))
|
return false;
|
||||||
.map(key => {
|
})
|
||||||
const title: any = findTitleByKey(key);
|
.then(result => {
|
||||||
hideAll[title] = false;
|
if (result) {
|
||||||
return {
|
if (kpiChart.value == null) {
|
||||||
name: title,
|
fnRanderChart();
|
||||||
data: res.data.map((item: any) => parseInt(item[key])),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
tableState.data = [];
|
fnRanderChartData();
|
||||||
state.designTreeData.forEach((item: any) => {
|
}
|
||||||
goldYData.push({ name: item.title, data: [] });
|
}
|
||||||
});
|
});
|
||||||
message.warning({
|
}
|
||||||
content: t('views.perfManage.goldTarget.nullTip'),
|
|
||||||
duration: 2,
|
/**绘制图表 */
|
||||||
|
function fnRanderChart() {
|
||||||
|
const container: HTMLElement | undefined = kpiChartDom.value;
|
||||||
|
if (!container) return;
|
||||||
|
kpiChart.value = markRaw(echarts.init(container, 'light'));
|
||||||
|
|
||||||
|
fnRanderChartData();
|
||||||
|
|
||||||
|
// 创建 ResizeObserver 实例
|
||||||
|
var observer = new ResizeObserver(entries => {
|
||||||
|
if (kpiChart.value) {
|
||||||
|
kpiChart.value.resize();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
// 监听元素大小变化
|
||||||
|
observer.observe(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**面积颜色 */
|
||||||
|
const areaStyleColor = [
|
||||||
|
{
|
||||||
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
|
{
|
||||||
|
offset: 0,
|
||||||
|
color: 'rgba(22, 119, 255, .5)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
offset: 1,
|
||||||
|
color: 'rgba(22, 119, 255, 0)',
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
|
{
|
||||||
|
offset: 0,
|
||||||
|
color: 'rgba(82, 196, 26, .5)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
offset: 1,
|
||||||
|
color: 'rgba(82, 196, 26, 0)',
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
|
{
|
||||||
|
offset: 0,
|
||||||
|
color: 'rgba(250, 173, 20, .5)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
offset: 1,
|
||||||
|
color: 'rgba(250, 173, 20, 0)',
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||||
|
{
|
||||||
|
offset: 0,
|
||||||
|
color: 'rgba(255, 77, 79, 0.5)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
offset: 1,
|
||||||
|
color: 'rgba(255, 77, 79, 0)',
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/**图表数据渲染 */
|
||||||
|
function fnRanderChartData() {
|
||||||
|
if (kpiChart.value == null && tableState.data.length <= 0) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图标参数
|
const xDatas: string[] = [];
|
||||||
const option = {
|
const yDatas: Record<string, any>[] = [];
|
||||||
xDatas: goldXDate,
|
|
||||||
yDatas: goldYData,
|
const tableColumnsKeyArr: string[] = [];
|
||||||
|
|
||||||
|
const columnsLen = tableColumnsDnd.value.length;
|
||||||
|
for (let i = 0; i < columnsLen; i++) {
|
||||||
|
const columns = tableColumnsDnd.value[i];
|
||||||
|
if (
|
||||||
|
columns.key === 'neName' ||
|
||||||
|
columns.key === 'startIndex' ||
|
||||||
|
columns.key === 'timeGroup'
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
yDatas.push({
|
||||||
|
name: `${columns.title}`,
|
||||||
|
type: 'line',
|
||||||
|
symbol: 'none',
|
||||||
|
sampling: 'lttb',
|
||||||
|
itemStyle: {
|
||||||
|
color: 'rgb(255, 70, 131)',
|
||||||
|
},
|
||||||
|
areaStyle: areaStyleColor[i % columnsLen],
|
||||||
|
data: [],
|
||||||
|
});
|
||||||
|
tableColumnsKeyArr.push(`${columns.key}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用降序就反转
|
||||||
|
let orgData = tableState.data;
|
||||||
|
if (queryParams.sortOrder === 'desc') {
|
||||||
|
orgData = orgData.toReversed();
|
||||||
|
}
|
||||||
|
for (const item of orgData) {
|
||||||
|
xDatas.push(item['timeGroup']);
|
||||||
|
const keys = Object.keys(item);
|
||||||
|
for (let i = 0; i < tableColumnsKeyArr.length; i++) {
|
||||||
|
for (const key of keys) {
|
||||||
|
if (tableColumnsKeyArr[i] === key) {
|
||||||
|
yDatas[i].data.push(+item[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// console.log(queryParams.sortOrder, xDatas, yDatas);
|
||||||
|
|
||||||
|
const option: EChartsOption = {
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: 'axis',
|
trigger: 'axis',
|
||||||
formatter: function (datas: any) {
|
position: function (pt: any) {
|
||||||
let res = datas[0].name + '<br/>';
|
return [pt[0], '10%'];
|
||||||
for (const item of datas) {
|
|
||||||
res += `${item.marker} ${item.seriesName}:${item.data}<br/>`;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
boundaryGap: false,
|
||||||
|
data: xDatas,
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
type: 'value',
|
||||||
|
boundaryGap: [0, '100%'],
|
||||||
|
},
|
||||||
legend: {
|
legend: {
|
||||||
// orient: 'vertical',
|
|
||||||
// left: 'left',
|
|
||||||
type: 'scroll',
|
type: 'scroll',
|
||||||
orient: 'vertical', // vertical
|
orient: 'vertical',
|
||||||
|
top: 40,
|
||||||
right: 20,
|
right: 20,
|
||||||
//itemWidth: 20,
|
itemWidth: 20,
|
||||||
itemGap: 25,
|
itemGap: 25,
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: '#646A73',
|
color: '#646A73',
|
||||||
},
|
},
|
||||||
icon: 'circle',
|
icon: 'circle',
|
||||||
selected: hideAll,
|
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
left: '10%',
|
left: '10%',
|
||||||
right: '30%',
|
right: '30%',
|
||||||
bottom: '20%',
|
bottom: '20%',
|
||||||
},
|
},
|
||||||
yAxis: [
|
dataZoom: [
|
||||||
{ type: 'value', splitNumber: 4, axisLabel: { fontSize: 10 } },
|
{
|
||||||
],
|
type: 'inside',
|
||||||
};
|
start: 90,
|
||||||
chartsOption.perfChart = option;
|
end: 100,
|
||||||
|
|
||||||
//处理表格数据
|
|
||||||
} else {
|
|
||||||
message.warning({
|
|
||||||
content: t('common.getInfoFail'),
|
|
||||||
duration: 2,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
tableState.loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出全部
|
|
||||||
*/
|
|
||||||
function fnExportAll() {
|
|
||||||
Modal.confirm({
|
|
||||||
title: 'Tip',
|
|
||||||
content: t('views.perfManage.goldTarget.exportSure'),
|
|
||||||
onOk() {
|
|
||||||
const key = 'exportAlarm';
|
|
||||||
message.loading({ content: t('common.loading'), key });
|
|
||||||
let sortArr: any = [];
|
|
||||||
tableColumnsDnd.value.forEach((item: any) => {
|
|
||||||
if (item.dataIndex) sortArr.push(item.title);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 排序字段
|
|
||||||
const sortData = {
|
|
||||||
header: sortArr,
|
|
||||||
};
|
|
||||||
if (!queryRangePicker.value) {
|
|
||||||
queryRangePicker.value = ['', ''];
|
|
||||||
}
|
|
||||||
queryParams.beginTime = queryRangePicker.value[0];
|
|
||||||
queryParams.endTime = queryRangePicker.value[1];
|
|
||||||
goldData(queryParams).then(res => {
|
|
||||||
if (res.code === RESULT_CODE_SUCCESS) {
|
|
||||||
message.success({
|
|
||||||
content: t('common.msgSuccess', { msg: t('common.export') }),
|
|
||||||
key,
|
|
||||||
duration: 3,
|
|
||||||
});
|
|
||||||
let realArr: any = [];
|
|
||||||
res.data.map((item: any) => {
|
|
||||||
const chineseData: any = {};
|
|
||||||
for (const key in item) {
|
|
||||||
const title: any = findTitleByKey(key);
|
|
||||||
if (['timeGroup', 'neName', 'startIndex'].includes(title)) {
|
|
||||||
switch (title) {
|
|
||||||
case 'timeGroup':
|
|
||||||
chineseData[t('views.perfManage.goldTarget.time')] =
|
|
||||||
item[key];
|
|
||||||
break;
|
|
||||||
case 'neName':
|
|
||||||
chineseData[t('views.perfManage.perfData.neName')] =
|
|
||||||
item[key];
|
|
||||||
break;
|
|
||||||
case 'startIndex':
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else chineseData[title] = item[key];
|
|
||||||
}
|
|
||||||
realArr.push(chineseData);
|
|
||||||
});
|
|
||||||
|
|
||||||
writeSheet(realArr, 'gold', sortData).then(fileBlob =>
|
|
||||||
saveAs(fileBlob, `gold_${Date.now()}.xlsx`)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
message.error({
|
|
||||||
content: `${res.msg}`,
|
|
||||||
key,
|
|
||||||
duration: 3,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
{
|
||||||
|
start: 90,
|
||||||
|
end: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
series: yDatas,
|
||||||
|
};
|
||||||
|
kpiChart.value.setOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -365,26 +507,27 @@ onMounted(() => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 默认选择AMF
|
// 默认选择UPF
|
||||||
const item = neCascaderOptions.value.find(s => s.value === 'UPF');
|
const item = neCascaderOptions.value.find(s => s.value === 'UPF');
|
||||||
if (item && item.children) {
|
if (item && item.children) {
|
||||||
const info = item.children[0];
|
const info = item.children[0];
|
||||||
queryParams.neType = [info.neType, info.neId];
|
state.neType = [info.neType, info.neId];
|
||||||
|
queryParams.neType = info.neType;
|
||||||
|
queryParams.neId = info.neId;
|
||||||
} else {
|
} else {
|
||||||
const info = neCascaderOptions.value[0].children[0];
|
const info = neCascaderOptions.value[0].children[0];
|
||||||
queryParams.neType = [info.neType, info.neId];
|
state.neType = [info.neType, info.neId];
|
||||||
|
queryParams.neType = info.neType;
|
||||||
|
queryParams.neId = info.neId;
|
||||||
}
|
}
|
||||||
const initTime: Date = new Date();
|
|
||||||
const startTime: Date = new Date(initTime);
|
|
||||||
startTime.setHours(0, 0, 0, 0); // 设置为今天的0点
|
|
||||||
const endTime: Date = new Date(initTime);
|
|
||||||
endTime.setHours(23, 59, 59, 59); // 设置为今天的12点
|
|
||||||
|
|
||||||
queryRangePicker.value = [
|
// 查询当天数据
|
||||||
parseDateToStr(startTime),
|
const nowDate: Date = new Date();
|
||||||
parseDateToStr(endTime),
|
nowDate.setHours(0, 0, 0, 0); // 设置为今天的0点
|
||||||
];
|
queryRangePicker.value[0] = '2024-01-31 00:00:00'; //parseDateToStr(nowDate);
|
||||||
fnGetList();
|
nowDate.setHours(23, 59, 59, 59); // 设置为今天的12点
|
||||||
|
queryRangePicker.value[1] = parseDateToStr(nowDate);
|
||||||
|
fnGetListTitle();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message.warning({
|
message.warning({
|
||||||
@@ -412,9 +555,8 @@ onMounted(() => {
|
|||||||
:label="t('views.traceManage.task.neType')"
|
:label="t('views.traceManage.task.neType')"
|
||||||
>
|
>
|
||||||
<a-cascader
|
<a-cascader
|
||||||
v-model:value="queryParams.neType"
|
v-model:value="state.neType"
|
||||||
:options="neCascaderOptions"
|
:options="neCascaderOptions"
|
||||||
@change="fnNeChange"
|
|
||||||
:allow-clear="false"
|
:allow-clear="false"
|
||||||
:placeholder="t('common.selectPlease')"
|
:placeholder="t('common.selectPlease')"
|
||||||
/>
|
/>
|
||||||
@@ -436,11 +578,11 @@ onMounted(() => {
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :lg="4" :md="12" :xs="24">
|
<a-col :lg="4" :md="12" :xs="24">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
:label="t('views.perfManage.goldTarget.particle')"
|
:label="t('views.perfManage.goldTarget.interval')"
|
||||||
name="particle"
|
name="interval"
|
||||||
>
|
>
|
||||||
<a-select
|
<a-select
|
||||||
v-model:value="queryParams.particle"
|
v-model:value="queryParams.interval"
|
||||||
:placeholder="t('common.selectPlease')"
|
:placeholder="t('common.selectPlease')"
|
||||||
:options="[
|
:options="[
|
||||||
{ label: '5S', value: 5 },
|
{ label: '5S', value: 5 },
|
||||||
@@ -456,7 +598,7 @@ onMounted(() => {
|
|||||||
<a-col :lg="2" :md="12" :xs="24">
|
<a-col :lg="2" :md="12" :xs="24">
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<a-space :size="8">
|
<a-space :size="8">
|
||||||
<a-button type="primary" @click.prevent="fnDesign()">
|
<a-button type="primary" @click.prevent="fnGetListTitle()">
|
||||||
<template #icon><SearchOutlined /></template>
|
<template #icon><SearchOutlined /></template>
|
||||||
{{ t('common.search') }}
|
{{ t('common.search') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
@@ -467,25 +609,34 @@ onMounted(() => {
|
|||||||
</a-form>
|
</a-form>
|
||||||
</a-card>
|
</a-card>
|
||||||
|
|
||||||
<template v-if="queryParams.cardFlag">
|
|
||||||
<a-card :bordered="false" :body-style="{ padding: '0px' }">
|
<a-card :bordered="false" :body-style="{ padding: '0px' }">
|
||||||
<!-- 插槽-卡片左侧侧 -->
|
<!-- 插槽-卡片左侧侧 -->
|
||||||
<template #title>
|
<template #title>
|
||||||
<a-space :size="8" align="center">
|
<a-space :size="8" align="center">
|
||||||
<a-button type="primary" @click.prevent="fnMakeTable(0)">
|
<a-button type="primary" @click.prevent="fnChangShowType()">
|
||||||
<template #icon> <area-chart-outlined /> </template>
|
<template #icon> <AreaChartOutlined /> </template>
|
||||||
{{ t('views.perfManage.goldTarget.kpiTitle') }}
|
{{
|
||||||
|
tableState.showTable
|
||||||
|
? t('views.perfManage.goldTarget.kpiChartTitle')
|
||||||
|
: t('views.perfManage.goldTarget.kpiTableTitle')
|
||||||
|
}}
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button type="primary" @click.prevent="fnExportAll()">
|
<a-button
|
||||||
<template #icon> <export-outlined /> </template>
|
type="dashed"
|
||||||
{{ t('views.faultManage.activeAlarm.exportAll') }}
|
@click.prevent="fnRecordExport()"
|
||||||
|
v-show="tableState.showTable"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<ExportOutlined />
|
||||||
|
</template>
|
||||||
|
{{ t('common.export') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- 插槽-卡片右侧 -->
|
<!-- 插槽-卡片右侧 -->
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<a-space :size="8" align="center">
|
<a-space :size="8" align="center" v-show="tableState.showTable">
|
||||||
<a-tooltip>
|
<a-tooltip>
|
||||||
<template #title>{{ t('common.searchBarText') }}</template>
|
<template #title>{{ t('common.searchBarText') }}</template>
|
||||||
<a-switch
|
<a-switch
|
||||||
@@ -502,7 +653,8 @@ onMounted(() => {
|
|||||||
</a-button>
|
</a-button>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<TableColumnsDnd
|
<TableColumnsDnd
|
||||||
:columns="tableState.tableColumns"
|
v-if="tableColumns.length > 0"
|
||||||
|
:columns="tableColumns"
|
||||||
v-model:columns-dnd="tableColumnsDnd"
|
v-model:columns-dnd="tableColumnsDnd"
|
||||||
></TableColumnsDnd>
|
></TableColumnsDnd>
|
||||||
<a-tooltip>
|
<a-tooltip>
|
||||||
@@ -534,50 +686,27 @@ onMounted(() => {
|
|||||||
|
|
||||||
<!-- 表格列表 -->
|
<!-- 表格列表 -->
|
||||||
<a-table
|
<a-table
|
||||||
|
v-show="tableState.showTable"
|
||||||
class="table"
|
class="table"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
:columns="tableColumnsDnd"
|
:columns="tableColumnsDnd"
|
||||||
:loading="tableState.loading"
|
:loading="tableState.loading"
|
||||||
:data-source="tableState.data"
|
:data-source="tableState.data"
|
||||||
:size="tableState.size"
|
:size="tableState.size"
|
||||||
:pagination="false"
|
:pagination="tablePagination"
|
||||||
:scroll="{ x: tableColumnsDnd.length * 200, y: 450 }"
|
:scroll="{ x: tableColumnsDnd.length * 200, y: 450 }"
|
||||||
@resizeColumn="(w:number, col:any) => (col.width = w)"
|
@resizeColumn="(w:number, col:any) => (col.width = w)"
|
||||||
:show-expand-column="false"
|
:show-expand-column="false"
|
||||||
@change="fnTableChange"
|
@change="fnTableChange"
|
||||||
>
|
>
|
||||||
</a-table>
|
</a-table>
|
||||||
</a-card>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<a-card :bordered="false" :body-style="{ marginBottom: '24px' }" v-else>
|
<!-- 图表 -->
|
||||||
<!-- 插槽-卡片左侧侧 -->
|
<div style="padding: 24px" v-show="!tableState.showTable">
|
||||||
<template #title>{{
|
<div ref="kpiChartDom" style="height: 450px; width: 100%"></div>
|
||||||
t('views.perfManage.goldTarget.kpiTitle')
|
|
||||||
}}</template>
|
|
||||||
<!-- 插槽-卡片右侧 -->
|
|
||||||
<template #extra>
|
|
||||||
<a-space :size="8" align="center">
|
|
||||||
<a-button type="default" size="small" @click.prevent="fnMakeTable(1)">
|
|
||||||
<template #icon> <bars-outlined /> </template>
|
|
||||||
{{ t('views.perfManage.goldTarget.allData') }}
|
|
||||||
</a-button>
|
|
||||||
</a-space>
|
|
||||||
</template>
|
|
||||||
<div class="chart">
|
|
||||||
<ChartLine
|
|
||||||
:option="chartsOption.perfChart"
|
|
||||||
:dataZoom="false"
|
|
||||||
height="400px"
|
|
||||||
></ChartLine>
|
|
||||||
</div>
|
</div>
|
||||||
</a-card>
|
</a-card>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped></style>
|
||||||
.chart {
|
|
||||||
width: 100%;
|
|
||||||
height: 400px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user