From: marina Date: Mon, 16 Jun 2025 07:04:06 +0000 (+0300) Subject: ERP-360 Сборка страницы автопм X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=80b8267dda7e28349229c54f915c7c49c70fa2c9;p=erp24_rep%2Fyii-erp24%2F.git ERP-360 Сборка страницы автопм --- diff --git a/erp24/views/auto-plannogramma/index.php b/erp24/views/auto-plannogramma/index.php index ef52591b..68cb03e8 100644 --- a/erp24/views/auto-plannogramma/index.php +++ b/erp24/views/auto-plannogramma/index.php @@ -165,6 +165,9 @@ $this->registerJsFile('/js/autoplannogramma/autoplannogramma.js', ['position' =>
+
+
+
@@ -204,9 +207,9 @@ $this->registerJsFile('/js/autoplannogramma/autoplannogramma.js', ['position' => $subcategories): ?> $storeName): ?> @@ -217,9 +220,9 @@ $this->registerJsFile('/js/autoplannogramma/autoplannogramma.js', ['position' => $storeName): ?> @@ -276,4 +279,22 @@ $this->registerJsFile('/js/autoplannogramma/autoplannogramma.js', ['position' => padding: 10px; border-right: 2px solid #ddd; } + + .list-group-item-action { + color:black; + } + + .loader-overlay { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(255, 255, 255, 0.7); + display: flex; + justify-content: center; + align-items: center; + z-index: 999; + } + \ No newline at end of file diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index e7a04e1e..a5ed14b0 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -8,7 +8,7 @@ document.addEventListener("DOMContentLoaded", () => { document.querySelectorAll(".category").forEach(category => { category.addEventListener("click", function () { - let row = this.parentElement.nextElementSibling; + let row = this.closest("tr").nextElementSibling; let isOpen = row?.style.display === "table-row"; while (row && !row.querySelector(".category")) { @@ -17,7 +17,7 @@ document.addEventListener("DOMContentLoaded", () => { } if (!isOpen) { - row = this.parentElement.nextElementSibling; + row = this.closest("tr").nextElementSibling; while (row && !row.querySelector(".category")) { if (row.querySelector(".subcategory")) { row.style.display = "table-row"; @@ -31,7 +31,7 @@ document.addEventListener("DOMContentLoaded", () => { document.querySelectorAll(".subcategory").forEach(sub => { sub.addEventListener("click", function (e) { e.stopPropagation(); - let row = this.parentElement.nextElementSibling; + let row = this.closest("tr").nextElementSibling; let isOpen = row?.style.display === "table-row"; while (row && !row.querySelector(".subcategory") && !row.querySelector(".category")) { @@ -42,7 +42,7 @@ document.addEventListener("DOMContentLoaded", () => { }); }); -$('.subcategory-link').on('click', function (e) { +$('.subcategory .list-group-item').on('click', function (e) { e.preventDefault(); window.getSelection()?.removeAllRanges(); this.blur(); @@ -60,6 +60,8 @@ $('.subcategory-link').on('click', function (e) { filters.category = category; filters.subcategory = subcategory; + $('.loader-overlay').removeClass('d-none'); + $.get('/auto-plannogramma/get-products', filters, response => { $row.nextAll('tr.inserted-row').remove(); @@ -72,11 +74,11 @@ $('.subcategory-link').on('click', function (e) { const subcategoryTd = $(` `); tr.append(subcategoryTd); @@ -126,8 +128,61 @@ $('.subcategory-link').on('click', function (e) { $row.after(tr); }); - }).fail(xhr => alert('Ошибка: ' + xhr.responseText)); + }) + .fail(xhr => alert('Ошибка: ' + xhr.responseText)) + .always(() => { + $('.loader-overlay').addClass('d-none'); + }); }); +// +// $('.category .list-group-item').on('click', function () { +// let $categorySpan = $(this); +// let category = $categorySpan.text().trim(); +// +// $.get('/path/to/subcategories', { category: category }, function (subcategories) { +// // пример: subcategories = ["Зелень", "Овощи", "Фрукты"] +// +// // удалим уже существующие строки подкатегорий +// $categorySpan.closest('tr').nextAll('tr').each(function () { +// if ($(this).find('.subcategory').length > 0) { +// $(this).remove(); +// } else { +// return false; // как только наткнулись на следующую категорию — останавливаемся +// } +// }); +// +// // вставим строки +// let $categoryRow = $categorySpan.closest('tr'); +// $.each(subcategories, function (i, subcategory) { +// let row = $(''); +// let td = $(''); +// let span = $('', { +// class: 'list-group-item list-group-item-action subcategory-link', +// style: 'width: 95%', +// 'data-category': category, +// 'data-subcategory': subcategory, +// text: subcategory +// }); +// td.append(span); +// row.append(td); +// +// // Добавим по колонке на каждый магазин +// $storeName): ?> +// row.append( +// $('
- - ▲ - + + +
- - ▶ - + + + - + ${item.name} - +
', { +// 'data-store-id': '', +// 'data-category': category, +// 'data-subcategory': subcategory +// }) +// ); +// +// +// $categoryRow.after(row); +// $categoryRow = row; // чтобы следующий вставлялся после предыдущего +// }); +// }); +// }); + $('#autoplannogramma').on('input', '.input', function () { $(this).closest('td').find('path').attr('fill', 'red');