From 1e3946fd1b3823f16adc34b60ba4834ec005f5fc Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 4 Jul 2025 14:12:46 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?utf8?q?=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20?= =?utf8?q?=D0=B7=D0=B0=D0=B2=D0=B5=D1=80=D1=88=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?utf8?q?=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/CategoryPlanController.php | 8 ++---- erp24/web/js/category-plan/index.js | 26 +++++++++++++++++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index 1a05858a..cf303251 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -263,7 +263,6 @@ class CategoryPlanController extends Controller { 'month' => $model->month, 'storeId' => $model->store_id, 'status' => 'pending', - 'info' => 'auto', 'startTime' => date('Y-m-d H:i:s'), 'progress' => 0, 'error' => null @@ -276,7 +275,6 @@ class CategoryPlanController extends Controller { $log->context = json_encode($cacheValue, JSON_UNESCAPED_UNICODE); $log->year = (int)$cacheValue['year']; $log->month = (int)$cacheValue['month']; - $log->info = $cacheValue['info']; $log->active = 1; $log->progress = 0; $log->status = 1; @@ -608,7 +606,6 @@ class CategoryPlanController extends Controller { $year = (int)Yii::$app->request->get('year'); $month = (int)Yii::$app->request->get('month'); $store = (int)Yii::$app->request->get('store_id'); - $changes = Yii::$app->request->get('changes'); $taskName = "taskApRecalculate"; $scriptLauncherLog = ScriptLauncherLog::find() @@ -629,14 +626,13 @@ class CategoryPlanController extends Controller { 'status' => 'pending', 'startTime' => date('Y-m-d H:i:s'), 'progress' => 0, - 'error' => null + 'error' => null, ]; $log = new ScriptLauncherLog(); $log->source = 'CronController'; $log->category = 'autoplannogramma'; $log->prefix = 'actionAutoplannogrammaRecalculate'; $log->name = $taskName; - $log->info = $cacheValue['info']; $log->context = json_encode($cacheValue, JSON_UNESCAPED_UNICODE); $log->year = (int)$cacheValue['year']; $log->month = (int)$cacheValue['month']; @@ -661,7 +657,7 @@ class CategoryPlanController extends Controller { ->limit(1) ->one(); $task = json_decode($scriptLauncherLog->context, true ); - if (!$task || $scriptLauncherLog->active == 0) { + if (!$task) { return $this->asJson(['status' => 'not_found']); } diff --git a/erp24/web/js/category-plan/index.js b/erp24/web/js/category-plan/index.js index be55dbde..952716c9 100644 --- a/erp24/web/js/category-plan/index.js +++ b/erp24/web/js/category-plan/index.js @@ -215,6 +215,7 @@ $(document).ready(() => { $('#rebuild').prop('disabled', true).text('Пересчёт запущен...'); $('#delete').prop('disabled', true); $('#filter-btn').prop('disabled', true); + $.ajax({ url: '/category-plan/rebuild', type: 'GET', @@ -222,7 +223,6 @@ $(document).ready(() => { year: $('#dynamicmodel-year').val(), month: $('#dynamicmodel-month').val(), store_id: store_id, - changes: localStorage.getItem('planChanges'), [param26]: token26 }, success: function (data) { @@ -236,7 +236,6 @@ $(document).ready(() => { } if (data.status == 'started') { startTaskPolling(); - console.log(data.data); } @@ -250,7 +249,26 @@ $(document).ready(() => { } }); }); - startTaskPolling(); + $.ajax({ + url: '/category-plan/check-task', + type: 'GET', + dataType: 'json', + success: function (data) { + console.log(data.status); + console.log(data.start); + if (data.status === 'running' || data.status === 'pending') { + startTaskPolling(); + $('#rebuild').prop('disabled', true).text('Пересчёт запущен...'); + $('#delete').prop('disabled', true); + $('#filter-btn').prop('disabled', true); + $('#changes-hint').hide(); + $('#changes').hide(); + $('#changes-count').hide(); + $('#categoryPlan').addClass('block_table'); + } + } + }); + }); let taskPollInterval = null; @@ -304,5 +322,5 @@ function startTaskPolling() { } } }); - }, 3000); + }, 5000); } \ No newline at end of file -- 2.39.5