派单逻辑

This commit is contained in:
hant 2025-03-11 23:20:44 +08:00
parent 3e75b4c593
commit e1a30208b9
6 changed files with 592 additions and 39 deletions

View File

@ -95,7 +95,26 @@ class Dispatch extends Backend
public function add() public function add()
{ {
if (false === $this->request->isPost()) { if (false === $this->request->isPost()) {
$this->assign('order_id',$this->request->param('order_id')); $id = $this->request->param('order_id');
$order = model('order')->where('id', $id)->find();
if (!$order) {
$this->error(__('No results were found'));
}
$code = $this->getSelectAreaCode(substr_replace($order->area_id, '00', -2));
$workers = model('worker')
->where('area_id','like', $code.'%')
->where('status',1)
->field(['id','name','tel','area_id','lng','lat'])
->select();
$area_name = model('area')->getNameByCode($order->area_id);
$order->area_name = str_replace(',','/',$area_name);
$workers = $this->getWorkers($workers);
$this->view->assign('workers', $workers);
$this->view->assign('row', $order);
return $this->view->fetch(); return $this->view->fetch();
} }
$params = $this->request->post('row/a'); $params = $this->request->post('row/a');
@ -116,7 +135,26 @@ class Dispatch 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);
} }
$result = $this->model->allowField(true)->save($params); $order = model('order')->where('id',$params['order_id'])->find();
if (!$order){
$this->error(__('No results were found'));
}
$insert = [
'admin_id' => $this->auth->id,
'admin_user' => $this->auth->nickname,
'order_id' => $params['order_id'],
'type' => 1,
'worker_id' => $params['worker_id'],
'plan_time' => $params['plan_time'],
];
$worker = model('worker')->where('id',$params['worker_id'])->find();
$insert ['worker_name'] = $worker->name;
$insert ['worker_tel'] = $worker->tel;
$result = $this->model->allowField(true)->save($insert);
$order->status = Order::STATUS_DISPATCHED;
$order->save();
Db::commit(); Db::commit();
} catch (ValidateException | PDOException | Exception $e) { } catch (ValidateException | PDOException | Exception $e) {
Db::rollback(); Db::rollback();
@ -237,4 +275,12 @@ class Dispatch extends Backend
$this->error(__('取消成功')); $this->error(__('取消成功'));
} }
private function getWorkers($workers)
{
foreach ($workers as $worker){
$worker->dist = '100m';
}
return $workers;
}
} }

View File

@ -1,24 +1,69 @@
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Customer')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-customer" data-rule="required" disabled class="form-control" type="text" value="{$row.customer}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Tel')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-tel" data-rule="required" disabled class="form-control" type="number" value="{$row.tel}">
</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" value="{$row.area_name}" disabled type="text" />
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-address" data-rule="required" disabled class="form-control" name="row[address]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Detail')}:</label>
<div class="col-xs-12 col-sm-8">
<textarea id="c-detail" disabled rows="4" style="width: 100%;resize: vertical" class="form-control">{$row.detail}</textarea>
</div>
</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 id="c-remark" disabled rows="4" style="width: 100%;resize: vertical" class="form-control" >{$row.remark}</textarea>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Order_id')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Order_id')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-order_id" data-rule="required" data-field="order_no" disabled data-source="order/index" class="form-control selectpage" name="row[order_id]" type="text" value="{$order_id}"> <input id="c-order_id" data-rule="required" data-field="order_no" disabled class="form-control" name="row[order_id]" type="text" value="{$row->order_no}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Worker_id')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Worker_id')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-worker_id" data-rule="required" data-field="worker_name" data-source="worker/index" class="form-control selectpage" name="row[worker_id]" type="text" value=""> <select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[worker_id]" class="form-control selectpicker">
</div> <!-- <option value="0">无可用工人</option>-->
</div>
{foreach $workers as $item}
<option data-subtext="电话:{$item['tel'].'-'.$item['dist'] }" value="{$item['id']}">{$item['name']}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Plan_time')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Plan_time')}:</label>
<div class="col-xs-12 col-sm-8"> <div class="col-xs-12 col-sm-8">
<input id="c-update_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:date('Y-m-d H:i:s')}"> <input id="c-update_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[plan_time]" type="text" value="{:date('Y-m-d H:i:s')}">
</div> </div>
</div> </div>
<div class="form-group layer-footer"> <div class="form-group layer-footer">
@ -27,4 +72,6 @@
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button> <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
</div> </div>
</div> </div>
<input style="display: none" class="form-control" name="row[order_id]" type="text" value="{$row->id}">
</form> </form>

View File

@ -33,12 +33,12 @@
<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" class="form-inline" role="form" style="margin-top: 5px"> <form id="select-form" class="form-inline" role="form" style="margin-top: 5px">
<div class='form-group' style="width: 100%"> <div class='form-group'>
<label style="padding-left: 0px;text-align: left">{:__('Area_id')}:</label> <label style="padding-left: 0px;text-align: left">{:__('Area_id')}:</label>
<div style="width: 350px;display: inline-block"> <div style="display: inline-block;width: 300px;margin-left: 5px">
<input id="c-city" style="width: 400px" class="form-control col-xs-12 col-sm-8" data-toggle="city-picker" name="row[address]" type="text" value="" /> <input id="c-city" style="width: 100%;height: 32px" data-toggle="city-picker" name="row[address]" type="text" value="" />
</div> </div>
<p id="reset" style="display: inline-block;margin-left: -20px" class="btn btn-default">重置</p> <p id="reset" style="display: inline-block;margin-bottom: 2px;" class="btn btn-default">重置</p>
</div> </div>
</form> </form>

View File

@ -294,11 +294,11 @@ return [
//登录页默认背景图 //登录页默认背景图
'login_background' => "", 'login_background' => "",
//是否启用多级菜单导航 //是否启用多级菜单导航
'multiplenav' => true, 'multiplenav' => false,
//是否开启多选项卡(仅在开启多级菜单时起作用) //是否开启多选项卡(仅在开启多级菜单时起作用)
'multipletab' => true, 'multipletab' => false,
//是否默认展示子菜单 //是否默认展示子菜单
'show_submenu' => true, 'show_submenu' => false,
//后台皮肤,为空时表示使用skin-black-blue //后台皮肤,为空时表示使用skin-black-blue
'adminskin' => '', 'adminskin' => '',
//后台是否启用面包屑 //后台是否启用面包屑

View File

@ -10,7 +10,7 @@
display: block; display: block;
outline: 0; outline: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
border-bottom: 1px solid #ccc; border: 1px solid #ccc;
background-color: #fff; background-color: #fff;
color: #ccc; color: #ccc;
cursor: pointer; cursor: pointer;

File diff suppressed because one or more lines are too long