diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index b70fd7b..e6f9716 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -124,6 +124,9 @@ class Order extends Backend if ($this->request->request('keyField')) { return $this->selectpage(); } + + $type = request()->get('type',1); + [$where, $sort, $order, $offset, $limit] = $this->buildparams(); $build = $this->model ->field(['id', 'order_no', 'admin_id', 'customer', 'tel', 'status', 'area_id', 'address', @@ -131,6 +134,14 @@ class Order extends Backend 'detail', 'remark', 'images', 'create_time', 'update_time', 'admin_id', 'dispatch_type', 'receive_type']) ->where($where); + if ($type == 1){ + $build->where('status','>=', 0); + } + + if ($type == 2){ + $build->where('status','<', 0); + } + if ($group == 2) { // 生成 SQL 语句 $area_codes = $this->filterAreaCodes(explode(',', $user->area_ids)); @@ -425,9 +436,13 @@ class Order extends Backend public function delete($ids = null){ if (false === $this->request->isPost()) { - $options = \app\admin\model\Order::DELETED_TYPE; + $options = \model('abnormal')->where('type',2)->select(); + $op = []; + foreach ($options as $option){ + $op[] = ['id' =>$option->id,'title'=>$option->title]; + } $order = model('order')->get($ids); - return $this->fetch('delete',['row' => $order,'options'=>$options]); + return $this->fetch('delete',['row' => $order,'options'=>$op]); } $params = $this->request->post('row/a'); if (empty($params)) { @@ -456,6 +471,46 @@ class Order extends Backend $this->success(); } + + public function send($ids = null){ + if (false === $this->request->isPost()) { + + $options = \model('admin')->select(); + $op = []; + foreach ($options as $option){ + $op[] = ['id' =>$option->id,'title'=>$option->nickname]; + } + $order = model('order')->get($ids); + return $this->fetch('delete',['row' => $order,'options'=>$op]); + } + $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/controller/setting/Abnormal.php b/application/admin/controller/setting/Abnormal.php index 4bf262b..12fdf86 100644 --- a/application/admin/controller/setting/Abnormal.php +++ b/application/admin/controller/setting/Abnormal.php @@ -33,5 +33,28 @@ class Abnormal extends Backend * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ + public function index() + { + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if (false === $this->request->isAjax()) { + return $this->view->fetch(); + } + //如果发送的来源是 Selectpage,则转发到 Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + [$where, $sort, $order, $offset, $limit] = $this->buildparams(); + + $type = request()->get('type',1); + + $list = $this->model + ->where($where) + ->where('type',$type) + ->order($sort, $order) + ->paginate($limit); + $result = ['total' => $list->total(), 'rows' => $list->items()]; + return json($result); + } } diff --git a/application/admin/view/order/delete.html b/application/admin/view/order/delete.html index 8a53540..b60bd41 100644 --- a/application/admin/view/order/delete.html +++ b/application/admin/view/order/delete.html @@ -16,9 +16,9 @@
- + {foreach $options as $item} + {/foreach}
diff --git a/application/admin/view/order/index.html b/application/admin/view/order/index.html index e3393c4..e370790 100644 --- a/application/admin/view/order/index.html +++ b/application/admin/view/order/index.html @@ -15,11 +15,7 @@
+ + +
+ +
+ +
+
+ + + + +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + diff --git a/application/admin/view/setting/abnormal/add.html b/application/admin/view/setting/abnormal/add.html index 7485883..f4a1a06 100644 --- a/application/admin/view/setting/abnormal/add.html +++ b/application/admin/view/setting/abnormal/add.html @@ -6,6 +6,18 @@ + +
+ +
+ +
+
+
diff --git a/application/admin/view/setting/abnormal/index.html b/application/admin/view/setting/abnormal/index.html index e0ca121..774eecc 100644 --- a/application/admin/view/setting/abnormal/index.html +++ b/application/admin/view/setting/abnormal/index.html @@ -1,6 +1,11 @@
{:build_heading()} - +
diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index 99b3885..7ad01f5 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -134,16 +134,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function buttons: [ { name: 'edit', + text:"编辑", icon: 'fa fa-pencil', title: __('Edit'), extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-success btn-editone' }, - { name: 'push', icon: 'fa fa-copy', title: '复制', + text:"复制", url: 'order/copy', extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-info btn-dialog', @@ -156,7 +157,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function text:"派单", title:"派单", extend: 'data-toggle="tooltip" data-container="body"', - classname: 'btn btn-xs btn-warning btn-dialog', + classname: 'btn btn-xs btn-info btn-dialog', //classname:"btn-view btn-dialog", icon:'fa fa-add', url: function(row){ @@ -170,6 +171,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function }, refresh:true, }, + { + name: 'send', + text: '中转订单', + title: '中转订单', + classname: 'btn btn-xs btn-info btn-dialog', + icon: 'fa fa-send', + url: 'order/send', + visible:function(row){ + if(row.status == 10){ + return true; + } + return false; + }, + }, { name:"reminder", text:"催单", @@ -192,7 +207,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function console.log(data, ret); Layer.alert(ret.msg); return false; - } + }, + visible:function(row){ + if(row.status > 0){ + return true; + } + return false; + }, }, { name:"error", @@ -210,10 +231,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function classname: 'btn btn-xs btn-danger btn-dialog', icon: 'fa fa-trash', url: 'order/delete', - visible: function (row) { - //返回true时按钮显示,返回false隐藏 - return true; - } + visible:function(row){ + if(row.status >= 0){ + return true; + } + return false; + }, }, ], } @@ -223,6 +246,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function // 为表格绑定事件 Table.api.bindevent(table); + let cloneQueryParams = null; + //绑定tab事件 + $('a[data-toggle="tab"]').on('show.bs.tab',function(event){ + let type =$(this).attr("data-value"); + let options = table.bootstrapTable('getOptions'); + $('.nav-tabs li').attr('class',''); + $(this).parent().attr("class",'active'); + options.pageNumber =1; + if (cloneQueryParams == null) { + cloneQueryParams = options.queryParams; + } + + options.queryParams =function(params){ + params.type = type; + return cloneQueryParams(params); + }; + table.bootstrapTable('refresh',{}); + return false; + }); + }, add: function () { $("#mybuttom").on("click", function() { diff --git a/public/assets/js/backend/setting/abnormal.js b/public/assets/js/backend/setting/abnormal.js index dc8dafb..961ee7b 100644 --- a/public/assets/js/backend/setting/abnormal.js +++ b/public/assets/js/backend/setting/abnormal.js @@ -28,6 +28,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ // {checkbox: true}, {field: 'id', title: __('Id')}, + {field: 'type', title: '种类',formatter: function ($val) { + return $val === 1 ? '异常类型' : '取消类型'; + }}, {field: 'title', title: __('Title'), operate: 'LIKE'}, {field: 'sort', title: __('Sort'),sortable:true}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} @@ -37,6 +40,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 为表格绑定事件 Table.api.bindevent(table); + + var cloneQueryParams = null; + //绑定tab事件 + $('a[data-toggle="tab"]').on('show.bs.tab',function(event){ + let type =$(this).attr("data-value"); + let options = table.bootstrapTable('getOptions'); + $('.nav-tabs li').attr('class',''); + $(this).parent().attr("class",'active'); + options.pageNumber =1; + if (cloneQueryParams == null) { + cloneQueryParams = options.queryParams; + } + + options.queryParams =function(params){ + params.type = type; + return cloneQueryParams(params); + }; + table.bootstrapTable('refresh',{}); + return false; + }); + }, add: function () { Controller.api.bindevent();