Commit d147cd23 by 汪伟伟

我的任务

parent 3854c0d1
<?php
namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\BackAction;
use App\Admin\Repositories\TasksReceive;
use App\Models\TasksApprove;
use App\Models\TasksCollect;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class AlreadyDoneTaskController extends AdminController
{
public $title='已完成任务';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(TasksReceive::with(['task', 'collects', 'user']), function (Grid $grid){
$user = Admin::user();
$user->is_admin == 0 && $grid->model()->where('user_id', $user->id);
$grid->model()->where('status', '>', 0);
// dd(trans('admin.view'));//查看
$grid->model()->orderBy('created_at','desc');
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
if ($user->is_admin == 1) {
$grid->column('user.name', '用户');
$grid->disableEditButton();
}
// $grid->column('id')->sortable();
$grid->column('task.name', '指标名称');
$grid->column('task.city_id', '地区')->distpicker();
$grid->column('task.year', '时间');
$grid->column('task.refer', '参考信源');
$grid->column('task.level', '等级');
$grid->column('task.price', '单价');
$grid->column('collects.value', '指标值');
$grid->column('collects.reality_refer', '实际信源');
// $grid->column('collects.net_img', '网页截图');
$grid->column('status', '状态')->display(function ($val) {
return \App\Models\TasksReceive::STATUS_DESC[$val];
});
$grid->column('created_at', '领取任务时间');
$grid->actions(function (Grid\Displayers\Actions $actions) use ($user) {
if ($user->is_admin == 0) {
if ($this->status <= 2) {
$actions->append(new BackAction());//退回按钮
} else {
$actions->disableEdit();//已经通过的任务不能编辑
}
}
});
$grid->disableBatchDelete();
$grid->filter(function (Grid\Filter $filter) {
// $filter->equal('id');
$filter->like('task.name', '指标名称');
});
$grid->disableDeleteButton()->disableCreateButton();
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, TasksReceive::with(['task', 'collects']), function (Show $show) use ($id) {
$show->field('id');
$show->field('task.name', '指标名称');
$show->field('task.city_id', '地区')->unserialize();
$show->field('task.year', '时间');
$show->field('task.refer', '参考信源');
$show->field('task.level', '等级');
// $show->field('task.guide','参考指南')->unescape();//不 转义html内容
$show->field('task.price', '单价');
if ($show->model()->status > 0) {
$show->field('collects.value', '指标值');
$show->field('collects.reality_refer', '实际信源');
$show->field('collects.refer_level', '信源等级');
$show->field('collects.net_img', '网页截图')->unescape();
$show->field('collects.remark', '备注信息');
}
// $show->field('created_at');
// $show->field('updated_at');
$show->disableDeleteButton()->disableEditButton();
});
}
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));
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form($id='')
{
// $model = \App\Models\TasksReceive::query()
// ->leftJoin('tasks as a','task_id','=','a.id')
// ->select(['a.name','a.city_id','a.year','a.refer','tasks_receives.*'])
// ->with(['collects']);
return Form::make(\App\Models\TasksReceive::with(['task','collects']), function (Form $form) use ($id) {
$form->display('id');
$form->display('task.name', '指标名称');
$form->display('area', '地区');
// $form->distpicker(['city_id'=>'市']);
$form->display('task.year', '时间');
$form->display('task.refer', '参考信源');
$form->text('collects.value', '指标值')->required();
$form->text('collects.reality_refer', '实际信源')->required();
$form->select('collects.refer_level', '信源等级')->options([1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5])->required();
$form->editor('collects.net_img', '网页截图')->required();
$form->text('collects.remark', '备注信息')->placeholder('如果找不到请填写备注信息')->attribute(['id'=>'remark-zbd']);
// $form->ignore(['task.city_id']);//忽略掉不需要保存的字段 (ignore)
// $form->display('created_at');
// $form->display('updated_at');
// // 在表单提交前调用
// $form->submitted(function (Form $form) {
// //...
// });
// //保存前回调
// $form->saving(function (Form $form) {
//
//
// });
//保存后回调
// $form->saved(function (Form $form) {
// });
$form->disableDeleteButton();
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\OrderDetailAction;
use App\Models\TasksOrder;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
class AlreadySettlementController extends AdminController
{
protected $title = '已经结算任务';
protected function grid()
{
return Grid::make(TasksOrder::query(), function (Grid $grid) {
$user = Admin::user();
$grid->model()->where('user_id', $user->id);
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
// $grid->column('id')->sortable();
$grid->column('time', '结算时间');
$grid->column('num', '数量');
$grid->column('amount', '金额');
$grid->column('pay_img', '转账截图');
$grid->column('status', '状态')->display(function ($val) {
return TasksOrder::ORDER_STATUS_DESC[$val];
});
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->actions(function (Grid\Displayers\Actions $actions) use ($user) {
$actions->append(new OrderDetailAction());//
});
$grid->disableCreateButton()->disableDeleteButton()->disableEditButton()->disableViewButton();
$grid->filter(function (Grid\Filter $filter) {
// $filter->equal('id');
});
});
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\BackAction;
use App\Admin\Repositories\TasksReceive;
use App\Models\TasksApprove;
use App\Models\TasksCollect;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Http\Request;
class NoDoneTaskController extends AdminController
{
public $title='未完成任务';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(TasksReceive::with(['task', 'collects', 'user']), function (Grid $grid) {
$user = Admin::user();
$user->is_admin == 0 && $grid->model()->where('user_id', $user->id);
$grid->model()->where('status', 0);
// dd(trans('admin.view'));//查看
$grid->model()->orderBy('created_at','desc');
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
if ($user->is_admin == 1) {
$grid->column('user.name', '用户');
$grid->disableEditButton();
}
// $grid->column('id')->sortable();
$grid->column('task.name', '指标名称');
$grid->column('task.city_id', '地区')->distpicker();
$grid->column('task.year', '时间');
$grid->column('task.refer', '参考信源');
$grid->column('task.level', '等级');
$grid->column('created_at', '领取任务时间');
$grid->actions(function (Grid\Displayers\Actions $actions) use ($user) {
if ($user->is_admin == 0) {
if ($this->status <= 2) {
$actions->append(new BackAction());//退回按钮
} else {
$actions->disableEdit();//已经通过的任务不能编辑
}
}
});
$grid->disableBatchDelete();
$grid->filter(function (Grid\Filter $filter) {
// $filter->equal('id');
$filter->like('task.name', '指标名称');
});
$grid->disableDeleteButton()->disableCreateButton();
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, TasksReceive::with(['task', 'collects']), function (Show $show) use ($id) {
$show->field('id');
$show->field('task.name', '指标名称');
$show->field('task.city_id', '地区')->unserialize();
$show->field('task.year', '时间');
$show->field('task.refer', '参考信源');
$show->field('task.level', '等级');
// $show->field('task.guide','参考指南')->unescape();//不 转义html内容
$show->field('task.price', '单价');
if ($show->model()->status > 0) {
$show->field('collects.value', '指标值');
$show->field('collects.reality_refer', '实际信源');
$show->field('collects.refer_level', '信源等级');
$show->field('collects.net_img', '网页截图')->unescape();
$show->field('collects.remark', '备注信息');
}
// $show->field('created_at');
// $show->field('updated_at');
$show->disableDeleteButton()->disableEditButton();
});
}
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 notFind($id,Request $request)
{
$remark = $request->get('remark');
$receive = \App\Models\TasksReceive::query()->find($id);
if ($receive){
$receive->status =1;
TasksCollect::query()->where('receive_id',$id)->update(['is_find'=>0,'remark'=>$remark]);
$receive->save();
}
$no = \App\Models\TasksReceive::query()
->where('id','!=',$id)
->where('status',0)
->orderBy('created_at')
->first();
if ($no){
$url = '/noDone/'.$no->id.'/edit';
}else{
$url = '/already';
}
return response()->redirectTo($url);//自动跳转下一个
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form($id='')
{
// $model = \App\Models\TasksReceive::query()
// ->leftJoin('tasks as a','task_id','=','a.id')
// ->select(['a.name','a.city_id','a.year','a.refer','tasks_receives.*'])
// ->with(['collects']);
return Form::make(\App\Models\TasksReceive::with(['task','collects']), function (Form $form) use ($id) {
$form->display('id');
$form->display('task.name', '指标名称');
$form->display('area', '地区');
// $form->distpicker(['city_id'=>'市']);
$form->display('task.year', '时间');
$form->display('task.refer', '参考信源');
$form->text('collects.value', '指标值')->required();
$form->text('collects.reality_refer', '实际信源')->required();
$form->select('collects.refer_level', '信源等级')->options([1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5])->required();
$form->editor('collects.net_img', '网页截图')->required();
$form->text('collects.remark', '备注信息')->placeholder('如果找不到请填写备注信息')->attribute(['id'=>'remark-zbd']);
// $form->button('<a style="color: white;" href=/notFind/' . $id . '?remark='.'>找不到<a>');
$form->footer(function ($footer)use ($id) {
$receive = \App\Models\TasksReceive::query()->find($id);
if ($receive && $receive->status == 0){
$footer->view('admin.button', ['id'=>$id]);
}
});
// $form->ignore(['task.city_id']);//忽略掉不需要保存的字段 (ignore)
// $form->display('created_at');
// $form->display('updated_at');
// // 在表单提交前调用
// $form->submitted(function (Form $form) {
// //...
// });
// //保存前回调
// $form->saving(function (Form $form) {
//
//
// });
//保存后回调
$form->saved(function (Form $form) {
if ($this->status == 0) {
// dd($this->id);
\App\Models\TasksReceive::query()->where('id', $this->id)->update(['status' => 1]);//状态更新成已完成
TasksCollect::query()->where('receive_id', $this->id)->update(['is_find' => 1]);//可以找到
TasksApprove::query()->updateOrCreate([//审核表里新增一条记录
'task_id' => $this->task_id,
'user_id' => $this->user_id,
'receive_id' => $this->id,
], [
'task_id' => $this->task_id,
'user_id' => $this->user_id,
'receive_id' => $this->id,
]);
$no = \App\Models\TasksReceive::query()
->where('id','!=',$this->id)
->where('status',0)
->orderBy('created_at','desc')
->first();
if ($no){
$url = '/noDone/'.$no->id.'/edit';
}else{
$url = '/already';
}
// var_dump($url);
return $form->response()->success('保存成功')->redirect($url);
}
});
$form->disableDeleteButton();
});
}
}
...@@ -19,16 +19,9 @@ use Illuminate\Http\Request; ...@@ -19,16 +19,9 @@ use Illuminate\Http\Request;
class TaskReceiveController extends AdminController class TaskReceiveController extends AdminController
{ {
protected $title = ' '; protected $title = '';
public function noDone(Content $content)
{
return $content
->translation($this->translation())
->title($this->title())
->description($this->description()['index'] ?? trans('admin.list'))
->body( $this->getData(0));
}
/** /**
* @return Tab * @return Tab
*/ */
......
...@@ -60,7 +60,7 @@ class BackAction extends RowAction ...@@ -60,7 +60,7 @@ class BackAction extends RowAction
// dd($id,$user->id); // dd($id,$user->id);
return $this->response()->success('退回成功') return $this->response()->success('退回成功')
->redirect('receives'); ->redirect('noDone');
} }
public function html() public function html()
......
...@@ -30,7 +30,7 @@ class ReturnBack extends Action ...@@ -30,7 +30,7 @@ class ReturnBack extends Action
$type = $request->get('type'); $type = $request->get('type');
if ($type == 1){ if ($type == 1){
$url = '/receives'; $url = '/settle';
} }
if ($type == 2){ if ($type == 2){
......
...@@ -22,12 +22,14 @@ Route::group([ ...@@ -22,12 +22,14 @@ Route::group([
$router->get('receive/{id}', 'TaskController@receiveDetail'); $router->get('receive/{id}', 'TaskController@receiveDetail');
$router->get('notFind/{id}', 'TaskReceiveController@notFind'); $router->get('notFind/{id}', 'NoDoneTaskController@notFind');
$router->resource('receives', 'TaskReceiveController'); $router->resource('receives', 'TaskReceiveController');
$router->get('noDone', 'TaskReceiveController@noDone'); $router->resource('noDone', 'NoDoneTaskController');
$router->resource('already', 'AlreadyDoneTaskController');
$router->resource('settle', 'AlreadySettlementController');
$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