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 $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
}
}

View File

@ -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('订单不是完成状态,不可进行今后');
}

View File

@ -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,9 +82,11 @@ 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) {
$build->where(function ($q) use ($keyword) {
@ -154,6 +157,7 @@ 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');
@ -253,7 +257,8 @@ 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();
@ -261,6 +266,15 @@ class Worker extends Backend
$build = model('worker')
->where('status', 1)
->with(['area'])
->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) {
@ -269,7 +283,6 @@ class Worker extends Backend
}
$list = $build
->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);

View File

@ -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');
}
}

View File

@ -3,7 +3,12 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('选择订单')}:</label>
<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="">
{/if}
</div>
</div>

View File

@ -6,6 +6,24 @@
<input id="c-username" class="form-control" name="row[username]" 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-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">
<label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label>
<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}">
</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">
<label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label>
<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>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<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>
<div class="col-xs-12 col-sm-8">
<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 2 == $row.dispatch_type} value="2">自动派单</option>
<option {if 1 == $row.dispatch_type} selected {/if} value="1">手动派单</option>
<option {if 2 == $row.dispatch_type} selected {/if} value="2">自动派单</option>
</select>
</div>
</div>
@ -67,8 +67,8 @@
<label class="control-label col-xs-12 col-sm-3">收款方式:</label>
<div class="col-xs-12 col-sm-8">
<select name="row[receive_type]" class="form-control selectpicker">
<option {if 1 == $row.receive_type} value="1">已收定金</option>
<option {if 2 == $row.receive_type} value="2">已收全款</option>
<option {if 1 == $row.receive_type} selected {/if} value="1">已收定金</option>
<option {if 2 == $row.receive_type} selected {/if} value="2">已收全款</option>
</select>
</div>
</div>

View File

@ -62,7 +62,7 @@
<div class="form-group">
<label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>
<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>

View File

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

View File

@ -4,6 +4,7 @@
<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)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>
</div>
<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="" />
</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">
<label class="control-label col-xs-12 col-sm-2">{:__('Deposit_amount')}:</label>
@ -35,7 +44,7 @@
</div>
<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">
<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>

View File

@ -37,6 +37,15 @@
value="{$row.area_id}"/>
</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">
<label class="control-label col-xs-12 col-sm-2">{:__('Deposit_amount')}:</label>
<div class="col-xs-12 col-sm-8">
@ -51,7 +60,7 @@
</div>
<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">
<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>

View File

@ -30,16 +30,16 @@
</ul>
</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="">
<!-- <div class="form-group">-->
<!-- <label class="col-xs-12 col-sm-2" style="padding-left: 0px;text-align: left">区域:</label>-->
<!-- <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="area_id" style="display: none" class="form-control" name="area_id" hidden type="text" />-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group">
<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">
<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" />
</div>
</div>
<!-- <div class="form-group">-->
<!-- <label class="col-xs-12 col-sm-2" style="text-align: left;padding-left: 0px;">工种:</label>-->
<!-- <div style="width: 300px;display: inline-block;">-->
@ -52,7 +52,7 @@
<!-- </div>-->
<!-- </div>-->
<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">
<input id="keyword" class="form-control" style="width: 100%;height: 32px" placeholder="名称或电话号码搜索" name="keyword" type="text" value="" />
</div>

View File

@ -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}
]
]
});

View File

@ -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();

View File

@ -32,38 +32,109 @@ 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: '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: [
{
@ -186,13 +257,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
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,14 +274,17 @@ 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 `<p class="btn btn-primary tab_chose" data-id="${id}">选择</p>`;
}},
}
},
]
],
search: false,
commonSearch: false,
});
function getQueryData() {
const
area_id = $('#area_id').val(),
@ -224,9 +301,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
if (keyword && keyword !== '') {
res += '&keyword=' + keyword;
}
console.log(res);
return res;
}
$("#c-city-search").on("cp:updated", function () {
var citypicker = $(this).data("citypicker");
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
@ -239,12 +316,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(),
});
});
var _data = items;
$("#reset_btn").on("click", function () {
$("#c-city-search").citypicker('reset');
$("#area_id").val('');
$("#test").val('');
$("#test").data('myvalue', '');
$("#keyword").val('');
$('#item_id').zdCascader.reload(_data,true);
table.bootstrapTable('refresh', {
url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(),
});
@ -259,17 +338,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer','cascader'], f
});
var _data = items;
$(function(){
$('#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);

View File

@ -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}
]
]
});

View File

@ -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}
]
]
});

View File

@ -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}
]
]
});

View File

@ -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 @@
</svg>
</span>
</span>`).insertAfter(this.$el);
//下拉列表
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>`));
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;
if (clear){
this.$el.val('').removeData('bindData').removeData('bindPathData');
}
this.$dropdownWrap.empty();
var selectedData = this.$el.data('bindData');
var $firstWrap = $(`<div class="zd-scrollbar ${this.CLASS.menuWrap}">
@ -240,16 +245,16 @@
</svg>`);
$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($(`<span class="${this.CLASS.checkClass.nodeSelectedIcon}">√</span>`));
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);
}
$.fn.zdCascader = function (options) {
options = $.extend({}, ZdCascader.DEFAULTS, options);
return this.each(function () {
var $this = $(this);
var data = $this.data('zdCascader');
if (!data) {
return;
data = new ZdCascader(this, options);
$this.data('zdCascader', data);
}
value = data[option].apply(data, args);
if (option === 'destroy') {
$this.removeData('zdCascader');
if (typeof options === 'string') {
if (ZdCascader.METHODS.indexOf(options) > -1) {
data[options]();
}
}
if (!data) {
$this.data('zdCascader', (data = new ZdCascader(this, options)));
}
});
}
return typeof value === 'undefined' ? this : value;
};
})(jQuery);