Commit 9cb0eb47 by 汪伟伟

add

parent 416385fe
......@@ -3,19 +3,15 @@
namespace App\Admin\Controllers;
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\PassAction;
use App\Admin\Repositories\TasksReceive;
use App\Models\TasksApprove;
use App\Models\TasksCollect;
use App\Models\TasksOrder;
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\Repositories\EloquentRepository;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Tab;
......@@ -91,6 +87,7 @@ class TaskReceiveController extends AdminController
if ($status == 1) $grid->model()->where('status', '>', 0);
// dd(trans('admin.view'));//查看
$grid->model()->orderBy('created_at','desc');
// 在 display 回调中使用
$grid->column('序号')->display(function () {
return $this->_index + 1;
......@@ -121,6 +118,8 @@ class TaskReceiveController extends AdminController
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) {
......@@ -191,43 +190,68 @@ class TaskReceiveController extends AdminController
->body($this->form($id)->edit($id));
}
public function update($id)
{
return $this->form()->update($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();
}
public function notFind($id)
{
dd(2323, $id);
$no = \App\Models\TasksReceive::query()
->where('id','!=',$id)
->where('status',0)
->orderBy('created_at')
->first();
if ($no){
$url = '/receives/'.$no->id.'/edit';
}else{
$url = '/receives';
}
public function edit3()
{
return response()->redirectTo($url);//自动跳转下一个
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form($id=123)
protected function form($id='')
{
return Form::make(TasksReceive::with(['task', 'collects']), function (Form $form) use ($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('task.city_id', '地区')->options('/getCity');
$form->display('area', '地区');
// $form->distpicker(['city_id'=>'市']);
$form->display('task.year', '时间');
$form->display('task.refer', '参考信源');
$form->text('collects.value', '指标值')->required();
$form->url('collects.reality_refer', '实际信源')->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', '备注信息');
$form->text('collects.remark', '备注信息')->placeholder('如果找不到请填写备注信息')->attribute(['id'=>'remark-zbd']);
$form->button('<a href=/notFind/' . $id . '>找不到<a');
// $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');
......@@ -240,13 +264,15 @@ class TaskReceiveController extends AdminController
// });
// //保存前回调
// $form->saving(function (Form $form) {
// dump($form->year);
//
//
// });
//保存后回调
$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,
......@@ -256,6 +282,19 @@ class TaskReceiveController extends AdminController
'user_id' => $this->user_id,
'receive_id' => $this->id,
]);
$no = \App\Models\TasksReceive::query()
->where('id','!=',$this->id)
->where('status',0)
->orderBy('created_at')
->first();
if ($no){
$url = '/receives/'.$no->id.'/edit';
}else{
$url = '/receives';
}
// var_dump($url);
$form->response()->redirect($url);
}
});
......@@ -264,4 +303,6 @@ class TaskReceiveController extends AdminController
}
}
......@@ -5,6 +5,7 @@ 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;
......@@ -205,7 +206,7 @@ class TasksApproveController extends AdminController
$show->field('task.name', '指标名称');
$show->field('task.city_id', '地区')->as(function ($val) {
return DcatDistpickerHelper::getAreaName($val);
return CityAreaService::getAreaName($val);
});
$show->field('task.year', '时间');
$show->field('task.refer', '参考信源');
......
<?php
namespace App\Admin\Controllers;
use App\Admin\Repositories\TasksCollect;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class TasksCollectController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new TasksCollect(), function (Grid $grid) {
$grid->column('id')->sortable();
$grid->column('task_id');
$grid->column('user_id');
$grid->column('receive_id');
$grid->column('value');
$grid->column('reality_refer');
$grid->column('refer_level');
$grid->column('net_img');
$grid->column('is_find');
$grid->column('remark');
$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 TasksCollect(), function (Show $show) {
$show->field('id');
$show->field('task_id');
$show->field('user_id');
$show->field('receive_id');
$show->field('value');
$show->field('reality_refer');
$show->field('refer_level');
$show->field('net_img');
$show->field('is_find');
$show->field('remark');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new TasksCollect(), function (Form $form) {
$form->display('id');
$form->text('task_id');
$form->text('user_id');
$form->text('receive_id');
$form->text('value');
$form->text('reality_refer');
$form->text('refer_level');
$form->text('net_img');
$form->text('is_find');
$form->text('remark');
$form->display('created_at');
$form->display('updated_at');
});
}
}
<?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();
}
}
......@@ -3,12 +3,14 @@
namespace App\Admin\Extensions\Tools;
use App\Admin\Services\CityAreaService;
use App\Models\Task;
use App\Models\TasksCollect;
use App\Models\TasksReceive;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
use SuperEggs\DcatDistpicker\DcatDistpickerHelper;
class ReceiveAction extends RowAction
......@@ -56,6 +58,7 @@ class ReceiveAction extends RowAction
$receive = TasksReceive::query()->create([
'task_id'=>$id,
'user_id'=>$user->id,
'area'=> CityAreaService::getAreaName($task->city_id),
]);
$task->num -= 1;
$task->save();
......
......@@ -2,8 +2,8 @@
namespace App\Admin\Extensions;
use App\Admin\Services\CityAreaService;
use Dcat\Admin\Show\AbstractField;
use SuperEggs\DcatDistpicker\DcatDistpickerHelper;
class UnSerialize extends AbstractField
{
......@@ -16,6 +16,6 @@ class UnSerialize extends AbstractField
// return unserialize($this->value);
// 返回任意可被渲染的内容
return DcatDistpickerHelper::getAreaName($this->value);//城市编码转成名称
return CityAreaService::getAreaName($this->value);//城市编码转成名称
}
}
<?php
namespace App\Admin\Repositories;
use App\Models\TasksCollect as Model;
use Dcat\Admin\Repositories\EloquentRepository;
class TasksCollect extends EloquentRepository
{
/**
* Model.
*
* @var string
*/
protected $eloquentClass = Model::class;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -55,10 +55,10 @@ class Task extends Model
$this->attributes['year'] = implode(',', $value);
}
public function setCityIdAttribute($value)
{
$this->attributes['city_id'] = implode(',', $value);
}
// public function setCityIdAttribute($value)
// {
// $this->attributes['cityId'] = implode(',', $value);
// }
public function approves()
{
......
......@@ -25,6 +25,7 @@ class TasksCollect extends Model
'reality_refer',
'refer_level',
'net_img',
'is_find',
'remark',
'created_at',
'updated_at',
......
......@@ -29,6 +29,7 @@ class TasksReceive extends Model
'task_id',
'user_id',
'order_id',
'area',
'status',
'created_at',
'updated_at',
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTasksCollectsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tasks_collects', 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('value')->default('')->comment('指标值');
$table->string('reality_refer')->default('')->comment('实际信源');
$table->string('refer_level')->nullable()->comment('信源等级');
$table->longText('net_img')->nullable()->comment('网页截图');
$table->unsignedTinyInteger('is_find')->default('0')->comment('是否找到');
$table->string('remark')->nullable()->comment('备注信息');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tasks_collects');
}
}
......@@ -18,6 +18,7 @@ class CreateTasksReceivesTable extends Migration
$table->bigInteger('task_id')->comment('系统任务id');
$table->bigInteger('user_id')->comment('领取任务的用户id');
$table->bigInteger('order_id')->default('0')->comment('所属结算单id');
$table->string('area')->default('')->comment('地区');
$table->tinyInteger('status')->default('0')->comment('任务状态:(0:已领取但未完成的任务;1:已经完成但未审核的任务;2:审核不通过的任务;3:审核通过但未结算的任务;4:已经结算的任务)');
$table->timestamps();
});
......
......@@ -57,6 +57,7 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection msg
* @property Grid\Column|Collection receive_id
* @property Grid\Column|Collection task_id
* @property Grid\Column|Collection is_find
* @property Grid\Column|Collection net_img
* @property Grid\Column|Collection reality_refer
* @property Grid\Column|Collection refer_level
......@@ -66,6 +67,7 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection time
* @property Grid\Column|Collection pay_confirm
* @property Grid\Column|Collection user_confirm
* @property Grid\Column|Collection area
* @property Grid\Column|Collection order_id
* @property Grid\Column|Collection email_verified_at
*
......@@ -115,6 +117,7 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection msg(string $label = null)
* @method Grid\Column|Collection receive_id(string $label = null)
* @method Grid\Column|Collection task_id(string $label = null)
* @method Grid\Column|Collection is_find(string $label = null)
* @method Grid\Column|Collection net_img(string $label = null)
* @method Grid\Column|Collection reality_refer(string $label = null)
* @method Grid\Column|Collection refer_level(string $label = null)
......@@ -124,6 +127,7 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection time(string $label = null)
* @method Grid\Column|Collection pay_confirm(string $label = null)
* @method Grid\Column|Collection user_confirm(string $label = null)
* @method Grid\Column|Collection area(string $label = null)
* @method Grid\Column|Collection order_id(string $label = null)
* @method Grid\Column|Collection email_verified_at(string $label = null)
*/
......@@ -178,6 +182,7 @@ namespace Dcat\Admin {
* @property Show\Field|Collection msg
* @property Show\Field|Collection receive_id
* @property Show\Field|Collection task_id
* @property Show\Field|Collection is_find
* @property Show\Field|Collection net_img
* @property Show\Field|Collection reality_refer
* @property Show\Field|Collection refer_level
......@@ -187,6 +192,7 @@ namespace Dcat\Admin {
* @property Show\Field|Collection time
* @property Show\Field|Collection pay_confirm
* @property Show\Field|Collection user_confirm
* @property Show\Field|Collection area
* @property Show\Field|Collection order_id
* @property Show\Field|Collection email_verified_at
*
......@@ -236,6 +242,7 @@ namespace Dcat\Admin {
* @method Show\Field|Collection msg(string $label = null)
* @method Show\Field|Collection receive_id(string $label = null)
* @method Show\Field|Collection task_id(string $label = null)
* @method Show\Field|Collection is_find(string $label = null)
* @method Show\Field|Collection net_img(string $label = null)
* @method Show\Field|Collection reality_refer(string $label = null)
* @method Show\Field|Collection refer_level(string $label = null)
......@@ -245,6 +252,7 @@ namespace Dcat\Admin {
* @method Show\Field|Collection time(string $label = null)
* @method Show\Field|Collection pay_confirm(string $label = null)
* @method Show\Field|Collection user_confirm(string $label = null)
* @method Show\Field|Collection area(string $label = null)
* @method Show\Field|Collection order_id(string $label = null)
* @method Show\Field|Collection email_verified_at(string $label = null)
*/
......
<?php
return [
'labels' => [
'TasksCollect' => 'TasksCollect',
'tasks-collect' => 'TasksCollect',
],
'fields' => [
'task_id' => '系统任务id',
'user_id' => '用户id',
'receive_id' => '用户领取的任务id',
'value' => '指标值',
'reality_refer' => '实际信源',
'refer_level' => '信源等级',
'net_img' => '网页截图',
'is_find' => '是否找到',
'remark' => '备注信息',
],
'options' => [
],
];
<div class="box-footer">
<div class="col-md-2 d-md-block" style="display: none"></div>
<div class="col-md-8">
<div class="btn-group pull-right">
<button class="btn btn-primary submit">
{{-- <i class="feather icon-save"></i>--}}
完 成</button>
</div>
<div class="btn-group pull-right" style="right: 10%">
<button onclick="jump({{$id}})" class="btn btn-primary ">找不到</button>
</div>
{{-- <div class="pull-right d-md-flex" style="margin:10px 15px 0 0;display: none"><div class="d-flex flex-wrap">--}}
{{-- <div class="vs-checkbox-con vs-checkbox-primary" style="margin-right: 16px">--}}
{{-- <input value="1" name="after-save" circle="1" type="checkbox" class=" Dcat_Admin_Widgets_Checkbox">--}}
{{-- <span class="vs-checkbox vs-checkbox-">--}}
{{-- <span class="vs-checkbox--check">--}}
{{-- <i class="vs-icon feather icon-check"></i>--}}
{{-- </span>--}}
{{-- </span>--}}
{{-- <span><span class="text-80 text-bold">继续编辑</span></span>--}}
{{-- </div>--}}
{{-- <div class="vs-checkbox-con vs-checkbox-primary" style="margin-right: 16px">--}}
{{-- <input value="3" name="after-save" circle="1" type="checkbox" class=" Dcat_Admin_Widgets_Checkbox">--}}
{{-- <span class="vs-checkbox vs-checkbox-">--}}
{{-- <span class="vs-checkbox--check">--}}
{{-- <i class="vs-icon feather icon-check"></i>--}}
{{-- </span>--}}
{{-- </span>--}}
{{-- <span><span class="text-80 text-bold">查看</span></span>--}}
{{-- </div>--}}
{{-- </div></div>--}}
<div class="btn-group pull-left">
<button type="reset" class="btn btn-white"><i class="feather icon-rotate-ccw"></i> 重置</button>
</div>
</div>
</div>
<script>
function jump(id){
remark = document.getElementById('remark-zbd').value
// console.log(remark)
if (remark == ''){
Dcat.error('备注信息不能为空')
}else {
window.location.href = '/notFind/'+id+'?remark='+remark
}
}
</script>
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