]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Разрешение проблемы с индексами origin/bug_smirnov_2024_12_10_mixed_indices
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 10 Dec 2024 11:22:19 +0000 (14:22 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 10 Dec 2024 11:22:19 +0000 (14:22 +0300)
erp24/views/shift-transfer/update.php
erp24/web/js/shift-transfer/update.js

index 5b88b7042c12c31971d7e165b5305c9ccd907032..3a949f6cbd49fba74dc9a450e9c732107fd6a57a 100644 (file)
@@ -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++;
index c08c274dc7cb586df48d347e3bf64781b18b79dc..227199830601ad44611dd3f53f360a7735054c07 100644 (file)
@@ -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 = $("<input>");
@@ -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);
     });