| | |
| | | }; |
| | | // 统计表格,需要增加累计值行,以及比例列 |
| | | 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) { |
| | |
| | | isShow: isShow, |
| | | } as TableCol; |
| | | }) ?? []; |
| | | |
| | | const storeCols = getStoreCols(originData); |
| | | colList.value = storeCols; |
| | | }); |
| | | |
| | | // 所有显示的 prop |
| | |
| | | const colFilterChange = () => { |
| | | // 重新计算宽度 |
| | | reloadTable(); |
| | | storeCols(colList.value); |
| | | }; |
| | | |
| | | const tableHeight = ref(0.7 * document.body.clientHeight); |