michealwoo 2 éve
szülő
commit
1370def9b3

+ 112 - 0
app/Admin/Controllers/AttendanceController.php

xqd
@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Attendance;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Layout\Content;
+//use Dcat\Admin\Http\Controllers\AdminController;
+use App\Admin\Controllers\AdminController;
+
+class AttendanceController extends AdminController
+{
+
+    public function index($parent, Content $content)
+    {
+        $title = '考勤记录';
+        return $content
+            ->title($title)
+            ->description('列表')
+            // 添加面包屑导航
+            ->breadcrumb([
+                    'text' => '返回列表',
+                    'url' => admin_url('/attendance'),
+                    'icon' => 'fa fa-step-backward'
+                ],['text' => $title]
+            )
+            ->body($this->grid($parent));
+    }
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new Attendance(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('type');
+            $grid->column('arrive_school_time');
+            $grid->column('off_school_time');
+            $grid->column('leave_type');
+            $grid->column('leave_start_time');
+            $grid->column('leave_end_time');
+            $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 Attendance(), function (Show $show) {
+            $show->field('id');
+            $show->field('type');
+            $show->field('arrive_school_time');
+            $show->field('off_school_time');
+            $show->field('leave_type');
+            $show->field('leave_start_time');
+            $show->field('leave_end_time');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form($id)
+    {
+        return Form::make(new Attendance(), function (Form $form) use($id) {
+
+            $form->row(function (Form\Row $row) {
+              $row->width(6)->select('type')->options(config('map.sex'));
+              $row->width(6)->datetime('arrive_school_time');
+            });
+
+            $form->row(function (Form\Row $row) {
+              $row->width(6)->datetime('off_school_time');
+              $row->width(6)->select('leave_type')->options(config('map.leave_type'));
+              
+            });
+
+            $form->row(function (Form\Row $row) {
+              $row->width(6)->datetime('leave_start_time');
+              $row->width(6)->datetime('leave_end_time');
+            });
+
+            $form->disableListButton();
+            $form->saved(function (Form $form) {
+              return $form
+                  ->response()
+                  ->success('保存成功')
+                  ->redirect('/student');
+            });
+          });
+    }
+}

+ 2 - 3
app/Admin/Controllers/StudentController.php

xqd
@@ -30,10 +30,9 @@ class StudentController extends AdminController
             $grid->actions(function (Grid\Displayers\Actions $actions){
               //$actions->append(new Send(Order::class,$actions->row->id));
               $actions->append('成长数据');
-              $actions->append('疫苗接种记录');
-              $actions->append('考勤登记');
+              $actions->append('<a href="' . admin_url('vaccination/' . $actions->row->id.'/index') . '">疫苗接种记录</i></a>');
+              $actions->append('<a href="' . admin_url('attendance/' . $actions->row->id.'/create') . '">考勤登记</i></a>');
               $actions->append('相册');
-              //$actions->append(new ToothLog(Student::class,$actions->row->id));
               $actions->append('<a href="' . admin_url('toothlog/' . $actions->row->id.'/index') . '">长牙记录</i></a>');
             });
             $grid->filter(function (Grid\Filter $filter) {

+ 97 - 0
app/Admin/Controllers/VaccinationController.php

xqd
@@ -0,0 +1,97 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Models\Student;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use App\Admin\Controllers\AdminController;
+
+use Dcat\Admin\Layout\Content;
+use App\Models\Vaccination;
+
+class VaccinationController extends AdminController
+{
+    public function index($parent, Content $content)
+    {
+        $title = '疫苗接种记录';
+        return $content
+            ->title($title)
+            ->description('列表')
+            // 添加面包屑导航
+            ->breadcrumb([
+                    'text' => '返回列表',
+                    'url' => admin_url('/student'),
+                    'icon' => 'fa fa-step-backward'
+                ],['text' => $title]
+            )
+            ->body($this->grid($parent));
+    }
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid($id)
+    {
+        return Grid::make(new Vaccination(), function (Grid $grid) use($id) {
+            //$grid->column('student_id');
+            $grid->column('student_id','学生信息')->display(function () {
+                  $str  = "";
+                  $str .= "<div style='margin-right:10px;display: flex;align-items: center;padding-right:10px;'>";
+                  $str .= '<img data-action="preview-img" src="' . $this->student_id . '" style="height:56px;width:56px;cursor:pointer;margin-right:10px;" class="img img-thumbnail">';
+                  $str .= '<div>';
+                  $str .= '<p style="margin:0px">姓名:小朋友</p>';
+                  $str .= '<p style="margin:0px">出生年月:2023-01-01</p>';
+                  $str .= '<p style="margin:0px">家庭住址:四川省成都市金牛区三泰魔方</p>';
+                  $str .= '<p style="margin:0px">所属班级:黄桃班</p>';
+                  $str .= '<p style="margin:0px">入园日期:2022-03-10</p>';
+                  $str .= "</div>";
+                  $str .= "</div>";
+                  return $str;
+            });
+            $grid->column('name');
+            $grid->column('inoculate_time');
+            $grid->column('inoculate_unit');
+            $grid->column('desc')->limit(50);
+            $grid->column('photos')->display(function ($photo_urls){
+                return json_decode($photo_urls, true);
+            })->image('', '60', '60');;
+            $grid->disableActions();
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->panel();
+                $filter->like('student_id')->width(4);
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new Vaccination(), function (Show $show) {
+            $show->field('id');
+           
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form($id)
+    {
+        return Form::make(new Vaccination(), function (Form $form) use($id) {
+          $form->width(6)->datetime('time')->required()->placeholder('时间');
+          $form->width(6)->textarea('desc')->placeholder('长牙描述');
+          $form->width(6)->multipleImage('photos')->placeholder('上传照片')->saveAsJson();
+        });
+    }
+}

+ 4 - 0
app/Admin/routes.php

xqd
@@ -30,5 +30,9 @@ Route::group([
     $router->resource('/leave_message', 'LeaveMessageController');//留言列表
 
     $router->resource('/toothlog/{id}/index', 'ToothLogController');//长牙记录
+    $router->resource('/attendance/{id}/', 'AttendanceController');//考勤登记
+    $router->resource('/attendances', 'AttendanceController');//考勤记录
+
+    $router->resource('/vaccination/{id}/index', 'VaccinationController');//疫苗接种记录
     
 });

+ 16 - 0
app/Models/Attendance.php

xqd
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+use Dcat\Admin\Traits\HasDateTimeFormatter;
+use Illuminate\Database\Eloquent\SoftDeletes;
+use Illuminate\Database\Eloquent\Model;
+
+class Attendance extends Model
+{
+	use HasDateTimeFormatter;
+    use SoftDeletes;
+
+    protected $table = 'attendance';
+    
+}

+ 16 - 0
app/Models/Vaccination.php

xqd
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+use Dcat\Admin\Traits\HasDateTimeFormatter;
+use Illuminate\Database\Eloquent\SoftDeletes;
+use Illuminate\Database\Eloquent\Model;
+
+class Vaccination extends Model
+{
+	use HasDateTimeFormatter;
+    use SoftDeletes;
+
+    protected $table = 'vaccination';
+    
+}

+ 28 - 4
dcat_admin_ide_helper.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -11,6 +11,7 @@ namespace Dcat\Admin {
     use Illuminate\Support\Collection;
 
     /**
+     * @property Grid\Column|Collection width
      * @property Grid\Column|Collection id
      * @property Grid\Column|Collection student_id
      * @property Grid\Column|Collection happen_time
@@ -49,6 +50,11 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection add_user_id
      * @property Grid\Column|Collection is_pdf
      * @property Grid\Column|Collection is_publish
+     * @property Grid\Column|Collection arrive_school_time
+     * @property Grid\Column|Collection off_school_time
+     * @property Grid\Column|Collection leave_type
+     * @property Grid\Column|Collection leave_start_time
+     * @property Grid\Column|Collection leave_end_time
      * @property Grid\Column|Collection look_time
      * @property Grid\Column|Collection is_share_to_parents
      * @property Grid\Column|Collection looker
@@ -109,7 +115,6 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection email
      * @property Grid\Column|Collection answer
      * @property Grid\Column|Collection look_num
-     * @property Grid\Column|Collection leave_type
      * @property Grid\Column|Collection reason
      * @property Grid\Column|Collection start_time
      * @property Grid\Column|Collection end_time
@@ -162,6 +167,7 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection time
      * @property Grid\Column|Collection plan_type
      * @property Grid\Column|Collection create_user_id
+     * @property Grid\Column|Collection log_time
      * @property Grid\Column|Collection likes_count
      * @property Grid\Column|Collection comments_count
      * @property Grid\Column|Collection fans_count
@@ -180,6 +186,7 @@ namespace Dcat\Admin {
      * @property Grid\Column|Collection lang
      * @property Grid\Column|Collection jpush_reg_id
      *
+     * @method Grid\Column|Collection width(string $label = null)
      * @method Grid\Column|Collection id(string $label = null)
      * @method Grid\Column|Collection student_id(string $label = null)
      * @method Grid\Column|Collection happen_time(string $label = null)
@@ -218,6 +225,11 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection add_user_id(string $label = null)
      * @method Grid\Column|Collection is_pdf(string $label = null)
      * @method Grid\Column|Collection is_publish(string $label = null)
+     * @method Grid\Column|Collection arrive_school_time(string $label = null)
+     * @method Grid\Column|Collection off_school_time(string $label = null)
+     * @method Grid\Column|Collection leave_type(string $label = null)
+     * @method Grid\Column|Collection leave_start_time(string $label = null)
+     * @method Grid\Column|Collection leave_end_time(string $label = null)
      * @method Grid\Column|Collection look_time(string $label = null)
      * @method Grid\Column|Collection is_share_to_parents(string $label = null)
      * @method Grid\Column|Collection looker(string $label = null)
@@ -278,7 +290,6 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection email(string $label = null)
      * @method Grid\Column|Collection answer(string $label = null)
      * @method Grid\Column|Collection look_num(string $label = null)
-     * @method Grid\Column|Collection leave_type(string $label = null)
      * @method Grid\Column|Collection reason(string $label = null)
      * @method Grid\Column|Collection start_time(string $label = null)
      * @method Grid\Column|Collection end_time(string $label = null)
@@ -331,6 +342,7 @@ namespace Dcat\Admin {
      * @method Grid\Column|Collection time(string $label = null)
      * @method Grid\Column|Collection plan_type(string $label = null)
      * @method Grid\Column|Collection create_user_id(string $label = null)
+     * @method Grid\Column|Collection log_time(string $label = null)
      * @method Grid\Column|Collection likes_count(string $label = null)
      * @method Grid\Column|Collection comments_count(string $label = null)
      * @method Grid\Column|Collection fans_count(string $label = null)
@@ -354,6 +366,7 @@ namespace Dcat\Admin {
     class MiniGrid extends Grid {}
 
     /**
+     * @property Show\Field|Collection width
      * @property Show\Field|Collection id
      * @property Show\Field|Collection student_id
      * @property Show\Field|Collection happen_time
@@ -392,6 +405,11 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection add_user_id
      * @property Show\Field|Collection is_pdf
      * @property Show\Field|Collection is_publish
+     * @property Show\Field|Collection arrive_school_time
+     * @property Show\Field|Collection off_school_time
+     * @property Show\Field|Collection leave_type
+     * @property Show\Field|Collection leave_start_time
+     * @property Show\Field|Collection leave_end_time
      * @property Show\Field|Collection look_time
      * @property Show\Field|Collection is_share_to_parents
      * @property Show\Field|Collection looker
@@ -452,7 +470,6 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection email
      * @property Show\Field|Collection answer
      * @property Show\Field|Collection look_num
-     * @property Show\Field|Collection leave_type
      * @property Show\Field|Collection reason
      * @property Show\Field|Collection start_time
      * @property Show\Field|Collection end_time
@@ -505,6 +522,7 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection time
      * @property Show\Field|Collection plan_type
      * @property Show\Field|Collection create_user_id
+     * @property Show\Field|Collection log_time
      * @property Show\Field|Collection likes_count
      * @property Show\Field|Collection comments_count
      * @property Show\Field|Collection fans_count
@@ -523,6 +541,7 @@ namespace Dcat\Admin {
      * @property Show\Field|Collection lang
      * @property Show\Field|Collection jpush_reg_id
      *
+     * @method Show\Field|Collection width(string $label = null)
      * @method Show\Field|Collection id(string $label = null)
      * @method Show\Field|Collection student_id(string $label = null)
      * @method Show\Field|Collection happen_time(string $label = null)
@@ -561,6 +580,11 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection add_user_id(string $label = null)
      * @method Show\Field|Collection is_pdf(string $label = null)
      * @method Show\Field|Collection is_publish(string $label = null)
+     * @method Show\Field|Collection arrive_school_time(string $label = null)
+     * @method Show\Field|Collection off_school_time(string $label = null)
+     * @method Show\Field|Collection leave_type(string $label = null)
+     * @method Show\Field|Collection leave_start_time(string $label = null)
+     * @method Show\Field|Collection leave_end_time(string $label = null)
      * @method Show\Field|Collection look_time(string $label = null)
      * @method Show\Field|Collection is_share_to_parents(string $label = null)
      * @method Show\Field|Collection looker(string $label = null)
@@ -621,7 +645,6 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection email(string $label = null)
      * @method Show\Field|Collection answer(string $label = null)
      * @method Show\Field|Collection look_num(string $label = null)
-     * @method Show\Field|Collection leave_type(string $label = null)
      * @method Show\Field|Collection reason(string $label = null)
      * @method Show\Field|Collection start_time(string $label = null)
      * @method Show\Field|Collection end_time(string $label = null)
@@ -674,6 +697,7 @@ namespace Dcat\Admin {
      * @method Show\Field|Collection time(string $label = null)
      * @method Show\Field|Collection plan_type(string $label = null)
      * @method Show\Field|Collection create_user_id(string $label = null)
+     * @method Show\Field|Collection log_time(string $label = null)
      * @method Show\Field|Collection likes_count(string $label = null)
      * @method Show\Field|Collection comments_count(string $label = null)
      * @method Show\Field|Collection fans_count(string $label = null)

+ 17 - 0
resources/lang/zh-CN/attendance.php

xqd
@@ -0,0 +1,17 @@
+<?php 
+return [
+    'labels' => [
+        'Attendance' => '出勤',
+        'attendance' => '出勤',
+    ],
+    'fields' => [
+        'type' => '出勤类型',
+        'arrive_school_time' => '到校时间',
+        'off_school_time' => '离校时间',
+        'leave_type' => '请假类型',
+        'leave_start_time' => '请假开始时间',
+        'leave_end_time' => '请假结束时间',
+    ],
+    'options' => [
+    ],
+];

+ 17 - 0
resources/lang/zh-CN/vaccination.php

xqd
@@ -0,0 +1,17 @@
+<?php 
+return [
+    'labels' => [
+        'Vaccination' => 'Vaccination',
+        'vaccination' => 'Vaccination',
+    ],
+    'fields' => [
+        'name' => '疫苗名称',
+        'inoculate_time' => '接种时间',
+        'inoculate_unit' => '接种单位',
+        'desc' => '接种说明',
+        'photos' => '照片',
+        'student_id' => '学生id',
+    ],
+    'options' => [
+    ],
+];