From 51676a39b4c5634f4d6fdbbd831d40c7721f8e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Mon, 26 May 2025 10:19:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(components):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=A0=B7=E5=BC=8F=E5=92=8C=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -调整表格样式,增加右内边距 - 优化饼图数据处理,移除空数据- 修改表格视图 HTML 样式,使用 flex 布局 --- src/components/YlTable/Index.vue | 8 +++-- .../AnalysisInfo/hooks/pieSeries.ts | 29 ++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/components/YlTable/Index.vue b/src/components/YlTable/Index.vue index 345850f..2873b60 100644 --- a/src/components/YlTable/Index.vue +++ b/src/components/YlTable/Index.vue @@ -123,14 +123,13 @@ function tooptipFormatter(data: { row: any; column: any; cellValue: any }): VNod :row-class-name="setStripeColor" :data="data" :empty-text="emptyText" - style="width: 100%" + style="width: 100%; padding-right: 10px" > diff --git a/src/views/Survey/views/Analysis/components/AnalysisInfo/hooks/pieSeries.ts b/src/views/Survey/views/Analysis/components/AnalysisInfo/hooks/pieSeries.ts index 50d88aa..cb98e99 100644 --- a/src/views/Survey/views/Analysis/components/AnalysisInfo/hooks/pieSeries.ts +++ b/src/views/Survey/views/Analysis/components/AnalysisInfo/hooks/pieSeries.ts @@ -21,11 +21,12 @@ export const series = ref({ } }); -export function formatData(data: any, index: number) { +export function formatData(data: any, index: number, isEmpty: boolean = true) { const _series = JSON.parse(JSON.stringify(series.value)); // 当内容为单选的时候处理方式 if (data.question_type === 1 || data.question_type === 2) { - const { option } = data; + let { option } = data; + _series.data = option.map((item: any) => { return { ...item, @@ -34,14 +35,26 @@ export function formatData(data: any, index: number) { questionItem: { ...data } }; }); + + if (isEmpty) { + _series.data = _series.data.filter((item) => item.value != 0); + } } if ( - data.question_type === 5 - || data.question_type === 9 - || data.question_type === 106 - || data.question_type === 10 + data.question_type === 5 || + data.question_type === 9 || + data.question_type === 106 || + data.question_type === 10 ) { - const copyData = setDimensionData(data); + let copyData = setDimensionData(data); + + // copyData 删除 value 为0 的数据 + if (isEmpty) { + copyData = copyData.map((item) => { + return item.filter((item) => item.value !== 0); + }); + } + _series.data = copyData[index || 0]?.map((item) => { return { ...item, @@ -54,7 +67,7 @@ export function formatData(data: any, index: number) { return _series; } -export function getTableData(data: any) { +export function getTableData(data: any, isEmpty = true) { const analysis = JSON.parse(JSON.stringify(data)); const rows = analysis.option || []; return rows.map((rowItem: any) => {