This commit is contained in:
李鹏宇
2026-03-27 17:04:27 +08:00
parent 4865d63123
commit 047aed753e
3 changed files with 49 additions and 2 deletions
@@ -88,6 +88,8 @@ class ReceivableFlowReport extends Component {
minWidth: 250,
flex: 1.5,
pinned: 'left',
// 合同/明细列左对齐显示
cellClass: 'receivable-group-left',
cellRendererParams: {
suppressCount: true,
innerRenderer: (params) => {
@@ -370,6 +372,33 @@ class ReceivableFlowReport extends Component {
this.grid.setGridOption('pinnedBottomRowData', []);
this.state.stats = [];
}
// 数据加载完成后,自动调整所有列宽,等价于菜单里的“自动调整所有列”
if (this.grid) {
// 优先走 columnApi(老版本写法)
const columnApi = this.grid.columnApi && this.grid.columnApi;
if (columnApi && typeof columnApi.autoSizeAllColumns === 'function') {
try {
if (typeof columnApi.getAllColumns === 'function') {
const allCols = columnApi.getAllColumns() || [];
const allColIds = allCols.map(col => col.getColId());
columnApi.autoSizeAllColumns(allColIds);
} else {
columnApi.autoSizeAllColumns();
}
} catch (e) {
// 忽略自动调整异常,避免影响报表使用
console.error('autoSizeAllColumns failed:', e);
}
} else if (typeof this.grid.autoSizeAllColumns === 'function') {
// 新版 GridApi 可能直接挂在 grid 上
try {
this.grid.autoSizeAllColumns();
} catch (e) {
console.error('grid.autoSizeAllColumns failed:', e);
}
}
}
}
this._applyManagementTypeFilter();
}
@@ -172,7 +172,7 @@
<!-- ag-grid 表格区域 -->
<div class="row flex-grow-1">
<div class="col-12 h-100">
<div class="ag-theme-alpine w-100 h-100" t-ref="grid"></div>
<div class="ag-theme-alpine w-100 h-100 receivable-flow-grid" t-ref="grid"></div>
</div>
</div>
</div>
@@ -62,4 +62,22 @@
color: #16a34a !important;
font-weight: bold;
text-align: center;
}
}
/* 应收流水报表:列标题/内容居中 */
.receivable-flow-grid .ag-header-cell-label {
justify-content: center;
}
.receivable-flow-grid .ag-cell {
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
/* 合同/明细列左对齐(通过 JS 的 cellClass: 'receivable-group-left' 标记) */
.receivable-flow-grid .ag-cell.receivable-group-left {
justify-content: flex-start;
text-align: left;
}