From 805e34f582afd0a547322b4fa4ed68cb6894c64f Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期一, 04 十一月 2024 13:50:20 +0800
Subject: [PATCH] storeCols

---
 src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
index 2bcc031..f8b63a0 100644
--- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
+++ b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue
@@ -113,6 +113,7 @@
 import { PATH_ICON } from '../../../common';
 import { ChartTypeEnum } from '../../../types';
 import { axisLabelFormatter } from '/@/utils/chart';
+import { Local } from '/@/utils/storage';
 
 const props = defineProps({
 	data: {
@@ -146,8 +147,10 @@
 };
 
 const isTotalTable = computed(() => checkIsTotalTable(props.data));
+
 const getTableCols = (propsData) => {
 	const current = propsData?.cols ?? [];
+
 	if (checkIsTotalTable(propsData)) {
 		current.push({
 			title: '姣斾緥',
@@ -219,6 +222,20 @@
 const tableValues = ref(getTableValues(props.data));
 
 const colList = ref([]);
+
+const storeCols = (originCols: any[]) => {
+	let isStored = false;
+	if (originCols.length === 0) return [isStored, originCols];
+	const key = originCols.map((item) => item.title).join(',');
+	if (!key) return [isStored, originCols];
+	const storeValue = Local.get(key);
+
+	if (!storeValue) {
+		Local.set(key, originCols);
+	}
+
+	return [!!storeValue, storeValue];
+};
 watchEffect(() => {
 	colList.value =
 		tableCols.value?.map((item, index) => {
@@ -291,9 +308,7 @@
 		return values;
 	}
 
-
-
-	const groupData = getItemMap(values,curGroupIndex,true)
+	const groupData = getItemMap(values, curGroupIndex, true);
 	// 椤哄欢涓嬩竴涓垎缁�
 	i++;
 	// 閲嶆柊鎺掑竷涓�涓嬩綅缃紝淇濊瘉 group 鐩搁偦锛屽悓鏃舵墦涓� rowspan
@@ -311,7 +326,7 @@
 	return result;
 };
 
- const getItemMap = <T>(arr: T[], defaultProps = 'ID', isMultiple = false) => {
+const getItemMap = <T>(arr: T[], defaultProps = 'ID', isMultiple = false) => {
 	if (!arr || arr.length === 0) return {};
 
 	const result = arr.reduce((acc, curr) => {
@@ -319,7 +334,9 @@
 			if (!acc.get(curr[defaultProps])) {
 				acc.set(curr[defaultProps], [curr]);
 			} else {
-				{/* acc[curr[defaultProps]].push(curr); */}
+				{
+					/* acc[curr[defaultProps]].push(curr); */
+				}
 				acc.get(curr[defaultProps]).push(curr);
 			}
 		} else {
@@ -359,7 +376,7 @@
 	for (const item of tableValues.value) {
 		item.map((subItem, index) => {
 			// subItem 鍙兘鏄� 鏁板瓧
-			const subItemLen = (subItem +'')?.gblen();
+			const subItemLen = (subItem + '')?.gblen();
 			if (maxLenList[index] < subItemLen) {
 				maxLenList[index] = subItemLen;
 				maxStrList[index] = subItem;
@@ -523,18 +540,19 @@
 	tableRef.value.doLayout();
 
 	// pager.index = 1;
-	chunkTableData.value = (_.chunk(tableValues.value ?? [], pager.size));
+	chunkTableData.value = _.chunk(tableValues.value ?? [], pager.size);
 };
 
 //#endregion
 
-const tableData = computed(()=>buildGroupData(chunkTableData.value[pager.index - 1]))
+const tableData = computed(() => buildGroupData(chunkTableData.value[pager.index - 1]));
 
 const reloadTable = () => {
 	// 閲嶆柊璁$畻瀹藉害
 
 	resizeEvent({ width: containerRef.value.clientWidth, height: containerRef.value.clientHeight });
 };
+
 const colFilterChange = () => {
 	// 閲嶆柊璁$畻瀹藉害
 	reloadTable();

--
Gitblit v1.9.3