From: Alexander Smirnov Date: Tue, 10 Dec 2024 11:22:19 +0000 (+0300) Subject: Разрешение проблемы с индексами X-Git-Tag: 1.7~181^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=25fb512468c7ea6a4ed3984621ea84e81185a202;p=erp24_rep%2Fyii-erp24%2F.git Разрешение проблемы с индексами --- diff --git a/erp24/views/shift-transfer/update.php b/erp24/views/shift-transfer/update.php index 5b88b704..3a949f6c 100644 --- a/erp24/views/shift-transfer/update.php +++ b/erp24/views/shift-transfer/update.php @@ -104,6 +104,7 @@ $this->registerJs('var getMeOut = false;', \yii\web\View::POS_HEAD, 'getMeOut') [ 'name' => 'index', 'title' => '№', + 'options' => ['readonly' => true], 'value' => function () { static $counter = 1; return $counter++; diff --git a/erp24/web/js/shift-transfer/update.js b/erp24/web/js/shift-transfer/update.js index c08c274d..22719983 100644 --- a/erp24/web/js/shift-transfer/update.js +++ b/erp24/web/js/shift-transfer/update.js @@ -4,7 +4,8 @@ const param24 = $('meta[name=csrf-param]').attr('content'); const token24 = $('meta[name=csrf-token]').attr('content'); -function checkInputRow(currentIndex, row, errorContainer) { +function checkInputRow(row, errorContainer) { + const currentIndex = $(row).find('.list-cell__index').find('input').val() - 1; const productGuid = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid'); const productName = $(row).find('#select2-shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid-container').text(); //const groupLabel = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-group_label'); @@ -34,7 +35,7 @@ function checkInputs() { let noError = true; const errorContainer = []; for (let currentIndex = 0; currentIndex < rows.length; currentIndex++) { - noError = checkInputRow(currentIndex, rows[currentIndex], errorContainer) && noError; + noError = checkInputRow(rows[currentIndex], errorContainer) && noError; } if (errorContainer.length > 0) { alert(errorContainer.join('\n')); @@ -42,10 +43,9 @@ function checkInputs() { return noError; } -function setMultipleInputHandlers(currentIndex, row) { - // updateProductsWithBalance(currentIndex, row); +function setMultipleInputHandlers(row) { + const currentIndex = $(row).find('.list-cell__index').find('input').val() - 1; const store = $('#shifttransfer-store_guid'); - // const groupLabel = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-group_label'); const productGuid = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid'); const retailPrice = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-retail_price'); const selfCost = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-self_cost'); @@ -76,7 +76,8 @@ function setMultipleInputHandlers(currentIndex, row) { remains_count.on('change', onChangeTarget); } -function makeInputReadonly(currentIndex, row) { +function makeInputReadonly(row) { + const currentIndex = $(row).find('.list-cell__index').find('input').val() - 1; const productGuid = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid'); productGuid.select2({disabled: true}); const inp = $(""); @@ -90,11 +91,11 @@ $(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]); - makeInputReadonly(currentIndex, rows[currentIndex]); + setMultipleInputHandlers(rows[currentIndex]); + makeInputReadonly(rows[currentIndex]); } }).on('afterAddRow', function(e, row, currentIndex) { - setMultipleInputHandlers(currentIndex, row); + setMultipleInputHandlers(row); const index = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-index'); index.val(currentIndex+1); });