This commit is contained in:
hant 2025-04-19 17:44:32 +08:00
parent 57caec1805
commit 12ab4135ca
21 changed files with 513 additions and 204 deletions

View File

@ -34,6 +34,7 @@ class Order extends Backend
protected $model = null; protected $model = null;
protected $sources = null; protected $sources = null;
protected $items = null; protected $items = null;
protected $itemsformattedTree = null;
public function _initialize() public function _initialize()
{ {
@ -81,6 +82,7 @@ class Order extends Backend
->select(); ->select();
$this->items = $items; $this->items = $items;
$this->itemsformattedTree = $formattedTree;
$coupons = Db::name('coupons') $coupons = Db::name('coupons')
@ -196,11 +198,12 @@ class Order extends Backend
} }
$sources = $this->sources; $sources = $this->sources;
$items = $this->items;
$sources = array_column($sources, 'title', 'id'); $sources = array_column($sources, 'title', 'id');
$items = array_column($items, 'title', 'id');
$params['source_shop'] = $sources[$params['source']] ?? null; $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']; $params['admin_id'] = ($params['admin_id'] ?? -1) == -1 ? $this->auth->id : $params['admin_id'];
if (empty($params['admin_id'])) { if (empty($params['admin_id'])) {
$params['admin_id'] = $this->auth->id; $params['admin_id'] = $this->auth->id;
@ -267,15 +270,13 @@ class Order extends Backend
$items = $this->items; $items = $this->items;
$sources = array_column($sources, 'title', 'id'); $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']; $params['admin_id'] = ($params['admin_id'] == -1) ? $this->auth->id : $params['admin_id'];
if (empty($params['admin_id'])) { if (empty($params['admin_id'])) {
$params['admin_id'] = $this->auth->id; $params['admin_id'] = $this->auth->id;
} }
$params['source_shop'] = $sources[$params['source']] ?? null; $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['create_time'] = date('Y-m-d H:i:s');
$params['update_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(); $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
}
} }

View File

@ -84,9 +84,15 @@ class Aftersale extends Backend
* @return string * @return string
* @throws \think\Exception * @throws \think\Exception
*/ */
public function add() public function add($ids = null)
{ {
if (false === $this->request->isPost()) { if (false === $this->request->isPost()) {
if ($ids){
$order = model('order')->get($ids);
$this->view->assign('order',$order);
}
return $this->view->fetch(); return $this->view->fetch();
} }
$params = $this->request->post('row/a'); $params = $this->request->post('row/a');
@ -114,7 +120,8 @@ class Aftersale extends Backend
if($order->status != Order::STATUS_FINISHED){ if($order->status != Order::STATUS_FINISHED){
$this->error('订单不是完成状态,不可进行今后'); $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('订单已存在售后信息,不可重复创建'); $this->error('订单已存在售后信息,不可重复创建');
} }
$params['admin_id'] = $this->auth->id; $params['admin_id'] = $this->auth->id;
@ -123,9 +130,9 @@ class Aftersale extends Backend
$params['worker_name'] = $order->dispatch->worker_name; $params['worker_name'] = $order->dispatch->worker_name;
$result = $this->model->allowField(true)->save($params); $result = $this->model->allowField(true)->save($params);
Db::commit(); Db::commit();
} catch (ValidateException|PDOException|Exception $e) { } catch (Exception $e) {
Db::rollback(); Db::rollback();
$this->error($e->getMessage()); throw $e;
} }
if ($result === false) { if ($result === false) {
$this->error(__('No rows were inserted')); $this->error(__('No rows were inserted'));
@ -152,10 +159,11 @@ class Aftersale extends Backend
$this->error(__('You have no permission')); $this->error(__('You have no permission'));
} }
if (false === $this->request->isPost()) { if (false === $this->request->isPost()) {
$order = Order::where($row->order_id)->find(); $order = Order::get($row->order_id);
if(empty($order)){ if(empty($order)){
$this->error('订单不存在'); $this->error('订单不存在');
} }
if($order->status != Order::STATUS_FINISHED){ if($order->status != Order::STATUS_FINISHED){
$this->error('订单不是完成状态,不可进行今后'); $this->error('订单不是完成状态,不可进行今后');
} }

View File

@ -4,6 +4,7 @@ namespace app\admin\controller\workers;
use app\admin\model\AuthGroup; use app\admin\model\AuthGroup;
use app\admin\model\Item; use app\admin\model\Item;
use app\admin\model\Order;
use app\common\controller\Backend; use app\common\controller\Backend;
use fast\Tree; use fast\Tree;
use think\Db; use think\Db;
@ -81,22 +82,24 @@ class Worker extends Backend
$item_id = request()->get('item_id'); $item_id = request()->get('item_id');
$keyword = request()->get('keyword'); $keyword = request()->get('keyword');
$build = $this->model $build = $this->model
->with(['area']) ->with(['area','admin' => function($q){
$q->withField(['id','username']);
}])
->where($where) ->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); ->order($sort, $order);
if ($keyword){ if ($keyword) {
$build->where(function ($q) use ($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){ if ($item_id) {
$build->join('worker_item','worker_item.worker_id = worker.id','left'); $build->join('worker_item', 'worker_item.worker_id = worker.id', 'left');
$build->where('worker_item.item_id',$item_id); $build->where('worker_item.item_id', $item_id);
} }
if ($area_code){ if ($area_code) {
$build->where('area_id','like',$this->getSelectAreaCode($area_code).'%'); $build->where('area_id', 'like', $this->getSelectAreaCode($area_code) . '%');
} }
$list = $build $list = $build
@ -108,21 +111,21 @@ class Worker extends Backend
} }
$items = Db::name('item') $items = Db::name('item')
->where('status',1) ->where('status', 1)
->field(['id','title','key_word','pid']) ->field(['id', 'title', 'key_word', 'pid'])
->order('pid','asc') ->order('pid', 'asc')
->order('sort','desc') ->order('sort', 'desc')
->select(); ->select();
$filtered = array_filter($items, function($item) { $filtered = array_filter($items, function ($item) {
return $item['pid'] == 0; return $item['pid'] == 0;
}); });
$pid_map = array_column($filtered,null,'id'); $pid_map = array_column($filtered, null, 'id');
$res_items = []; $res_items = [];
foreach ($items as $item){ foreach ($items as $item) {
if ($item['pid'] != 0 && isset($pid_map[$item['pid']])){ if ($item['pid'] != 0 && isset($pid_map[$item['pid']])) {
$res_items [] = [ $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; $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate); $this->model->validateFailException()->validate($validate);
} }
$params['admin_id'] = $this->auth->id;
$result = $this->model->allowField(true)->save($params); $result = $this->model->allowField(true)->save($params);
$item_map = model('item')->getAll(); $item_map = model('item')->getAll();
$item_map = array_column($item_map,'level','id'); $item_map = array_column($item_map, 'level', 'id');
if ($result) { if ($result) {
$items = explode(',', $params['rules']); $items = explode(',', $params['rules']);
if ($items) { if ($items) {
@ -173,7 +177,7 @@ class Worker extends Backend
} }
Db::commit(); Db::commit();
} catch (ValidateException|PDOException|Exception $e) { } catch (ValidateException | PDOException | Exception $e) {
Db::rollback(); Db::rollback();
$this->error($e->getMessage()); $this->error($e->getMessage());
} }
@ -188,12 +192,12 @@ class Worker extends Backend
{ {
if (!$ids) { if (!$ids) {
if (request()->isPost()){ if (request()->isPost()) {
$ids = input('id'); $ids = input('id');
if (!$ids){ if (!$ids) {
$this->error('缺少订单ID'); $this->error('缺少订单ID');
} }
}else{ } else {
$this->error('缺少订单ID'); $this->error('缺少订单ID');
} }
} }
@ -210,7 +214,7 @@ class Worker extends Backend
$params = input('post.row/a'); $params = input('post.row/a');
$item_map = model('item')->getAll(); $item_map = model('item')->getAll();
$item_map = array_column($item_map,'level','id'); $item_map = array_column($item_map, 'level', 'id');
if ($ids) { if ($ids) {
$items = explode(',', $params['rules']); $items = explode(',', $params['rules']);
if ($items) { if ($items) {
@ -222,7 +226,7 @@ class Worker extends Backend
'item_path_id' => $item_map[$item] ?? 0 '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); model('WorkerItem')->insertAll($insert);
} }
} }
@ -234,14 +238,14 @@ class Worker extends Backend
$this->success('更新成功', 'index'); $this->success('更新成功', 'index');
} }
$area_name = model('area')->getNameByCode($worker->area_id); $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();
$select_ids = array_column($select_ids,'item_id'); $select_ids = array_column($select_ids, 'item_id');
foreach ($this->tree as $index=>$item){ foreach ($this->tree as $index => $item) {
if (in_array($item['parent'],$select_ids)){ if (in_array($item['parent'], $select_ids)) {
$this->tree[$index]['state']['selected'] = true; $this->tree[$index]['state']['selected'] = true;
} }
} }
@ -253,23 +257,32 @@ class Worker extends Backend
return $this->fetch(); return $this->fetch();
} }
public function dispatchList(){ public function dispatchList()
{
$area_id = request()->get('area_id'); $area_id = request()->get('area_id');
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$build = model('worker') $build = model('worker')
->where('status',1) ->where('status', 1)
->with(['area']) ->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)); $code = $this->getSelectAreaCode(substr_replace($area_id, '00', -2));
$build->where('area_id','like', $code.'%'); $build->where('area_id', 'like', $code . '%');
} }
$list = $build $list = $build
->paginate($limit); ->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items()); $result = array("total" => $list->total(), "rows" => $list->items());
return json($result); return json($result);

View File

@ -50,4 +50,16 @@ class Worker extends BaseModel
return $this->belongsTo('Area', 'area_id', 'area_code'); 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');
}
} }

View File

@ -3,7 +3,12 @@
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('选择订单')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('选择订单')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
{if isset($order)}
<input id="c-order_sn" disabled data-rule="required" value="{$order.order_no}" class="form-control" type="text" >
<input id="c-order_id" value="{$order.id}" style="display: none" class="form-control" name="row[order_id]" type="text" >
{else /}value3
<input id="c-order_id" data-field="order_no" data-rule="required" data-source="order/index" class="form-control selectpage" name="row[order_id]" type="text" value=""> <input id="c-order_id" data-field="order_no" data-rule="required" data-source="order/index" class="form-control selectpage" name="row[order_id]" type="text" value="">
{/if}
</div> </div>
</div> </div>

View File

@ -6,6 +6,24 @@
<input id="c-username" class="form-control" name="row[username]" type="text"> <input id="c-username" class="form-control" name="row[username]" type="text">
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">昵称:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-nickname" class="form-control" name="row[nickname]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">电话:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-phone" class="form-control" name="row[phone]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">地址:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-address" class="form-control " rows="5" name="row[address]" cols="50"></textarea>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -6,12 +6,33 @@
<input id="c-username" class="form-control" name="row[username]" type="text" value="{$row.username|htmlentities}"> <input id="c-username" class="form-control" name="row[username]" type="text" value="{$row.username|htmlentities}">
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">昵称:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-nickname" class="form-control" value="{$row.nickname|htmlentities}" name="row[nickname]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">电话:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-phone" class="form-control" value="{$row.phone|htmlentities}" name="row[phone]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">地址:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-address" class="form-control " rows="5" name="row[address]" cols="50">{$row.address|htmlentities}</textarea>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<textarea id="c-reason" class="form-control " rows="5" name="row[reason]" cols="50">{$row.reason|htmlentities}</textarea> <textarea id="c-reason" class="form-control " rows="5" name="row[reason]" cols="50">{$row.reason|htmlentities}</textarea>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">

View File

@ -56,8 +56,8 @@
<label class="control-label col-xs-12 col-sm-3">派单方式:</label> <label class="control-label col-xs-12 col-sm-3">派单方式:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<select data-live-search="true" value="" name="row[dispatch_type]" class="form-control selectpicker show-tick"> <select data-live-search="true" value="" name="row[dispatch_type]" class="form-control selectpicker show-tick">
<option {if 1 == $row.dispatch_type} value="1">手动派单</option> <option {if 1 == $row.dispatch_type} selected {/if} value="1">手动派单</option>
<option {if 2 == $row.dispatch_type} value="2">自动派单</option> <option {if 2 == $row.dispatch_type} selected {/if} value="2">自动派单</option>
</select> </select>
</div> </div>
</div> </div>
@ -67,8 +67,8 @@
<label class="control-label col-xs-12 col-sm-3">收款方式:</label> <label class="control-label col-xs-12 col-sm-3">收款方式:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<select name="row[receive_type]" class="form-control selectpicker"> <select name="row[receive_type]" class="form-control selectpicker">
<option {if 1 == $row.receive_type} value="1">已收定金</option> <option {if 1 == $row.receive_type} selected {/if} value="1">已收定金</option>
<option {if 2 == $row.receive_type} value="2">已收全款</option> <option {if 2 == $row.receive_type} selected {/if} value="2">已收全款</option>
</select> </select>
</div> </div>
</div> </div>

View File

@ -62,7 +62,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label> <label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>
<div style="width: 300px;display: inline-block;"> <div style="width: 300px;display: inline-block;">
<input type="text" id="item_id" name="item_id" data-value="{$row.item_title}" value="{$row.item_id}" class="zd-input__inner"> <input type="text" id="item_id" name="item_id" value="{$row.item_title}" class="zd-input__inner">
</div> </div>
</div> </div>

View File

@ -14,6 +14,7 @@
class="form-control"> class="form-control">
<option selected value="1">异常类型</option> <option selected value="1">异常类型</option>
<option value="2">取消类型</option> <option value="2">取消类型</option>
<option value="3">报错类型</option>
</select> </select>
</div> </div>
</div> </div>

View File

@ -4,6 +4,7 @@
<ul class="nav nav-tabs" data-field="type"> <ul class="nav nav-tabs" data-field="type">
<li class="{:$Think.get.type === (string)1 ? 'active' : ''}"><a href="#t-1" data-value="1" data-toggle="tab">异常类型</a></li> <li class="{:$Think.get.type === (string)1 ? 'active' : ''}"><a href="#t-1" data-value="1" data-toggle="tab">异常类型</a></li>
<li class="{:$Think.get.type === (string)2 ? 'active' : ''}"><a href="#t-2" data-value="2" data-toggle="tab">取消类型</a></li> <li class="{:$Think.get.type === (string)2 ? 'active' : ''}"><a href="#t-2" data-value="2" data-toggle="tab">取消类型</a></li>
<li class="{:$Think.get.type === (string)2 ? 'active' : ''}"><a href="#t-3" data-value="3" data-toggle="tab">报错类型</a></li>
</ul> </ul>
</div> </div>
<div class="panel-body"> <div class="panel-body">

View File

@ -20,6 +20,15 @@
<input id="area_id" style="display: none" class="form-control" name="row[area_id]" hidden type="text" value="" /> <input id="area_id" style="display: none" class="form-control" name="row[area_id]" hidden type="text" value="" />
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅归属:</label>
<div class='col-xs-12 col-sm-8'>
<select data-live-search="true" name="row[type]" class="form-control">
<option selected value="1">自营</option>
<option value="2">非自营</option>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Deposit_amount')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Deposit_amount')}:</label>
@ -35,7 +44,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Items')}:</label> <label class="control-label col-xs-12 col-sm-2">师傅技能:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<span class="text-muted"><input type="checkbox" name="" id="checkall" /> <label for="checkall"><span>{:__('Check all')}</span></label></span> <span class="text-muted"><input type="checkbox" name="" id="checkall" /> <label for="checkall"><span>{:__('Check all')}</span></label></span>
<span class="text-muted"><input type="checkbox" name="" id="expandall" /> <label for="expandall"><span>{:__('Expand all')}</span></label></span> <span class="text-muted"><input type="checkbox" name="" id="expandall" /> <label for="expandall"><span>{:__('Expand all')}</span></label></span>

View File

@ -37,6 +37,15 @@
value="{$row.area_id}"/> value="{$row.area_id}"/>
</div> </div>
</div> </div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">师傅归属:</label>
<div class='col-xs-12 col-sm-8'>
<select data-live-search="true" name="row[type]" class="form-control">
<option {if 1 == $row.type} selected {/if} value="1">自营</option>
<option {if 2 == $row.type} selected {/if} value="2">非自营</option>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Deposit_amount')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Deposit_amount')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
@ -51,7 +60,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Items')}:</label> <label class="control-label col-xs-12 col-sm-2">师傅技能:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<span class="text-muted"><input type="checkbox" name="" id="checkall"/> <label for="checkall"><span>{:__('Check all')}</span></label></span> <span class="text-muted"><input type="checkbox" name="" id="checkall"/> <label for="checkall"><span>{:__('Check all')}</span></label></span>
<span class="text-muted"><input type="checkbox" name="" id="expandall"/> <label for="expandall"><span>{:__('Expand all')}</span></label></span> <span class="text-muted"><input type="checkbox" name="" id="expandall"/> <label for="expandall"><span>{:__('Expand all')}</span></label></span>

View File

@ -30,16 +30,16 @@
</ul> </ul>
</div> </div>
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('workers/worker/recyclebin')?'':'hide'}" href="workers/worker/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a> <!-- <a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('workers/worker/recyclebin')?'':'hide'}" href="workers/worker/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>-->
<form id="select-form" style="padding-left: 15px;margin-top: 10px" role="form" class="form-horizontal" data-toggle="validator" method="POST" action=""> <form id="select-form" style="padding-left: 15px;margin-top: 10px" role="form" class="form-horizontal" data-toggle="validator" method="POST" action="">
<!-- <div class="form-group">--> <div class="form-group">
<!-- <label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">区域:</label>--> <label class="col-xs-12 col-sm-3" style="padding-left: 0px;text-align: left">区域:</label>
<!-- <div style="display: inline-block;width: 300px;position: absolute">--> <div style="display: inline-block;width: 300px;position: absolute">
<!-- <input id="c-city-search" data-rule="required" class="form-control" data-toggle="city-picker" type="text" />--> <input id="c-city-search" data-rule="required" class="form-control" data-toggle="city-picker" type="text" />
<!-- <input id="area_id" style="display: none" class="form-control" name="area_id" hidden type="text" />--> <input id="area_id" style="display: none" class="form-control" name="area_id" hidden type="text" />
<!-- </div>--> </div>
<!-- </div>--> </div>
<!-- <div class="form-group">--> <!-- <div class="form-group">-->
<!-- <label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>--> <!-- <label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>-->
<!-- <div style="width: 300px;display: inline-block;">--> <!-- <div style="width: 300px;display: inline-block;">-->
@ -52,7 +52,7 @@
<!-- </div>--> <!-- </div>-->
<!-- </div>--> <!-- </div>-->
<div class="form-group"> <div class="form-group">
<label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">关键字:</label> <label class="col-xs-12 col-sm-3" style="padding-left: 0px;text-align: left">关键字:</label>
<div style="display: inline-block;width: 300px;position: absolute"> <div style="display: inline-block;width: 300px;position: absolute">
<input id="keyword" class="form-control" style="width: 100%;height: 32px" placeholder="名称或电话号码搜索" name="keyword" type="text" value="" /> <input id="keyword" class="form-control" style="width: 100%;height: 32px" placeholder="名称或电话号码搜索" name="keyword" type="text" value="" />
</div> </div>

View File

@ -26,12 +26,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[ [
{checkbox: true}, {checkbox: true},
{field: 'id', title: __('Id')}, {field: 'id', title: __('Id')},
{field: 'user.nickname', title: __('User_id')}, {field: 'user.nickname', title: '创建人'},
{field: 'username', title: __('Username'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {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: '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: '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: '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}
] ]
] ]
}); });

View File

@ -186,18 +186,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
buttons: [ buttons: [
{ {
name: 'edit', name: 'edit',
text: "编辑", text: "修改",
icon: 'fa fa-pencil', icon: 'fa fa-pencil',
title: __('Edit'), title: __('Edit'),
extend: 'data-toggle="tooltip" data-container="body"', extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-info btn-editone', classname: 'btn btn-xs btn-info btn-editone',
visible: function (row) {
if (row.status != 60) {
return true;
}
return false;
},
}, },
{ {
name: 'push', name: 'push',
icon: 'fa fa-copy', icon: 'fa fa-copy',
title: '复制', title: '复制订单',
text: "复制", text: "复制订单",
url: 'order/copy', url: 'order/copy',
extend: 'data-toggle="tooltip" data-container="body"', extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-dialog', classname: 'btn btn-dialog',
@ -268,14 +274,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
} }
}, { }, {
name: 'delete', name: 'delete',
text: '取消', text: '取消订单',
title: '取消', title: '取消订单',
classname: 'btn btn-dialog', classname: 'btn btn-dialog',
icon: 'fa fa-trash', icon: 'fa fa-trash',
url: 'order/delete', url: 'order/delete',
dropdown: "更多", dropdown: "更多",
visible: function (row) { visible: function (row) {
if (row.status >= 0) { if (row.status >= 0 && row.status < 60) {
return true; return true;
} }
return false; return false;
@ -291,6 +297,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
url: 'order/addAbnormal', url: 'order/addAbnormal',
refresh:true, refresh:true,
dropdown: "更多", dropdown: "更多",
visible: function (row) {
if (row.status != 60) {
return true;
}
return false;
},
}, },
{ {
name: 'invoice', name: 'invoice',
@ -302,12 +314,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
dropdown: "更多", dropdown: "更多",
visible: function (row) { visible: function (row) {
if (row.status >= 0) { if (row.status == 60) {
return true; return true;
} }
return false; 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 () { 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(); Controller.api.bindevent();
}, },
copy: function () { copy: function () {
@ -429,13 +467,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
}); });
}, },
delete: function () { delete: function () {
console.log('delete');
Form.api.bindevent($("form[role=form]")); Form.api.bindevent($("form[role=form]"));
}, },
invoice: function () { invoice: function () {
function toggleInvoiceFields() { function toggleInvoiceFields() {
const type = $('#c-source').val(); const type = $('#c-source').val();
console.log(type);
if (type === '1') { if (type === '1') {
// 公司发票 // 公司发票
$('#c-tax_number').closest('.form-group').show(); $('#c-tax_number').closest('.form-group').show();

View File

@ -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 = { var Controller = {
index: function () { 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: '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_id', title: __('Worker_id')},
{field: 'worker_name', title: __('Worker_name'), operate: 'LIKE'}, {field: 'worker_name', title: __('Worker_name'), operate: 'LIKE'},
{field: 'worker_tel', title: __('Worker_tel'), 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_shop', title: __('Order.source_shop'), operate: 'LIKE'},
{field: 'order.source', title: __('Order.source')}, {field: 'order.source', title: __('Order.source')},
{field: 'order.customer', title: __('Order.customer'), operate: 'LIKE'}, {field: 'order.customer', title: __('Order.customer'), operate: 'LIKE'},
{field: 'order.tel', title: __('Order.tel'), 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.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: '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: 'finish_time',
title: __('Finish_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false
},
// {field: 'admin_id', title: __('Admin_id')}, // {field: 'admin_id', title: __('Admin_id')},
{field: 'admin_user', title: __('Admin_user'), operate: 'LIKE'}, {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, formatter: Table.api.formatter.operate,
buttons: [ buttons: [
{ {
name: 'edit', name: 'edit',
text:"修改", text: "修改",
title:"修改", title: "修改",
icon: 'fa fa-pencil', icon: 'fa fa-pencil',
//title: __('Edit'), //title: __('Edit'),
extend: 'data-toggle="tooltip" data-container="body"', extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-editone', classname: 'btn btn-xs btn-success btn-editone',
visible:function(row){ visible: function (row) {
if(row.btn_edit){ if (row.btn_edit) {
return true; return true;
} }
return false; return false;
@ -83,37 +154,37 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
}, },
{ {
name:"income", name: "income",
text:"新增收款", text: "新增收款",
title:"新增收款", title: "新增收款",
classname:"btn-view btn-dialog", classname: "btn-view btn-dialog",
extend: 'data-toggle="tooltip" data-container="body"', extend: 'data-toggle="tooltip" data-container="body"',
icon:'fa fa-money', icon: 'fa fa-money',
url: function(row){ url: function (row) {
return 'orders/income/add?order_id='+row.order_id; return 'orders/income/add?order_id=' + row.order_id;
}, },
dropdown:"更多", dropdown: "更多",
visible:function(row){ visible: function (row) {
if(row.btn_income){ if (row.btn_income) {
return true; return true;
} }
return false; return false;
}, },
refresh:true, refresh: true,
}, },
{ {
name:"abnormal", name: "abnormal",
text:"创建异常", text: "创建异常",
title:"创建异常", title: "创建异常",
classname:"btn-add btn-dialog", classname: "btn-add btn-dialog",
extend: 'data-toggle="tooltip" data-container="body"', extend: 'data-toggle="tooltip" data-container="body"',
icon:'fa fa-question', icon: 'fa fa-question',
url:function(row) { url: function (row) {
return "orders/abnormal/add?order_id="+row.order_id return "orders/abnormal/add?order_id=" + row.order_id
}, },
dropdown:"更多", dropdown: "更多",
visible:function(row){ visible: function (row) {
if(row.btn_income){ if (row.btn_income) {
return true; return true;
} }
return false; return false;
@ -122,27 +193,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
}, },
{ {
name: 'del', name: 'del',
text:"取消任务", text: "取消任务",
title:"取消任务", title: "取消任务",
icon: 'fa fa-trash red', icon: 'fa fa-trash red',
//title: __('Del'), //title: __('Del'),
extend: 'data-toggle="tooltip" data-container="body"', extend: 'data-toggle="tooltip" data-container="body"',
classname: '', classname: '',
dropdown:"更多", dropdown: "更多",
click: function (data, row) { click: function (data, row) {
layer.prompt({ layer.prompt({
formType: 1, formType: 1,
value: '', value: '',
title: '请输入备注', title: '请输入备注',
maxlength: 140, maxlength: 140,
},function(value, index, elem) { }, function (value, index, elem) {
var url = 'orders/dispatch/del' + row.id; var url = 'orders/dispatch/del' + row.id;
var options = {url: url, data: {remark: value}}; var options = {url: url, data: {remark: value}};
Fast.api.ajax(options, function (data, ret) { Fast.api.ajax(options, function (data, ret) {
// table.trigger("uncheckbox"); // table.trigger("uncheckbox");
table.bootstrapTable('refresh'); table.bootstrapTable('refresh');
}) })
},function (data, ret) { }, function (data, ret) {
var error = $(this).data("error") || $.noop; var error = $(this).data("error") || $.noop;
if (typeof error === 'function') { if (typeof error === 'function') {
if (false === error.call(this, data, ret)) { if (false === error.call(this, data, ret)) {
@ -152,8 +223,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
}); });
layer.close(index); layer.close(index);
}, },
visible:function(row){ visible: function (row) {
if(row.btn_cancel){ if (row.btn_cancel) {
return true; return true;
} }
return false; return false;
@ -183,16 +254,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
// 初始化表格 // 初始化表格
table.bootstrapTable({ table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url + '?'+ getQueryData(), url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(),
pk: 'id', pk: 'id',
sortName: 'id', sortName: 'id',
fixedColumns: true, fixedColumns: false,
fixedRightNumber: 1, fixedRightNumber: 1,
columns: [ columns: [
[ [
// {checkbox: true}, // {checkbox: true},
{field: 'id', title: __('Id')}, {field: 'id', title: __('Id')},
{field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'finish_order', title: '接单总数'},
{field: 'doing_order', title: '当前服务订单数'},
{field: 'star', title: '星级'},
{field: 'tel', title: '电话', operate: 'LIKE'}, {field: 'tel', title: '电话', operate: 'LIKE'},
// {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status}, // {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
//{field: 'area_id', title: __('Area_id')}, //{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: 'lat', title: __('Lat'), operate:'BETWEEN'},
{field: 'area.short_merge_name', title: '区域', operate: 'LIKE'}, {field: 'area.short_merge_name', title: '区域', operate: 'LIKE'},
// {field: 'deposit_amount', title: __('Deposit_amount'), operate:'BETWEEN'}, // {field: 'deposit_amount', title: __('Deposit_amount'), operate:'BETWEEN'},
{field: 'id', title: '操作',formatter:function (id) { {
field: 'id', title: '操作', formatter: function (id) {
return `<p class="btn btn-primary tab_chose" data-id="${id}">选择</p>`; return `<p class="btn btn-primary tab_chose" data-id="${id}">选择</p>`;
}}, }
},
] ]
], ],
search:false, search: false,
commonSearch:false, commonSearch: false,
}); });
function getQueryData(){
function getQueryData() {
const const
area_id = $('#area_id').val(), area_id = $('#area_id').val(),
item_id = $('#item_id').data('myvalue'), item_id = $('#item_id').data('myvalue'),
keyword = $('#keyword').val() keyword = $('#keyword').val()
; ;
let res = ''; let res = '';
if (area_id && area_id !== ''){ if (area_id && area_id !== '') {
res += '&area_id=' + area_id; res += '&area_id=' + area_id;
} }
if (item_id && item_id !== ''){ if (item_id && item_id !== '') {
res += '&item_id=' + item_id; res += '&item_id=' + item_id;
} }
if (keyword && keyword !== ''){ if (keyword && keyword !== '') {
res += '&keyword=' + keyword; res += '&keyword=' + keyword;
} }
console.log(res);
return res; return res;
} }
$("#c-city-search").on("cp:updated", function() {
$("#c-city-search").on("cp:updated", function () {
var citypicker = $(this).data("citypicker"); var citypicker = $(this).data("citypicker");
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province"); var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
// table.bootstrapTable('refresh',{query: {area_code: code}}); // table.bootstrapTable('refresh',{query: {area_code: code}});
$('#area_id').val(code); $('#area_id').val(code);
}); });
$("#search_btn").on("click", function() { $("#search_btn").on("click", function () {
console.log($.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData()); console.log($.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData());
table.bootstrapTable('refresh',{ table.bootstrapTable('refresh', {
url:$.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(), 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'); $("#c-city-search").citypicker('reset');
$("#area_id").val(''); $("#area_id").val('');
$("#test").val(''); $("#test").val('');
$("#test").data('myvalue',''); $("#test").data('myvalue', '');
$("#keyword").val(''); $("#keyword").val('');
table.bootstrapTable('refresh',{ $('#item_id').zdCascader.reload(_data,true);
url:$.fn.bootstrapTable.defaults.extend.index_url +'?' + getQueryData(), table.bootstrapTable('refresh', {
url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(),
}); });
}); });
Form.events.citypicker($("#select-form")); Form.events.citypicker($("#select-form"));
$(document).on('click', '.tab_chose', function() { $(document).on('click', '.tab_chose', function () {
var dataId = $(this).data('id'); // 获取 data-id 的值 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_name').val(worker.name + '--' + worker.tel).trigger('input').trigger('change');
$('#c-worker_id').val(worker.id).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); Table.api.bindevent(table);
@ -281,7 +359,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
}, },
api: { api: {
bindevent: function () { 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")); // Form.api.submit($("#add-form"));
// return false; // return false;
}); });

View File

@ -55,7 +55,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'recipient_phone', title: __('Recipient_phone'), operate: 'LIKE'}, {field: 'recipient_phone', title: __('Recipient_phone'), operate: 'LIKE'},
{field: 'issued_at', title: __('Issued_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {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}
] ]
] ]
}); });

View File

@ -33,7 +33,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}}, }},
{field: 'title', title: __('Title'), operate: 'LIKE'}, {field: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'sort', title: __('Sort'),sortable:true}, {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}
] ]
] ]
}); });

View File

@ -43,7 +43,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
[ [
{checkbox: true}, {checkbox: true},
{field: 'id', title: __('Id')}, {field: 'id', title: __('Id')},
{field: 'admin.username', title:'创建人'},
{field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'type', title: '师傅归属', formatter: function (val){
return val === 1 ? '自营':'非自营';
}},
{field: 'tel', title: __('Tel'), operate: 'LIKE'}, {field: 'tel', title: __('Tel'), operate: 'LIKE'},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status}, {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
//{field: 'area_id', title: __('Area_id')}, //{field: 'area_id', title: __('Area_id')},
@ -54,7 +58,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','jstree'],
{field: 'star', title: __('Star'), operate:'BETWEEN'}, {field: 'star', title: __('Star'), operate:'BETWEEN'},
{field: 'create_time', title: __('Create_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: '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}
] ]
] ]
}); });

View File

@ -49,7 +49,8 @@
ZdCascader.DEFAULTS = { ZdCascader.DEFAULTS = {
data: null, //支持格式[{value:"",label:"",children:[{value:"",label:""}]}] data: null, //支持格式[{value:"",label:"",children:[{value:"",label:""}]}]
range: ' / ', //分割符 range: ' / ', //分割符
onChange: function (data) {} onChange: function (data) {},
defaultValue: null // 新增 defaultValue 属性
} }
ZdCascader.METHODS = ['reload', 'destroy']; ZdCascader.METHODS = ['reload', 'destroy'];
@ -84,6 +85,7 @@
</svg> </svg>
</span> </span>
</span>`).insertAfter(this.$el); </span>`).insertAfter(this.$el);
//下拉列表 //下拉列表
this.$dropdownWrap = $(`<div class="${this.CLASS.dropdownPanel}"></div>`).appendTo(this.$container).wrap(`<div class="${this.CLASS.dropdownWrap}"></div>`); this.$dropdownWrap = $(`<div class="${this.CLASS.dropdownPanel}"></div>`).appendTo(this.$container).wrap(`<div class="${this.CLASS.dropdownWrap}"></div>`);
@ -145,6 +147,7 @@
$that.prepend($(`<span class="${this.CLASS.checkClass.nodeSelectedIcon}">√</span>`)); $that.prepend($(`<span class="${this.CLASS.checkClass.nodeSelectedIcon}">√</span>`));
this.$el.data('bindData', data); this.$el.data('bindData', data);
this.$el.data('bindPathData', allPathData); this.$el.data('bindPathData', allPathData);
console.log(allPathData);
if (this.options.onChange && typeof this.options.onChange === "function") if (this.options.onChange && typeof this.options.onChange === "function")
this.options.onChange(this, data, allPathData); this.options.onChange(this, data, allPathData);
event.stopPropagation(); event.stopPropagation();
@ -212,9 +215,11 @@
this.$el.remove(); this.$el.remove();
} }
//重新加载下拉数据 //重新加载下拉数据
ZdCascader.prototype.reload = function (data) { ZdCascader.prototype.reload = function (data,clear = false) {
data = data || this.options.data; data = data || this.options.data;
if (clear){
this.$el.val('').removeData('bindData').removeData('bindPathData'); this.$el.val('').removeData('bindData').removeData('bindPathData');
}
this.$dropdownWrap.empty(); this.$dropdownWrap.empty();
var selectedData = this.$el.data('bindData'); var selectedData = this.$el.data('bindData');
var $firstWrap = $(`<div class="zd-scrollbar ${this.CLASS.menuWrap}"> var $firstWrap = $(`<div class="zd-scrollbar ${this.CLASS.menuWrap}">
@ -240,16 +245,16 @@
</svg>`); </svg>`);
$li.append($label).data('bindData', m); $li.append($label).data('bindData', m);
if (m.children && m.children.length > 0) $li.append($icon); 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(); this.$dropdownWrap.find('.' + this.CLASS.checkClass.nodeSelectedIcon).remove();
$li.prepend($(`<span class="${this.CLASS.checkClass.nodeSelectedIcon}">√</span>`)); $li.prepend($(`<span class="${this.CLASS.checkClass.nodeSelectedIcon}">√</span>`));
this.$el.val(m.label);
} }
$ul.append($li); $ul.append($li);
}); });
this.$dropdownWrap.find('li.' + this.CLASS.checkClass.nodeAnchor).removeClass(this.CLASS.checkClass.nodeAnchor); this.$dropdownWrap.append($firstWrap);
this.$dropdownWrap.append($firstWrap).find(this.CLASS.menuNode).eq(0).focus().addClass(this.CLASS.checkClass
.nodeAnchor);
} }
ZdCascader.prototype._keyup = function (event) { ZdCascader.prototype._keyup = function (event) {
var keycode = event.which; var keycode = event.which;
switch (keycode) { switch (keycode) {
@ -359,38 +364,22 @@
this.$el.focus(); this.$el.focus();
} }
$.fn.zdCascader = function (option) { $.fn.zdCascader = function (options) {
var value, options = $.extend({}, ZdCascader.DEFAULTS, options);
args = Array.prototype.slice.call(arguments, 1); return this.each(function () {
var $this = $(this);
this.each(function () { var data = $this.data('zdCascader');
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) { if (!data) {
return; data = new ZdCascader(this, options);
$this.data('zdCascader', data);
} }
if (typeof options === 'string') {
value = data[option].apply(data, args); if (ZdCascader.METHODS.indexOf(options) > -1) {
data[options]();
if (option === 'destroy') {
$this.removeData('zdCascader');
} }
} }
if (!data) {
$this.data('zdCascader', (data = new ZdCascader(this, options)));
}
}); });
}
return typeof value === 'undefined' ? this : value;
};
})(jQuery); })(jQuery);