/* Filter existing supplier/material options without changing their submitted IDs. */ window.POFilterSelect = { bind: function (input, select) { if (!input || !select) return; const options = Array.from(select.options); const normalize = value => String(value || '').trim().toLocaleLowerCase(); input.addEventListener('input', function () { const term = normalize(input.value); const matches = options.filter((option, index) => index === 0 || normalize(option.textContent + ' ' + (option.dataset.search || '')).includes(term)); select.replaceChildren(...matches); select.selectedIndex = 0; select.setAttribute('aria-label', term ? `匹配 ${matches.length - 1} 项,请选择` : '请选择'); }); } };