]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-242] автоматика на старые значения и скрытие автоматически вычисляемых
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 27 Nov 2024 12:12:40 +0000 (15:12 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 27 Nov 2024 12:12:40 +0000 (15:12 +0300)
erp24/views/shift-transfer/update.php
erp24/web/js/shift-transfer/update.js

index 04527fc3c9071b4789e17aa7ca11e55c38969d64..140e665373872e6531d31e46a05454bcc96f8c47 100644 (file)
@@ -175,7 +175,7 @@ $this->registerCss('
                     'name'  => 'retail_price',
                     'title' => 'Розничная цена, руб',
                     'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
                     'value' => function($data) {
                         return $data['retail_price'] ?? '';
                     },
@@ -187,7 +187,7 @@ $this->registerCss('
                     'name'  => 'self_cost',
                     'title' => 'Себестоимость, руб',
                     'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
                     'value' => function($data) {
                         return $data['self_cost'] ?? '';
                     },
@@ -199,7 +199,7 @@ $this->registerCss('
                     'name'  => 'remains_summ',
                     'title' => 'Сумма остатков (недостача или излишек), руб',
                     'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
                     'value' => function($data) {
                         return $data['remains_summ'] ?? '';
                     },
@@ -223,7 +223,7 @@ $this->registerCss('
                     'name'  => 'fact_and_1c_diff',
                     'title' => 'Разница факт и по программе 1с, шт',
                     'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
                     'value' => function($data) {
                         return $data['fact_and_1c_diff'] ?? '';
                     },
@@ -235,7 +235,7 @@ $this->registerCss('
                     'name'  => 'remains_1c',
                     'title' => 'Остатки по 1с, шт',
                     'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01],
+                    'options' => ['type' => 'number', 'step' => 0.01, 'disabled' => true],
                     'value' => function($data) {
                         return $data['remains_1c'] ?? '';
                     },
index 636cc233a84edb860042746099981a6d5f731bd8..cdd4939356d700b35291e173e7c0943181bc3d53 100644 (file)
@@ -3,53 +3,64 @@
 const param24 = $('meta[name=csrf-param]').attr('content');
 const token24 = $('meta[name=csrf-token]').attr('content');
 
-$(document).ready(() => {
-    $('.multiple-input').on('afterAddRow', function(e, row, currentIndex) {
-        var store = $('#shifttransfer-store_guid');
-        var groupLabel = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-group_label');
-        var productGuid = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-product_guid');
-        var retailPrice = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-retail_price');
-        var selfCost = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-self_cost');
-        var remains1c = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_1c');
-        var remains_summ = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_summ');
-        var remains_count = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_count');
-        var fact_and_1c_diff = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-fact_and_1c_diff');
+function setMultipleInputHandlers(currentIndex, row) {
+    const store = $('#shifttransfer-store_guid');
+    const groupLabel = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-group_label');
+    const productGuid = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-product_guid');
+    const retailPrice = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-retail_price');
+    const selfCost = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-self_cost');
+    const remains1c = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_1c');
+    const remains_summ = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_summ');
+    const remains_count = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-remains_count');
+    const fact_and_1c_diff = $(row).find('#shifttransfer-shiftremains-' + currentIndex + '-fact_and_1c_diff');
 
-        function onChangeTarget() {
-            fact_and_1c_diff.val(remains_count.val() - remains1c.val());
-            remains_summ.val(remains_count.val() * retailPrice.val())
-        }
+    function onChangeTarget() {
+        fact_and_1c_diff.val(remains_count.val() - remains1c.val());
+        remains_summ.val(remains_count.val() * retailPrice.val())
+    }
 
-        groupLabel.on('change', (e) => {
-            $.ajax({
-                type: 'POST',
-                url: '/shift-transfer/get-products-by-group-label',
-                data: { groupLabel: e.target.value, [param24]: token24 },
-                dataType: 'json',
-                success: (data) => {
-                    productGuid.empty();
-                    $.each(data, (guid, name) => {
-                        var option = document.createElement('option');
-                        option.text = name;
-                        option.value = guid;
-                        productGuid.append(option);
-                    })
-                }
-            });
+    groupLabel.on('change', (e) => {
+        $.ajax({
+            type: 'POST',
+            url: '/shift-transfer/get-products-by-group-label',
+            data: { groupLabel: e.target.value, [param24]: token24 },
+            dataType: 'json',
+            success: (data) => {
+                productGuid.empty();
+                $.each(data, (guid, name) => {
+                    const option = document.createElement('option');
+                    option.text = name;
+                    option.value = guid;
+                    productGuid.append(option);
+                })
+            }
         });
-        productGuid.on('change', (e) => {
-            $.ajax({
-                type: 'POST',
-                url: '/shift-transfer/get-product-price-self-cost-and-remains',
-                data: { productGuid: e.target.value, storeGuid: store.val(), [param24]: token24 },
-                dataType: 'json',
-                success: (data) => {
-                    if (data.price) { retailPrice.val(data.price); }
-                    if (data.selfCost) { selfCost.val(data.selfCost); }
-                    if (data.quantity) { remains1c.val(data.quantity); }
-                }
-            });
+    });
+
+    productGuid.on('change', (e) => {
+        $.ajax({
+            type: 'POST',
+            url: '/shift-transfer/get-product-price-self-cost-and-remains',
+            data: { productGuid: e.target.value, storeGuid: store.val(), [param24]: token24 },
+            dataType: 'json',
+            success: (data) => {
+                if (data.price) { retailPrice.val(data.price); }
+                if (data.selfCost) { selfCost.val(data.selfCost); }
+                if (data.quantity) { remains1c.val(data.quantity); }
+            }
         });
-        remains_count.on('change', onChangeTarget);
+    });
+    remains_count.on('change', onChangeTarget);
+}
+
+
+$(document).ready(() => {
+    $('.multiple-input').on('afterInit', function(){
+        const rows = $('.multiple-input-list__item');
+        for (let currentIndex = 0; currentIndex < rows.length; currentIndex++) {
+            setMultipleInputHandlers(currentIndex, rows[currentIndex]);
+        }
+    }).on('afterAddRow', function(e, row, currentIndex) {
+        setMultipleInputHandlers(currentIndex, row);
     });
 });