Commit a7a7b87b by 汪伟伟

orders

parent 9f1562e5
......@@ -40,7 +40,12 @@ class TaskController extends AdminController
// dd(Admin::user()->is_admin);
// dd(trans('admin.view'));//查看
$grid->column('id')->sortable();
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
// $grid->column('id')->sortable();
$grid->column('name');
$grid->column('level');
$grid->column('city_id')->distpicker();
......@@ -114,8 +119,12 @@ class TaskController extends AdminController
}
// dd(trans('admin.view'));//查看
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
$grid->column('id')->sortable();
// $grid->column('id')->sortable();
$grid->column('name');
$grid->column('level');
$grid->column('city_id')->distpicker();
......
......@@ -24,22 +24,38 @@ class TaskReceiveController extends AdminController
$tab = Tab::make();
// $tab->add('选项卡1', view('...'));
$tab->add('全部任务', $this->getData(-1));
$user = Admin::user();
if ($user->is_admin){
$tab->add('全部任务', $this->getData(-1));
};
$tab->add('待完成任务', $this->getData(0));
$tab->add('已完成任务', $this->getData(1));
if ($user->is_admin == 0) {//用户
$tab->add('已经结算任务', $this->getOrderData());
}
return $tab;
}
protected function getData($status)
protected function getOrderData()
{
return Grid::make(TasksReceive::with(['task','collects']), function (Grid $grid) use ($status) {
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);
$status != -1 && $grid->model()->where('status', $status);
if ($status == 0) $grid->model()->where('status', 0);
if ($status == 1) $grid->model()->where('status','>',0);
// dd(trans('admin.view'));//查看
$grid->column('id')->sortable();
// 在 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', '时间');
......@@ -54,13 +70,17 @@ class TaskReceiveController extends AdminController
// $grid->column('collects.net_img', '网页截图');
}
if ($status == -1){
$grid->column('status', '状态');
if ($status == -1 || $status == 1){
$grid->column('status', '状态')->display(function ($val){
return \App\Models\TasksReceive::STATUS_DESC[$val];
});
}
$grid->actions(function (Grid\Displayers\Actions $actions) use ($user) {
if ($user->is_admin == 0) {
if ($this->status <= 1) {
if ($this->status <= 2) {
$actions->append(new BackAction());//退回按钮
}else{
$actions->disableEdit();//已经通过的任务不能编辑
}
}
......@@ -72,10 +92,74 @@ class TaskReceiveController extends AdminController
});
$grid->disableDeleteButton()->disableCreateButton();
});
}
protected function getData($status)
{
return Grid::make(TasksReceive::with(['task','collects','user']), function (Grid $grid) use ($status) {
$user = Admin::user();
$user->is_admin == 0 && $grid->model()->where('user_id', $user->id);
if ($status == 0) $grid->model()->where('status', 0);
if ($status == 1) $grid->model()->where('status','>',0);
// dd(trans('admin.view'));//查看
// 在 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', '等级');
if ($status == 1) {
$grid->column('task.price', '单价');
$grid->column('collects.value', '指标值');
$grid->column('collects.reality_refer', '实际信源');
// $grid->column('collects.net_img', '网页截图');
}
if ($status == -1 || $status == 1){
$grid->column('status', '状态')->display(function ($val){
return \App\Models\TasksReceive::STATUS_DESC[$val];
});
}
$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->filter(function (Grid\Filter $filter) {
// $filter->equal('id');
$filter->like('task.name', '指标名称');
});
$grid->disableDeleteButton()->disableCreateButton();
......
......@@ -4,32 +4,61 @@ namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\NotPassAction;
use App\Admin\Extensions\Tools\PassAction;
use App\Admin\Forms\MsgSetting;
use App\Admin\Repositories\Task;
use App\Admin\Repositories\TasksApprove;
use App\Models\TasksReceive;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Card;
use Dcat\Admin\Widgets\Modal;
use Dcat\Admin\Widgets\Tab;
use Illuminate\Support\Facades\DB;
class TasksApproveController extends AdminController
{
/**
* @return Tab
*/
protected function grid()
{
$tab = Tab::make();
// $tab->add('选项卡1', view('...'));
$tab->add('未审核', $this->getData(0));
$tab->add('已审核', $this->getData(1));
return $tab;
}
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
protected function getData($status)
{
// $taskIds = TasksReceive::query()->where('status',1)->pluck('task_id');
// $model = \App\Models\Task::query()->with(['approves'])->whereIn('id',$taskIds);
// dd($taskIds);
return Grid::make(TasksApprove::with(['task', 'collects']), function (Grid $grid) {
$grid->model()->orderBy('task_id', 'desc');
return Grid::make(TasksApprove::with(['task', 'collects','user']), function (Grid $grid) use ($status) {
if ($status == 0) {
$grid->model()->where('status', 0)->orderBy('task_id', 'desc');
} else {
$grid->model()->where('status', '>', 0)->orderBy('task_id', 'desc');
}
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
$grid->column('user.name', '用户');
// $grid->column('id')->sortable();
$grid->column('task.name', '指标名称');
......@@ -42,7 +71,13 @@ class TasksApproveController extends AdminController
$grid->column('collects.reality_refer', '实际信源');
$grid->column('collects.refer_level', '信源等级');
$grid->column('collects.net_img', '截图链接');
if ($status) {
$grid->column('status', '状态')->display(function ($statusValue) {//是当前字段的值
return $statusValue == 1 ? '未通过' : '通过';
});
}
// $grid->tools('<a class="btn btn-primary disable-outline">测试按钮</a>');
$grid->disableEditButton()->disableDeleteButton()->disableCreateButton()->disableFilterButton()->disableViewButton();
$grid->filter(function (Grid\Filter $filter) {
......@@ -50,11 +85,10 @@ class TasksApproveController extends AdminController
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->append(new PassAction());//通过按钮
$actions->append(new NotPassAction());//不通过按钮
$grid->actions([new PassAction()]);//通过按钮
$grid->actions([new NotPassAction()]);//不通过按钮
});
});
}
......@@ -87,15 +121,32 @@ class TasksApproveController extends AdminController
protected function form()
{
return Form::make(new TasksApprove(), function (Form $form) {
$form->display('id');
$form->text('task_id');
$form->text('user_id');
$form->text('receive_id');
$form->text('status');
// $form->display('id');
// $form->text('task_id');
// $form->text('user_id');
// $form->text('receive_id');
// $form->text('status');
$form->text('msg');
$form->display('created_at');
$form->display('updated_at');
// $form->display('created_at');
// $form->display('updated_at');
});
}
// public function edit($id, Content $content)
// {
//// dd($id);
// return $content
// ->translation($this->translation())
// ->title($this->title())
// ->description($this->description()['edit'] ?? trans('admin.edit'))
// ->body($this->form());
// }
public function update($id)
{
dd($id);
return $this->res;
}
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\TasksOrder;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class TasksOrderController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new TasksOrder(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('task_id');
$grid->column('user_id');
$grid->column('receive_id');
$grid->column('name');
$grid->column('city_id');
$grid->column('year');
$grid->column('refer');
$grid->column('reality_refer');
$grid->column('value');
$grid->column('pay_img');
$grid->column('amount');
$grid->column('user_confirm');
$grid->column('pay_confirm');
$grid->column('created_at');
$grid->column('updated_at')->sortable();
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new TasksOrder(), function (Show $show) {
$show->field('id');
$show->field('task_id');
$show->field('user_id');
$show->field('receive_id');
$show->field('name');
$show->field('city_id');
$show->field('year');
$show->field('refer');
$show->field('reality_refer');
$show->field('value');
$show->field('pay_img');
$show->field('amount');
$show->field('user_confirm');
$show->field('pay_confirm');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new TasksOrder(), function (Form $form) {
$form->display('id');
$form->text('task_id');
$form->text('user_id');
$form->text('receive_id');
$form->text('name');
$form->text('city_id');
$form->text('year');
$form->text('refer');
$form->text('reality_refer');
$form->text('value');
$form->text('pay_img');
$form->text('amount');
$form->text('user_confirm');
$form->text('pay_confirm');
$form->display('created_at');
$form->display('updated_at');
});
}
}
......@@ -3,68 +3,23 @@
namespace App\Admin\Extensions\Tools;
use App\Models\Task;
use App\Models\TasksCollect;
use App\Models\TasksReceive;
use Dcat\Admin\Admin;
use App\Admin\Forms\MsgSetting;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
use Dcat\Admin\Widgets\Modal;
class NotPassAction extends RowAction
{
protected $title = '不通过';
/**
* 返回字段标题
*
*
* * @return string
*/
public function title()
public function render()
{
return '不通过';
// 实例化表单类并传递自定义参数
$form = MsgSetting::make()->payload(['id' => $this->getKey()]);
return Modal::make()
->lg()
->title('请填写不通过原因')
->body($form)
->button($this->title);
}
/**
* 添加JS
*
*
* * @return string
*/
/**
* 处理请求,如果不需要接口处理,请直接删除这个方法
*
* @param Request $request
*
* @return \Dcat\Admin\Actions\Response
*/
public function handle(Request $request)
{
// 获取主键
$id = $this->getKey();
$user = Admin::user();
// dd($id,$user->id);
return $this->response()->success('领取成功')
->redirect('receive');
}
public function html()
{
// $this->setHtmlAttribute(['data-excel' => $this->row->excel_url, 'class' => 'download-btn fa fa-download']);
return parent::html();
}
}
......@@ -4,6 +4,7 @@
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;
......@@ -25,7 +26,7 @@ class PassAction extends RowAction
{
return "通过<br><br>";
return '通过&nbsp;&nbsp;&nbsp;';
}
......@@ -48,23 +49,21 @@ class PassAction extends RowAction
{
// 获取主键
$id = $this->getKey();
$user = Admin::user();
// $user = Admin::user();
$approve = TasksApprove::query()->find($id);
TasksReceive::query()->where('id', $approve->receive_id)->update(['status' => 3]);//3:审核通过但未结算的任务
$approve->status = 2;//审核通过
$approve->save();
// dd($id,$user->id);
return $this->response()->success('领取成功')
->redirect('receive');
return $this->response()->success('Processed successfully')
->refresh();
}
public function html()
{
// $this->setHtmlAttribute(['data-excel' => $this->row->excel_url, 'class' => 'download-btn fa fa-download']);
return parent::html();
}
}
<?php
namespace App\Admin\Forms;
use App\Models\TasksApprove;
use App\Models\TasksReceive;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
class MsgSetting extends Form implements LazyRenderable
{
use LazyWidget; // 使用异步加载功能
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
// 获取外部传递参数
$id = $this->payload['id'] ?? null;
// 表单参数
$msg = $input['msg'] ?? null;
$approve = TasksApprove::query()->find($id);
TasksReceive::query()->where('id', $approve->receive_id)->update(['status' => 2]);//2:审核不通过的任务
$approve->status = 1;//审核不通过
$approve->msg = $msg;
$approve->save();
return $this
->response()
->success('Processed successfully')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
// Since v1.6.5 弹出确认弹窗
// $this->confirm('您确定要提交表单吗', 'content');
$this->text('msg','原因')->required();
}
/**
* The data of the form.
*
* @return array
*/
public function default()
{
return [
// 'name' => 'John Doe',
// 'email' => 'John.Doe@gmail.com',
];
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\TasksOrder as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class TasksOrder extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}
......@@ -19,5 +19,8 @@ Route::group([
$router->resource('receives', 'TaskReceiveController');
$router->resource('approves', 'TasksApproveController');
$router->resource('orders', 'TasksOrderController');
// $router->get('/approves/{id}/edit', 'TasksApproveController@edit');
});
......@@ -35,6 +35,11 @@ class TasksApprove extends Model
*/
protected $casts = [];
public function user()
{
return $this->belongsTo(AdminUser::class);
}
public function task()
{
return $this->belongsTo(Task::class);
......
<?php
namespace App\Models;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class TasksOrder extends Model
{
use HasDateTimeFormatter;
protected $table = 'tasks_orders';
}
......@@ -8,7 +8,15 @@ use Illuminate\Database\Eloquent\Model;
class TasksReceive extends Model
{
use HasDateTimeFormatter;
use HasDateTimeFormatter;
const STATUS_DESC = [
0 => '未完成',
1 => '已完成',
2 => '未通过',
3 => '通过',
4 => '已结算',
];
protected $table = 'tasks_receives';
......@@ -38,14 +46,19 @@ class TasksReceive extends Model
return $this->belongsTo(Task::class);
}
public function user()
{
return $this->belongsTo(AdminUser::class);
}
public function collects()
{
return $this->hasOne(TasksCollect::class,'receive_id','id');
return $this->hasOne(TasksCollect::class, 'receive_id', 'id');
}
public function approve()
{
return $this->hasOne(TasksApprove::class,'receive_id','id');
return $this->hasOne(TasksApprove::class, 'receive_id', 'id');
}
}
......@@ -175,7 +175,7 @@ return [
| HTTP Access Only
|--------------------------------------------------------------------------
|
| Setting this value to true will prevent JavaScript from accessing the
| MsgSetting this value to true will prevent JavaScript from accessing the
| value of the cookie and the cookie will only be accessible through
| the HTTP protocol. You are free to modify this option if needed.
|
......
......@@ -18,7 +18,7 @@ class CreateTasksApprovesTable extends Migration
$table->bigInteger('task_id')->comment('系统任务id');
$table->bigInteger('user_id')->default('1')->comment('用户id');
$table->bigInteger('receive_id')->comment('用户领取的任务id');
$table->tinyInteger('status')->default('0')->comment('审核通 0:未通过,1:通过');
$table->tinyInteger('status')->default('0')->comment('0:未审核,1:审核不通过,2:审核通过');
$table->string('msg')->nullable()->comment('未通过原因');
$table->timestamps();
});
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tasks_orders', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('task_id')->comment('系统任务id');
$table->bigInteger('user_id')->default('1')->comment('用户id');
$table->bigInteger('receive_id')->comment('用户领取的任务id');
$table->string('name')->default('1')->nullable()->comment('指标名称');
$table->string('city_id')->nullable()->comment('地区');
$table->string('year')->nullable()->comment('年份');
$table->string('refer')->nullable()->comment('参考信源');
$table->string('reality_refer')->nullable()->comment('实际信源链接');
$table->string('value')->nullable()->comment('数值');
$table->string('pay_img')->nullable()->comment('转账截图');
$table->decimal('amount')->default('0.00')->comment('总金额');
$table->tinyInteger('user_confirm')->default('0')->comment('用户是否确认');
$table->tinyInteger('pay_confirm')->default('0')->comment('用户是否确认收款');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tasks_orders');
}
}
.extension-demo {
font-size: 1.3rem;
cursor: pointer;
}
\ No newline at end of file
(function (w, $) {
function ExtensionDemo(options) {
this.options = $.extend({
$el: $('.demo'),
}, options);
this.init(this.options);
}
ExtensionDemo.prototype = {
init: function (options) {
options.$el.on('click', function () {
Dcat.success($(this).text());
});
console.log('Done.');
},
};
$.fn.extensionDemo = function (options) {
options = options || {};
options.$el = $(this);
return new ExtensionDemo(options);
};
})(window, jQuery);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -46,7 +46,7 @@ return [
'online' => 'Online',
'login' => 'Login',
'logout' => 'Logout',
'setting' => 'Setting',
'setting' => 'MsgSetting',
'name' => 'Name',
'username' => 'Username',
'user' => 'User',
......
<?php
return [
'labels' => [
'TasksOrder' => 'TasksOrder',
'tasks-order' => 'TasksOrder',
],
'fields' => [
'task_id' => '系统任务id',
'user_id' => '用户id',
'receive_id' => '用户领取的任务id',
'name' => '指标名称',
'city_id' => '地区',
'year' => '年份',
'refer' => '参考信源',
'reality_refer' => '实际信源链接',
'value' => '数值',
'pay_img' => '转账截图',
'amount' => '总金额',
'user_confirm' => '用户是否确认',
'pay_confirm' => '用户是否确认收款',
],
'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