From 74523c710f1428712a1f0091efbe89473ebff987 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 1 Nov 2023 16:52:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=B5=8B=E8=AF=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=AE=8C=E5=BA=8F=E5=8F=B7=E5=B1=95=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E5=87=86=E5=A4=87=E7=BA=BF=E4=B8=8A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_frontend/__manifest__.py | 3 ++- jikimo_frontend/static/src/list/custom_width.js | 16 ++++++++++++---- .../src/views/list_nums/extent_purchase.xml | 7 +++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 jikimo_frontend/static/src/views/list_nums/extent_purchase.xml 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