]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
добавил обновление данных feature_fomichev_erp_32_api_integration_save_fix
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 11 Sep 2024 11:25:28 +0000 (14:25 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 11 Sep 2024 11:25:28 +0000 (14:25 +0300)
erp24/views/api/integrations_index.php

index 8a65a493dd4d86bfbe9843ffa1d8b9b6d0f1e798..5c9afa6c0a9ef7c6502c8d4968c597014a04aec1 100644 (file)
@@ -18,17 +18,42 @@ use yii\web\View;
 
 $this->registerJs(<<<JS
     function ajaxLogSave(id, val) {
-        $.ajax({
-            url: '/api/integration-save/',
-            method: 'POST',
-            data: '&id=' + id + '&val=' + val + '&entity=$entity&export_id=$export_id',
-            success: function(data) {
-                alert(data);
-                // После успешного сохранения удаляем кнопки
+    $.ajax({
+        url: '/api/integration-save/',
+        method: 'POST',
+        data: '&id=' + id + '&val=' + val + '&entity=$entity&export_id=$export_id',
+        success: function(data) {
+            alert(data);
+
+            // Найти select с атрибутом name = id
+            var selectElement = $('select[name="' + id + '"]');
+
+            // Проверить, существует ли элемент
+            if (selectElement.length > 0) {
+                // Найти соседний элемент с data-select2-id, соответствующим id
+                var select2Container = $('*[data-select2-id="' + selectElement.attr('id').replace('w', '') + '"]');
+
+                // Найти элемент с классом select2-selection__rendered и получить значение атрибута title
+                var title = select2Container.find('.select2-selection__rendered').attr('title');
+
+                // Найти tr, содержащий этот select
+                var trElement = selectElement.closest('tr');
+
+                // Найти третью ячейку td в этом tr
+                var thirdTd = trElement.find('td').eq(2);
+
+                // Присвоить значение из title третьей ячейке td
+                if (title) {
+                    thirdTd.text(title);
+                }
+
+                // Удалить кнопки
                 $('.save-guid, .cancel-guid').remove();
             }
-        });
-    }
+        }
+    });
+}
+
 
     // Функция для отображения кнопок "Сохранить" и "Отмена"
     function showActionButtons(inputElement) {