Accept Merge Request #149: (feature/hant -> develop)
Merge Request: Merge remote-tracking branch 'origin/develop' into feature/hant Created By: @todayswind Accepted By: @todayswind URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/149?initial=true
This commit is contained in:
commit
95bd51b5d8
|
|
@ -35,9 +35,8 @@ class Test extends Command
|
|||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$key = 'ae0ab397a2febfa1ce0a2c780f3f23a3';
|
||||
$res = $this->getAddressByKeyword('重庆武隆区凤山街道锦江竹苑6幢31-4');
|
||||
dd($res);
|
||||
$order = Order::where('id',221)->select()[0];
|
||||
AutoDispatchLogic::autoDispatch($order);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class AutoDispatchLogic
|
|||
|
||||
|
||||
$worker_id = (new DispatchLogic())->getMaxScoreWorker($order);
|
||||
// dd($worker_id);
|
||||
if (!$worker_id) {
|
||||
$order->dispatch_type = 1;
|
||||
$order->save();
|
||||
|
|
|
|||
|
|
@ -148,4 +148,33 @@ class Message extends Backend
|
|||
|
||||
}
|
||||
|
||||
public function markallread(){
|
||||
$list = $this->model
|
||||
->where('type',1)
|
||||
->where('to_id',$this->auth->id)
|
||||
//->auth($this->auth)
|
||||
//->whereRaw("FIND_IN_SET(?, read_uid) = 0 OR read_uid IS NULL OR read_uid = ''", [$this->auth->id])
|
||||
->whereRaw("FIND_IN_SET({$this->auth->id}, read_uid) = 0 OR read_uid = '' or read_uid is null")
|
||||
->whereTime('create_time', '>=', '-3 days')
|
||||
->select();
|
||||
$update = [];
|
||||
foreach ($list as &$item){
|
||||
$readUids = explode(',',$item->read_uid??'');
|
||||
$item->status = 1;
|
||||
if(!in_array($this->auth->id,$readUids)){
|
||||
$readUids[] = $this->auth->id;
|
||||
$update[] = [
|
||||
'id' => $item->id,
|
||||
'read_uid' => implode(',',$readUids),
|
||||
'update_time' => date('Y-m-d H:i:s')
|
||||
];
|
||||
$item->status = 0;
|
||||
}
|
||||
}
|
||||
if($update){
|
||||
$this->batchUpdateByIdSimple('fa_message',$update);
|
||||
}
|
||||
$this->success("全部已读");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ use app\admin\model\Worker;
|
|||
use app\admin\model\WorkerItem;
|
||||
use app\common\controller\Backend;
|
||||
use app\common\Logic\OrderLogic;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Traits\Creator;
|
||||
use fast\Tree;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
|
@ -146,6 +148,7 @@ class Order extends Backend
|
|||
'receive_type',
|
||||
'plan_time',
|
||||
'coupon_id',
|
||||
'create_time',
|
||||
'total',
|
||||
'online_amount',
|
||||
'aftersale_id'
|
||||
|
|
@ -153,18 +156,33 @@ class Order extends Backend
|
|||
->where($where);
|
||||
$filter = (array)json_decode(input()['filter'] ?? '', true);
|
||||
$admin_filter = $filter['user.nickname'] ?? false;
|
||||
|
||||
$is_timeout = $filter['is_timeout'] ?? null;
|
||||
// dd($create_time,$filter);
|
||||
if ($admin_filter) {
|
||||
$admin_ids = Admin::where('nickname', 'like', '%' . $admin_filter . '%')->column('id');
|
||||
$build->whereIn('admin_id', $admin_ids);
|
||||
}
|
||||
if (!is_null($is_timeout)) {
|
||||
if ($is_timeout == 1){
|
||||
$build->where('status', '>=', \app\admin\model\Order::STATUS_DISPATCHING)
|
||||
->where('create_time', '<=', (new Carbon())->subMinutes(20)
|
||||
->format('Y-m-d H:i:s'));
|
||||
}else{
|
||||
$build->where('status', '>=', \app\admin\model\Order::STATUS_DISPATCHING)
|
||||
->where('create_time', '>', (new Carbon())->subMinutes(20)
|
||||
->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($type == 1) {
|
||||
$build->where('status', '>=', 0);
|
||||
}
|
||||
|
||||
if ($type == 2) {
|
||||
}elseif ($type == 2) {
|
||||
$build->where('status', '<', 0);
|
||||
}elseif ($type == 3){
|
||||
$build->where('status', '>=', \app\admin\model\Order::STATUS_DISPATCHING)
|
||||
->where('create_time', '<=', (new Carbon())->subMinutes(20)
|
||||
->format('Y-m-d H:i:s'));
|
||||
}
|
||||
if ($group == 2 || $group == 6) {
|
||||
// 生成 SQL 语句
|
||||
|
|
@ -449,7 +467,7 @@ class Order extends Backend
|
|||
$insert [] = [
|
||||
'to_id' => $re,
|
||||
'type' => 1,
|
||||
'title' => '订单报错通知',
|
||||
'title' => '催单通知',
|
||||
'content' => '【催单通知】您有一条订单号为' . $order->order_no . '的订单被催单,请立即派单!'
|
||||
];
|
||||
}
|
||||
|
|
@ -616,6 +634,9 @@ class Order extends Backend
|
|||
$op[] = ['id' => $option->id, 'title' => $option->title];
|
||||
}
|
||||
$order = model('order')->get($ids);
|
||||
if ($order){
|
||||
$this->error('订单未找到,请重试');
|
||||
}
|
||||
return $this->fetch('delete', ['row' => $order, 'options' => $op]);
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
|
|
@ -648,7 +669,7 @@ class Order extends Backend
|
|||
$hookparams['order'] = $order;
|
||||
$hookparams['role'] = 1;
|
||||
$hookparams['auth'] = null;
|
||||
$hookparams['remark'] = $params['remark'] ?? '';
|
||||
$hookparams['remark'] = $params['remark'] ?? '取消订单';
|
||||
Hook::listen('order_change', $hookparams);
|
||||
}
|
||||
Db::commit();
|
||||
|
|
@ -846,7 +867,7 @@ class Order extends Backend
|
|||
$index = 0;
|
||||
|
||||
foreach ($filter as $k => $v) {
|
||||
if ($k == 'user.nickname') continue;
|
||||
if ($k == 'user.nickname' || $k =='is_timeout') continue;
|
||||
if (!preg_match('/^[a-zA-Z0-9_\-\.]+$/', $k)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ FROM (
|
|||
point(lng, lat),
|
||||
point(?, ?)
|
||||
) AS distance
|
||||
FROM fa_worker where deletetime is null
|
||||
FROM fa_worker where deletetime is null and type = 1 and status = 1
|
||||
) AS t
|
||||
WHERE distance < 40000
|
||||
ORDER BY distance;",[$order->lng,$order->lat]);
|
||||
|
||||
|
||||
|
||||
$worker_ids = array_column($worker_info,'id');
|
||||
|
||||
|
||||
|
|
@ -47,7 +49,7 @@ ORDER BY distance;",[$order->lng,$order->lat]);
|
|||
|
||||
$out_worker_ids = array_intersect($worker_ids, $worker_items_ids);
|
||||
$out_worker_ids = array_values(array_diff($out_worker_ids, $out_worker));
|
||||
|
||||
// dd($out_worker_ids);
|
||||
$worker_doings = (new OrderDispatch())
|
||||
->whereIn('worker_id', $out_worker_ids)
|
||||
->group('worker_id')
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use app\admin\model\Area;
|
|||
use app\admin\model\AuthGroup;
|
||||
use app\admin\model\Item;
|
||||
use app\admin\model\Order;
|
||||
use app\admin\model\WorkerItem;
|
||||
use app\common\controller\Backend;
|
||||
use fast\Tree;
|
||||
use think\Db;
|
||||
|
|
@ -160,7 +161,7 @@ class Worker extends Backend
|
|||
}
|
||||
$params['admin_id'] = $this->auth->id;
|
||||
|
||||
if(!empty($params['area_id'])){
|
||||
if((!empty($params['area_id'])) && isset($params['lng'])){
|
||||
|
||||
$area = Area::getByCode($params['area_id']);
|
||||
if($area){
|
||||
|
|
@ -171,7 +172,9 @@ class Worker extends Backend
|
|||
}
|
||||
}
|
||||
}
|
||||
// dd($params);
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
// dd($result);
|
||||
$item_map = model('item')->getAll();
|
||||
$item_map = array_column($item_map, 'level', 'id');
|
||||
if ($result) {
|
||||
|
|
@ -275,6 +278,7 @@ class Worker extends Backend
|
|||
public function dispatchList()
|
||||
{
|
||||
$area_id = request()->get('area_id');
|
||||
$item_id = request()->get('item_id');
|
||||
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
||||
|
||||
$build = model('worker')
|
||||
|
|
@ -297,6 +301,10 @@ class Worker extends Backend
|
|||
$code = $this->getSelectAreaCode(substr_replace($area_id, '00', -2));
|
||||
$build->where('area_id', 'like', $code . '%');
|
||||
}
|
||||
if ($item_id) {
|
||||
$worker_ids = WorkerItem::where('item_id',$item_id)->column('worker_id');
|
||||
$build->whereIn('id',$worker_ids);
|
||||
}
|
||||
$list = $build
|
||||
->paginate($limit);
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
|
|
|||
|
|
@ -7,11 +7,13 @@
|
|||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('message/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('message/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('message/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
-->
|
||||
<a href="javascript:;" class="btn btn-success btn-all-read"><i class="fa fa-check-square-o"></i> 全部标记已读</a>
|
||||
|
||||
<!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('message/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('message/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('message/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
-->
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('message/edit')}"
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
<div class='address line' style="position: relative">
|
||||
<input id="c-address"
|
||||
class="form-control"
|
||||
placeholder="请通过地图查找选择"
|
||||
placeholder="输入地址搜索"
|
||||
autocomplete="off"
|
||||
name="row[address]"
|
||||
type="text" />
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<ul class="nav nav-tabs" data-field="status">
|
||||
<li class="{:$Think.get.status === (string)1 ? 'active' : ''}"><a href="#t-active" data-value="1" data-toggle="tab">正常订单</a></li>
|
||||
<li class="{:$Think.get.status === (string)2 ? 'active' : ''}"><a href="#t-cancel" data-value="2" data-toggle="tab">取消订单</a></li>
|
||||
<li class="{:$Think.get.status === (string)2 ? 'active' : ''}"><a href="#t-overtime" data-value="3" data-toggle="tab">超时订单</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@
|
|||
<div class="form-group">
|
||||
<label class="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" value="{$row.item_title}" class="zd-input__inner">
|
||||
<input type="text" id="item_id" name="item_id" data-myvalue="{$row.item_id}" value="{$row.item_title}" data-value="{$row.item_title}" class="zd-input__inner">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,40 +16,40 @@
|
|||
</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-customer" readonly class="form-control" type="text" value="{$order.customer|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-customer" readonly class="form-control" type="text" value="{$order.customer|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-tel" readonly class="form-control" type="text" value="{$order.tel|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-tel" readonly class="form-control" type="text" value="{$order.tel|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-address" readonly class="form-control" type="text" value="{$order.area.short_merge_name|htmlentities} {$order.address|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-address" readonly class="form-control" type="text" value="{$order.area.short_merge_name|htmlentities} {$order.address|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-item_title" readonly class="form-control" type="text" value="{$order.item_title|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-item_title" readonly class="form-control" type="text" value="{$order.item_title|htmlentities}">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Order.detail')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-detail" readonly class="form-control" type="text" value="{$order.detail|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Order.detail')}:</label>-->
|
||||
<!-- <div class="col-xs-12 col-sm-8">-->
|
||||
<!-- <input id="c-detail" readonly class="form-control" type="text" value="{$order.detail|htmlentities}">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
{notempty name ='action'}
|
||||
|
||||
|
|
@ -69,12 +69,15 @@
|
|||
</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 readonly type="text" class="form-control" value="{$row.status_text|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 readonly type="text" class="form-control" value="{$row.status_text|htmlentities}">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
|
||||
|
||||
|
|
@ -135,7 +138,7 @@
|
|||
<label for="c-image" class="control-label col-xs-12 col-sm-2">{:__('收款凭据')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-image" class="form-control" size="35" name="row[image]" type="text" value="">
|
||||
<input id="c-image" data-rule="required" class="form-control" size="35" name="row[image]" type="text" value="">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
|
|
@ -148,8 +151,29 @@
|
|||
|
||||
{/if}
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('材料成本(¥)')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input name="order[material_cost]" min="1" step="0.01" type="number" class="form-control" value="{$order.material_cost}">
|
||||
</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">
|
||||
<div class="input-group">
|
||||
<input id="c-material_images" class="form-control" size="50" value="{$order.material_images}" name="order[material_images]" type="text">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-material_images" class="btn btn-danger faupload" data-input-id="c-material_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-material_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-material_images" class="btn btn-primary fachoose" data-input-id="c-material_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-material_images"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-material_images"></ul>
|
||||
</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">
|
||||
|
|
@ -166,12 +190,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea class="form-control" data-rule="required" placeholder="备注" name="row[remark]" >{$row.remark|htmlentities}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('师傅提点(%)')}:</label>
|
||||
|
|
@ -193,31 +212,13 @@
|
|||
<input data-rule="required" name="order[cost]" type="number" min="0" max="100" step="1" class="form-control" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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">{:__('Remark')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input data-rule="required" name="order[material_cost]" min="1" step="0.01" type="number" class="form-control" value="{$order.material_cost}">
|
||||
<textarea class="form-control" placeholder="备注" name="row[remark]" >{$row.remark|htmlentities}</textarea>
|
||||
</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">
|
||||
<div class="input-group">
|
||||
<input id="c-material_images" class="form-control" size="50" value="{$order.material_images}" name="order[material_images]" type="text">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-material_images" class="btn btn-danger faupload" data-input-id="c-material_images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-material_images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-material_images" class="btn btn-primary fachoose" data-input-id="c-material_images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-material_images"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-material_images"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<div class="panel-heading">
|
||||
{:build_heading(null, FALSE)}
|
||||
<ul class="nav nav-tabs" data-field="type">
|
||||
<li class="{:$Think.get.type === null || $Think.get.type == '1' ? 'active' : ''}">
|
||||
<li class="{:$Think.get.type === null || $Think.get.type == '1'|| $Think.get.type == '0' ? 'active' : ''}">
|
||||
<a href="#t-1" data-value="1" data-toggle="tab">手动派单</a>
|
||||
</li>
|
||||
<li class="{:$Think.get.type == '2' ? 'active' : ''}">
|
||||
|
|
|
|||
|
|
@ -13,18 +13,22 @@
|
|||
<input id="c-tel" data-rule="required" class="form-control" name="row[tel]" type="text" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Area_id')}:</label>
|
||||
<div class='col-xs-12 col-sm-8'>
|
||||
<input id="c-city" data-rule="required" class="form-control" data-toggle="city-picker" name="row[address]" type="text" value="" />
|
||||
<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">
|
||||
<input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="">
|
||||
<input id="c-address"
|
||||
class="form-control"
|
||||
placeholder="请通过地图查找选择"
|
||||
autocomplete="off"
|
||||
name="row[address]"
|
||||
type="text" />
|
||||
<ul id="suggestionList"></ul>
|
||||
<input type="text" style="display: none"
|
||||
name="row[lng]" id="lng" >
|
||||
<input type="text" style="display: none"
|
||||
name="row[lat]" id="lat">
|
||||
<input id="area_id" style="display: none" class="form-control" name="row[area_id]" hidden type="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -84,11 +88,6 @@
|
|||
<ul class="row list-inline faupload-preview" id="p-images"></ul>
|
||||
</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">
|
||||
|
|
@ -108,4 +107,42 @@
|
|||
</form>
|
||||
<script>
|
||||
var nodeData = {:json_encode($tree); };
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
#suggestionList {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
max-height: 240px;
|
||||
overflow-y: auto;
|
||||
margin-top: 4px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||
z-index: 9999;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#suggestionList li {
|
||||
padding: 10px 14px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
}
|
||||
|
||||
#suggestionList li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
#suggestionList li:hover {
|
||||
background-color: #f5f8fa;
|
||||
color: #007aff;
|
||||
}
|
||||
#suggestionList li.active {
|
||||
background-color: #82b0e1;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -29,20 +29,21 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Area_id')}:</label>
|
||||
<div class='col-xs-12 col-sm-8'>
|
||||
<input id="c-city" data-rule="required" class="form-control" data-toggle="city-picker" value="{$row.area_name}"
|
||||
type="text" name="row[address]"/>
|
||||
<input id="area_id" style="display: none" class="form-control" name="row[area_id]" hidden type="text"
|
||||
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">
|
||||
<input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="{$row.address}">
|
||||
<input id="c-address"
|
||||
class="form-control"
|
||||
placeholder="输入地址搜索"
|
||||
autocomplete="off"
|
||||
value="{$row.address}"
|
||||
name="row[address]"
|
||||
type="text" />
|
||||
<ul id="suggestionList"></ul>
|
||||
<input type="text" style="display: none"
|
||||
name="row[lng]" id="lng" value="{$row.lng}">
|
||||
<input type="text" style="display: none"
|
||||
name="row[lat]" id="lat" value="{$row.lat}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -122,4 +123,42 @@
|
|||
</form>
|
||||
<script>
|
||||
var nodeData = {:json_encode($tree);};
|
||||
</script>
|
||||
</script>
|
||||
<style>
|
||||
#suggestionList {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
max-height: 240px;
|
||||
overflow-y: auto;
|
||||
margin-top: 4px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||
z-index: 9999;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#suggestionList li {
|
||||
padding: 10px 14px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
}
|
||||
|
||||
#suggestionList li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
#suggestionList li:hover {
|
||||
background-color: #f5f8fa;
|
||||
color: #007aff;
|
||||
}
|
||||
#suggestionList li.active {
|
||||
background-color: #82b0e1;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -54,6 +54,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
|
||||
$(".btn-all-read").click(function () {
|
||||
Layer.confirm("确定要将所有消息标记为已读吗?", function (index) {
|
||||
Fast.api.ajax({
|
||||
url: 'message/markallread',
|
||||
},function (){
|
||||
Layer.close(index);
|
||||
table.bootstrapTable('refresh');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
fixed: true,
|
||||
searchList: {
|
||||
"0": __('Status 0'),
|
||||
"10": __('Status 10'),
|
||||
"10": __('Status 10'),
|
||||
"20": __('Status 20'),
|
||||
"30": __('Status 30'),
|
||||
"40": __('Status 40'),
|
||||
|
|
@ -101,6 +101,33 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
"10": "my_dispatch"
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'is_timeout',
|
||||
title: '是否超时',
|
||||
formatter: function (value, row) {
|
||||
value = row.create_time;
|
||||
|
||||
if (row.status !== 10 || !value) {
|
||||
return '';
|
||||
}
|
||||
// 解析 create_time 时间戳或字符串为时间对象
|
||||
var createTime = typeof value === 'string' ? new Date(value.replace(/-/g, '/')) : new Date(value * 1000); // 兼容时间戳和时间字符串
|
||||
var now = new Date();
|
||||
var diffMinutes = (now - createTime) / (1000 * 60); // 计算分钟差
|
||||
|
||||
return diffMinutes > 20 ? '<span style="color: red;">超时</span>' : '<span class="label label-success">未超时</span>';;
|
||||
},
|
||||
searchList: {
|
||||
"1": '超时',
|
||||
"0": '未超时',
|
||||
},
|
||||
searchable: true,
|
||||
custom: {
|
||||
'1': 'danger',
|
||||
'0': 'success'
|
||||
},
|
||||
operate: '=',
|
||||
},
|
||||
{
|
||||
field: 'dispatch_type',
|
||||
title: '派单方式',
|
||||
|
|
@ -228,24 +255,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
},
|
||||
dropdown: "更多"
|
||||
},
|
||||
{
|
||||
name: "dispatch",
|
||||
text: "派单",
|
||||
title: "派单",
|
||||
extend: 'data-toggle="tooltip" data-container="body"',
|
||||
classname: 'btn btn-xs btn-info btn-dialog',
|
||||
icon: 'fa fa-add',
|
||||
url: function (row) {
|
||||
return 'orders/dispatch/add?order_id=' + row.id;
|
||||
},
|
||||
visible: function (row) {
|
||||
if (row.status == 10) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
refresh: true,
|
||||
},
|
||||
|
||||
{
|
||||
name: "warning",
|
||||
|
|
@ -284,6 +293,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
table.bootstrapTable('refresh');
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "dispatch",
|
||||
text: "派单",
|
||||
title: "派单",
|
||||
extend: 'data-toggle="tooltip" data-container="body"',
|
||||
classname: 'btn btn-xs btn-info btn-dialog',
|
||||
icon: 'fa fa-add',
|
||||
url: function (row) {
|
||||
return 'orders/dispatch/add?order_id=' + row.id;
|
||||
},
|
||||
visible: function (row) {
|
||||
if (row.status == 10) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
refresh: true,
|
||||
},
|
||||
{
|
||||
name: "reminder",
|
||||
text: "催单",
|
||||
|
|
@ -416,9 +443,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
table.bootstrapTable('refresh', {});
|
||||
return false;
|
||||
});
|
||||
const timer = setInterval(function () {
|
||||
table.bootstrapTable('refresh', {});
|
||||
}, 1000 * 120);
|
||||
let idleTimer = null;
|
||||
|
||||
function resetIdleTimer() {
|
||||
clearTimeout(idleTimer);
|
||||
idleTimer = setTimeout(function () {
|
||||
// 30秒无操作后执行刷新
|
||||
table.bootstrapTable('refresh', {});
|
||||
}, 30 * 1000); // 30 秒
|
||||
}
|
||||
|
||||
['mousemove', 'keydown', 'click', 'scroll'].forEach(function (event) {
|
||||
document.addEventListener(event, resetIdleTimer, false);
|
||||
});
|
||||
|
||||
resetIdleTimer();
|
||||
|
||||
},
|
||||
add: function () {
|
||||
$("#mybuttom").on("click", function () {
|
||||
|
|
@ -616,7 +656,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
$('#item_id_value').val(data.value);
|
||||
}
|
||||
});
|
||||
$('#item_id').val($('#item_id').data('value')).focus();
|
||||
$('#item_id').val($('#item_id').data('value'));
|
||||
|
||||
const mainSelect = document.getElementById('receive_type');
|
||||
const otherSelect = document.getElementById('coupon');
|
||||
|
|
@ -721,7 +761,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function handleInput(e) {
|
||||
selectedIndex = -1;
|
||||
addressSelected = false;
|
||||
|
|
@ -759,7 +798,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
$('#suggestionList').on('mousedown', 'li', function (e) {
|
||||
const name = $(this).data('name');
|
||||
const location = $(this).data('location'); // "经度,纬度"
|
||||
|
|
|
|||
|
|
@ -320,10 +320,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'layer', 'cascader'],
|
|||
$("#reset_btn").on("click", function () {
|
||||
$("#c-city-search").citypicker('reset');
|
||||
$("#area_id").val('');
|
||||
$("#test").val('');
|
||||
$("#test").data('myvalue', '');
|
||||
$("#item_id").data('myvalue', '');
|
||||
$("#keyword").val('');
|
||||
$('#item_id').zdCascader.reload(_data,true);
|
||||
table.bootstrapTable('refresh', {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(),
|
||||
});
|
||||
|
|
@ -336,27 +334,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'layer', 'cascader'],
|
|||
$('#c-worker_id').val(worker.id).trigger('input').trigger('change');
|
||||
});
|
||||
$('#add_worker').on('click',function (){
|
||||
console.log(1);
|
||||
Fast.api.open('workers/worker/add?type=2', '添加工人',{
|
||||
callback: function (value) {
|
||||
console.log(2222,value);
|
||||
table.bootstrapTable('refresh', {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url + '?' + getQueryData(),
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#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(),
|
||||
clear:true,
|
||||
clickParent:true
|
||||
// clear:true,
|
||||
// clickParent:true
|
||||
});
|
||||
|
||||
$('#item_id').val($('#item_id').data('value'));
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
// {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'),"2":__('自动')}, formatter: Table.api.formatter.normal,
|
||||
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('自动')}, formatter: Table.api.formatter.normal
|
||||
// defaultValue: '1'
|
||||
},
|
||||
|
||||
|
|
@ -196,7 +196,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// {
|
||||
// name: "dispatch",
|
||||
// text: "派单",
|
||||
// title: "派单",
|
||||
// extend: 'data-toggle="tooltip" data-container="body"',
|
||||
// classname: 'btn btn-xs btn-info btn-dialog',
|
||||
// icon: 'fa fa-add',
|
||||
// url: function (row) {
|
||||
// return 'orders/dispatch/add?order_id=' + row.order_id;
|
||||
// },
|
||||
// visible: function (row) {
|
||||
// if (row.type == 2) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// },
|
||||
// refresh: true,
|
||||
// },
|
||||
{
|
||||
name: 'addrecord',
|
||||
text:"跟进",
|
||||
|
|
@ -242,7 +259,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
|
||||
dropdown: "更多",
|
||||
visible: function (row) {
|
||||
if (row.orderb.status >= 0 && row.orderb.status < 60 && row.status >0 && row.status < 60) {
|
||||
return true;
|
||||
if (row.orderb.status >= 0 && row.orderb.status < 60 && row.status >=0 && row.status < 60) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -261,7 +279,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
refresh:true,
|
||||
dropdown: "更多",
|
||||
visible: function (row) {
|
||||
if (row.orderb.status != 60 && row.status > 0 && row.status < 60) {
|
||||
return true;
|
||||
if (row.orderb.status != 60 && row.status >=0 && row.status < 60) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -279,7 +298,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
dropdown: "更多",
|
||||
|
||||
visible: function (row) {
|
||||
if (row.orderb.status == 60 && row.status>0) {
|
||||
return true;
|
||||
if (row.orderb.status == 60 && row.status>=0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'aftersale',
|
||||
text: '申请售后',
|
||||
title: '申请售后',
|
||||
classname: 'btn btn-dialog',
|
||||
icon: 'fa fa-phone-square',
|
||||
url: function(row){
|
||||
return 'aftersales/aftersale/add/'+row.order_id;
|
||||
},
|
||||
dropdown: "更多",
|
||||
visible: function (row) {
|
||||
return true;
|
||||
if (row.orderb.status !== -10 && row.orderb.status !== 70) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -218,11 +218,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'],
|
|||
Form.events.citypicker($("form"));
|
||||
},
|
||||
add: function () {
|
||||
$("#c-city").on("cp:updated", function () {
|
||||
var citypicker = $(this).data("citypicker");
|
||||
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
|
||||
$("#area_id").val(code);
|
||||
});
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const type = urlParams.get('type');
|
||||
if (type) {
|
||||
|
|
@ -232,14 +228,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'],
|
|||
}
|
||||
}
|
||||
Controller.api.bindevent();
|
||||
Controller.api.area();
|
||||
},
|
||||
edit: function () {
|
||||
$("#c-city").on("cp:updated", function () {
|
||||
var citypicker = $(this).data("citypicker");
|
||||
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
|
||||
$("#area_id").val(code);
|
||||
});
|
||||
|
||||
Controller.api.bindevent();
|
||||
Controller.api.area();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
|
|
@ -290,6 +284,152 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'],
|
|||
"data": content
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
area: function (){
|
||||
const amapKey = 'c299da50c080dfccf9b1d00560ff9639';
|
||||
|
||||
let isComposing = false;
|
||||
let addressSelected = false;
|
||||
let selectedIndex = -1;
|
||||
$('#c-address')
|
||||
.on('compositionstart', () => {
|
||||
isComposing = true;
|
||||
})
|
||||
.on('compositionend', () => {
|
||||
isComposing = false;
|
||||
// 不执行 handleInput,由 input 触发
|
||||
})
|
||||
.on('input', debounce(function (e) {
|
||||
if (!isComposing) handleInput(e);
|
||||
}, 300))
|
||||
.on('blur', function () {
|
||||
// 如果还没有选择地址,且列表中有内容,则默认选择第一个
|
||||
|
||||
// 如果还没有选择地址,且列表中有内容,则默认选择第一个
|
||||
if (!addressSelected && $('#suggestionList li').length > 0) {
|
||||
choseFirst();
|
||||
}
|
||||
|
||||
$('#suggestionList').hide();
|
||||
})
|
||||
.on('focus', function () {
|
||||
// 如果还没有选择地址,且列表中有内容,则默认选择第一个
|
||||
$('#suggestionList').show();
|
||||
})
|
||||
.on('keydown', function (e) {
|
||||
const $items = $('#suggestionList li');
|
||||
const len = $items.length;
|
||||
|
||||
if (!len) return;
|
||||
|
||||
if (e.key === 'ArrowDown') {
|
||||
e.preventDefault();
|
||||
selectedIndex = (selectedIndex + 1) % len;
|
||||
updateActiveItem($items);
|
||||
} else if (e.key === 'ArrowUp') {
|
||||
e.preventDefault();
|
||||
selectedIndex = (selectedIndex - 1 + len) % len;
|
||||
updateActiveItem($items);
|
||||
} else if (e.key === 'Enter') {
|
||||
if (selectedIndex >= 0 && selectedIndex < len) {
|
||||
e.preventDefault();
|
||||
$items.eq(selectedIndex).trigger('mousedown');
|
||||
}
|
||||
}
|
||||
});
|
||||
function updateActiveItem($items) {
|
||||
$items.removeClass('active');
|
||||
if (selectedIndex >= 0) {
|
||||
const $active = $items.eq(selectedIndex);
|
||||
$active.addClass('active');
|
||||
|
||||
// 自动滚动使其可见
|
||||
const container = $('#suggestionList')[0];
|
||||
const item = $active[0];
|
||||
|
||||
if (item && container) {
|
||||
const itemTop = item.offsetTop;
|
||||
const itemBottom = itemTop + item.offsetHeight;
|
||||
const containerTop = container.scrollTop;
|
||||
const containerBottom = containerTop + container.clientHeight;
|
||||
|
||||
if (itemTop < containerTop) {
|
||||
container.scrollTop = itemTop;
|
||||
} else if (itemBottom > containerBottom) {
|
||||
container.scrollTop = itemBottom - container.clientHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleInput(e) {
|
||||
selectedIndex = -1;
|
||||
addressSelected = false;
|
||||
const keyword = $(e.target).val();
|
||||
if (!keyword.trim() || /^[\s\p{P}]+$/u.test(keyword)) return;
|
||||
if (!keyword) return $('#c-address').empty();
|
||||
|
||||
$.getJSON('https://restapi.amap.com/v3/assistant/inputtips', {
|
||||
key: amapKey,
|
||||
keywords: keyword,
|
||||
datatype: 'all',
|
||||
city: '全国',
|
||||
}, function (res) {
|
||||
if (res.tips) {
|
||||
let html = '';
|
||||
res.tips.forEach(tip => {
|
||||
if (tip.location) {
|
||||
html += `<li data-name="${tip.district} ${tip.name}" data-area_id="${tip.adcode}" data-location="${tip.location}">
|
||||
${tip.district} ${tip.name}
|
||||
</li>`;
|
||||
}
|
||||
});
|
||||
$('#suggestionList').html(html).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function debounce(fn, delay = 300) {
|
||||
let timer = null;
|
||||
return function (...args) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
fn.apply(this, args);
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
|
||||
$('#suggestionList').on('mousedown', 'li', function (e) {
|
||||
const name = $(this).data('name');
|
||||
const location = $(this).data('location'); // "经度,纬度"
|
||||
const area_id = $(this).data('area_id'); // "经度,纬度"
|
||||
const [lng, lat] = location.split(',');
|
||||
$('#c-address').val(name);
|
||||
$('#lng').val(lng);
|
||||
$('#lat').val(lat);
|
||||
$('#area_id').val(area_id);
|
||||
// 隐藏提示列表
|
||||
$('#suggestionList').hide();
|
||||
selectedIndex = -1;
|
||||
addressSelected = true;
|
||||
});
|
||||
|
||||
function choseFirst(){
|
||||
const first = $('#suggestionList li').first();
|
||||
const name = first.data('name');
|
||||
const location = first.data('location'); // "经度,纬度"
|
||||
const area_id = first.data('area_id'); // "经度,纬度"
|
||||
const [lng, lat] = location.split(',');
|
||||
console.log('chose');
|
||||
$('#lng').val(lng);
|
||||
$('#lat').val(lat);
|
||||
$('#area_id').val(area_id);
|
||||
// 隐藏提示列表
|
||||
$('#suggestionList').hide();
|
||||
selectedIndex = -1;
|
||||
addressSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user