feat(inventory): улучшить поиск товаров для инвентаризации
Добавлен параметр skip_stock_filter для отключения фильтрации по остаткам, опция excludeKits для исключения комплектов из поиска, а также добавлено явное указание API URL и расширенное логирование для отладки.
This commit is contained in:
@@ -107,7 +107,7 @@
|
||||
<h6 class="mb-0"><i class="bi bi-plus-square me-2"></i>Добавить товар в инвентаризацию</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% include 'products/components/product_search_picker.html' with container_id='inventory-product-picker' title='Поиск товара для инвентаризации...' warehouse_id=inventory.warehouse.id filter_in_stock_only=False categories=categories tags=tags add_button_text='Добавить товар' content_height='250px' %}
|
||||
{% include 'products/components/product_search_picker.html' with container_id='inventory-product-picker' title='Поиск товара для инвентаризации...' warehouse_id=inventory.warehouse.id filter_in_stock_only=False categories=categories tags=tags add_button_text='Добавить товар' content_height='250px' skip_stock_filter=True %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -288,13 +288,17 @@
|
||||
<script src="{% static 'inventory/js/inventory_detail.js' %}" onerror="console.error('Failed to load inventory_detail.js');"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('DOM loaded, initializing inventory components...');
|
||||
|
||||
// Проверка загрузки ProductSearchPicker
|
||||
if (typeof ProductSearchPicker === 'undefined') {
|
||||
console.error('ProductSearchPicker is not defined. Check if product-search-picker.js loaded correctly.');
|
||||
console.error('Script URL: {% static "products/js/product-search-picker.js" %}');
|
||||
return;
|
||||
} else {
|
||||
console.log('ProductSearchPicker is available');
|
||||
}
|
||||
|
||||
|
||||
// Инициализация компонента поиска товаров
|
||||
{% if inventory.status != 'completed' %}
|
||||
const pickerElement = document.querySelector('#inventory-product-picker');
|
||||
@@ -302,29 +306,43 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
console.error('Picker container #inventory-product-picker not found');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log('Initializing ProductSearchPicker for inventory...');
|
||||
const picker = ProductSearchPicker.init('#inventory-product-picker', {
|
||||
apiUrl: '{% url "products:api-search-products-variants" %}', // Явно указываем URL API
|
||||
excludeKits: true, // Исключаем комплекты из поиска
|
||||
onSelect: function(product, instance) {
|
||||
console.log('Product selected:', product);
|
||||
},
|
||||
onAddSelected: function(product, instance) {
|
||||
console.log('Adding selected product to inventory:', product);
|
||||
if (product) {
|
||||
addInventoryLine(product.id);
|
||||
instance.clearSelection();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!picker) {
|
||||
console.error('Failed to initialize ProductSearchPicker');
|
||||
} else {
|
||||
console.log('ProductSearchPicker initialized successfully');
|
||||
}
|
||||
{% else %}
|
||||
console.log('Inventory is completed, skipping product picker initialization');
|
||||
{% endif %}
|
||||
|
||||
// Инициализация обработчиков
|
||||
const inventoryId = {{ inventory.pk }};
|
||||
console.log('Initializing inventory detail handlers for ID:', inventoryId);
|
||||
window.inventoryDetailHandlers = initInventoryDetailHandlers(inventoryId, {
|
||||
addLineUrl: '{% url "inventory:inventory-line-add" inventory.pk %}',
|
||||
updateLineUrl: '{% url "inventory:inventory-line-update" inventory.pk 999 %}',
|
||||
deleteLineUrl: '{% url "inventory:inventory-line-delete" inventory.pk 999 %}',
|
||||
completeUrl: '{% url "inventory:inventory-complete" inventory.pk %}'
|
||||
});
|
||||
|
||||
console.log('Inventory detail handlers initialized');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user