Commit 5f5ef3db by 汪伟伟

领取任务

parent 1404b31a
......@@ -2,6 +2,8 @@
namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\ReceiveAction;
use App\Admin\Extensions\Tools\ShowArtwork;
use App\Admin\Repositories\Task;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
......@@ -26,6 +28,8 @@ class TaskController extends AdminController
$grid->model()->where('status', $tab);
}
// dd(trans('admin.view'));//查看
$grid->column('id')->sortable();
$grid->column('name');
$grid->column('level');
......@@ -42,6 +46,11 @@ class TaskController extends AdminController
$filter->like('name');
});
// $grid->actions(function (Grid\Displayers\Actions $actions){
// $actions->append( new ReceiveAction());
// });
});
}
......@@ -70,11 +79,11 @@ class TaskController extends AdminController
$show->field('id');
$show->field('name');
$show->field('level');
$show->field('city_id')->value(DcatDistpickerHelper::getAreaName(\App\Models\Task::query()->find($id)->city_id));
$show->city_id()->unserialize();
$show->field('year');
$show->field('refer');
$show->field('guide');
$show->guide()->unescape();//不 转义html内容
// $show->field('status');
// $show->field('created_at');
......@@ -137,6 +146,7 @@ class TaskController extends AdminController
// dump($form->name);
// });
});
}
......
<?php
namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\BatchReceiveAction;
use App\Admin\Extensions\Tools\ReceiveAction;
use App\Admin\Repositories\Task;
use App\Admin\Repositories\TasksReceive;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Illuminate\Support\Facades\Auth;
class TaskReceiveController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Task(), function (Grid $grid) {
// dd(Auth::guard('admin')->id());
// dd(trans('admin.view'));//查看
$grid->column('id')->sortable();
$grid->column('name');
$grid->column('level');
$grid->column('city_id')->distpicker();
$grid->column('year');
$grid->column('refer');
// $grid->column('guide');
// $grid->column('status');
// $grid->column('created_at');
// $grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
// $filter->equal('id');
$filter->like('name');
});
$grid->actions(function (Grid\Displayers\Actions $actions){
if ($this->id > 1){
$actions->append( new ReceiveAction());//领取按钮
}
});
$grid->disableEditButton()->disableDeleteButton()->disableCreateButton();
$grid->tools(function (Grid\Tools $tools) {
$tools->append( new BatchReceiveAction());//新增批量领取按钮
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Task(), function (Show $show)use ($id) {
$show->field('id');
$show->field('name');
$show->field('level');
$show->city_id()->unserialize();
$show->field('year');
$show->field('refer');
$show->guide()->unescape();//不 转义html内容
// $show->field('status');
// $show->field('created_at');
// $show->field('updated_at');
$show->disableDeleteButton()->disableEditButton();
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new TasksReceive(), function (Form $form) {
$form->display('id');
$form->text('task_id');
$form->text('user_id');
$form->text('status');
$form->display('created_at');
$form->display('updated_at');
});
}
}
<?php
namespace App\Admin\Extensions;
use Dcat\Admin\Grid\Displayers\Actions;
/**
* 重写行操作按钮样式
*/
class TextActions extends Actions
{
/**
* @return string
*/
protected function getViewLabel()
{
$label = '查看';
// $label = trans('admin.show');
// return '<i class="feather icon-eye text-success"></i> <span class="text-success">' . $label . '</span> &emsp;';
return '<i class=""></i> <span class="text-success">' . $label . '</span> &emsp;';
}
/**
* @return string
*/
protected function getEditLabel()
{
$label = trans('admin.edit');
// return '<i class="feather icon-edit-1 text-custom"></i> <span class="text-custom">' . $label . '</span> &emsp;';
return '<i class=""></i> <span class="text-custom">' . $label . '</span> &emsp;';
}
/**
* @return string
*/
protected function getQuickEditLabel()
{
$label = trans('admin.edit');
$label2 = trans('admin.quick_edit');
return '<i class="feather icon-edit-1 text-custom"></i> <span class="text-custom" title="' . $label2 . '">' . $label . '</span> &emsp;';
}
/**
* @return string
*/
protected function getDeleteLabel()
{
$label = trans('admin.delete');
// return '<i class="feather icon-alert-triangle text-danger"></i> <span class="text-danger">' . $label . '</span> &emsp;';
return '<i class=""></i> <span class="text-danger">' . $label . '</span> &emsp;';
}
}
<?php
namespace App\Admin\Extensions\Tools;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
class BatchReceiveAction extends RowAction
{
/**
* 返回字段标题
*
*
* * @return string
*/
public function title()
{
return '<button data-action="refresh" class="btn btn-primary grid-refresh btn-mini btn-outline" style="margin-right:3px">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline">&nbsp; 批量领取</span></button>';
}
/**
* 添加JS
*
*
* * @return string
*/
/**
* 处理请求,如果不需要接口处理,请直接删除这个方法
*
* @param Request $request
*
* @return \Dcat\Admin\Actions\Response
*/
public function handle(Request $request)
{
// 获取主键
$key = $this->getKey();
// dd($key);
return $this->response()
->success('Processed successfully.')
->redirect('/');
}
public function html()
{
// $this->setHtmlAttribute(['data-excel' => $this->row->excel_url, 'class' => 'download-btn fa fa-download']);
return parent::html();
}
}
<?php
namespace App\Admin\Extensions\Tools;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
class ReceiveAction extends RowAction
{
/**
* 返回字段标题
*
*
* * @return string
*/
public function title()
{
return '领取';
}
/**
* 添加JS
*
*
* * @return string
*/
/**
* 处理请求,如果不需要接口处理,请直接删除这个方法
*
* @param Request $request
*
* @return \Dcat\Admin\Actions\Response
*/
public function handle(Request $request)
{
// 获取主键
$key = $this->getKey();
dd($key);
return $this->response()
->success('Processed successfully.')
->redirect('/');
}
public function html()
{
// $this->setHtmlAttribute(['data-excel' => $this->row->excel_url, 'class' => 'download-btn fa fa-download']);
return parent::html();
}
}
<?php
namespace App\Admin\Extensions;
use Dcat\Admin\Show\AbstractField;
use SuperEggs\DcatDistpicker\DcatDistpickerHelper;
class UnSerialize extends AbstractField
{
// 这个属性设置为false则不会转义HTML代码
public $escape = false;
public function render($arg = '')
{
// return unserialize($this->value);
// 返回任意可被渲染的内容
return DcatDistpickerHelper::getAreaName($this->value);//城市编码转成名称
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\TasksReceive as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class TasksReceive extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}
......@@ -18,3 +18,7 @@
* Admin::js('/packages/prettydocs/js/main.js');
*
*/
use Dcat\Admin\Show\Field;
Field::extend('unserialize', \App\Admin\Extensions\UnSerialize::class);
......@@ -15,5 +15,7 @@ Route::group([
$router->resource('tasks', 'TaskController');
$router->resource('receives', 'TaskReceiveController');
// $router->get('/api/city', 'TaskController@city');
});
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class TasksReceive extends Model
{
use HasDateTimeFormatter;
protected $table = 'tasks_receives';
}
......@@ -161,7 +161,8 @@ return [
'grid' => [
// The global Grid action display class.
'grid_action_class' => Dcat\Admin\Grid\Displayers\DropdownActions::class,
// 'grid_action_class' => Dcat\Admin\Grid\Displayers\DropdownActions::class,
'grid_action_class' => \App\Admin\Extensions\TextActions::class,
// The global Grid batch action display class.
'batch_action_class' => Dcat\Admin\Grid\Tools\BatchActions::class,
......
......@@ -17,10 +17,12 @@ class CreateTasksTable extends Migration
$table->bigIncrements('id');
$table->string('name')->default('')->comment('指标名称');
$table->integer('level')->default('1')->comment('难度等级');
$table->string('area')->default('')->comment('地区');
$table->string('city_id')->default('')->comment('市');
$table->string('province_id')->default('')->comment('省');
$table->string('year')->default('')->comment('年份');
$table->string('refer')->nullable()->comment('参考信源');
$table->longText('guide')->nullable()->comment('收集指南');
$table->decimal('price')->default('0.00')->comment('单价');
$table->tinyInteger('status')->default('0')->nullable()->comment('任务状态');
$table->timestamps();
});
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksReceivesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tasks_receives', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('task_id')->comment('系统任务id');
$table->bigInteger('user_id')->comment('领取任务的用户id');
$table->tinyInteger('status')->default('0')->comment('任务状态:(0:已领取但未完成的任务;1:已经完成但未审核的任务;2:审核不通过的任务;3:审核通过但未结算的任务;4:已经结算的任务)');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tasks_receives');
}
}
......@@ -14,5 +14,9 @@ return [
'status' => '状态',
],
'options' => [
// 'add'=>[
// 'submit'=>'保存嘉宾',
// 'reset'=>'取消'
// ]
],
];
<?php
return [
'labels' => [
'TasksReceive' => 'TasksReceive',
'tasks-receive' => 'TasksReceive',
],
'fields' => [
'task_id' => '系统任务id',
'user_id' => '领取任务的用户id',
'status' => '任务状态:(0:已领取但未完成的任务;1:已经完成但未审核的任务;2:审核不通过的任务;3:审核通过但未结算的任务;4:已经结算的任务)',
],
'options' => [
],
];
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