From 6d9772e6c94f6750d7657611f7fd8eb036da2604 Mon Sep 17 00:00:00 2001 From: hant Date: Wed, 9 Apr 2025 20:21:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Order.php | 34 ++++++++++++++++ application/admin/model/Order.php | 11 +++++ application/admin/view/order/delete.html | 40 +++++++++++++++++++ application/admin/view/order/index.html | 9 +++++ .../admin/view/orders/dispatch/index.html | 11 ----- public/assets/js/backend/order.js | 15 +++++++ 6 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 application/admin/view/order/delete.html diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 9ee351c..b70fd7b 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -422,6 +422,40 @@ class Order extends Backend } + public function delete($ids = null){ + if (false === $this->request->isPost()) { + + $options = \app\admin\model\Order::DELETED_TYPE; + $order = model('order')->get($ids); + return $this->fetch('delete',['row' => $order,'options'=>$options]); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + + $result = false; + Db::startTrans(); + try { + $order = model('order')->get($params['order_id']); + if (!$order){ + $this->error('Not Find'); + } + $params['status'] = \app\admin\model\Order::STATUS_CANCEL; + $result = $order->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException | PDOException | Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + private function filterAreaCodes(array $area_codes) { // 提取所有两位区号 diff --git a/application/admin/model/Order.php b/application/admin/model/Order.php index 6ccc972..411d49a 100644 --- a/application/admin/model/Order.php +++ b/application/admin/model/Order.php @@ -152,6 +152,17 @@ class Order extends Model return $tabStatus[$tab] ?? []; } + public const DELETED_TYPE = [ + 1 => '无相关师傅', + 2 => '距离客户太远', + 3 => '价格不同意', + 4 => '重复订单', + 5 => '联系客户已晚', + 6 => '询价后没有后续', + 7 => '一直联系不上', + 8 => '客户不能久等', + ]; + public function incomeBtnStatus(){ return array_merge($this->tabStatus(self::TAB_PENDING),[self::STATUS_AUDITING]); diff --git a/application/admin/view/order/delete.html b/application/admin/view/order/delete.html new file mode 100644 index 0000000..8a53540 --- /dev/null +++ b/application/admin/view/order/delete.html @@ -0,0 +1,40 @@ +
+ + +
+ +
+ +
+
+ + + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ + +
diff --git a/application/admin/view/order/index.html b/application/admin/view/order/index.html index 635c107..e3393c4 100644 --- a/application/admin/view/order/index.html +++ b/application/admin/view/order/index.html @@ -1,5 +1,14 @@
+ +
+ {:build_heading(null,FALSE)} + +
+
diff --git a/application/admin/view/orders/dispatch/index.html b/application/admin/view/orders/dispatch/index.html index b02bcb2..1f94282 100644 --- a/application/admin/view/orders/dispatch/index.html +++ b/application/admin/view/orders/dispatch/index.html @@ -1,15 +1,4 @@
- -
- {:build_heading(null,FALSE)} - -
-
diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index 71c3989..99b3885 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -203,6 +203,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function icon: 'fa fa-bolt', url: 'order/addAbnormal', refresh:true, + }, { + name: 'delete', + text: '取消', + title: '取消', + classname: 'btn btn-xs btn-danger btn-dialog', + icon: 'fa fa-trash', + url: 'order/delete', + visible: function (row) { + //返回true时按钮显示,返回false隐藏 + return true; + } }, ], } @@ -304,6 +315,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function // return false; }); }, + delete: function () { + console.log('delete'); + Form.api.bindevent($("form[role=form]")); + }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]"));