From 478dd3710f12a410d8f4f829de7daf3c81fd11e3 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Thu, 11 Sep 2025 12:32:00 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=81=D0=B5=D1=87=D0=B5?= =?utf8?q?=D0=BD=D0=B8=D0=B5=20=D0=B8=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=B4?= =?utf8?q?=D0=B8=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../web/js/matrix-bouquet-actuality/index.js | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/erp24/web/js/matrix-bouquet-actuality/index.js b/erp24/web/js/matrix-bouquet-actuality/index.js index c0220c85..e010a4a7 100644 --- a/erp24/web/js/matrix-bouquet-actuality/index.js +++ b/erp24/web/js/matrix-bouquet-actuality/index.js @@ -173,10 +173,46 @@ filterSubgroups(); + function checkIntervalsForBouquetId(id) { + // Собираем все интервалы для товара (всех строк) + let intervals = []; + $('#actuality-form table tbody tr').each(function(){ + let $row = $(this); + let rowGuid = $row.find('input[type=hidden][name*="[bouquet_id]"]').val(); + if (rowGuid == id) { + let from = $row.find('select.from-month').val(); + let to = $row.find('select.to-month').val(); + if (from && to) intervals.push({from, to, $row}); + } + }); + intervals.sort((a,b) => a.from.localeCompare(b.from)); + + let hasOverlap = false; + for(let i=0; i= intervals[j].from) { + // Пересечение! + intervals[i].$row.addClass('table-danger'); + intervals[j].$row.addClass('table-danger'); + hasOverlap = true; + } + } + } + if (hasOverlap) { + if (!$('.interval-overlap-alert').length) { + $('
Пересекающиеся диапазоны по одному товару!
') + .insertBefore('#actuality-form'); + } + } else { + $('.interval-overlap-alert').remove(); + $('#actuality-form table tbody tr').removeClass('table-danger'); + } + return hasOverlap; + } $(document).on('change', '.from-month, .to-month', function(){ let $row = $(this).closest('tr'); - let guid = $row.find('input[type=hidden][name*="[guid]"]').val(); - checkIntervalsForGuid(guid); + let id = $row.find('input[type=hidden][name*="[bouquet_id]"]').val(); + checkIntervalsForBouquetId(id); }); function ymParse(ym) { @@ -323,7 +359,7 @@ const newRow = ` -
${name} (${id})
Новая запись. Заполните интервал
+
${name} (${guid})
Новая запись. Заполните интервал
${price}
-- 2.39.5