From 12ab4135ca1c03f2866a1eec63e318b9d0ca2947 Mon Sep 17 00:00:00 2001 From: hant Date: Sat, 19 Apr 2025 17:44:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Order.php | 34 ++- .../admin/controller/aftersales/Aftersale.php | 18 +- .../admin/controller/workers/Worker.php | 87 +++--- application/admin/model/Worker.php | 12 + .../admin/view/aftersales/aftersale/add.html | 7 +- application/admin/view/blacklist/add.html | 18 ++ application/admin/view/blacklist/edit.html | 21 ++ application/admin/view/order/edit.html | 8 +- .../admin/view/orders/dispatch/add.html | 2 +- .../admin/view/setting/abnormal/add.html | 1 + .../admin/view/setting/abnormal/index.html | 1 + .../admin/view/workers/worker/add.html | 11 +- .../admin/view/workers/worker/edit.html | 11 +- .../admin/view/workers/worker/index.html | 18 +- public/assets/js/backend/blacklist.js | 30 ++- public/assets/js/backend/order.js | 54 +++- public/assets/js/backend/orders/dispatch.js | 254 ++++++++++++------ public/assets/js/backend/orders/invoice.js | 22 +- public/assets/js/backend/setting/abnormal.js | 21 +- public/assets/js/backend/workers/worker.js | 26 +- public/assets/js/cascader.js | 61 ++--- 21 files changed, 513 insertions(+), 204 deletions(-) diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 624463d..33b0184 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -34,6 +34,7 @@ class Order extends Backend protected $model = null; protected $sources = null; protected $items = null; + protected $itemsformattedTree = null; public function _initialize() { @@ -81,6 +82,7 @@ class Order extends Backend ->select(); $this->items = $items; + $this->itemsformattedTree = $formattedTree; $coupons = Db::name('coupons') @@ -196,11 +198,12 @@ class Order extends Backend } $sources = $this->sources; - $items = $this->items; $sources = array_column($sources, 'title', 'id'); - $items = array_column($items, 'title', 'id'); $params['source_shop'] = $sources[$params['source']] ?? null; - $params['item_title'] = $items[$params['item_id']] ?? null; + + $params['item_title'] = $this->findElementByValue($this->itemsformattedTree,$params['item_id'] ?? null); + + $params['admin_id'] = ($params['admin_id'] ?? -1) == -1 ? $this->auth->id : $params['admin_id']; if (empty($params['admin_id'])) { $params['admin_id'] = $this->auth->id; @@ -267,15 +270,13 @@ class Order extends Backend $items = $this->items; $sources = array_column($sources, 'title', 'id'); - $items = array_column($items, 'title', 'id'); $params['admin_id'] = ($params['admin_id'] == -1) ? $this->auth->id : $params['admin_id']; if (empty($params['admin_id'])) { $params['admin_id'] = $this->auth->id; } $params['source_shop'] = $sources[$params['source']] ?? null; - $params['item_title'] = $items[$params['item_id']] ?? null; - + $params['item_title'] = $this->findElementByValue($this->itemsformattedTree,$params['item_id'] ?? null); // $params['create_time'] = date('Y-m-d H:i:s'); $params['update_time'] = date('Y-m-d H:i:s'); @@ -610,4 +611,25 @@ class Order extends Backend } $this->success(); } + + function findElementByValue($data, $targetValue, $path = []) { + foreach ($data as $item) { + // 将当前节点的 label 添加到路径中 + $newPath = array_merge($path, [$item['label']]); + + // 如果找到目标值,返回路径 + if ($item['value'] == $targetValue) { + return implode(' / ', $newPath); + } + + // 如果当前节点有 children,递归搜索 + if (isset($item['children']) && is_array($item['children'])) { + $result = $this->findElementByValue($item['children'], $targetValue, $newPath); + if ($result) { + return $result; + } + } + } + return null; // 如果找不到返回 null + } } diff --git a/application/admin/controller/aftersales/Aftersale.php b/application/admin/controller/aftersales/Aftersale.php index ec94f8a..aa64433 100644 --- a/application/admin/controller/aftersales/Aftersale.php +++ b/application/admin/controller/aftersales/Aftersale.php @@ -84,9 +84,15 @@ class Aftersale extends Backend * @return string * @throws \think\Exception */ - public function add() + public function add($ids = null) { if (false === $this->request->isPost()) { + + if ($ids){ + $order = model('order')->get($ids); + $this->view->assign('order',$order); + } + return $this->view->fetch(); } $params = $this->request->post('row/a'); @@ -114,7 +120,8 @@ class Aftersale extends Backend if($order->status != Order::STATUS_FINISHED){ $this->error('订单不是完成状态,不可进行今后'); } - if(\app\admin\model\Aftersale::where('order_id',$params['order_id'])->where('status',[1,2,3])->find()){ + if(model('aftersale')->where('order_id',$params['order_id']) + ->whereIn('status',[1,2,3])->find()){ $this->error('订单已存在售后信息,不可重复创建'); } $params['admin_id'] = $this->auth->id; @@ -123,9 +130,9 @@ class Aftersale extends Backend $params['worker_name'] = $order->dispatch->worker_name; $result = $this->model->allowField(true)->save($params); Db::commit(); - } catch (ValidateException|PDOException|Exception $e) { + } catch (Exception $e) { Db::rollback(); - $this->error($e->getMessage()); + throw $e; } if ($result === false) { $this->error(__('No rows were inserted')); @@ -152,10 +159,11 @@ class Aftersale extends Backend $this->error(__('You have no permission')); } if (false === $this->request->isPost()) { - $order = Order::where($row->order_id)->find(); + $order = Order::get($row->order_id); if(empty($order)){ $this->error('订单不存在'); } + if($order->status != Order::STATUS_FINISHED){ $this->error('订单不是完成状态,不可进行今后'); } diff --git a/application/admin/controller/workers/Worker.php b/application/admin/controller/workers/Worker.php index 160b03b..27d11fd 100644 --- a/application/admin/controller/workers/Worker.php +++ b/application/admin/controller/workers/Worker.php @@ -4,6 +4,7 @@ namespace app\admin\controller\workers; use app\admin\model\AuthGroup; use app\admin\model\Item; +use app\admin\model\Order; use app\common\controller\Backend; use fast\Tree; use think\Db; @@ -81,22 +82,24 @@ class Worker extends Backend $item_id = request()->get('item_id'); $keyword = request()->get('keyword'); $build = $this->model - ->with(['area']) + ->with(['area','admin' => function($q){ + $q->withField(['id','username']); + }]) ->where($where) - ->field('worker.id,name,tel,area_id,create_time,deposit_amount,update_time,status,star') + ->field('worker.id,admin_id,type,name,tel,area_id,create_time,deposit_amount,update_time,status,star') ->order($sort, $order); - if ($keyword){ + if ($keyword) { $build->where(function ($q) use ($keyword) { - $q->where('name','like','%'.$keyword.'%')->whereOr('tel','like','%'.$keyword.'%'); + $q->where('name', 'like', '%' . $keyword . '%')->whereOr('tel', 'like', '%' . $keyword . '%'); }); } - if ($item_id){ - $build->join('worker_item','worker_item.worker_id = worker.id','left'); - $build->where('worker_item.item_id',$item_id); + if ($item_id) { + $build->join('worker_item', 'worker_item.worker_id = worker.id', 'left'); + $build->where('worker_item.item_id', $item_id); } - if ($area_code){ - $build->where('area_id','like',$this->getSelectAreaCode($area_code).'%'); + if ($area_code) { + $build->where('area_id', 'like', $this->getSelectAreaCode($area_code) . '%'); } $list = $build @@ -107,22 +110,22 @@ class Worker extends Backend return json($result); } - $items = Db::name('item') - ->where('status',1) - ->field(['id','title','key_word','pid']) - ->order('pid','asc') - ->order('sort','desc') + $items = Db::name('item') + ->where('status', 1) + ->field(['id', 'title', 'key_word', 'pid']) + ->order('pid', 'asc') + ->order('sort', 'desc') ->select(); - $filtered = array_filter($items, function($item) { + $filtered = array_filter($items, function ($item) { return $item['pid'] == 0; }); - $pid_map = array_column($filtered,null,'id'); + $pid_map = array_column($filtered, null, 'id'); $res_items = []; - foreach ($items as $item){ - if ($item['pid'] != 0 && isset($pid_map[$item['pid']])){ + foreach ($items as $item) { + if ($item['pid'] != 0 && isset($pid_map[$item['pid']])) { $res_items [] = [ - ...$item,'ptitle' => $pid_map[$item['pid']]['title'] + ...$item, 'ptitle' => $pid_map[$item['pid']]['title'] ]; } } @@ -154,9 +157,10 @@ class Worker extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; $this->model->validateFailException()->validate($validate); } + $params['admin_id'] = $this->auth->id; $result = $this->model->allowField(true)->save($params); $item_map = model('item')->getAll(); - $item_map = array_column($item_map,'level','id'); + $item_map = array_column($item_map, 'level', 'id'); if ($result) { $items = explode(',', $params['rules']); if ($items) { @@ -173,7 +177,7 @@ class Worker extends Backend } Db::commit(); - } catch (ValidateException|PDOException|Exception $e) { + } catch (ValidateException | PDOException | Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -188,12 +192,12 @@ class Worker extends Backend { if (!$ids) { - if (request()->isPost()){ + if (request()->isPost()) { $ids = input('id'); - if (!$ids){ + if (!$ids) { $this->error('缺少订单ID'); } - }else{ + } else { $this->error('缺少订单ID'); } } @@ -210,7 +214,7 @@ class Worker extends Backend $params = input('post.row/a'); $item_map = model('item')->getAll(); - $item_map = array_column($item_map,'level','id'); + $item_map = array_column($item_map, 'level', 'id'); if ($ids) { $items = explode(',', $params['rules']); if ($items) { @@ -222,7 +226,7 @@ class Worker extends Backend 'item_path_id' => $item_map[$item] ?? 0 ]; } - model('WorkerItem')->where('worker_id',$ids)->delete(); + model('WorkerItem')->where('worker_id', $ids)->delete(); model('WorkerItem')->insertAll($insert); } } @@ -234,14 +238,14 @@ class Worker extends Backend $this->success('更新成功', 'index'); } $area_name = model('area')->getNameByCode($worker->area_id); - $worker->area_name = str_replace(',','/',$area_name); + $worker->area_name = str_replace(',', '/', $area_name); - $select_ids = model('WorkerItem')->where('worker_id',$ids)->field('item_id') + $select_ids = model('WorkerItem')->where('worker_id', $ids)->field('item_id') ->select(); - $select_ids = array_column($select_ids,'item_id'); - foreach ($this->tree as $index=>$item){ - if (in_array($item['parent'],$select_ids)){ + $select_ids = array_column($select_ids, 'item_id'); + foreach ($this->tree as $index => $item) { + if (in_array($item['parent'], $select_ids)) { $this->tree[$index]['state']['selected'] = true; } } @@ -253,23 +257,32 @@ class Worker extends Backend return $this->fetch(); } - public function dispatchList(){ + public function dispatchList() + { $area_id = request()->get('area_id'); list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $build = model('worker') - ->where('status',1) + ->where('status', 1) ->with(['area']) - ->field(['id','name','tel','area_id','lng','lat']); + ->withCount(['myorder' => function ($query) { + $query->where('status', Order::STATUS_FINISHED); + return 'finish_order'; + },]) + ->withCount(['myorder' => function ($query) { + $query->where('status', '<', Order::STATUS_FINISHED) + ->where('status', '>=', Order::STATUS_DRAFT); + return 'doing_order'; + }]) + ->field(['id', 'name', 'tel', 'area_id', 'lng', 'lat']); - if ($area_id){ + if ($area_id) { $code = $this->getSelectAreaCode(substr_replace($area_id, '00', -2)); - $build->where('area_id','like', $code.'%'); + $build->where('area_id', 'like', $code . '%'); } $list = $build ->paginate($limit); - $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); diff --git a/application/admin/model/Worker.php b/application/admin/model/Worker.php index e5f554e..6f22ed1 100644 --- a/application/admin/model/Worker.php +++ b/application/admin/model/Worker.php @@ -50,4 +50,16 @@ class Worker extends BaseModel return $this->belongsTo('Area', 'area_id', 'area_code'); } + public function admin() + { + return $this->belongsTo('admin', 'admin_id'); + } + + + public function myorder(){ + + return $this->hasMany(OrderDispatch::class, 'worker_id'); + + } + } diff --git a/application/admin/view/aftersales/aftersale/add.html b/application/admin/view/aftersales/aftersale/add.html index 0b8c088..0303c06 100644 --- a/application/admin/view/aftersales/aftersale/add.html +++ b/application/admin/view/aftersales/aftersale/add.html @@ -3,7 +3,12 @@
- + {if isset($order)} + + + {else /}value3 + + {/if}
diff --git a/application/admin/view/blacklist/add.html b/application/admin/view/blacklist/add.html index 09765fb..1e6dd1c 100644 --- a/application/admin/view/blacklist/add.html +++ b/application/admin/view/blacklist/add.html @@ -6,6 +6,24 @@ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
diff --git a/application/admin/view/blacklist/edit.html b/application/admin/view/blacklist/edit.html index 6892123..a428f5b 100644 --- a/application/admin/view/blacklist/edit.html +++ b/application/admin/view/blacklist/edit.html @@ -6,12 +6,33 @@
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
diff --git a/application/admin/view/order/edit.html b/application/admin/view/order/edit.html index a211ac9..b8211c0 100644 --- a/application/admin/view/order/edit.html +++ b/application/admin/view/order/edit.html @@ -56,8 +56,8 @@
@@ -67,8 +67,8 @@
diff --git a/application/admin/view/orders/dispatch/add.html b/application/admin/view/orders/dispatch/add.html index 0198677..0bb919f 100644 --- a/application/admin/view/orders/dispatch/add.html +++ b/application/admin/view/orders/dispatch/add.html @@ -62,7 +62,7 @@
- +
diff --git a/application/admin/view/setting/abnormal/add.html b/application/admin/view/setting/abnormal/add.html index f4a1a06..a4a3473 100644 --- a/application/admin/view/setting/abnormal/add.html +++ b/application/admin/view/setting/abnormal/add.html @@ -14,6 +14,7 @@ class="form-control"> + diff --git a/application/admin/view/setting/abnormal/index.html b/application/admin/view/setting/abnormal/index.html index 774eecc..a59c6e8 100644 --- a/application/admin/view/setting/abnormal/index.html +++ b/application/admin/view/setting/abnormal/index.html @@ -4,6 +4,7 @@
diff --git a/application/admin/view/workers/worker/add.html b/application/admin/view/workers/worker/add.html index 00fc0df..c872d5f 100644 --- a/application/admin/view/workers/worker/add.html +++ b/application/admin/view/workers/worker/add.html @@ -20,6 +20,15 @@
+
+ +
+ +
+
@@ -35,7 +44,7 @@
- +
diff --git a/application/admin/view/workers/worker/edit.html b/application/admin/view/workers/worker/edit.html index d1c51f4..a0a7966 100644 --- a/application/admin/view/workers/worker/edit.html +++ b/application/admin/view/workers/worker/edit.html @@ -37,6 +37,15 @@ value="{$row.area_id}"/>
+
+ +
+ +
+
@@ -51,7 +60,7 @@
- +
diff --git a/application/admin/view/workers/worker/index.html b/application/admin/view/workers/worker/index.html index f96cc4c..cfc788f 100644 --- a/application/admin/view/workers/worker/index.html +++ b/application/admin/view/workers/worker/index.html @@ -30,16 +30,16 @@
- {:__('Recycle bin')} +
- - - - - - - +
+ +
+ + +
+
@@ -52,7 +52,7 @@
- +
diff --git a/public/assets/js/backend/blacklist.js b/public/assets/js/backend/blacklist.js index 510cf20..efb9a6b 100644 --- a/public/assets/js/backend/blacklist.js +++ b/public/assets/js/backend/blacklist.js @@ -26,12 +26,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'user.nickname', title: __('User_id')}, - {field: 'username', title: __('Username'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'user.nickname', title: '创建人'}, + {field: 'username', title: '账号', operate: 'LIKE', formatter: Table.api.formatter.content}, + {field: 'nickname', title: '昵称'}, + {field: 'phone', title: '电话'}, + {field: 'address', title: '地址'}, + {field: 'reason', title: '原因'}, + {field: 'remarks', title: '备注'}, {field: 'added_time', title: __('Added_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'removed_time', title: __('Removed_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'status', title: __('Status'), searchList: {"active":__('Active'),"removed":__('Removed')}, formatter: Table.api.formatter.status}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, + buttons:[ + { + name: 'edit', + text: "修改", + icon: 'fa fa-pencil', + title: __('Edit'), + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-info btn-editone', + }, + { + name: 'del', + text: "删除", + icon: 'fa fa-trash', + title: __('Delete'), + extend: 'data-toggle="tooltip"', + classname: 'btn btn-xs btn-danger btn-delone', + }, + ], + events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index 436bc9b..11f3e1d 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -186,18 +186,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function buttons: [ { name: 'edit', - text: "编辑", + text: "修改", icon: 'fa fa-pencil', title: __('Edit'), extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-info btn-editone', + visible: function (row) { + if (row.status != 60) { + return true; + } + return false; + }, }, { name: 'push', icon: 'fa fa-copy', - title: '复制', - text: "复制", + title: '复制订单', + text: "复制订单", url: 'order/copy', extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-dialog', @@ -268,14 +274,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function } }, { name: 'delete', - text: '取消', - title: '取消', + text: '取消订单', + title: '取消订单', classname: 'btn btn-dialog', icon: 'fa fa-trash', url: 'order/delete', dropdown: "更多", visible: function (row) { - if (row.status >= 0) { + if (row.status >= 0 && row.status < 60) { return true; } return false; @@ -291,6 +297,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function url: 'order/addAbnormal', refresh:true, dropdown: "更多", + visible: function (row) { + if (row.status != 60) { + return true; + } + return false; + }, }, { name: 'invoice', @@ -302,12 +314,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function dropdown: "更多", visible: function (row) { - if (row.status >= 0) { + if (row.status == 60) { return true; } return false; }, }, + { + name: 'aftersale', + text: '申请售后', + title: '申请售后', + classname: 'btn btn-dialog', + icon: 'fa fa-phone-square', + url: 'aftersales/aftersale/add', + dropdown: "更多", + visible: function (row) { + if (row.status === 60) { + return true; + } + return false; + }, + }, + ], } ] @@ -415,6 +443,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function }); }, edit: function () { + var _data = items; + + $('#item_id').zdCascader({ + data: _data, + onChange: function ($this, data, allPathData) { + // console.log(data,allPathData); + $('#item_id_value').val(data.value); + } + }); + $('#item_id').val($('#item_id').data('value')).focus(); Controller.api.bindevent(); }, copy: function () { @@ -429,13 +467,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function }); }, delete: function () { - console.log('delete'); Form.api.bindevent($("form[role=form]")); }, invoice: function () { function toggleInvoiceFields() { const type = $('#c-source').val(); - console.log(type); if (type === '1') { // 公司发票 $('#c-tax_number').closest('.form-group').show(); diff --git a/public/assets/js/backend/orders/dispatch.js b/public/assets/js/backend/orders/dispatch.js index 497cc4d..a44baeb 100644 --- a/public/assets/js/backend/orders/dispatch.js +++ b/public/assets/js/backend/orders/dispatch.js @@ -1,4 +1,4 @@ -define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], function ($, undefined, Backend, Table, Form) { +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'layer', 'cascader'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { @@ -32,50 +32,121 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f {field: 'order.order_no', title: __('Order.order_no'), operate: 'LIKE'}, - {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"10":__('Status 10'),"20":__('Status 20'),"25":__('Status 25'),"30":__('Status 30'),"60":__('Status 60'),"-10":__('Status -10'),"-20":__('Status -20'),"-30":__('Status -30')}, formatter: Table.api.formatter.status}, + { + field: 'status', + title: __('Status'), + searchList: { + "0": __('Status 0'), + "10": __('Status 10'), + "20": __('Status 20'), + "25": __('Status 25'), + "30": __('Status 30'), + "60": __('Status 60'), + "-10": __('Status -10'), + "-20": __('Status -20'), + "-30": __('Status -30') + }, + formatter: Table.api.formatter.status + }, // {field: 'worker_id', title: __('Worker_id')}, {field: 'worker_name', title: __('Worker_name'), operate: 'LIKE'}, {field: 'worker_tel', title: __('Worker_tel'), operate: 'LIKE'}, - {field: 'type', title: __('Type'), searchList: {"1":__('Type 1')}, formatter: Table.api.formatter.normal}, - + { + field: 'type', + title: __('Type'), + searchList: {"1": __('Type 1')}, + formatter: Table.api.formatter.normal + }, {field: 'order.source_shop', title: __('Order.source_shop'), operate: 'LIKE'}, {field: 'order.source', title: __('Order.source')}, {field: 'order.customer', title: __('Order.customer'), operate: 'LIKE'}, {field: 'order.tel', title: __('Order.tel'), operate: 'LIKE'}, - {field: 'order.address', title: __('Order.address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + { + field: 'order.address', + title: __('Order.address'), + operate: 'LIKE', + table: table, + class: 'autocontent', + formatter: Table.api.formatter.content + }, {field: 'order.item_title', title: __('Order.item_title'), operate: 'LIKE'}, - {field: 'order.detail', title: __('Order.detail'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + { + field: 'order.detail', + title: __('Order.detail'), + operate: 'LIKE', + table: table, + class: 'autocontent', + formatter: Table.api.formatter.content + }, - {field: 'order.images', title: __('Order.images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, + { + field: 'order.images', + title: __('Order.images'), + operate: false, + events: Table.api.events.image, + formatter: Table.api.formatter.images + }, - {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + { + field: 'remark', + title: __('Remark'), + operate: 'LIKE', + table: table, + class: 'autocontent', + formatter: Table.api.formatter.content + }, - {field: 'plan_time', title: __('Plan_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + { + field: 'plan_time', + title: __('Plan_time'), + operate: 'RANGE', + addclass: 'datetimerange', + autocomplete: false + }, // {field: 'is_notice', title: __('Is_notice'), searchList: {"0":__('Is_notice 0'),"1":__('Is_notice 1')}, formatter: Table.api.formatter.normal}, - {field: 'finish_time', title: __('Finish_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - // {field: 'admin_id', title: __('Admin_id')}, + { + field: 'finish_time', + title: __('Finish_time'), + operate: 'RANGE', + addclass: 'datetimerange', + autocomplete: false + }, + // {field: 'admin_id', title: __('Admin_id')}, {field: 'admin_user', title: __('Admin_user'), operate: 'LIKE'}, - {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + { + field: 'create_time', + title: __('Create_time'), + operate: 'RANGE', + addclass: 'datetimerange', + autocomplete: false + }, + { + field: 'update_time', + title: __('Update_time'), + operate: 'RANGE', + addclass: 'datetimerange', + autocomplete: false + }, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, + { + field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons: [ { name: 'edit', - text:"修改", - title:"修改", + text: "修改", + title: "修改", icon: 'fa fa-pencil', //title: __('Edit'), extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-success btn-editone', - visible:function(row){ - if(row.btn_edit){ + visible: function (row) { + if (row.btn_edit) { return true; } return false; @@ -83,37 +154,37 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f }, { - name:"income", - text:"新增收款", - title:"新增收款", - classname:"btn-view btn-dialog", + name: "income", + text: "新增收款", + title: "新增收款", + classname: "btn-view btn-dialog", extend: 'data-toggle="tooltip" data-container="body"', - icon:'fa fa-money', - url: function(row){ - return 'orders/income/add?order_id='+row.order_id; + icon: 'fa fa-money', + url: function (row) { + return 'orders/income/add?order_id=' + row.order_id; }, - dropdown:"更多", - visible:function(row){ - if(row.btn_income){ + dropdown: "更多", + visible: function (row) { + if (row.btn_income) { return true; } return false; }, - refresh:true, + refresh: true, }, { - name:"abnormal", - text:"创建异常", - title:"创建异常", - classname:"btn-add btn-dialog", + name: "abnormal", + text: "创建异常", + title: "创建异常", + classname: "btn-add btn-dialog", extend: 'data-toggle="tooltip" data-container="body"', - icon:'fa fa-question', - url:function(row) { - return "orders/abnormal/add?order_id="+row.order_id + icon: 'fa fa-question', + url: function (row) { + return "orders/abnormal/add?order_id=" + row.order_id }, - dropdown:"更多", - visible:function(row){ - if(row.btn_income){ + dropdown: "更多", + visible: function (row) { + if (row.btn_income) { return true; } return false; @@ -122,38 +193,38 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f }, { name: 'del', - text:"取消任务", - title:"取消任务", + text: "取消任务", + title: "取消任务", icon: 'fa fa-trash red', //title: __('Del'), extend: 'data-toggle="tooltip" data-container="body"', classname: '', - dropdown:"更多", - click: function (data, row) { + dropdown: "更多", + click: function (data, row) { layer.prompt({ - formType: 1, - value: '', - title: '请输入备注', - maxlength: 140, - },function(value, index, elem) { + formType: 1, + value: '', + title: '请输入备注', + maxlength: 140, + }, function (value, index, elem) { var url = 'orders/dispatch/del' + row.id; var options = {url: url, data: {remark: value}}; Fast.api.ajax(options, function (data, ret) { // table.trigger("uncheckbox"); table.bootstrapTable('refresh'); }) - },function (data, ret) { - var error = $(this).data("error") || $.noop; - if (typeof error === 'function') { - if (false === error.call(this, data, ret)) { - return false; + }, function (data, ret) { + var error = $(this).data("error") || $.noop; + if (typeof error === 'function') { + if (false === error.call(this, data, ret)) { + return false; } } }); layer.close(index); }, - visible:function(row){ - if(row.btn_cancel){ + visible: function (row) { + if (row.btn_cancel) { return true; } return false; @@ -183,16 +254,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f // 初始化表格 table.bootstrapTable({ - url: $.fn.bootstrapTable.defaults.extend.index_url + '?'+ getQueryData(), + url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(), pk: 'id', sortName: 'id', - fixedColumns: true, + fixedColumns: false, fixedRightNumber: 1, columns: [ [ // {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'name', title: __('Name'), operate: 'LIKE'}, + {field: 'finish_order', title: '接单总数'}, + {field: 'doing_order', title: '当前服务订单数'}, + {field: 'star', title: '星级'}, {field: 'tel', title: '电话', operate: 'LIKE'}, // {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status}, //{field: 'area_id', title: __('Area_id')}, @@ -200,77 +274,81 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f //{field: 'lat', title: __('Lat'), operate:'BETWEEN'}, {field: 'area.short_merge_name', title: '区域', operate: 'LIKE'}, // {field: 'deposit_amount', title: __('Deposit_amount'), operate:'BETWEEN'}, - {field: 'id', title: '操作',formatter:function (id) { + { + field: 'id', title: '操作', formatter: function (id) { return `

选择

`; - }}, + } + }, ] ], - search:false, - commonSearch:false, + search: false, + commonSearch: false, }); - function getQueryData(){ + + function getQueryData() { const area_id = $('#area_id').val(), item_id = $('#item_id').data('myvalue'), keyword = $('#keyword').val() ; let res = ''; - if (area_id && area_id !== ''){ + if (area_id && area_id !== '') { res += '&area_id=' + area_id; } - if (item_id && item_id !== ''){ + if (item_id && item_id !== '') { res += '&item_id=' + item_id; } - if (keyword && keyword !== ''){ + if (keyword && keyword !== '') { res += '&keyword=' + keyword; } - console.log(res); return res; } - $("#c-city-search").on("cp:updated", function() { + + $("#c-city-search").on("cp:updated", function () { var citypicker = $(this).data("citypicker"); var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province"); // table.bootstrapTable('refresh',{query: {area_code: code}}); $('#area_id').val(code); }); - $("#search_btn").on("click", function() { - console.log($.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData()); - table.bootstrapTable('refresh',{ - url:$.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(), + $("#search_btn").on("click", function () { + console.log($.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData()); + table.bootstrapTable('refresh', { + url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(), }); }); - $("#reset_btn").on("click", function() { + var _data = items; + $("#reset_btn").on("click", function () { $("#c-city-search").citypicker('reset'); $("#area_id").val(''); $("#test").val(''); - $("#test").data('myvalue',''); + $("#test").data('myvalue', ''); $("#keyword").val(''); - table.bootstrapTable('refresh',{ - url:$.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(), + $('#item_id').zdCascader.reload(_data,true); + table.bootstrapTable('refresh', { + url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(), }); }); Form.events.citypicker($("#select-form")); - $(document).on('click', '.tab_chose', function() { + $(document).on('click', '.tab_chose', function () { var dataId = $(this).data('id'); // 获取 data-id 的值 - const worker = Table.api.getrowbyid(table ,dataId); + const worker = Table.api.getrowbyid(table, dataId); $('#c-worker_name').val(worker.name + '--' + worker.tel).trigger('input').trigger('change'); $('#c-worker_id').val(worker.id).trigger('input').trigger('change'); }); - var _data = items; - $(function(){ - $('#item_id').zdCascader({ - data:_data, - onChange: function ($this,data,allPathData) { - // console.log(data,allPathData); - $('#item_id').data('myvalue',data.value); - } - }); - }); + $('#item_id').zdCascader({ + data: _data, + onChange: function ($this, data, allPathData) { + // console.log(data,allPathData); + $('#item_id').data('myvalue', data.value); + }, + defaultValue:$('#item_id_name').val() + }); + // 为表格绑定事件 Table.api.bindevent(table); @@ -281,7 +359,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f }, api: { bindevent: function () { - Form.api.bindevent($("#add-form"),null,null,function (data) { + Form.api.bindevent($("#add-form"), null, null, function (data) { // Form.api.submit($("#add-form")); // return false; }); diff --git a/public/assets/js/backend/orders/invoice.js b/public/assets/js/backend/orders/invoice.js index 2c99569..daf391c 100644 --- a/public/assets/js/backend/orders/invoice.js +++ b/public/assets/js/backend/orders/invoice.js @@ -55,7 +55,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'recipient_phone', title: __('Recipient_phone'), operate: 'LIKE'}, {field: 'issued_at', title: __('Issued_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), table: table, + events: Table.api.events.operate, + buttons:[ + { + name: 'edit', + text: "修改", + icon: 'fa fa-pencil', + title: __('Edit'), + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-info btn-editone', + }, + { + name: 'del', + text: "删除", + icon: 'fa fa-trash', + title: __('Delete'), + extend: 'data-toggle="tooltip"', + classname: 'btn btn-xs btn-danger btn-delone', + }, + ], + formatter: Table.api.formatter.operate} ] ] }); diff --git a/public/assets/js/backend/setting/abnormal.js b/public/assets/js/backend/setting/abnormal.js index 961ee7b..03866a9 100644 --- a/public/assets/js/backend/setting/abnormal.js +++ b/public/assets/js/backend/setting/abnormal.js @@ -33,7 +33,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin }}, {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} + {field: 'operate', title: __('Operate'), table: table, + buttons:[ + { + name: 'edit', + text: "修改", + icon: 'fa fa-pencil', + title: __('Edit'), + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-info btn-editone', + }, + { + name: 'del', + text: "删除", + icon: 'fa fa-trash', + title: __('Delete'), + extend: 'data-toggle="tooltip"', + classname: 'btn btn-xs btn-danger btn-delone', + }, + ], + events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); diff --git a/public/assets/js/backend/workers/worker.js b/public/assets/js/backend/workers/worker.js index 8a8abfa..c0cd15b 100644 --- a/public/assets/js/backend/workers/worker.js +++ b/public/assets/js/backend/workers/worker.js @@ -43,7 +43,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'], [ {checkbox: true}, {field: 'id', title: __('Id')}, + {field: 'admin.username', title:'创建人'}, {field: 'name', title: __('Name'), operate: 'LIKE'}, + {field: 'type', title: '师傅归属', formatter: function (val){ + return val === 1 ? '自营':'非自营'; + }}, {field: 'tel', title: __('Tel'), operate: 'LIKE'}, {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status}, //{field: 'area_id', title: __('Area_id')}, @@ -54,7 +58,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'], {field: 'star', title: __('Star'), operate:'BETWEEN'}, {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + {field: 'operate', title: __('Operate'), + buttons:[ + { + name: 'edit', + text: "修改", + icon: 'fa fa-pencil', + title: __('Edit'), + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-info btn-editone', + }, + { + name: 'del', + text: "删除", + icon: 'fa fa-trash', + title: __('Delete'), + extend: 'data-toggle="tooltip"', + classname: 'btn btn-xs btn-danger btn-delone', + }, + ], + table: table, events: Table.api.events.operate, + formatter: Table.api.formatter.operate} ] ] }); diff --git a/public/assets/js/cascader.js b/public/assets/js/cascader.js index 4eea347..6a496a0 100644 --- a/public/assets/js/cascader.js +++ b/public/assets/js/cascader.js @@ -49,7 +49,8 @@ ZdCascader.DEFAULTS = { data: null, //支持格式[{value:"",label:"",children:[{value:"",label:""}]}] range: ' / ', //分割符 - onChange: function (data) {} + onChange: function (data) {}, + defaultValue: null // 新增 defaultValue 属性 } ZdCascader.METHODS = ['reload', 'destroy']; @@ -84,6 +85,7 @@ `).insertAfter(this.$el); + //下拉列表 this.$dropdownWrap = $(`
`).appendTo(this.$container).wrap(`
`); @@ -145,6 +147,7 @@ $that.prepend($(``)); this.$el.data('bindData', data); this.$el.data('bindPathData', allPathData); + console.log(allPathData); if (this.options.onChange && typeof this.options.onChange === "function") this.options.onChange(this, data, allPathData); event.stopPropagation(); @@ -212,9 +215,11 @@ this.$el.remove(); } //重新加载下拉数据 - ZdCascader.prototype.reload = function (data) { + ZdCascader.prototype.reload = function (data,clear = false) { data = data || this.options.data; - this.$el.val('').removeData('bindData').removeData('bindPathData'); + if (clear){ + this.$el.val('').removeData('bindData').removeData('bindPathData'); + } this.$dropdownWrap.empty(); var selectedData = this.$el.data('bindData'); var $firstWrap = $(`
@@ -240,16 +245,16 @@ `); $li.append($label).data('bindData', m); if (m.children && m.children.length > 0) $li.append($icon); - else if (selectedData && m.value == selectedData.value) { + else if (this.options.defaultValue && m.value == this.options.defaultValue) { this.$dropdownWrap.find('.' + this.CLASS.checkClass.nodeSelectedIcon).remove(); $li.prepend($(``)); + this.$el.val(m.label); } $ul.append($li); }); - this.$dropdownWrap.find('li.' + this.CLASS.checkClass.nodeAnchor).removeClass(this.CLASS.checkClass.nodeAnchor); - this.$dropdownWrap.append($firstWrap).find(this.CLASS.menuNode).eq(0).focus().addClass(this.CLASS.checkClass - .nodeAnchor); + this.$dropdownWrap.append($firstWrap); } + ZdCascader.prototype._keyup = function (event) { var keycode = event.which; switch (keycode) { @@ -359,38 +364,22 @@ this.$el.focus(); } - $.fn.zdCascader = function (option) { - var value, - args = Array.prototype.slice.call(arguments, 1); - - this.each(function () { - var $this = $(this), - data = $this.data('zdCascader'), - options = $.extend({}, ZdCascader.DEFAULTS, $this.data(), - typeof option === 'object' && option); - - if (typeof option === 'string') { - if ($.inArray(option, ZdCascader.METHODS) < 0) { - throw new Error("Unknown method: " + option); - } - - if (!data) { - return; - } - - value = data[option].apply(data, args); - - if (option === 'destroy') { - $this.removeData('zdCascader'); - } - } - + $.fn.zdCascader = function (options) { + options = $.extend({}, ZdCascader.DEFAULTS, options); + return this.each(function () { + var $this = $(this); + var data = $this.data('zdCascader'); if (!data) { - $this.data('zdCascader', (data = new ZdCascader(this, options))); + data = new ZdCascader(this, options); + $this.data('zdCascader', data); + } + if (typeof options === 'string') { + if (ZdCascader.METHODS.indexOf(options) > -1) { + data[options](); + } } }); + } - return typeof value === 'undefined' ? this : value; - }; })(jQuery); \ No newline at end of file