| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 | 
							- <?php
 
- namespace App\Admin\Controllers\PersonalTalents;
 
- use App\Http\Controllers\Controller;
 
- use App\Models\PersonalTalents;
 
- use App\Models\PersonalTalentsLog;
 
- use Encore\Admin\Controllers\HasResourceActions;
 
- use Encore\Admin\Facades\Admin;
 
- use Encore\Admin\Form;
 
- use Encore\Admin\Grid;
 
- use Encore\Admin\Layout\Content;
 
- class PersonalTalentsLogController extends Controller
 
- {
 
-     protected $role_id_1 = 30;
 
-     use HasResourceActions;
 
-     /**
 
-      * Index interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function index(Content $content)
 
-     {
 
-         return $content
 
-             ->header('进度列表')
 
-             ->description('')
 
-             ->body($this->grid());
 
-     }
 
-     /**
 
-      * Show interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function show($id, Content $content)
 
-     {
 
-     }
 
-     /**
 
-      * Edit interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function edit($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('进度列表')
 
-             ->description('编辑')
 
-             ->body($this->form()->edit($id));
 
-     }
 
-     /**
 
-      * Create interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function create(Content $content)
 
-     {
 
-         return $content
 
-             ->header('进度列表')
 
-             ->description('创建')
 
-             ->body($this->form());
 
-     }
 
-     /**
 
-      * Make a grid builder.
 
-      *
 
-      * @return Grid
 
-      */
 
-     protected function grid()
 
-     {
 
-         $id = request()->id;
 
-         if(empty($id)){
 
-             admin_toastr('请选择人才!', 'error');
 
-             return back();
 
-         }
 
-         $grid = new Grid(new PersonalTalentsLog());
 
-         $grid->model()->where('talents_id', $id)->where('log_class', 5)->orderBy('id', 'desc');
 
-         $grid->id('ID');
 
-         $grid->log_time('操作时间')->display(function ($log_time) {
 
-             return date('Y-m-d',$log_time) ;
 
-         });
 
-         $grid->content('日志内容');
 
-         $grid->auth_man('操作人员');
 
-         $grid->actions(function ($actions) use ($grid) {
 
-             $actions->disableView();
 
-         });
 
-         $grid->filter(function ($filter) {
 
-             $filter->like('content', '内容');
 
-         });
 
-         return $grid;
 
-     }
 
-     /**
 
-      * Make a form builder.
 
-      *
 
-      * @return Form
 
-      */
 
-     protected function form()
 
-     {
 
-         $id = request()->id;
 
-         $form = new Form(new PersonalTalentsLog);
 
-         $form->date('log_time',
 
-             '处理时间')->format('YYYY-MM-DD')->default(date('Y-m-s', time()))->setMustMark();
 
-         $form->textarea('inplan_content', '进度内容')->attribute(['maxlength'=>1000])->rules(['required'], ['required'=>"请填写进度内容"])->setMustMark();
 
-         $form->hidden('ids')->default($id);
 
-         return $form;
 
-     }
 
-     public function personalTalentsLogList(Content $content)
 
-     {
 
-         return $content
 
-             ->header('进度列表')
 
-             ->description('进度列表')
 
-             ->body($this->grid());
 
-     }
 
-     public function store()
 
-     {
 
-         $id = request()->ids;
 
-         $log_time = request()->log_time;
 
-         if (empty($log_time)) {
 
-             admin_toastr('请选择日期', 'error');
 
-             return back();
 
-         }
 
-         $inplan_content = request()->inplan_content;
 
-         if (empty($inplan_content)) {
 
-             admin_toastr('请填入进度内容', 'error');
 
-             return back();
 
-         }
 
-         $role_arr = [];
 
-         if (!empty(Admin::user()->roles)) {
 
-             foreach (Admin::user()->roles as $key => $val) {
 
-                 $role_arr[] = $val->id;
 
-             }
 
-         }
 
-         if (!in_array($this->role_id_1, $role_arr)) {
 
-             admin_toastr('人才客服才可以操作', 'error');
 
-             return back();
 
-         }
 
-         //判断是否为此人才的所属客服在操作
 
-         $adminid = PersonalTalents::where(array('id' => $id))->value('admin_id');
 
-         if ($adminid != Admin::user()->id) {
 
-             admin_toastr('此人才的客服才可以操作', 'error');
 
-             return back();
 
-         }
 
-         try {
 
-             $log['talents_id'] = $id;
 
-             $log['content'] = $inplan_content;
 
-             $log['log_time'] = strtotime($log_time);
 
-             $log['log_class'] = 5;//日志类型
 
-             $log['auth_man'] = Admin::user()->username;
 
-             PersonalTalentsLog::create($log);
 
-             admin_toastr('操作成功', 'success');
 
-         } catch (\Exception $e) {
 
-             admin_toastr('操作失败', 'error');
 
-         }
 
-         return redirect(admin_base_path("personalTalents/personalTalentsLog/list/".request()->ids));
 
-     }
 
- }
 
 
  |