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); + }); });