修复配置默认排序卡死问题
修复配置默认排序卡死问题以及注释Table_Layout代码
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
|
||||
import { ListController } from "@web/views/list/list_controller";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { onWillStart, useState, useRef, useExternalListener,onWillRender} from "@odoo/owl";
|
||||
import { onWillStart, useState, useRef, useExternalListener, onWillRender } from "@odoo/owl";
|
||||
import { Dropdown } from "@web/core/dropdown/dropdown";
|
||||
import { CheckBox } from "@web/core/checkbox/checkbox";
|
||||
import { useSortable } from "@web/core/utils/sortable_owl";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { usePosition } from "@web/core/position_hook";
|
||||
|
||||
import { usePager } from "@web/search/pager_hook";
|
||||
|
||||
patch(ListController.prototype, {
|
||||
setup() {
|
||||
@@ -63,19 +63,14 @@ patch(ListController.prototype, {
|
||||
}
|
||||
this.ooManager.show = manager_data.show;
|
||||
})
|
||||
onWillRender(() => {
|
||||
if (this.ooManager.default_page_size>0) {
|
||||
this.model.config.limit = this.ooManager.default_page_size;
|
||||
// this.model.load();
|
||||
}
|
||||
onWillRender(async() => {
|
||||
if (this.ooManager.default_order_field) {
|
||||
this.model.config.orderBy = [];
|
||||
this.model.config.orderBy.push({
|
||||
this.model.config.orderBy = [{
|
||||
name: this.ooManager.default_order_field,
|
||||
[this.ooManager.default_order_type]: true
|
||||
});
|
||||
[this.ooManager.default_order_type || 'asc']: true
|
||||
}]
|
||||
}
|
||||
});
|
||||
})
|
||||
usePosition('ooListRef', () => this.ooManagerRef.el, {
|
||||
position: "bottom-start",
|
||||
})
|
||||
@@ -87,8 +82,37 @@ patch(ListController.prototype, {
|
||||
cursor: "move",
|
||||
onDrop: (params) => this.sortColumnDrop(params)
|
||||
})
|
||||
|
||||
useExternalListener(window, "click", this.onGlobalClick.bind(this));
|
||||
usePager(() => {
|
||||
if (this.model.useSampleModel) {
|
||||
return;
|
||||
}
|
||||
const { count, hasLimitedCount, isGrouped, offset } = this.model.root;
|
||||
let { limit } = this.model.root;
|
||||
limit = this.ooManager.default_page_size > 0
|
||||
? this.ooManager.default_page_size
|
||||
: limit;
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
total: count,
|
||||
onUpdate: async ({ offset, limit }, hasNavigated) => {
|
||||
if (this.editedRecord) {
|
||||
if (!(await this.editedRecord.save())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
await this.model.root.load({ limit, offset });
|
||||
if (hasNavigated) {
|
||||
this.onPageChangeScroll();
|
||||
}
|
||||
},
|
||||
updateTotal:
|
||||
!isGrouped && hasLimitedCount
|
||||
? () => this.model.root.fetchCount()
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
},
|
||||
onGlobalClick(ev) {
|
||||
if (this.ooListRef.el && !this.ooListRef.el.contains(ev.target)) {
|
||||
|
||||
@@ -14,13 +14,11 @@ patch(ListRenderer.prototype, {
|
||||
}
|
||||
const computeFunction = this.computeFreeze.bind(this);
|
||||
const resizeObserver = new ResizeObserver(computeFunction);
|
||||
|
||||
|
||||
useEffect(
|
||||
(tableEl) => {
|
||||
if (tableEl) {
|
||||
// Lucky by 2025/08/08添加此行:设置 table-layout: fixed
|
||||
tableEl.style.setProperty('table-layout', 'fixed', 'important');
|
||||
// Lucky by 2025/08/08添加此行:设置 table-layout: fixed,先注释反馈有Bug
|
||||
// tableEl.style.setProperty('table-layout', 'fixed', 'important');
|
||||
resizeObserver.observe(tableEl);
|
||||
return () => resizeObserver.unobserve(tableEl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user