]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Фильтры и даты
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 19 Aug 2025 11:45:04 +0000 (14:45 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 19 Aug 2025 11:45:04 +0000 (14:45 +0300)
erp24/web/js/products1cNomenclatureActuality/index.js

index 8d8ec7929b136ea315ddb24f0ce7fff51bf6df72..8316b9b745bb3c9e9764aa1b6be620eec8341a92 100644 (file)
@@ -79,19 +79,24 @@ document.addEventListener("DOMContentLoaded", () => {
     $('#filter-date-from').on('change', function(){
         var from = $(this).val();
         var to = $('#filter-date-to');
+
         to.find('option').each(function(){
             var val = $(this).val();
-            if (val === '' || val >= from) {
-                $(this).show();
+            $(this).toggle(val === '' || !from || val >= from);
+        });
+
+        var cur = to.val();
+        if (from && (!cur || cur < from)) {
+            if (to.find(`option[value="${from}"]`).length) {
+                to.val(from).trigger('change');
             } else {
-                $(this).hide();
+                var firstVisible = to.find('option').filter(function(){ return $(this).is(':visible') && $(this).val(); }).first().val();
+                if (firstVisible) to.val(firstVisible).trigger('change');
             }
-        });
-        if (to.val() && to.val() < from) {
-            to.val(from);
         }
     });
 
+
     $('.clear-btn').on('click', function(){
         var target = $(this).data('target');
         $('#' + target).val(null).trigger('change');
@@ -239,17 +244,22 @@ document.addEventListener("DOMContentLoaded", () => {
         const $to = fromSelect.closest('td').find('.to-month');
         if (!$to.length) return;
 
-        // покажем только значения >= from (и пустую)
         $to.find('option').each(function(){
             const val = $(this).val();
             $(this).toggle(!val || !from || val >= from);
         });
 
         const curTo = $to.val();
-        if (from && curTo && curTo < from) {
-            $to.val(from);
+        if (from && (!curTo || curTo < from)) {
+            if ($to.find(`option[value="${from}"]`).length) {
+                $to.val(from).trigger('change');
+            } else {
+                const firstVisible = $to.find('option').filter(function(){ return $(this).is(':visible') && $(this).val(); }).first().val();
+                if (firstVisible) $to.val(firstVisible).trigger('change');
+            }
         }
     }
 
 
+
 });