Commit 8b8f892f authored by 水玉婷's avatar 水玉婷
Browse files

feat:修复当表格只有两列时不均分问题

parent 6631789f
......@@ -236,6 +236,21 @@ const getColumnAlign = (header: string) => {
// 获取列宽度
const getColumnWidth = (header: string) => {
// 获取当前表格的列数
const headers = processedTableData.value.length > 0 ? Object.keys(processedTableData.value[0]) : [];
const columnCount = headers.length;
// 当只有两列时,强制设置固定宽度实现均分
if (columnCount === 2) {
return '50%'; // 每列占50%宽度
}
// 当列数较少时(小于等于4列),让列宽自动均分
if (columnCount <= 4) {
return undefined; // 返回undefined让antd-table自动计算宽度
}
// 列数较多时,使用固定宽度
if (isNumericColumn(header)) {
return 120;
} else if (isTrendColumn(header)) {
......@@ -319,6 +334,12 @@ const getTableScroll = () => {
border-collapse: collapse;
background-color: white;
table-layout: auto;
/* 当只有两列时,强制使用固定布局实现均分 */
&:has(th:nth-child(2):last-child) {
table-layout: fixed;
width: 100%;
}
}
.data-table {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment