解决设置宽度不生效问题
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import {ListRenderer} from "@web/views/list/list_renderer";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
import {loadJS, loadCSS} from "@web/core/assets";
|
||||
import {ListRendererCust} from "@tree_view_advanced_filter/tree_view_advanced_filter/tree"
|
||||
import {onWillDestroy, useEffect} from "@odoo/owl";
|
||||
import { ListRenderer } from "@web/views/list/list_renderer";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { loadJS, loadCSS } from "@web/core/assets";
|
||||
import { ListRendererCust } from "@tree_view_advanced_filter/tree_view_advanced_filter/tree"
|
||||
import { onWillDestroy, useEffect } from "@odoo/owl";
|
||||
|
||||
patch(ListRenderer.prototype, {
|
||||
setup() {
|
||||
@@ -19,6 +19,8 @@ patch(ListRenderer.prototype, {
|
||||
useEffect(
|
||||
(tableEl) => {
|
||||
if (tableEl) {
|
||||
// Lucky by 2025/08/08添加此行:设置 table-layout: fixed
|
||||
tableEl.style.setProperty('table-layout', 'fixed', 'important');
|
||||
resizeObserver.observe(tableEl);
|
||||
return () => resizeObserver.unobserve(tableEl);
|
||||
}
|
||||
@@ -53,54 +55,6 @@ patch(ListRenderer.prototype, {
|
||||
setTimeout(computeFunction, 200);
|
||||
});
|
||||
},
|
||||
|
||||
// _computeLock() {
|
||||
// const table = this.tableRef.el;
|
||||
// if (!table) return;
|
||||
|
||||
// const thead = [...table.querySelectorAll('thead tr:first-child th')];
|
||||
// const filterBox = [...table.querySelectorAll('thead .o_filter_box td')];
|
||||
// const tbody = [...table.querySelectorAll('tbody tr')];
|
||||
// const tfoot = [...table.querySelectorAll('tfoot tr')];
|
||||
|
||||
// const setStyle = (element, left, z = 10) => {
|
||||
// element.classList.add('position-sticky', 'o_column_freeze');
|
||||
// Object.assign(element.style, {
|
||||
// left: `${left}px`,
|
||||
// zIndex: `${z}`,
|
||||
// });
|
||||
// };
|
||||
|
||||
// const removeStyle = (element) => {
|
||||
// element.classList.remove('position-sticky', 'o_column_freeze');
|
||||
// element.style.left = '';
|
||||
// element.style.zIndex = '';
|
||||
// };
|
||||
|
||||
// for (let i = 0; i < thead.length; i++) {
|
||||
// const th = thead[i];
|
||||
// const shouldFreeze = th.classList.contains('o_column_freeze') ||
|
||||
// th.classList.contains('o_list_record_selector') ||
|
||||
// th.classList.contains('list-number');
|
||||
|
||||
// if (shouldFreeze) {
|
||||
// let left = 0;
|
||||
// for (let j = 0; j < i; j++) {
|
||||
// left += thead[j].getBoundingClientRect().width;
|
||||
// }
|
||||
|
||||
// setStyle(th, left, 20);
|
||||
// if (filterBox[i]) setStyle(filterBox[i], left, 30);
|
||||
// tbody.forEach(tr => tr.classList.contains('o_data_row') && setStyle(tr.children[i], left, 10));
|
||||
// tfoot.forEach(tr => setStyle(tr.children[i], left, 10));
|
||||
// } else {
|
||||
// removeStyle(th);
|
||||
// if (filterBox[i]) removeStyle(filterBox[i]);
|
||||
// tbody.forEach(tr => tr.classList.contains('o_data_row') && removeStyle(tr.children[i]));
|
||||
// tfoot.forEach(tr => removeStyle(tr.children[i]));
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
_computeLock() {
|
||||
const table = this.tableRef.el;
|
||||
if (!table) return;
|
||||
@@ -334,11 +288,18 @@ patch(ListRenderer.prototype, {
|
||||
getColumnStyle(column) {
|
||||
if (!this.props.ooManagerColumns) return '';
|
||||
const mColumn = this.props.ooManagerColumns.find(item => item.id === column.id);
|
||||
if (mColumn && mColumn.color) {
|
||||
return 'color: ' + mColumn.color;
|
||||
} else {
|
||||
return '';
|
||||
const styles = [];
|
||||
if (mColumn?.width) {
|
||||
styles.push(`width: ${mColumn.width}px`);
|
||||
styles.push(`min-width: ${mColumn.width}px`);
|
||||
styles.push(`max-width: ${mColumn.width}px`);
|
||||
}
|
||||
|
||||
if (mColumn?.color) {
|
||||
styles.push(`color: ${mColumn.color}`);
|
||||
}
|
||||
|
||||
return styles.join('; ');
|
||||
},
|
||||
|
||||
_renderSearchPanel: async function () {
|
||||
@@ -358,7 +319,7 @@ patch(ListRenderer.prototype, {
|
||||
tableRef.removeAttribute('style');
|
||||
const columns = this.getActiveColumns(this.props.list);
|
||||
|
||||
const $tr1 = $('<tr>', {class: 'o_filter_box'}).append(columns.map(col => this._renderHeaderCellSearch(col)));
|
||||
const $tr1 = $('<tr>', { class: 'o_filter_box' }).append(columns.map(col => this._renderHeaderCellSearch(col)));
|
||||
if (this.props.ooManagerSerialNum) $tr1.prepend($('<td>').addClass('web_list_num'));
|
||||
if (this.hasSelectors) $tr1.prepend($('<td>').addClass('o_list_record_selector'));
|
||||
if (this.isStudioEditable || this.displayOptionalFields) $tr1.append($('<td>').addClass('o_list_record_selector'));
|
||||
|
||||
Reference in New Issue
Block a user