refactor(components): 优化表格样式和图表数据处理
-调整表格样式,增加右内边距 - 优化饼图数据处理,移除空数据- 修改表格视图 HTML 样式,使用 flex 布局
This commit is contained in:
@@ -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"
|
||||
>
|
||||
<el-table-column
|
||||
v-for="item in props"
|
||||
:width="item.width"
|
||||
:prop="item.prop"
|
||||
:label="item.label"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="scope">
|
||||
<slot name="column-default" :scope="scope">
|
||||
@@ -147,9 +146,14 @@ function tooptipFormatter(data: { row: any; column: any; cellValue: any }): VNod
|
||||
</template>
|
||||
<style>
|
||||
.table-view-html {
|
||||
display: flex;
|
||||
//align-items: center;
|
||||
flex-direction: row;
|
||||
|
||||
& img {
|
||||
width: 50px;
|
||||
height: 100%;
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user