cancel任务
This commit is contained in:
parent
4c26d857e8
commit
80a65b325f
|
|
@ -228,66 +228,56 @@ class Dispatch2 extends Backend
|
|||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function del($ids = null)
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
$ids = $ids ?: $this->request->post("ids");
|
||||
if (empty($ids)) {
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
$pk = $this->model->getPk();
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds)) {
|
||||
$this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||
}
|
||||
$list = $this->model->where($pk, 'in', $ids)->whereIn('status', $this->model->deleteStatusList())->select();
|
||||
|
||||
$remark = $this->request->param('remark', '');
|
||||
|
||||
$count = 0;
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach ($list as $item) {
|
||||
//$count += $item->delete();
|
||||
$order = Order::where('id', $item->order_id)->where('status', Order::STATUS_DISPATCHED)->find();
|
||||
if (!$order) {
|
||||
$this->error('订单状态已变更,请刷新后操作');
|
||||
}
|
||||
//取消
|
||||
$item->save(['status' => OrderDispatch::STATUS_CANCEL, 'remark' => $remark]);
|
||||
//回退订单状态
|
||||
$order->allowField(true)->save(['status' => Order::STATUS_DISPATCHING]);
|
||||
|
||||
$params['order'] = $order->ref;
|
||||
$params['role'] = 1;
|
||||
$params['auth'] = $this->auth;
|
||||
$params['remark'] = '派单被取消[ID:' . $item->id . '],订单状态回退';
|
||||
if (!empty($remark)) {
|
||||
$params['remark'] .= ',操作备注:' . $remark;
|
||||
}
|
||||
Hook::listen('order_change', $params);
|
||||
}
|
||||
Db::commit();
|
||||
} catch (PDOException | Exception $e) {
|
||||
Db::rollback();
|
||||
throw $e;
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
/* if ($count) {
|
||||
$this->success();
|
||||
}*/
|
||||
$this->error(__('取消成功'));
|
||||
}
|
||||
|
||||
private function getWorkers($workers)
|
||||
{
|
||||
foreach ($workers as $worker){
|
||||
$worker->dist = '100m';
|
||||
}
|
||||
return $workers;
|
||||
}
|
||||
// public function del($ids = null)
|
||||
// {
|
||||
// if (false === $this->request->isPost()) {
|
||||
// $this->error(__("Invalid parameters"));
|
||||
// }
|
||||
// $ids = $ids ?: $this->request->post("ids");
|
||||
// if (empty($ids)) {
|
||||
// $this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
// }
|
||||
// $pk = $this->model->getPk();
|
||||
// $adminIds = $this->getDataLimitAdminIds();
|
||||
// if (is_array($adminIds)) {
|
||||
// $this->model->where($this->dataLimitField, 'in', $adminIds);
|
||||
// }
|
||||
// $list = $this->model->where($pk, 'in', $ids)->whereIn('status', $this->model->deleteStatusList())->select();
|
||||
//
|
||||
// $remark = $this->request->param('remark', '');
|
||||
//
|
||||
// $count = 0;
|
||||
// Db::startTrans();
|
||||
// try {
|
||||
// foreach ($list as $item) {
|
||||
// //$count += $item->delete();
|
||||
// $order = Order::where('id', $item->order_id)->where('status', Order::STATUS_DISPATCHED)->find();
|
||||
// if (!$order) {
|
||||
// $this->error('订单状态已变更,请刷新后操作');
|
||||
// }
|
||||
// //取消
|
||||
// $item->save(['status' => OrderDispatch::STATUS_CANCEL, 'remark' => $remark]);
|
||||
// //回退订单状态
|
||||
// $order->allowField(true)->save(['status' => Order::STATUS_DISPATCHING]);
|
||||
//
|
||||
// $params['order'] = $order->ref;
|
||||
// $params['role'] = 1;
|
||||
// $params['auth'] = $this->auth;
|
||||
// $params['remark'] = '派单被取消[ID:' . $item->id . '],订单状态回退';
|
||||
// if (!empty($remark)) {
|
||||
// $params['remark'] .= ',操作备注:' . $remark;
|
||||
// }
|
||||
// Hook::listen('order_change', $params);
|
||||
// }
|
||||
// Db::commit();
|
||||
// } catch (PDOException | Exception $e) {
|
||||
// Db::rollback();
|
||||
// throw $e;
|
||||
// $this->error($e->getMessage());
|
||||
// }
|
||||
//
|
||||
// $this->error(__('取消成功'));
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -299,7 +289,7 @@ class Dispatch2 extends Backend
|
|||
* @throws DataNotFoundException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function cancel()
|
||||
public function del()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__("Invalid parameters"));
|
||||
|
|
@ -317,6 +307,10 @@ class Dispatch2 extends Backend
|
|||
}
|
||||
$list = $this->model->where($pk, 'in', $ids)->whereIn('status', $this->model->deleteStatusList())->select();
|
||||
|
||||
if(count($list) != count($ids)){
|
||||
$this->error(__("任务状态不可操作,请刷新页面后再操作"));
|
||||
}
|
||||
|
||||
$remark = $reason;
|
||||
$count = 0;
|
||||
Db::startTrans();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Order_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<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="{$row.order_id|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<a href="javascript:;" class="btn btn-warning btn-add btn-disabled disabled {:$auth->check('orders/abnormal/add')}?'':'hide'}" title="{:__('创建异常')}" ><i class="fa fa-plus"></i> {:__('创建异常')}</a>
|
||||
|
||||
<a href="javascript:;" class="btn btn-danger btn-cancel-selected btn-disabled disabled {:$auth->check('orders/dispatch2/cancel')?'':'hide'}" title="{:__('取消任务')}" ><i class="fa fa-trash"></i> {:__('取消任务')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-cancel-selected btn-disabled disabled {:$auth->check('orders/dispatch2/del')?'':'hide'}" title="{:__('取消任务')}" ><i class="fa fa-trash"></i> {:__('取消任务')}</a>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
|
|||
|
||||
//这里可以加入 Ajax 请求处理逻辑
|
||||
$.ajax({
|
||||
url: 'orders/dispatch2/cancel',
|
||||
url: 'orders/dispatch2/del',
|
||||
type: 'POST',
|
||||
data: {
|
||||
ids: selectedIds,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user