From 2db90bb54eaae120dca4f0d2c538ff9f013fa831 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Wed, 27 Nov 2024 15:12:40 +0300 Subject: [PATCH] =?utf8?q?[ERP-242]=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=B0?= =?utf8?q?=D1=82=D0=B8=D0=BA=D0=B0=20=D0=BD=D0=B0=20=D1=81=D1=82=D0=B0?= =?utf8?q?=D1=80=D1=8B=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D1=8F=20=D0=B8=20=D1=81=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B5=20?= =?utf8?q?=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=B0=D1=82=D0=B8=D1=87=D0=B5?= =?utf8?q?=D1=81=D0=BA=D0=B8=20=D0=B2=D1=8B=D1=87=D0=B8=D1=81=D0=BB=D1=8F?= =?utf8?q?=D0=B5=D0=BC=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/views/shift-transfer/update.php | 10 +-- erp24/web/js/shift-transfer/update.js | 99 +++++++++++++++------------ 2 files changed, 60 insertions(+), 49 deletions(-) diff --git a/erp24/views/shift-transfer/update.php b/erp24/views/shift-transfer/update.php index 04527fc3..140e6653 100644 --- a/erp24/views/shift-transfer/update.php +++ b/erp24/views/shift-transfer/update.php @@ -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'] ?? ''; }, diff --git a/erp24/web/js/shift-transfer/update.js b/erp24/web/js/shift-transfer/update.js index 636cc233..cdd49393 100644 --- a/erp24/web/js/shift-transfer/update.js +++ b/erp24/web/js/shift-transfer/update.js @@ -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); }); }); -- 2.39.5