diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index a6cdabd..9ee351c 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -13,6 +13,7 @@ use think\Db; use think\exception\PDOException; use think\exception\ValidateException; use think\Model; +use function Symfony\Component\Clock\now; /** * 订单列管理 @@ -374,6 +375,53 @@ class Order extends Backend $this->success($order['order_no']); } + + public function addAbnormal($ids = null){ + if (false === $this->request->isPost()) { + + $abnormals = model('abnormal')->order('sort','desc')->select(); + $abnormals_data = []; + foreach ($abnormals as $abnormal){ + $abnormals_data [] = $abnormal->toArray(); + } + $order = model('order')->get($ids); + return $this->fetch('abnormal',['row' => $order,'options'=>$abnormals_data]); + } + $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 { + $insert = [ + 'order_id' => $params['order_id'], + 'status' => 0, + 'abnormal_id' => $params['abnormal_id'], + 'abnormal_title' => model('abnormal')->get($params['abnormal_id'])->title ?? '', + 'detail' => $params['detail'], + 'admin_id' => $this->auth->id, + 'admin_user' => $this->auth->getUserInfo()['username'] ?? '', + 'create_time' => now()->format('Y-m-d H:m:s'), + 'update_time' => now()->format('Y-m-d H:m:s'), + ]; + + $result = \model('order_abnormal')->insert($insert); + 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/view/order/abnormal.html b/application/admin/view/order/abnormal.html new file mode 100644 index 0000000..a078151 --- /dev/null +++ b/application/admin/view/order/abnormal.html @@ -0,0 +1,41 @@ +
diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index bb0b183..71c3989 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -18,6 +18,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function multi_url: 'order/multi', import_url: 'order/import', push_url: 'order/status', + addabnormal: 'order/addAbnormal', table: 'order', } }); @@ -193,6 +194,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function return false; } }, + { + name:"error", + text:"订单报错", + title:"订单报错", + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-warning btn-dialog', + icon: 'fa fa-bolt', + url: 'order/addAbnormal', + refresh:true, + }, ], } ] @@ -285,6 +296,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function copy: function () { Controller.api.bindevent(); }, + addabnormal: function () { + console.log('abnormal'); + Form.api.bindevent($("#add-form"),null,null,function (data) { + Form.api.submit($("#add-form")); + // console.log(data); + // return false; + }); + }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); @@ -292,10 +311,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function } }; - function parseAndFill() { - // 获取左侧输入框的内容 - } - return Controller; });