|
@ -127,85 +127,6 @@ export default { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
// syncTableColumns(tableRef) {
|
|
|
|
|
|
// const table = this.$refs[tableRef].$refs.guiptable;
|
|
|
|
|
|
// if (!table) return;
|
|
|
|
|
|
|
|
|
|
|
|
// // 计算各列宽度
|
|
|
|
|
|
// const columnWidths = this.calculateColumnWidths();
|
|
|
|
|
|
// if (!columnWidths) return;
|
|
|
|
|
|
|
|
|
|
|
|
// this.$nextTick(() => {
|
|
|
|
|
|
// // 1. 设置列定义的宽度
|
|
|
|
|
|
// table.columns.forEach(column => {
|
|
|
|
|
|
// if (columnWidths[column.property]) {
|
|
|
|
|
|
// column.width = columnWidths[column.property];
|
|
|
|
|
|
// column.realWidth = columnWidths[column.property]; // 关键:设置realWidth
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// // 2. 同步DOM元素的宽度
|
|
|
|
|
|
// const headerCols = table.$el.querySelectorAll('.el-table__header col');
|
|
|
|
|
|
// const bodyCols = table.$el.querySelectorAll('.el-table__body col');
|
|
|
|
|
|
// const headerCells = table.$el.querySelectorAll('.el-table__header .cell');
|
|
|
|
|
|
// // const bodyCells = table.$el.querySelectorAll('.el-table__body .cell');
|
|
|
|
|
|
|
|
|
|
|
|
// table.columns.forEach((column, index) => {
|
|
|
|
|
|
// if (columnWidths[column.property]) {
|
|
|
|
|
|
// const width = columnWidths[column.property];
|
|
|
|
|
|
|
|
|
|
|
|
// // 同步colgroup中的宽度
|
|
|
|
|
|
// if (headerCols[index]) {
|
|
|
|
|
|
// headerCols[index].width = width;
|
|
|
|
|
|
// headerCols[index].style.width = `${width}px`;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (bodyCols[index]) {
|
|
|
|
|
|
// bodyCols[index].width = width;
|
|
|
|
|
|
// bodyCols[index].style.width = `${width}px`;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// // 同步单元格的实际宽度
|
|
|
|
|
|
// if (headerCells[index]) {
|
|
|
|
|
|
// headerCells[index].style.width = `${width}px`;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // body单元格通常不需要强制设置宽度
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// // 3. 强制更新布局
|
|
|
|
|
|
// table.store.scheduleLayout();
|
|
|
|
|
|
|
|
|
|
|
|
// // 4. 处理固定列
|
|
|
|
|
|
// this.syncFixedColumns(table);
|
|
|
|
|
|
// });
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
// syncFixedColumns(table) {
|
|
|
|
|
|
// // 处理左侧固定列
|
|
|
|
|
|
// const fixedLeftWrapper = table.$el.querySelector('.el-table__fixed');
|
|
|
|
|
|
// if (fixedLeftWrapper) {
|
|
|
|
|
|
// const fixedLeftCols = fixedLeftWrapper.querySelectorAll('col');
|
|
|
|
|
|
// const originalCols = table.$el.querySelectorAll('.el-table__header col');
|
|
|
|
|
|
|
|
|
|
|
|
// fixedLeftCols.forEach((col, index) => {
|
|
|
|
|
|
// if (originalCols[index]) {
|
|
|
|
|
|
// const width = originalCols[index].width;
|
|
|
|
|
|
// col.width = width;
|
|
|
|
|
|
// // col.style.width = `${width}px`;
|
|
|
|
|
|
// col.style.setProperty('width',`${width}px`, 'important');
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// // 强制重绘固定列
|
|
|
|
|
|
// fixedLeftWrapper.style.display = 'none';
|
|
|
|
|
|
// this.$nextTick(() => {
|
|
|
|
|
|
// fixedLeftWrapper.style.display = '';
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// // 同样处理右侧固定列...
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 销毁观察者
|
|
|
// 销毁观察者
|
|
|