]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
readonly и поменяли и спрятали колонки origin/feature_smirnov_2024_12_10_readonly
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 10 Dec 2024 10:38:06 +0000 (13:38 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 10 Dec 2024 10:38:06 +0000 (13:38 +0300)
erp24/views/shift-transfer/update.php
erp24/web/js/shift-transfer/update.js

index af154eaeaf1571bfce2e15e75bc09a3dfec9849b..5b88b7042c12c31971d7e165b5305c9ccd907032 100644 (file)
@@ -25,6 +25,10 @@ $this->registerCss('
         display: block !important;
         width: 40px;
     }
+
+    [data-hidden] {
+        display: none;
+    }
 ');
 
 $this->registerJs('var getMeOut = false;',  \yii\web\View::POS_HEAD, 'getMeOut');
@@ -122,21 +126,18 @@ $this->registerJs('var getMeOut = false;',  \yii\web\View::POS_HEAD, 'getMeOut')
                         'style' => 'width: 70px;',
                     ]
                 ],
-                /*[
-                    'name'  => 'group_label',
-                    'title' => 'Название группы',
-                    'type'  => Select2::class,
-                    'options' => [
-                        'data' => ProductsClass::getHints(),
-                        'readonly' => true
-                    ],
+                [
+                    'name'  => 'retail_price',
+                    'title' => 'Розничная цена, руб',
+                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
+                    'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true],
                     'value' => function($data) {
-                        return $data['group_label'] ?? 'other_items';
+                        return $data['retail_price'] ?? '';
                     },
                     'headerOptions' => [
                         'style' => 'width: 70px;',
                     ]
-                ], */
+                ],
                 [
                     'name'  => 'remains_count',
                     'title' => 'Фактические остатки кол-во, шт',
@@ -173,40 +174,28 @@ $this->registerJs('var getMeOut = false;',  \yii\web\View::POS_HEAD, 'getMeOut')
                         'style' => 'width: 70px;',
                     ]
                 ],
-                [
-                    'name'  => 'retail_price',
-                    'title' => 'Розничная цена, руб',
-                    'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true],
-                    'value' => function($data) {
-                        return $data['retail_price'] ?? '';
-                    },
-                    'headerOptions' => [
-                        'style' => 'width: 70px;',
-                    ]
-                ],
                 [
                     'name'  => 'self_cost',
-                    'title' => 'Себестоимость, руб',
+                    'title' => '',//'Себестоимость, руб',
                     'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true],
+                    'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true, 'data-hidden' => true],
                     'value' => function($data) {
                         return $data['self_cost'] ?? '';
                     },
                     'headerOptions' => [
-                        'style' => 'width: 70px;',
+                        'style' => 'width: 10px;',
                     ]
                 ],
                 [
                     'name'  => 'remains_summ',
-                    'title' => 'Сумма остатков (недостача или излишек), руб',
+                    'title' => '',//'Сумма остатков (недостача или излишек), руб',
                     'type'  => BaseColumn::TYPE_TEXT_INPUT,
-                    'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true],
+                    'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true, 'data-hidden' => true],
                     'value' => function($data) {
                         return $data['remains_summ'] ?? '';
                     },
                     'headerOptions' => [
-                        'style' => 'width: 70px;',
+                        'style' => 'width: 10px;',
                     ]
                 ],
             ],
index c1c4bea4e85e0b07461533a5187a770ad7f478d7..c08c274dc7cb586df48d347e3bf64781b18b79dc 100644 (file)
@@ -4,35 +4,6 @@
 const param24 = $('meta[name=csrf-param]').attr('content');
 const token24 = $('meta[name=csrf-token]').attr('content');
 
-// function updateProductsWithBalance(currentIndex, row) {
-//     const store = $('#shifttransfer-store_guid');
-//     const productGuid = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid');
-//     productGuid.empty();
-//     $.ajax({
-//         type: 'POST',
-//         url: '/shift-transfer/get-products-with-remains',
-//         data: { storeGuid: store.val(), [param24]: token24 },
-//         dataType: 'json',
-//         success: (data) => {
-//             console.log(data);
-//             $.each(data, (key, el) => {
-//                 console.log(key, el)
-//                 const opt = document.createElement('option');
-//                 opt.text = el;
-//                 opt.value = key;
-//                 productGuid.append(opt);
-//             })
-//         }
-//     });
-// }
-
-// function updateProductsWithBalanceAll() {
-//     const rows = $('.multiple-input-list__item');
-//     for (let currentIndex = 0; currentIndex < rows.length; currentIndex++) {
-//         updateProductsWithBalance(currentIndex + 1, rows[currentIndex]);
-//     }
-// }
-
 function checkInputRow(currentIndex, row, errorContainer) {
     const productGuid = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid');
     const productName = $(row).find('#select2-shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid-container').text();
@@ -105,12 +76,22 @@ function setMultipleInputHandlers(currentIndex, row) {
     remains_count.on('change', onChangeTarget);
 }
 
+function makeInputReadonly(currentIndex, row) {
+    const productGuid = $(row).find('#shifttransfer-shiftremainscopy-' + currentIndex + '-product_guid');
+    productGuid.select2({disabled: true});
+    const inp = $("<input>");
+    inp.attr('type', 'hidden');
+    inp.attr('value', productGuid.val());
+    inp.attr('name', 'ShiftTransfer[shiftRemainsCopy][' + currentIndex + '][product_guid]');
+    productGuid.parent().append(inp);
+}
 
 $(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]);
         }
     }).on('afterAddRow', function(e, row, currentIndex) {
         setMultipleInputHandlers(currentIndex, row);