From 90a9f36b95943ee7140b9c6a145945ce5b3f1d0e Mon Sep 17 00:00:00 2001 From: hjhan Date: Fri, 28 Aug 2026 09:17:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A2=84=E4=BB=98=E9=87=91=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=A4=9A=E9=80=89=20chosen=20=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E5=85=A8=E9=80=89=E5=90=8E=E9=9A=90=E8=97=8F=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E5=8F=96=E6=B6=88=E5=8B=BE=E9=80=89=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 空搜索框无可选项可选时仍占一行(全局 input 152px 撑宽后换行),把控件行撑高一截; 买卖方向/预付金场景这类全选项固定的小多选尤为明显 --- .../marginTemplateV2DefaultEdit.js | 17 +++++++++++++++++ .../app/marginTemplate/marginTemplateV2Edit.js | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2DefaultEdit.js b/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2DefaultEdit.js index a3975cf5..34699cb4 100644 --- a/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2DefaultEdit.js +++ b/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2DefaultEdit.js @@ -631,5 +631,22 @@ $(function () { if (!isNaN(idx)) vue.onUnderlyingTypeChange(idx); }); + //多选 chosen:可选项已全部选中时隐藏搜索框——没有剩余项可选,空搜索框只会把控件撑高一截; + //取消勾选后自动恢复。勾选变化会触发原 select 的 jQuery change(trigger_form_field_change), + //加载重建/增删区块后的 refreshChosen 会触发 chosen:updated,两处都走这里的委托统一刷新 + function refreshChosenSearchField(select) { + var $sel = $(select); + var $container = $sel.next('.chosen-container-multi'); + if ($container.length === 0) return; + var allSelected = $sel.find('option').length > 0 && $sel.find('option:not(:selected)').length === 0; + $container.find('li.search-field').toggle(!allSelected); + } + $(document).on('change chosen:updated', 'select.chosen-select[multiple]', function () { + refreshChosenSearchField(this); + }); + SetAceDropDown(); + $('select.chosen-select[multiple]').each(function () { + refreshChosenSearchField(this); + }); }); diff --git a/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2Edit.js b/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2Edit.js index 1a04d355..f725c624 100644 --- a/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2Edit.js +++ b/YLErpWeb/wwwroot/Scripts/app/marginTemplate/marginTemplateV2Edit.js @@ -599,5 +599,22 @@ $(function () { if (!isNaN(idx)) vue.onUnderlyingTypeChange(idx); }); + //多选 chosen:可选项已全部选中时隐藏搜索框——没有剩余项可选,空搜索框只会把控件撑高一截; + //取消勾选后自动恢复。勾选变化会触发原 select 的 jQuery change(trigger_form_field_change), + //加载重建/增删区块后的 refreshChosen 会触发 chosen:updated,两处都走这里的委托统一刷新 + function refreshChosenSearchField(select) { + var $sel = $(select); + var $container = $sel.next('.chosen-container-multi'); + if ($container.length === 0) return; + var allSelected = $sel.find('option').length > 0 && $sel.find('option:not(:selected)').length === 0; + $container.find('li.search-field').toggle(!allSelected); + } + $(document).on('change chosen:updated', 'select.chosen-select[multiple]', function () { + refreshChosenSearchField(this); + }); + SetAceDropDown(); + $('select.chosen-select[multiple]').each(function () { + refreshChosenSearchField(this); + }); });