Commit f90682b5 by 汪伟伟

找不到

parent a841ad99
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
namespace App\Admin\Controllers; namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\BackAction; use App\Admin\Extensions\Tools\BackAction;
use App\Admin\Extensions\Tools\CreateSettlementOrder;
use App\Admin\Extensions\Tools\NotFindAction;
use App\Admin\Extensions\Tools\OrderDetailAction; use App\Admin\Extensions\Tools\OrderDetailAction;
use App\Admin\Extensions\Tools\PassAction;
use App\Admin\Repositories\TasksReceive; use App\Admin\Repositories\TasksReceive;
use App\Models\TasksApprove; use App\Models\TasksApprove;
use App\Models\TasksOrder; use App\Models\TasksOrder;
...@@ -11,14 +14,17 @@ use Dcat\Admin\Actions\Action; ...@@ -11,14 +14,17 @@ 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;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Repositories\EloquentRepository; 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\Tab; use Dcat\Admin\Widgets\Tab;
use Illuminate\Http\Request;
class TaskReceiveController extends AdminController class TaskReceiveController extends AdminController
{ {
protected $title = ' '; protected $title = ' ';
/** /**
* @return Tab * @return Tab
*/ */
...@@ -28,13 +34,13 @@ class TaskReceiveController extends AdminController ...@@ -28,13 +34,13 @@ 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,'1'); $tab->add('全部任务', $this->getData(-1), true, '1');
} }
$tab->add('待完成任务', $this->getData(0),true,'2'); $tab->add('待完成任务', $this->getData(0), true, '2');
$tab->add('已完成任务', $this->getData(1),true,'3'); $tab->add('已完成任务', $this->getData(1), true, '3');
if ($user->is_admin == 0) {//用户 if ($user->is_admin == 0) {//用户
$tab->add('已经结算任务', $this->getOrderData(),true,'4'); $tab->add('已经结算任务', $this->getOrderData(), true, '4');
} }
return $tab; return $tab;
} }
...@@ -43,7 +49,7 @@ class TaskReceiveController extends AdminController ...@@ -43,7 +49,7 @@ class TaskReceiveController extends AdminController
{ {
return Grid::make(TasksOrder::query(), function (Grid $grid) { return Grid::make(TasksOrder::query(), function (Grid $grid) {
$user = Admin::user(); $user = Admin::user();
$grid->model()->where('user_id',$user->id); $grid->model()->where('user_id', $user->id);
// 在 display 回调中使用 // 在 display 回调中使用
$grid->column('序号')->display(function () { $grid->column('序号')->display(function () {
...@@ -51,10 +57,10 @@ class TaskReceiveController extends AdminController ...@@ -51,10 +57,10 @@ class TaskReceiveController extends AdminController
}); });
// $grid->column('id')->sortable(); // $grid->column('id')->sortable();
$grid->column('time','结算时间'); $grid->column('time', '结算时间');
$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) { $grid->column('status', '状态')->display(function ($val) {
return TasksOrder::ORDER_STATUS_DESC[$val]; return TasksOrder::ORDER_STATUS_DESC[$val];
}); });
...@@ -78,11 +84,11 @@ class TaskReceiveController extends AdminController ...@@ -78,11 +84,11 @@ class TaskReceiveController extends AdminController
protected function getData($status) protected function getData($status)
{ {
return Grid::make(TasksReceive::with(['task','collects','user']), function (Grid $grid) use ($status) { return Grid::make(TasksReceive::with(['task', 'collects', 'user']), function (Grid $grid) use ($status) {
$user = Admin::user(); $user = Admin::user();
$user->is_admin == 0 && $grid->model()->where('user_id', $user->id); $user->is_admin == 0 && $grid->model()->where('user_id', $user->id);
if ($status == 0) $grid->model()->where('status', 0); if ($status == 0) $grid->model()->where('status', 0);
if ($status == 1) $grid->model()->where('status','>',0); if ($status == 1) $grid->model()->where('status', '>', 0);
// dd(trans('admin.view'));//查看 // dd(trans('admin.view'));//查看
// 在 display 回调中使用 // 在 display 回调中使用
...@@ -110,8 +116,8 @@ class TaskReceiveController extends AdminController ...@@ -110,8 +116,8 @@ class TaskReceiveController extends AdminController
// $grid->column('collects.net_img', '网页截图'); // $grid->column('collects.net_img', '网页截图');
} }
if ($status == -1 || $status == 1){ if ($status == -1 || $status == 1) {
$grid->column('status', '状态')->display(function ($val){ $grid->column('status', '状态')->display(function ($val) {
return \App\Models\TasksReceive::STATUS_DESC[$val]; return \App\Models\TasksReceive::STATUS_DESC[$val];
}); });
} }
...@@ -119,7 +125,7 @@ class TaskReceiveController extends AdminController ...@@ -119,7 +125,7 @@ class TaskReceiveController extends AdminController
if ($user->is_admin == 0) { if ($user->is_admin == 0) {
if ($this->status <= 2) { if ($this->status <= 2) {
$actions->append(new BackAction());//退回按钮 $actions->append(new BackAction());//退回按钮
}else{ } else {
$actions->disableEdit();//已经通过的任务不能编辑 $actions->disableEdit();//已经通过的任务不能编辑
} }
} }
...@@ -135,8 +141,6 @@ class TaskReceiveController extends AdminController ...@@ -135,8 +141,6 @@ class TaskReceiveController extends AdminController
}); });
$grid->disableDeleteButton()->disableCreateButton(); $grid->disableDeleteButton()->disableCreateButton();
...@@ -155,7 +159,7 @@ class TaskReceiveController extends AdminController ...@@ -155,7 +159,7 @@ class TaskReceiveController extends AdminController
return Show::make($id, TasksReceive::with(['task', 'collects']), function (Show $show) use ($id) { return Show::make($id, TasksReceive::with(['task', 'collects']), function (Show $show) use ($id) {
$show->field('id'); $show->field('id');
$show->field('task.name', '指标名称'); $show->field('task.name', '指标名称');
$show->field('task.city_id', '地区'); $show->field('task.city_id', '地区')->unserialize();
$show->field('task.year', '时间'); $show->field('task.year', '时间');
$show->field('task.refer', '参考信源'); $show->field('task.refer', '参考信源');
$show->field('task.level', '等级'); $show->field('task.level', '等级');
...@@ -178,19 +182,44 @@ class TaskReceiveController extends AdminController ...@@ -178,19 +182,44 @@ class TaskReceiveController extends AdminController
}); });
} }
public function edit($id, Content $content)
{
return $content
->translation($this->translation())
->title($this->title())
->description($this->description()['edit'] ?? trans('admin.edit'))
->body($this->form($id)->edit($id));
}
public function update($id)
{
return $this->form()->update($id);
}
public function notFind($id)
{
dd(2323, $id);
}
public function edit3()
{
}
/** /**
* Make a form builder. * Make a form builder.
* *
* @return Form * @return Form
*/ */
protected function form() protected function form($id=123)
{ {
return Form::make(TasksReceive::with(['task', 'collects']), function (Form $form) { return Form::make(TasksReceive::with(['task', 'collects']), function (Form $form) use ($id) {
$form->display('id'); $form->display('id');
$form->display('task.name'); $form->display('task.name', '指标名称');
$form->display('task.city_id'); $form->display('task.city_id', '地区')->options('/getCity');
$form->display('task.year'); $form->display('task.year', '时间');
$form->display('task.refer'); $form->display('task.refer', '参考信源');
$form->text('collects.value', '指标值')->required(); $form->text('collects.value', '指标值')->required();
$form->url('collects.reality_refer', '实际信源')->required(); $form->url('collects.reality_refer', '实际信源')->required();
...@@ -198,6 +227,9 @@ class TaskReceiveController extends AdminController ...@@ -198,6 +227,9 @@ class TaskReceiveController extends AdminController
$form->editor('collects.net_img', '网页截图')->required(); $form->editor('collects.net_img', '网页截图')->required();
$form->text('collects.remark', '备注信息'); $form->text('collects.remark', '备注信息');
$form->button('<a href=/notFind/' . $id . '>找不到<a');
// $form->display('created_at'); // $form->display('created_at');
// $form->display('updated_at'); // $form->display('updated_at');
...@@ -216,13 +248,13 @@ class TaskReceiveController extends AdminController ...@@ -216,13 +248,13 @@ class TaskReceiveController extends AdminController
if ($this->status == 0) { if ($this->status == 0) {
\App\Models\TasksReceive::query()->where('id', $this->id)->update(['status' => 1]);//状态更新成已完成 \App\Models\TasksReceive::query()->where('id', $this->id)->update(['status' => 1]);//状态更新成已完成
TasksApprove::query()->updateOrCreate([//审核表里新增一条记录 TasksApprove::query()->updateOrCreate([//审核表里新增一条记录
'task_id'=>$this->task_id, 'task_id' => $this->task_id,
'user_id'=>$this->user_id, 'user_id' => $this->user_id,
'receive_id'=>$this->id, 'receive_id' => $this->id,
],[ ], [
'task_id'=>$this->task_id, 'task_id' => $this->task_id,
'user_id'=>$this->user_id, 'user_id' => $this->user_id,
'receive_id'=>$this->id, 'receive_id' => $this->id,
]); ]);
} }
}); });
......
...@@ -5,8 +5,14 @@ namespace App\Admin\Controllers; ...@@ -5,8 +5,14 @@ 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\Repositories\TasksApprove; use App\Admin\Repositories\TasksApprove;
use App\Models\Task;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Form; use Dcat\Admin\Form;
use Dcat\Admin\Grid; use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\Dashboard;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Show; use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController; use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Tab; use Dcat\Admin\Widgets\Tab;
...@@ -23,14 +29,107 @@ class TasksApproveController extends AdminController ...@@ -23,14 +29,107 @@ class TasksApproveController extends AdminController
$tab = Tab::make(); $tab = Tab::make();
// $tab->add('选项卡1', view('...')); // $tab->add('选项卡1', view('...'));
$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;
} }
public function checkData($status)
{
$content = Content::make();
return $content->body(view('admin.check',['id'=>1]));
}
protected function getData22($status)
{
$taskIds = \App\Models\TasksApprove::query()->where('status', 0)->pluck('task_id');
$model = \App\Models\Task::query()->with(['approves'])->whereIn('id', $taskIds);
// dd($taskIds);
$header = Grid::make($model, function (Grid $grid) use ($status) {
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
// $grid->column('id')->sortable();
$grid->column('name', '指标名称');
$grid->column('city_id', '地区')->distpicker();
$grid->column('year', '时间');
$grid->column('refer', '参考信源');
$grid->column('price', '单价');
$grid->disableEditButton()->disableDeleteButton()->disableCreateButton()->disableFilterButton()->disableBatchDelete();
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->append(new PassAction());//通过按钮
$actions->append(new NotPassAction());//不通过按钮
});
});
$body = Grid::make(TasksApprove::with(['task', 'collects', 'user']), function (Grid $grid) use ($status) {
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
// $grid->column('id')->sortable();
$grid->column('collects.value', '指标值');
$grid->column('collects.reality_refer', '实际信源');
$grid->column('collects.refer_level', '信源等级');
// $grid->column('collects.net_img', '截图链接');
$grid->disableEditButton()->disableDeleteButton()->disableCreateButton()->disableFilterButton()->disableBatchDelete();
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->append(new PassAction());//通过按钮
$actions->append(new NotPassAction());//不通过按钮
});
});
$content = Content::make();
$row = new Row();
$row->column(12, function (Column $column) use ($header){
$column->row(
$header
// function (Row $row) {
// $row->column(12 / 7, '序号');
// $row->column(12 / 7, '指标名称');
// $row->column(12 / 7, '地区');
// $row->column(12 / 7, '时间');
// $row->column(12 / 7, '参考信源');
// $row->column(12 / 7, '单价');
// $row->column(12 / 7, '操作');
// }
);
$column->row(function (Row $row) {
$row->column(6, 4);
$row->column(6, 5);
});
});
return $row;
}
/** /**
* Make a grid builder. * Make a grid builder.
* *
...@@ -42,13 +141,15 @@ class TasksApproveController extends AdminController ...@@ -42,13 +141,15 @@ class TasksApproveController extends AdminController
// $model = \App\Models\Task::query()->with(['approves'])->whereIn('id',$taskIds); // $model = \App\Models\Task::query()->with(['approves'])->whereIn('id',$taskIds);
// dd($taskIds); // dd($taskIds);
return Grid::make(TasksApprove::with(['task', 'collects','user']), function (Grid $grid) use ($status) { return Grid::make(TasksApprove::with(['task', 'collects', 'user']), function (Grid $grid) use ($status) {
if ($status == 0) { if ($status == 0) {
$grid->model()->where('status', 0)->orderBy('task_id', 'desc'); $grid->model()->where('status', 0)->orderBy('task_id', 'desc');
} else { } else {
$grid->model()->where('status', '>', 0)->orderBy('task_id', 'desc'); $grid->model()->where('status', '>', 0)->orderBy('task_id', 'desc');
} }
// 在 display 回调中使用 // 在 display 回调中使用
$grid->column('序号')->display(function () { $grid->column('序号')->display(function () {
return $this->_index + 1; return $this->_index + 1;
...@@ -79,8 +180,8 @@ class TasksApproveController extends AdminController ...@@ -79,8 +180,8 @@ class TasksApproveController extends AdminController
$filter->equal('id'); $filter->equal('id');
}); });
$grid->actions(function (Grid\Displayers\Actions $actions){ $grid->actions(function (Grid\Displayers\Actions $actions) {
if ($this->status < 3){ if ($this->status < 3) {
$actions->append(new PassAction());//通过按钮 $actions->append(new PassAction());//通过按钮
$actions->append(new NotPassAction());//不通过按钮 $actions->append(new NotPassAction());//不通过按钮
} }
...@@ -99,11 +200,11 @@ class TasksApproveController extends AdminController ...@@ -99,11 +200,11 @@ class TasksApproveController extends AdminController
*/ */
protected function detail($id) protected function detail($id)
{ {
return Show::make($id,TasksApprove::with(['task', 'collects','user']), function (Show $show) { return Show::make($id, TasksApprove::with(['task', 'collects', 'user']), function (Show $show) {
$show->field('user.name', '用户'); $show->field('user.name', '用户');
$show->field('task.name', '指标名称'); $show->field('task.name', '指标名称');
$show->field('task.city_id', '地区')->as(function ($val){ $show->field('task.city_id', '地区')->as(function ($val) {
return DcatDistpickerHelper::getAreaName($val); return DcatDistpickerHelper::getAreaName($val);
}); });
$show->field('task.year', '时间'); $show->field('task.year', '时间');
...@@ -115,7 +216,7 @@ class TasksApproveController extends AdminController ...@@ -115,7 +216,7 @@ class TasksApproveController extends AdminController
$show->field('collects.refer_level', '信源等级'); $show->field('collects.refer_level', '信源等级');
$show->field('collects.net_img', '截图链接')->unescape(); $show->field('collects.net_img', '截图链接')->unescape();
$show->field('status','状态')->as(function ($statusValue){ $show->field('status', '状态')->as(function ($statusValue) {
// 获取当前行的其他字段 // 获取当前行的其他字段
// $username = $this->username; // $username = $this->username;
return \App\Models\TasksApprove::APPROVE_STATUS_DESC[$statusValue]; return \App\Models\TasksApprove::APPROVE_STATUS_DESC[$statusValue];
......
<?php
namespace App\Admin\Extensions\Tools;
use App\Models\Task;
use App\Models\TasksApprove;
use App\Models\TasksCollect;
use App\Models\TasksReceive;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
class NotFindAction extends RowAction
{
public $id;
public function __construct($id,$title = null)
{
$this->id = $id;
}
/**
* 返回字段标题
*
*
* * @return string
*/
public function title()
{
return '通过&nbsp;&nbsp;&nbsp;';
}
/**
* 添加JS
*
*
* * @return string
*/
/**
* 处理请求,如果不需要接口处理,请直接删除这个方法
*
* @param Request $request
*
* @return \Dcat\Admin\Actions\Response
*/
public function handle(Request $request)
{
// 获取主键
dd(111);
// $user = Admin::user();
return $this->response()->success('Processed successfully')
->refresh();
}
public function html()
{
return parent::html();
}
}
...@@ -22,6 +22,8 @@ Route::group([ ...@@ -22,6 +22,8 @@ Route::group([
$router->get('receive/{id}', 'TaskController@receiveDetail'); $router->get('receive/{id}', 'TaskController@receiveDetail');
$router->get('notFind/{id}', 'TaskReceiveController@notFind');
$router->resource('receives', 'TaskReceiveController'); $router->resource('receives', 'TaskReceiveController');
$router->resource('approves', 'TasksApproveController'); $router->resource('approves', 'TasksApproveController');
......
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