| | |
| | | import { PATH_ICON } from '../../../common'; |
| | | import { ChartTypeEnum } from '../../../types'; |
| | | import { axisLabelFormatter } from '/@/utils/chart'; |
| | | import { Local } from '/@/utils/storage'; |
| | | |
| | | const props = defineProps({ |
| | | data: { |
| | |
| | | }; |
| | | |
| | | const isTotalTable = computed(() => checkIsTotalTable(props.data)); |
| | | |
| | | const getTableCols = (propsData) => { |
| | | const current = propsData?.cols ?? []; |
| | | |
| | | if (checkIsTotalTable(propsData)) { |
| | | current.push({ |
| | | title: '比例', |
| | |
| | | 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) => { |
| | |
| | | return values; |
| | | } |
| | | |
| | | |
| | | |
| | | const groupData = getItemMap(values,curGroupIndex,true) |
| | | const groupData = getItemMap(values, curGroupIndex, true); |
| | | // 顺延下一个分组 |
| | | i++; |
| | | // 重新排布一下位置,保证 group 相邻,同时打上 rowspan |
| | |
| | | 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) => { |
| | |
| | | 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 { |
| | |
| | | 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; |
| | |
| | | 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(); |