From 346b6f8d306aba92d45ac7ce6ee31be3d38662ad Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 05 十一月 2024 16:25:10 +0800 Subject: [PATCH] 缓存列 --- src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue index f8b63a0..5aa82d0 100644 --- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue +++ b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue @@ -220,24 +220,27 @@ }; // 缁熻琛ㄦ牸锛岄渶瑕佸鍔犵疮璁″�艰锛屼互鍙婃瘮渚嬪垪 const tableValues = ref(getTableValues(props.data)); - +const storeCols = (colList: any[]) => { + const key = colList.map((item) => item.label).join(','); + if (!key) return; + Local.set(key, colList); +}; 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 getStoreCols = (colList: any[]) => { + if (colList.length === 0) return colList; + const key = colList.map((item) => item.label).join(','); + if (!key) return colList; const storeValue = Local.get(key); if (!storeValue) { - Local.set(key, originCols); + return colList; + } else { + return storeValue; } - - return [!!storeValue, storeValue]; }; + watchEffect(() => { - colList.value = + const originData = tableCols.value?.map((item, index) => { let isShow = true; if (props.data.max_cols != null) { @@ -252,6 +255,9 @@ isShow: isShow, } as TableCol; }) ?? []; + + const storeCols = getStoreCols(originData); + colList.value = storeCols; }); // 鎵�鏈夋樉绀虹殑 prop @@ -556,6 +562,7 @@ const colFilterChange = () => { // 閲嶆柊璁$畻瀹藉害 reloadTable(); + storeCols(colList.value); }; const tableHeight = ref(0.7 * document.body.clientHeight); -- Gitblit v1.9.3