Commit bba7cb61 by 汪伟伟

1

parent bb38f148
...@@ -28,12 +28,12 @@ class TaskReceiveController extends AdminController ...@@ -28,12 +28,12 @@ class TaskReceiveController extends AdminController
// $tab->add('选项卡1', view('...')); // $tab->add('选项卡1', view('...'));
$user = Admin::user(); $user = Admin::user();
if ($user->is_admin){ if ($user->is_admin){
$tab->add('全部任务', $this->getData(-1),true,'a'); $tab->add('全部任务', $this->getData(-1),true,'1');
}; }
$tab->add('待完成任务', $this->getData(0),true,'b'); $tab->add('待完成任务', $this->getData(0),true,'2');
$tab->add('已完成任务', $this->getData(1),true,'c'); $tab->add('已完成任务', $this->getData(1),true,'3');
if ($user->is_admin == 0) {//用户 if ($user->is_admin == 0) {//用户
$tab->add('已经结算任务', $this->getOrderData(),true,'d'); $tab->add('已经结算任务', $this->getOrderData(),true,'4');
} }
return $tab; return $tab;
} }
......
...@@ -4,21 +4,12 @@ namespace App\Admin\Controllers; ...@@ -4,21 +4,12 @@ namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\NotPassAction; use App\Admin\Extensions\Tools\NotPassAction;
use App\Admin\Extensions\Tools\PassAction; use App\Admin\Extensions\Tools\PassAction;
use App\Admin\Forms\MsgSetting;
use App\Admin\Repositories\Task;
use App\Admin\Repositories\TasksApprove; use App\Admin\Repositories\TasksApprove;
use App\Models\TasksReceive;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Show; use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Widgets\Modal;
use Dcat\Admin\Widgets\Tab; use Dcat\Admin\Widgets\Tab;
use Illuminate\Support\Facades\DB;
class TasksApproveController extends AdminController class TasksApproveController extends AdminController
{ {
...@@ -34,7 +25,7 @@ class TasksApproveController extends AdminController ...@@ -34,7 +25,7 @@ class TasksApproveController extends AdminController
$tab->add('未审核', $this->getData(0),true,'a'); $tab->add('未审核', $this->getData(0),true,'a');
$tab->add('已审核', $this->getData(1),true,'b'); $tab->add('已审核', $this->getData(1),true,'b');
return $tab; return $tab->withCard();
} }
/** /**
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
namespace App\Admin\Controllers; namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\CreateSettlementOrder; use App\Admin\Extensions\Tools\CreateSettlementOrder;
use App\Admin\Extensions\Tools\NotPassAction; use App\Admin\Extensions\Tools\ReturnBack;
use App\Admin\Extensions\Tools\UserConfirmOrder;
use App\Admin\Repositories\TasksReceive; use App\Admin\Repositories\TasksReceive;
use App\Models\AdminUser; use App\Models\AdminUser;
use App\Models\TasksOrder; use App\Models\TasksOrder;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Admin; use Dcat\Admin\Admin;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
...@@ -20,12 +20,12 @@ class TasksOrderController extends AdminController ...@@ -20,12 +20,12 @@ class TasksOrderController extends AdminController
{ {
/** /**
* 领取任务页
* *
* @param Content $content *
* @param Content $content
* @return Content * @return Content
*/ */
public function orderReceive($id,Content $content) public function orderReceive($id, Content $content)
{ {
return $content return $content
// ->translation($this->translation()) // ->translation($this->translation())
...@@ -34,15 +34,15 @@ class TasksOrderController extends AdminController ...@@ -34,15 +34,15 @@ class TasksOrderController extends AdminController
->body($this->getOderDetail($id)); ->body($this->getOderDetail($id));
} }
public function getOderDetail($id) public function getOderDetail($id, $type = 1)
{ {
return Grid::make(\App\Admin\Repositories\TasksReceive::with(['task','collects','user']), function (Grid $grid)use ($id) { return Grid::make(\App\Admin\Repositories\TasksReceive::with(['task', 'collects', 'user']), function (Grid $grid) use ($id, $type) {
$user = Admin::user(); $user = Admin::user();
// dd(trans('admin.view'));//查看 // dd(trans('admin.view'));//查看
$grid->title('结算单详情'); $grid->title('结算单详情');
$grid->header(function ($collection)use ($grid,$id) { $grid->header(function ($collection) use ($grid, $id) {
$data = $collection->toArray(); $data = $collection->toArray();
$count = count($data); $count = count($data);
$order = TasksOrder::query()->find($id); $order = TasksOrder::query()->find($id);
...@@ -56,7 +56,7 @@ class TasksOrderController extends AdminController ...@@ -56,7 +56,7 @@ class TasksOrderController extends AdminController
}); });
$grid->model()->where('order_id',$id); $grid->model()->where('order_id', $id);
// 在 display 回调中使用 // 在 display 回调中使用
$grid->column('序号')->display(function () { $grid->column('序号')->display(function () {
...@@ -78,11 +78,35 @@ class TasksOrderController extends AdminController ...@@ -78,11 +78,35 @@ class TasksOrderController extends AdminController
// $grid->column('collects.net_img', '网页截图'); // $grid->column('collects.net_img', '网页截图');
$order = TasksOrder::query()->find($id);
if ($user->is_admin == 0){ if ($user->is_admin == 0) {
$grid->tools(new CreateSettlementOrder('<button class="btn btn-primary ">确认结账</button>')); if ($order->status == 0){
$grid->tools(new CreateSettlementOrder('<button class="btn btn-primary ">确认收款</button>')); $grid->tools(new UserConfirmOrder('<button class="btn btn-primary btn-outline">确认结账</button>', $id, 1));
$grid->tools(new UserConfirmOrder('<button class="btn btn-primary btn-outline">确认收款</button>', $id, 2));
}
if ($order->status == 1) {
$grid->tools('<button class="btn btn-primary ">已确认结账</button>');
$grid->tools(new UserConfirmOrder('<button class="btn btn-primary btn-outline">确认收款</button>', $id, 2));
}
if ($order->status == 2) {
$grid->tools('<button class="btn btn-primary ">已确认结账</button>');
$grid->tools('<button class="btn btn-primary ">已确认收款</button>');
}
}else{
if ($order->status == 0){
$grid->tools('<button class="btn btn-primary ">未确认结账</button>');
$grid->tools('<button class="btn btn-primary ">未确认收款</button>');
}
if ($order->status == 1) {
$grid->tools('<button class="btn btn-primary ">已确认结账</button>');
$grid->tools('<button class="btn btn-primary ">未确认收款</button>');
}
if ($order->status == 2) {
$grid->tools('<button class="btn btn-primary ">已确认结账</button>');
$grid->tools('<button class="btn btn-primary ">已确认收款</button>');
}
} }
$grid->tools(new ReturnBack('<button class="btn btn-primary btn-outline">返回上一级</button>', $type))->toolsWithOutline(false);
$grid->disableRowSelector();//禁用行选择器 $grid->disableRowSelector();//禁用行选择器
$grid->disableRefreshButton();// 禁用刷新功能 $grid->disableRefreshButton();// 禁用刷新功能
...@@ -102,8 +126,8 @@ class TasksOrderController extends AdminController ...@@ -102,8 +126,8 @@ class TasksOrderController extends AdminController
// $tab->add('选项卡1', view('...')); // $tab->add('选项卡1', view('...'));
// $user = Admin::user(); // $user = Admin::user();
$tab->add('结算列表', $this->getData(),true,'a'); $tab->add('结算列表', $this->getData(), true, '11111');
$tab->add('生成结算单', $this->getReceiveData(),true,'b'); $tab->add('生成结算单', $this->getReceiveData(), true, '22222');
return $tab; return $tab;
} }
...@@ -143,23 +167,23 @@ class TasksOrderController extends AdminController ...@@ -143,23 +167,23 @@ class TasksOrderController extends AdminController
// $grid->actions([new NotPassAction()]);//不通过按钮 // $grid->actions([new NotPassAction()]);//不通过按钮
$grid->filter(function (Grid\Filter $filter) { $grid->filter(function (Grid\Filter $filter) {
$filter->expand();//展开过滤器 $filter->expand();//展开过滤器
// 更改为 panel 布局 // 更改为 panel 布局
$filter->panel(); $filter->panel();
// 注意切换为panel布局方式时需要重新调整表单字段的宽度 // 注意切换为panel布局方式时需要重新调整表单字段的宽度
$filter->equal('user.id','用户')->width(2)->select(function (){ $filter->equal('user.id', '用户')->width(2)->select(function () {
$userIds = \App\Models\TasksReceive::query()->where('status',3)->pluck('user_id')->toArray(); $userIds = \App\Models\TasksReceive::query()->where('status', 3)->pluck('user_id')->toArray();
$userArr= AdminUser::query()->whereIn('id',$userIds)->get()->toArray(); $userArr = AdminUser::query()->whereIn('id', $userIds)->get()->toArray();
return array_column($userArr,'name','id'); return array_column($userArr, 'name', 'id');
});
$filter->equal('status','状态')->width(2)->select(['3'=>'未结算'])->default(3);
}); });
$filter->equal('status', '状态')->width(2)->select(['3' => '未结算'])->default(3);
});
$grid->disableFilterButton(); $grid->disableFilterButton();
$grid->disableDeleteButton()->disableCreateButton()->disableEditButton()->disableViewButton()->disableActions()->disableBatchDelete(); $grid->disableDeleteButton()->disableCreateButton()->disableEditButton()->disableViewButton()->disableActions()->disableBatchDelete();
...@@ -186,8 +210,8 @@ class TasksOrderController extends AdminController ...@@ -186,8 +210,8 @@ class TasksOrderController extends AdminController
$grid->column('num'); $grid->column('num');
$grid->column('amount'); $grid->column('amount');
$grid->column('pay_img'); $grid->column('pay_img');
$grid->column('status', '状态')->display(function ($val) use ($grid){ $grid->column('status', '状态')->display(function ($val) use ($grid) {
if ($val == 3){ if ($val == 3) {
$grid->disableEditButton(); $grid->disableEditButton();
} }
return TasksOrder::ORDER_STATUS_DESC[$val]; return TasksOrder::ORDER_STATUS_DESC[$val];
...@@ -197,7 +221,6 @@ class TasksOrderController extends AdminController ...@@ -197,7 +221,6 @@ class TasksOrderController extends AdminController
// $grid->column('updated_at')->sortable(); // $grid->column('updated_at')->sortable();
$grid->disableCreateButton()->disableDeleteButton(); $grid->disableCreateButton()->disableDeleteButton();
$grid->filter(function (Grid\Filter $filter) { $grid->filter(function (Grid\Filter $filter) {
// $filter->equal('id'); // $filter->equal('id');
...@@ -215,10 +238,10 @@ class TasksOrderController extends AdminController ...@@ -215,10 +238,10 @@ class TasksOrderController extends AdminController
protected function detail($id) protected function detail($id)
{ {
return Content::make() return Content::make()
// ->translation($this->translation()) // ->translation($this->translation())
// ->title($this->title()) // ->title($this->title())
// ->description($this->description()['index'] ?? trans('admin.list')) // ->description($this->description()['index'] ?? trans('admin.list'))
->body($this->getOderDetail($id)); ->body($this->getOderDetail($id,2));
} }
......
<?php
namespace App\Admin\Extensions\Tools;
use App\Models\Task;
use App\Models\TasksApprove;
use App\Models\TasksOrder;
use App\Models\TasksReceive;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Grid\BatchAction;
use Illuminate\Http\Request;
class ReturnBack extends Action
{
protected $type;
// 注意action的构造方法参数一定要给默认值
public function __construct($title = null,$type = 1)
{
$this->title = $title;
$this->type = $type;
}
// 处理请求
public function handle(Request $request)
{
// 获取请求参数
$type = $request->get('type');
if ($type == 1){
$url = '/receives';
}
if ($type == 2){
$url = '/orders';
}
return $this->response()->redirect($url);
}
// 设置请求参数
public function parameters()
{
return [
'type' => $this->type,
];
}
}
<?php
namespace App\Admin\Extensions\Tools;
use App\Models\Task;
use App\Models\TasksApprove;
use App\Models\TasksOrder;
use App\Models\TasksReceive;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Grid\BatchAction;
use Illuminate\Http\Request;
class UserConfirmOrder extends Action
{
protected $status;
protected $orderId;
// 注意action的构造方法参数一定要给默认值
public function __construct($title = null,$orderId = 0, $status = 1)
{
$this->title = $title;
$this->orderId = $orderId;
$this->status = $status;
}
// 确认弹窗信息
public function confirm()
{
return $this->status == 1 ?'您确定结账吗?':'您确定收款吗?';
}
// 处理请求
public function handle(Request $request)
{
// 获取请求参数
$status = $request->get('status');
$orderId = $request->get('order_id');
$order = TasksOrder::query()->find($orderId);
if ($order){
if ($order->status == 0 && $status == 1){
$order->status = $status;
$order->save();
}
if ($order->status == 1 && $status == 2){
$order->status = $status;
$order->save();
}
}
return $this->response()->success('操作成功')->refresh();
}
// 设置请求参数
public function parameters()
{
return [
'status' => $this->status,
'order_id' => $this->orderId,
];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment