Commit 5a1e0464 by 汪伟伟

jiesuan

parent fd2b97a7
<?php
namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\NotPassAction;
use App\Admin\Extensions\Tools\PassAction;
use App\Admin\Repositories\TasksApprove;
use App\Admin\Services\CityAreaService;
use App\Models\Task;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Form;
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\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Tab;
use SuperEggs\DcatDistpicker\DcatDistpickerHelper;
class AlreadyApproveController extends AdminController
{
protected $title='已审核';
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(TasksApprove::with(['task', 'collects', 'user']), function (Grid $grid) {
$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', '指标名称');
$grid->column('task.city_id', '地区')->distpicker();
$grid->column('task.year', '时间');
$grid->column('task.refer', '参考信源');
$grid->column('task.price', '单价');
$grid->column('collects.value', '指标值');
$grid->column('collects.reality_refer', '实际信源');
$grid->column('collects.refer_level', '信源等级');
// $grid->column('collects.net_img', '截图链接');
$grid->column('status', '状态')->display(function ($statusValue) {//是当前字段的值
return \App\Models\TasksApprove::APPROVE_STATUS_DESC[$statusValue];
});
// $grid->tools('<a class="btn btn-primary disable-outline">测试按钮</a>');
$grid->disableEditButton()->disableDeleteButton()->disableCreateButton()->disableFilterButton()->disableBatchDelete();
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
});
$grid->actions(function (Grid\Displayers\Actions $actions) {
if ($this->status < 3) {
$actions->append(new PassAction());//通过按钮
$actions->append(new NotPassAction());//不通过按钮
}
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, TasksApprove::with(['task', 'collects', 'user']), function (Show $show) {
$show->field('user.name', '用户');
$show->field('task.name', '指标名称');
$show->field('task.city_id', '地区')->as(function ($val) {
return CityAreaService::getAreaName($val);
});
$show->field('task.year', '时间');
$show->field('task.refer', '参考信源');
$show->field('task.price', '单价');
$show->field('collects.value', '指标值');
$show->field('collects.reality_refer', '实际信源');
$show->field('collects.refer_level', '信源等级');
$show->field('collects.net_img', '截图链接')->unescape();
$show->field('status', '状态')->as(function ($statusValue) {
// 获取当前行的其他字段
// $username = $this->username;
return \App\Models\TasksApprove::APPROVE_STATUS_DESC[$statusValue];
});
$show->field('msg','未通过原因');
// $show->field('created_at');
// $show->field('updated_at');
$show->disableDeleteButton()->disableEditButton();
});
}
/**
* Make a form builder.
*
* @return Form
*/
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->text('msg');
// $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());
// }
}
<?php
namespace App\Admin\Controllers;
use App\Admin\Extensions\Tools\CreateSettlementOrder;
use App\Admin\Extensions\Tools\ReturnBack;
use App\Admin\Extensions\Tools\UserConfirmOrder;
use App\Admin\Repositories\TasksReceive;
use App\Models\AdminUser;
use App\Models\TasksOrder;
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 Dcat\Admin\Widgets\Tab;
class CreateOrderController extends AdminController
{
protected $title='数据';
protected function grid()
{
return Grid::make(TasksReceive::with(['task', 'collects', 'user']), function (Grid $grid) {
$grid->model()->where('status', 3);//3:审核通过但未结算的任务
$grid->disablePagination();
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
});
$grid->column('user.name', '用户');
// $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.price', '单价');
$grid->column('collects.value', '指标值');
$grid->column('collects.reality_refer', '实际信源');
$grid->column('status', '状态')->display(function ($val) {
return \App\Models\TasksReceive::STATUS_DESC[$val];
});
$grid->tools(new CreateSettlementOrder('<button class="btn btn-primary ">生成结算单</button>'));
// $grid->actions([new PassAction()]);//通过按钮
// $grid->actions([new NotPassAction()]);//不通过按钮
$grid->filter(function (Grid\Filter $filter) {
$filter->expand();//展开过滤器
// 更改为 panel 布局
$filter->panel();
// 注意切换为panel布局方式时需要重新调整表单字段的宽度
$filter->equal('user.id', '用户')->width(2)->select(function () {
$userIds = \App\Models\TasksReceive::query()->where('status', 3)->pluck('user_id')->toArray();
$userArr = AdminUser::query()->whereIn('id', $userIds)->get()->toArray();
return array_column($userArr, 'name', 'id');
});
$filter->equal('status', '状态')->width(2)->select(['3' => '未结算'])->default(3);
});
$grid->disableFilterButton();
$grid->disableDeleteButton()->disableCreateButton()->disableEditButton()->disableViewButton()->disableActions()->disableBatchDelete();
});
}
}
......@@ -29,7 +29,7 @@ class TaskController extends AdminController
{
return $content
// ->translation($this->translation())
// ->title($this->title())
->title('待领取任务列表')
// ->description($this->description()['index'] ?? trans('admin.list'))
->body($this->getData());
}
......@@ -43,6 +43,7 @@ class TaskController extends AdminController
// $model = \App\Models\Task::query()->whereNotIn('id',$exists)
return Grid::make(new Task(), function (Grid $grid)use ($user,$exists) {
// $grid->title('dasd');
$grid->model()->whereNotIn('id',$exists);
// dd(Admin::user()->is_admin);
// dd(trans('admin.view'));//查看
......
......@@ -22,22 +22,9 @@ use SuperEggs\DcatDistpicker\DcatDistpickerHelper;
class TasksApproveController extends AdminController
{
/**
* @return Tab
*/
protected function grid()
{
$tab = Tab::make();
// $tab->add('选项卡1', view('...'));
$tab->add('未审核', $this->getData(0), false, 'a');
$tab->add('已审核', $this->getData(1), false, 'b');
return $tab;
protected $title='未审核';
}
public function checkData($status)
{
$content = Content::make();
......@@ -136,20 +123,14 @@ class TasksApproveController extends AdminController
*
* @return Grid
*/
protected function getData($status)
protected function grid()
{
// $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', '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');
}
return Grid::make(TasksApprove::with(['task', 'collects', 'user']), function (Grid $grid) {
$grid->model()->where('status', 0)->orderBy('task_id', 'desc');
// 在 display 回调中使用
$grid->column('序号')->display(function () {
......@@ -168,11 +149,7 @@ 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 \App\Models\TasksApprove::APPROVE_STATUS_DESC[$statusValue];
});
}
// $grid->tools('<a class="btn btn-primary disable-outline">测试按钮</a>');
......
......@@ -116,87 +116,13 @@ class TasksOrderController extends AdminController
});
}
/**
* @return Tab
*/
protected function grid()
{
$tab = Tab::make();
// $tab->add('选项卡1', view('...'));
// $user = Admin::user();
$tab->add('结算列表', $this->getData(), true, '11111');
$tab->add('生成结算单', $this->getReceiveData(), true, '22222');
return $tab;
}
protected function getReceiveData()
{
return Grid::make(TasksReceive::with(['task', 'collects', 'user']), function (Grid $grid) {
$grid->model()->where('status', 3);//3:审核通过但未结算的任务
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 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.price', '单价');
$grid->column('collects.value', '指标值');
$grid->column('collects.reality_refer', '实际信源');
$grid->column('status', '状态')->display(function ($val) {
return \App\Models\TasksReceive::STATUS_DESC[$val];
});
$grid->tools(new CreateSettlementOrder('<button class="btn btn-primary ">生成结算单</button>'));
// $grid->actions([new PassAction()]);//通过按钮
// $grid->actions([new NotPassAction()]);//不通过按钮
$grid->filter(function (Grid\Filter $filter) {
$filter->expand();//展开过滤器
// 更改为 panel 布局
$filter->panel();
// 注意切换为panel布局方式时需要重新调整表单字段的宽度
$filter->equal('user.id', '用户')->width(2)->select(function () {
$userIds = \App\Models\TasksReceive::query()->where('status', 3)->pluck('user_id')->toArray();
$userArr = AdminUser::query()->whereIn('id', $userIds)->get()->toArray();
return array_column($userArr, 'name', 'id');
});
$filter->equal('status', '状态')->width(2)->select(['3' => '未结算'])->default(3);
});
$grid->disableFilterButton();
$grid->disableDeleteButton()->disableCreateButton()->disableEditButton()->disableViewButton()->disableActions()->disableBatchDelete();
});
}
/**
* Make a grid builder.
*
* @return Grid
*/
protected function getData()
protected function grid()
{
return Grid::make(TasksOrder::with(['user']), function (Grid $grid) {
// 在 display 回调中使用
......
......@@ -33,7 +33,9 @@ Route::group([
$router->resource('approves', 'TasksApproveController');
$router->resource('alreadyApprove', 'AlreadyApproveController');
$router->resource('orders', 'TasksOrderController');
$router->resource('createOrder', 'CreateOrderController');
$router->get('orderReceive/{id}', 'TasksOrderController@orderReceive');
......
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