Исправлено: ProductSearchPicker динамически создает <option> для HTML select
- Проблема: при выборе товара через ProductSearchPicker, select оставался пустым - Решение: динамическое создание <option> элемента с выбранным товаром - Затронутые файлы: - incoming_document_detail.html: функции selectProduct() и clearSelectedProduct() - writeoff_document/detail.html: аналогичные исправления - Теперь компонент корректно работает во всех документах системы
This commit is contained in:
@@ -337,7 +337,16 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
// Устанавливаем значение в select формы
|
||||
if (productSelect) {
|
||||
productSelect.value = productId;
|
||||
// Очищаем существующие опции
|
||||
productSelect.innerHTML = '';
|
||||
|
||||
// Создаем новую опцию для выбранного товара
|
||||
const option = document.createElement('option');
|
||||
option.value = productId;
|
||||
option.textContent = productName;
|
||||
option.selected = true;
|
||||
productSelect.appendChild(option);
|
||||
|
||||
// Триггерим change для Select2, если он используется
|
||||
const event = new Event('change', { bubbles: true });
|
||||
productSelect.dispatchEvent(event);
|
||||
@@ -358,7 +367,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
selectedProductPhoto.style.display = 'none';
|
||||
|
||||
if (productSelect) {
|
||||
productSelect.value = '';
|
||||
productSelect.innerHTML = '';
|
||||
// Добавляем пустую опцию
|
||||
const emptyOption = document.createElement('option');
|
||||
emptyOption.value = '';
|
||||
emptyOption.textContent = '---------';
|
||||
emptyOption.selected = true;
|
||||
productSelect.appendChild(emptyOption);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -319,7 +319,16 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
// Устанавливаем значение в select формы
|
||||
if (productSelect) {
|
||||
productSelect.value = productId;
|
||||
// Очищаем существующие опции
|
||||
productSelect.innerHTML = '';
|
||||
|
||||
// Создаем новую опцию для выбранного товара
|
||||
const option = document.createElement('option');
|
||||
option.value = productId;
|
||||
option.textContent = productName;
|
||||
option.selected = true;
|
||||
productSelect.appendChild(option);
|
||||
|
||||
// Триггерим change для Select2, если он используется
|
||||
const event = new Event('change', { bubbles: true });
|
||||
productSelect.dispatchEvent(event);
|
||||
@@ -340,7 +349,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
selectedProductPhoto.style.display = 'none';
|
||||
|
||||
if (productSelect) {
|
||||
productSelect.value = '';
|
||||
productSelect.innerHTML = '';
|
||||
// Добавляем пустую опцию
|
||||
const emptyOption = document.createElement('option');
|
||||
emptyOption.value = '';
|
||||
emptyOption.textContent = '---------';
|
||||
emptyOption.selected = true;
|
||||
productSelect.appendChild(emptyOption);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user