From d9f1cc24e4c0059c4f638d8484ce6ebbd7959a59 Mon Sep 17 00:00:00 2001 From: todaywindy Date: Thu, 3 Jul 2025 14:18:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BE=E5=8D=95=E9=87=8D=E5=A4=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/orders/Dispatch.php | 3 ++- .../admin/controller/workers/Worker.php | 2 -- .../admin/view/orders/dispatch/map.html | 22 ++++++++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/application/admin/controller/orders/Dispatch.php b/application/admin/controller/orders/Dispatch.php index 92a717f..a465e3a 100644 --- a/application/admin/controller/orders/Dispatch.php +++ b/application/admin/controller/orders/Dispatch.php @@ -116,6 +116,7 @@ class Dispatch extends Backend return $this->view->fetch(); } +// dd(1); $params = $this->request->post('row/a'); // $this->success(); if (empty($params)) { @@ -149,7 +150,6 @@ class Dispatch extends Backend if(!empty($existDispatch)){ $this->error('该订单已经派单,不可重复操作'); } - sleep(2); $insert = [ 'admin_id' => $this->auth->id, @@ -202,6 +202,7 @@ class Dispatch extends Backend Db::rollback(); $this->error($e->getMessage()); } + sleep(2); if ($result === false) { $this->error(__('No rows were inserted')); } diff --git a/application/admin/controller/workers/Worker.php b/application/admin/controller/workers/Worker.php index 5c802f2..87d8fc2 100644 --- a/application/admin/controller/workers/Worker.php +++ b/application/admin/controller/workers/Worker.php @@ -403,8 +403,6 @@ WHERE distance < 50000 ORDER BY distance;",[$order->lng,$order->lat]); $worker_ids = array_column($worker_distance,'id'); - - $ids = $this->getParentIdsFromArray($order->item_id,$this->items); $ids [] = $order->item_id; $worker_items_ids = (new WorkerItem()) diff --git a/application/admin/view/orders/dispatch/map.html b/application/admin/view/orders/dispatch/map.html index 041aa05..31167ba 100644 --- a/application/admin/view/orders/dispatch/map.html +++ b/application/admin/view/orders/dispatch/map.html @@ -196,20 +196,24 @@ } function assignOrder(worker_id) { - // 可发起请求 const params = new URLSearchParams(window.location.search); const order_id = params.get('order_id'); + + const loadingIndex = layer.load(1, {shade: [0.1, '#fff']}); // 显示 loading + $.ajax({ url: '/admin/orders/dispatch/add', method: 'POST', contentType: 'application/json', - data: JSON.stringify({ worker_id,order_id }), + data: JSON.stringify({ worker_id, order_id }), success: function (res) { + layer.close(loadingIndex); // 关闭 loading Toastr.info('派单成功'); - close() + close(); }, error: function () { - Toastr.info('派单失败,请重试。'); + layer.close(loadingIndex); // 关闭 loading + Toastr.error('派单失败,请重试。'); } }); } @@ -247,7 +251,15 @@ // 委托方式绑定事件:监听 .assign-btn 点击 $(document).on('click', '.assign-btn', function () { const worker_id = $(this).data('id'); - assignOrder(worker_id); + const worker_name = $(this).data('name'); + + layer.confirm( + '确定要将订单派给 "' + worker_name + '" 吗?', + {icon: 3, title: '确认派单'}, + function (index) { + assignOrder(worker_id); + } + ); }); // 事件委托,绑定点击工人卡片的事件 $(document).on('click', '.worker-card', function (e) {