From b70c8e7689a1ddc6e684cbf6a796440d950ba5ba Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期三, 23 十月 2024 17:30:21 +0800
Subject: [PATCH] 优化 列表->图表

---
 src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue |   39 ++++++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
index f7b6056..2fa6d81 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
+++ b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
@@ -28,10 +28,10 @@
 					:header-cell-style="tableHeaderCellStyle"
 					:data="chunkTableData[pager.index - 1]"
 					@row-click="recordSelectChange"
-					rowClassName="cursor-pointer"
 					:spanMethod="objectSpanMethod"
 					class="w-full h-full"
 					highlightCurrentRow
+					:rowClassName="tableRowClassName"
 					cellClassName="text-sm"
 					headerCellClassName="text-sm"
 				>
@@ -197,11 +197,20 @@
 			totalRow[rateColIndex] = '100%';
 			// 鍚堣鎬绘暟
 			totalRow[valueColIndex] = sumValue + '';
-
+			(totalRow as any).isTotal = true;
 			current.push(totalRow);
 		}
 	}
 	return current;
+};
+
+const tableRowClassName = ({ row, rowIndex }) => {
+	let className = 'cursor-pointer';
+	if (row.isTotal) {
+		const bgColor = '!bg-[#c5d9f1]';
+		className += ` font-bold ${bgColor} hover:${bgColor} active:${bgColor}`;
+	}
+	return className;
 };
 // 缁熻琛ㄦ牸锛岄渶瑕佸鍔犵疮璁″�艰锛屼互鍙婃瘮渚嬪垪
 const tableValues = ref(getTableValues(props.data));
@@ -768,7 +777,7 @@
 	groupTitle = groupCols[groupCols.length - 1].title;
 
 	const data = groupValues.map((item) => {
-		const groupName = item.filter((item, index) => !excludeIndex.includes(index) && index !== valueColIndex).join(',');
+		const groupName = item.filter((item, index) => !excludeIndex.includes(index) && index !== valueColIndex).join('_');
 		const value = item[valueColIndex];
 		return {
 			value,
@@ -779,12 +788,6 @@
 	return data;
 };
 
-const getTooltip = () => {
-	return {
-		trigger: 'item',
-		valueFormatter: (value) => `${value} / ${toPercent(sumValue === 0 ? 0 : (value as number) / sumValue, true, 2)}`,
-	} as any;
-};
 
 const getCommonOption = () => {
 	return {
@@ -801,6 +804,10 @@
 			// orient:'vertical',
 			top: 33,
 			left: 'center',
+		},
+		tooltip: {
+			trigger: 'item',
+			valueFormatter: (value) => `${value} / ${toPercent(sumValue === 0 ? 0 : (value as number) / sumValue, true, 2)}`,
 		},
 	} as echarts.EChartsOption;
 };
@@ -867,8 +874,8 @@
 				// 		return value;
 				// 	}
 				// },
-				width:86,
-				overflow:'truncate',
+				width: 86,
+				overflow: 'truncate',
 				// nameTruncate: {
 				// 	maxWidth: 52,
 				// },
@@ -919,8 +926,8 @@
 	}
 
 	const option: echarts.EChartsOption = {
-		...getCommonOption,
-		tooltip: getTooltip(),
+		...getCommonOption(),
+
 		toolbox: {
 			show: true,
 			feature: {
@@ -932,8 +939,7 @@
 						activeChartType = ChartTypeEnum.Bar;
 						chartInstance.value.setOption(
 							{
-								...getCommonOption,
-								tooltip: getTooltip(),
+								...getCommonOption(),
 
 								toolbox: option.toolbox,
 								...getBarOption(chartData),
@@ -953,8 +959,7 @@
 						activeChartType = ChartTypeEnum.Pie;
 						chartInstance.value.setOption(
 							{
-								...getCommonOption,
-								tooltip: getTooltip(),
+								...getCommonOption(),
 								toolbox: option.toolbox,
 								...getPieOption(chartData),
 							},

--
Gitblit v1.9.3