]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix plantation
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 22 Apr 2026 06:48:20 +0000 (09:48 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 22 Apr 2026 06:48:20 +0000 (09:48 +0300)
erp24/web/js/supplier/index.js

index 55be3fa566db525564c5a75c61f0a1ae0919833d..ff8f6e5da5686db819155244733db02fdc095a6c 100644 (file)
     console.log('[supplier] #supplier-modal найден:', !!modalEl);
 
     if (!modalEl) {
-        console.error('[supplier] КРИТИЧНО: #supplier-modal не найден в DOM — modal не создан');
         return;
     }
 
-    // Проверяем, есть ли уже Bootstrap-инстанс на элементе
-    var existingInstance = bootstrap.Modal.getInstance(modalEl);
-    console.log('[supplier] существующий bootstrap.Modal.getInstance:', existingInstance);
-
-    var supplierModal = new bootstrap.Modal(modalEl);
-    console.log('[supplier] новый bootstrap.Modal создан:', supplierModal);
-
     var editingId = null;
     var shouldReload = false;
+    var _bsModal = null;
 
     var loaderHtml = '<div class="text-center p-4"><i class="fa fa-spinner fa-spin fa-2x text-secondary"></i></div>';
 
+    function getModal() {
+        if (!_bsModal) {
+            _bsModal = new bootstrap.Modal(modalEl);
+        }
+        return _bsModal;
+    }
+
     modalEl.addEventListener('hidden.bs.modal', function () {
         if (shouldReload) {
             shouldReload = false;
@@ -50,9 +50,8 @@
         editingId = null;
         $('#supplier-modal-title').text('Добавить поставщика');
         $('#supplier-modal-body').html(loaderHtml);
-        console.log('[supplier] вызываем supplierModal.show()');
-        supplierModal.show();
-        console.log('[supplier] supplierModal.show() вызван, загружаем форму:', urls.createForm);
+        getModal().show();
+        console.log('[supplier] форму загружаем:', urls.createForm);
         $.get(urls.createForm, function (html) {
             console.log('[supplier] createForm ответ получен, длина HTML:', html.length);
             $('#supplier-modal-body').html(html);
@@ -73,7 +72,7 @@
         editingId = $btn.data('id');
         $('#supplier-modal-title').text('Редактировать поставщика');
         $('#supplier-modal-body').html(loaderHtml);
-        supplierModal.show();
+        getModal().show();
         $.get(urls.updateForm, {id: editingId}, function (html) {
             console.log('[supplier] updateForm ответ получен');
             $('#supplier-modal-body').html(html);
                 console.log('[supplier] сохранение ответ:', resp);
                 if (resp.success) {
                     shouldReload = true;
-                    supplierModal.hide();
+                    getModal().hide();
                 } else if (resp.errors) {
                     $saveBtn.prop('disabled', false);
                     $.each(resp.errors, function (field, messages) {