diff --git a/jikimo_frontend/__manifest__.py b/jikimo_frontend/__manifest__.py index 81eb73e0..a90a374e 100644 --- a/jikimo_frontend/__manifest__.py +++ b/jikimo_frontend/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['web'], + 'depends': ['web', 'purchase'], 'data': [ ], @@ -33,6 +33,7 @@ 'jikimo_frontend/static/src/list/list_up_down_button.xml', 'jikimo_frontend/static/src/list/custom_import.js', 'jikimo_frontend/static/src/list/custom_width.js', + 'jikimo_frontend/static/src/views/list_nums/extent_purchase.xml', ], diff --git a/jikimo_frontend/static/src/list/custom_width.js b/jikimo_frontend/static/src/list/custom_width.js index 3a1443a4..512abc44 100644 --- a/jikimo_frontend/static/src/list/custom_width.js +++ b/jikimo_frontend/static/src/list/custom_width.js @@ -17,6 +17,7 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { const table = this.tableRef.el; const headers = [...table.querySelectorAll("thead th:not(.o_list_actions_header)")]; + const column_num = headers.length if (!this.columnWidths || !this.columnWidths.length) { // no column widths to restore @@ -28,7 +29,7 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { th.style.maxWidth = null; }); - this.setDefaultColumnWidths(); + this.setDefaultColumnWidths(column_num); // Squeeze the table by applying a max-width on largest columns to // ensure that it doesn't overflow @@ -42,11 +43,12 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { }); }, - setDefaultColumnWidths() { + setDefaultColumnWidths(column_num) { + const bbb = this.state.columns[0].name const widths = this.state.columns.map((col) => this.calculateColumnWidth(col)); const sumOfRelativeWidths = (widths .filter(({ type }) => type === "relative") - .reduce((sum, { value }) => sum + value, 0)) + 1; + .reduce((sum, { value }) => sum + value, 0)); // 获取数组的最后一项 const lastItem = widths[widths.length - 1]; @@ -56,6 +58,12 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { // 将新的对象添加到数组的末尾 widths.push(newItem); + + // 判断销售的sequence + if (this.state.columns[0].name === "sequence") { + widths[1] = { type: "relative", value: 0.1 }; + } + // 1 because nth-child selectors are 1-indexed, 2 when the first column contains // the checkboxes to select records. const columnOffset = this.hasSelectors ? 2 : 1; @@ -68,7 +76,7 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { headerEl.style.minWidth = value; } } else if (type === "relative" && this.isEmpty) { - headerEl.style.width = `${((value / sumOfRelativeWidths) * 100).toFixed(2)}%`; + headerEl.style.width = `${((value / column_num) * 100).toFixed(2)}%`; } }); }, diff --git a/jikimo_frontend/static/src/views/list_nums/extent_purchase.xml b/jikimo_frontend/static/src/views/list_nums/extent_purchase.xml new file mode 100644 index 00000000..f9c25a3d --- /dev/null +++ b/jikimo_frontend/static/src/views/list_nums/extent_purchase.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file