From bfe893e818c75815b249fbfaed954458930d5600 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期日, 29 九月 2024 10:53:29 +0800 Subject: [PATCH] recordSetTable group --- src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue index f1f59ae..8971a45 100644 --- a/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue +++ b/src/components/chat/chatComponents/summaryCom/components/recordSetTable/RecordSetTable.vue @@ -9,6 +9,7 @@ :cell-style="{ textAlign: 'center' }" :header-cell-style="{ textAlign: 'center' }" :data="data?.values" + :spanMethod="objectSpanMethod" highlight-current-row class="w-full h-full" cellClassName="text-sm" @@ -47,11 +48,48 @@ const tableRef = ref<TableInstance>(null); const measureWidthOffset = 28; +const groupColIndex = []; +(props.data?.cols ?? []).map((item, index) => { + if (item.group) { + groupColIndex.push(index); + } +}); + +const objectSpanMethod = ({ row, column, rowIndex, columnIndex }) => { + if (groupColIndex.includes(columnIndex)) { + return { + rowspan: row.rowspan, + colspan: 1, + }; + } +}; const resizeEvent = ({ width, height }) => { if (width === 0 || height === 0) { return; } + if (props.data?.cols?.length > 0 && props.data?.values?.length > 0) { + const groupData = _.groupBy(props.data.values, (item, index) => { + // 鎵惧嚭鎵�鏈夐渶瑕� group 鐨勫�硷紝鍔犺捣鏉� + const groupKey = item.reduce((preVal, curVal, index) => { + const isGroup = props.data.cols[index].group; + if (isGroup) { + preVal += curVal; + } + return preVal; + }, ''); + return groupKey; + }); + + // 閲嶆柊鎺掑竷涓�涓嬩綅缃紝淇濊瘉 group 鐩搁偦锛屽悓鏃舵墦涓� rowspan + props.data.values = Object.values(groupData).reduce((preVal, curVal) => { + curVal.map((item, index, array) => { + item.rowspan = index === 0 ? array.length : undefined; + }); + preVal = preVal.concat(curVal); + return preVal; + }, []); + const maxStrList = props.data.cols.map((item) => item.title); const maxLenList = props.data.cols.map((item) => item.title.gblen()); for (const item of props.data.values) { -- Gitblit v1.9.3