| | |
| | | :maxHeight="tableHeight" |
| | | :cell-style="tableCellStyle" |
| | | :header-cell-style="tableHeaderCellStyle" |
| | | :data="chunkTableData[pager.index - 1]" |
| | | :data="tableData" |
| | | @row-click="recordSelectChange" |
| | | :spanMethod="objectSpanMethod" |
| | | class="w-full h-full" |
| | |
| | | return values; |
| | | } |
| | | |
| | | const groupData = _.groupBy(values, (item, index) => { |
| | | const groupValue = item[curGroupIndex]; |
| | | return groupValue; |
| | | }); |
| | | |
| | | |
| | | const groupData = getItemMap(values,curGroupIndex,true) |
| | | // 顺延下一个分组 |
| | | i++; |
| | | // 重新排布一下位置,保证 group 相邻,同时打上 rowspan |
| | | const result = Object.values(groupData).reduce((preVal, curVal) => { |
| | | const result = Object.values(Array.from(groupData.values())).reduce((preVal, curVal) => { |
| | | curVal.map((item, index) => { |
| | | // 行列作为 key |
| | | const key = `${j + index},${curGroupIndex}`; |
| | |
| | | j += curVal.length; |
| | | return preVal; |
| | | }, []); |
| | | return result; |
| | | }; |
| | | |
| | | const getItemMap = <T>(arr: T[], defaultProps = 'ID', isMultiple = false) => { |
| | | if (!arr || arr.length === 0) return {}; |
| | | |
| | | const result = arr.reduce((acc, curr) => { |
| | | if (isMultiple) { |
| | | if (!acc.get(curr[defaultProps])) { |
| | | acc.set(curr[defaultProps], [curr]); |
| | | } else { |
| | | {/* acc[curr[defaultProps]].push(curr); */} |
| | | acc.get(curr[defaultProps]).push(curr); |
| | | } |
| | | } else { |
| | | acc.set(curr[defaultProps], curr); |
| | | } |
| | | return acc; |
| | | }, new Map()) as Map<string, T | T[]>; |
| | | |
| | | return result; |
| | | }; |
| | | |
| | |
| | | // 计算每一列最长的标题字符串和标题字符串长度 |
| | | for (const item of tableValues.value) { |
| | | item.map((subItem, index) => { |
| | | const subItemLen = subItem?.gblen(); |
| | | // subItem 可能是 数字 |
| | | const subItemLen = (subItem +'')?.gblen(); |
| | | if (maxLenList[index] < subItemLen) { |
| | | maxLenList[index] = subItemLen; |
| | | maxStrList[index] = subItem; |
| | |
| | | } |
| | | if (tableCols.value.length > 0) { |
| | | cellRowSpanMap.clear(); |
| | | tableValues.value = buildGroupData(tableValues.value); |
| | | // tableValues.value = buildGroupData(tableValues.value); |
| | | calcColWidth(width); |
| | | nextTick(() => { |
| | | calcPagerHeight(); |
| | |
| | | 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 reloadTable = () => { |
| | | // 重新计算宽度 |
| | | |