添加订单取消

This commit is contained in:
hant 2025-04-10 21:55:43 +08:00
parent 3e338e94a5
commit 017d9456c3
9 changed files with 217 additions and 19 deletions

View File

@ -124,6 +124,9 @@ class Order extends Backend
if ($this->request->request('keyField')) {
return $this->selectpage();
}
$type = request()->get('type',1);
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$build = $this->model
->field(['id', 'order_no', 'admin_id', 'customer', 'tel', 'status', 'area_id', 'address',
@ -131,6 +134,14 @@ class Order extends Backend
'detail', 'remark', 'images', 'create_time', 'update_time', 'admin_id', 'dispatch_type', 'receive_type'])
->where($where);
if ($type == 1){
$build->where('status','>=', 0);
}
if ($type == 2){
$build->where('status','<', 0);
}
if ($group == 2) {
// 生成 SQL 语句
$area_codes = $this->filterAreaCodes(explode(',', $user->area_ids));
@ -425,9 +436,13 @@ class Order extends Backend
public function delete($ids = null){
if (false === $this->request->isPost()) {
$options = \app\admin\model\Order::DELETED_TYPE;
$options = \model('abnormal')->where('type',2)->select();
$op = [];
foreach ($options as $option){
$op[] = ['id' =>$option->id,'title'=>$option->title];
}
$order = model('order')->get($ids);
return $this->fetch('delete',['row' => $order,'options'=>$options]);
return $this->fetch('delete',['row' => $order,'options'=>$op]);
}
$params = $this->request->post('row/a');
if (empty($params)) {
@ -456,6 +471,46 @@ class Order extends Backend
$this->success();
}
public function send($ids = null){
if (false === $this->request->isPost()) {
$options = \model('admin')->select();
$op = [];
foreach ($options as $option){
$op[] = ['id' =>$option->id,'title'=>$option->nickname];
}
$order = model('order')->get($ids);
return $this->fetch('delete',['row' => $order,'options'=>$op]);
}
$params = $this->request->post('row/a');
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
$result = false;
Db::startTrans();
try {
$order = model('order')->get($params['order_id']);
if (!$order){
$this->error('Not Find');
}
$params['status'] = \app\admin\model\Order::STATUS_CANCEL;
$result = $order->allowField(true)->save($params);
Db::commit();
} catch (ValidateException | PDOException | Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
private function filterAreaCodes(array $area_codes)
{
// 提取所有两位区号

View File

@ -33,5 +33,28 @@ class Abnormal extends Backend
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if (false === $this->request->isAjax()) {
return $this->view->fetch();
}
//如果发送的来源是 Selectpage则转发到 Selectpage
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$type = request()->get('type',1);
$list = $this->model
->where($where)
->where('type',$type)
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);
}
}

View File

@ -16,9 +16,9 @@
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">作废原因:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-coupon" title="请选择" data-rule="required" name="row[cancel_reason_id]" class="form-control selectpicker">
{foreach $options as $key=>$item}
<option {if $key == $row.cancel_reason_id} selected {/if} value="{$key}">{$item}</option>
<select id="c-coupon" title="请选择" data-rule="required" name="row[cancel_reason_id]" class="form-control">
{foreach $options as $item}
<option {if $item.id == $row.cancel_reason_id} selected {/if} value="{$item.id}">{$item.title}</option>
{/foreach}
</select>
</div>

View File

@ -15,11 +15,7 @@
<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('order/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('order/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('order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<a href="javascript:;" class="btn btn-success btn-edit {:$auth->check('order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-edit"></i> {:__('Edit')}</a>
<!-- <div class="dropdown btn-group {:$auth->check('order/multi')?'':'hide'}">-->
<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>-->
<!-- <ul class="dropdown-menu text-left" role="menu">-->
@ -29,7 +25,7 @@
<!-- </ul>-->
<!-- </div>-->
<a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('order/recyclebin')?'':'hide'}" href="order/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>
<!-- <a class="btn btn-success btn-recyclebin btn-dialog {:$auth->check('order/recyclebin')?'':'hide'}" href="order/recyclebin" title="{:__('Recycle bin')}"><i class="fa fa-recycle"></i> {:__('Recycle bin')}</a>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"

View File

@ -0,0 +1,40 @@
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="{:url('order/delete')}">
<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-order_id"
disabled
class="form-control" type="text" value="{$row->order_no}">
</div>
</div>
<input type="hidden" name="row[order_id]" value="{$row->id}" >
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">转给人:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-coupon" title="请选择" data-rule="required" name="row[cancel_reason_id]" class="form-control">
{foreach $options as $item}
<option {if $item.id == $row.cancel_reason_id} selected {/if} value="{$item.id}">{$item.title}</option>
{/foreach}
</select>
</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-detail" data-rule="required" class="form-control" rows="5" name="row[cancel_detail]" cols="50">{$row->cancel_detail}</textarea>
</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">
<button type="submit" class="btn btn-primary btn-embossed">{:__('OK')}</button>
</div>
</div>
</form>

View File

@ -6,6 +6,18 @@
<input id="c-title" data-rule="required" class="form-control" name="row[title]" 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 id="c-source" data-live-search="true" title="请选择" data-rule="required" 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">{:__('Sort')}:</label>
<div class="col-xs-12 col-sm-8">

View File

@ -1,6 +1,11 @@
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-heading">
<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>
</ul>
</div>
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">

View File

@ -134,16 +134,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
buttons: [
{
name: 'edit',
text:"编辑",
icon: 'fa fa-pencil',
title: __('Edit'),
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-editone'
},
{
name: 'push',
icon: 'fa fa-copy',
title: '复制',
text:"复制",
url: 'order/copy',
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-info btn-dialog',
@ -156,7 +157,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
text:"派单",
title:"派单",
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-warning btn-dialog',
classname: 'btn btn-xs btn-info btn-dialog',
//classname:"btn-view btn-dialog",
icon:'fa fa-add',
url: function(row){
@ -170,6 +171,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
},
refresh:true,
},
{
name: 'send',
text: '中转订单',
title: '中转订单',
classname: 'btn btn-xs btn-info btn-dialog',
icon: 'fa fa-send',
url: 'order/send',
visible:function(row){
if(row.status == 10){
return true;
}
return false;
},
},
{
name:"reminder",
text:"催单",
@ -192,7 +207,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
console.log(data, ret);
Layer.alert(ret.msg);
return false;
}
},
visible:function(row){
if(row.status > 0){
return true;
}
return false;
},
},
{
name:"error",
@ -210,10 +231,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
classname: 'btn btn-xs btn-danger btn-dialog',
icon: 'fa fa-trash',
url: 'order/delete',
visible: function (row) {
//返回true时按钮显示,返回false隐藏
return true;
}
visible:function(row){
if(row.status >= 0){
return true;
}
return false;
},
},
],
}
@ -223,6 +246,26 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function
// 为表格绑定事件
Table.api.bindevent(table);
let cloneQueryParams = null;
//绑定tab事件
$('a[data-toggle="tab"]').on('show.bs.tab',function(event){
let type =$(this).attr("data-value");
let options = table.bootstrapTable('getOptions');
$('.nav-tabs li').attr('class','');
$(this).parent().attr("class",'active');
options.pageNumber =1;
if (cloneQueryParams == null) {
cloneQueryParams = options.queryParams;
}
options.queryParams =function(params){
params.type = type;
return cloneQueryParams(params);
};
table.bootstrapTable('refresh',{});
return false;
});
},
add: function () {
$("#mybuttom").on("click", function() {

View File

@ -28,6 +28,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
// {checkbox: true},
{field: 'id', title: __('Id')},
{field: 'type', title: '种类',formatter: function ($val) {
return $val === 1 ? '异常类型' : '取消类型';
}},
{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}
@ -37,6 +40,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table.api.bindevent(table);
var cloneQueryParams = null;
//绑定tab事件
$('a[data-toggle="tab"]').on('show.bs.tab',function(event){
let type =$(this).attr("data-value");
let options = table.bootstrapTable('getOptions');
$('.nav-tabs li').attr('class','');
$(this).parent().attr("class",'active');
options.pageNumber =1;
if (cloneQueryParams == null) {
cloneQueryParams = options.queryParams;
}
options.queryParams =function(params){
params.type = type;
return cloneQueryParams(params);
};
table.bootstrapTable('refresh',{});
return false;
});
},
add: function () {
Controller.api.bindevent();