diff --git a/src/components/YlTable/Index.vue b/src/components/YlTable/Index.vue index 467e9c6..089732e 100644 --- a/src/components/YlTable/Index.vue +++ b/src/components/YlTable/Index.vue @@ -123,7 +123,7 @@ 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) => {