!8964 Merge remote-tracking branch 'origin/dev' into dev
Merge pull request !8964 from 李鹏宇/dev
This commit is contained in:
@@ -19,8 +19,7 @@ class ReceivableReport extends Component {
|
||||
this.gridRef = useRef("grid");
|
||||
console.log(this.props.action.context.report_config)
|
||||
|
||||
this.serviceOrm = useService("orm");
|
||||
this.actionService = useService("action"); // 获取 actionService 用于跳转
|
||||
this.serviceOrm = useService("orm")
|
||||
|
||||
// 计算 本月的开始,结束
|
||||
|
||||
@@ -47,17 +46,10 @@ class ReceivableReport extends Component {
|
||||
onMounted(async () => {
|
||||
// 加载 ag-grid
|
||||
//await loadJS("https://cdn.jsdelivr.net/npm/ag-grid-community/dist/ag-grid-community.min.js");
|
||||
|
||||
// 统一处理 columns:给所有列添加穿透渲染器
|
||||
const columns = this.config.columns || [];
|
||||
columns.forEach((col) => {
|
||||
col.cellRenderer = this.linkRender.bind(this);
|
||||
});
|
||||
|
||||
this.gridOptions = {
|
||||
localeText: AG_GRID_LOCALE_CN,
|
||||
theme: agGrid.themeMaterial,
|
||||
columnDefs: columns,
|
||||
columnDefs: this.config.columns || [],
|
||||
rowData: [],
|
||||
rowClassRules: {
|
||||
'ag-row-new-rent': function(params) {
|
||||
@@ -110,9 +102,6 @@ class ReceivableReport extends Component {
|
||||
items.push("chartRange");
|
||||
return items;
|
||||
},
|
||||
context: {
|
||||
actionService: this.actionService // 传递 actionService 用于穿透跳转
|
||||
}
|
||||
|
||||
};
|
||||
this.grid = new agGrid.createGrid(this.gridRef.el, this.gridOptions);
|
||||
@@ -120,39 +109,6 @@ class ReceivableReport extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 穿透渲染器:将对象格式的字段渲染为可点击的链接
|
||||
* 如果字段值是对象(包含 model、id、display_name),则渲染为可点击链接
|
||||
* 否则直接显示原值
|
||||
*/
|
||||
linkRender(params) {
|
||||
if (!params.value) return '';
|
||||
|
||||
// 如果是对象格式(包含 model 和 id),渲染为可点击链接
|
||||
if (typeof params.value === 'object' && params.value.model && params.value.id) {
|
||||
const { model, id, display_name } = params.value;
|
||||
|
||||
const el = document.createElement('div');
|
||||
el.className = 'o_record_cell';
|
||||
el.innerText = display_name || '';
|
||||
el.classList.add('btn');
|
||||
el.classList.add('btn-link');
|
||||
el.onclick = () => {
|
||||
params.context.actionService.doAction({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: model,
|
||||
res_id: id,
|
||||
views: [[false, 'form']]
|
||||
});
|
||||
};
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
// 否则直接返回原值(纯文本/数字)
|
||||
return params.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变布尔值
|
||||
* @param e
|
||||
|
||||
Reference in New Issue
Block a user