Jelajahi Sumber

宝妈社区端

whj 4 tahun lalu
induk
melakukan
7d551c22a5

+ 16 - 0
app/Admin/Actions/Cdmuser.php

xqd
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Admin\Actions;
+
+use Encore\Admin\Actions\Action;
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Http\Request;
+
+class Cdmuser extends RowAction
+{
+    public $name = '创建账号';
+    public function href()
+    {
+        return '/admin/cdms_user?id='.$this->row->id;
+    }
+}

+ 17 - 0
app/Admin/Actions/UpdateCdms.php

xqd
@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Admin\Actions;
+
+use Encore\Admin\Actions\RowAction;
+use Illuminate\Http\Request;
+
+class UpdateCdm extends RowAction
+{
+   public $name = '修改账号';
+
+    public function href(Request $request)
+    {
+        $id = $this->row->id;
+        return "/cdms_user/".$id."/edit";
+    }
+}

+ 24 - 0
app/Admin/Controllers/ApiController.php

xqd
@@ -0,0 +1,24 @@
+<?php
+
+
+namespace App\Admin\Controllers;
+
+
+use App\Http\Controllers\Controller;
+use App\Models\Area;
+
+class ApiController extends Controller
+{
+
+    public function getCity()
+    {
+        $id  = request('q');
+        return Area::where(['level'=>2,'parent_id'=>$id])->get(['name as text','id']);
+    }
+
+    public function getArea()
+    {
+        $id  = request('q');
+        return Area::where(['level'=>3,'parent_id'=>$id])->get(['name as text','id']);
+    }
+}

+ 58 - 0
app/Admin/Controllers/CdmsController.php

xqd
@@ -0,0 +1,58 @@
+<?php
+
+
+namespace App\Admin\Controllers;
+
+
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+
+class CdmsController extends AdminController
+{
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    public function form()
+    {
+        $userModel = config('tenancy.database.users_model');
+        $permissionModel = config('tenancy.database.permissions_model');
+        $roleModel = config('tenancy.database.roles_model');
+
+        $form = new Form(new $userModel());
+
+        $userTable = config('tenancy.database.users_table');
+        $connection = config('tenancy.database.connection');
+
+        $form->display('id', 'ID');
+        $form->text('username', trans('tenancy.username'))
+            ->creationRules(['required', "unique:{$connection}.{$userTable}"])
+            ->updateRules(['required', "unique:{$connection}.{$userTable},username,{{id}}"]);
+
+        $form->text('name', trans('tenancy.name'))->rules('required');
+        $form->image('avatar', trans('tenancy.avatar'));
+        $form->password('password', trans('tenancy.password'))->rules('required|confirmed');
+        $form->password('password_confirmation', trans('tenancy.password_confirmation'))->rules('required')
+            ->default(function ($form) {
+                return $form->model()->password;
+            });
+
+        $form->ignore(['password_confirmation']);
+
+        $form->multipleSelect('roles', trans('tenancy.roles'))->options($roleModel::all()->pluck('name', 'id'));
+        $form->multipleSelect('permissions', trans('tenancy.permissions'))->options($permissionModel::all()->pluck('name', 'id'));
+
+        $form->display('created_at', trans('tenancy.created_at'));
+        $form->display('updated_at', trans('tenancy.updated_at'));
+
+        $form->saving(function (Form $form) {
+            if ($form->password && $form->model()->password != $form->password) {
+                $form->password = bcrypt($form->password);
+            }
+        });
+
+        return $form;
+    }
+}

+ 99 - 0
app/Admin/Controllers/OrganizationController.php

xqd
@@ -0,0 +1,99 @@
+<?php
+
+namespace App\Admin\Controllers;
+
+use App\Admin\Actions\Cdmuser;
+use App\Models\Area;
+use App\Models\Organization;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrganizationController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '机构列表';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Organization());
+
+        $grid->column('id', __('Id'));
+        $grid->column('type', __('类型'));
+        $grid->column('name', __('名称'));
+        $grid->column('province_id', __('省份'));
+        $grid->column('city_id', __('城市'));
+        $grid->column('area_id', __('地区'));
+        $grid->column('address', __('详细地址'));
+        $grid->column('latitude', __('经度'));
+        $grid->column('longitude', __('纬度'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        $grid->actions(function ($actions){
+            $actions->add(new Cdmuser());
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Organization::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('type', __('Type'));
+        $show->field('name', __('Name'));
+        $show->field('province_id', __('Province id'));
+        $show->field('city_id', __('City id'));
+        $show->field('area_id', __('Area id'));
+        $show->field('address', __('Address'));
+        $show->field('latitude', __('Latitude'));
+        $show->field('longitude', __('Longitude'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Organization());
+
+        $form->select('type', __('类型'))->options(Organization::getType());
+        $form->text('name', __('名称'));
+        $form->select('province_id', __('省份'))->options(function (){
+            return Area::where('level',1)->pluck('name','id');
+        })->load('city_id','/admin/api/getCity');
+        $form->select('city_id', __('城市'))->options(function (){
+            return Area::where('level',2)->pluck('name','id');
+        })->load('area_id','/admin/api/getArea');;
+        $form->select('area_id', __('地区'));
+        $form->text('address', __('详细地址'));
+        $form->decimal('latitude', __('经度'));
+        $form->decimal('longitude', __('纬度'));
+
+        return $form;
+    }
+}

+ 5 - 2
app/Admin/routes.php

xqd
@@ -10,7 +10,10 @@ Route::group([
     'middleware'    => config('admin.route.middleware'),
     'as'            => config('admin.route.prefix') . '.',
 ], function (Router $router) {
-
     $router->get('/', 'HomeController@index')->name('home');
-
+    $router->get('/api/getCity', 'ApiController@getCity');
+    $router->get('/api/getArea', 'ApiController@getArea');
+    $router->get('/cdms_user', 'CdmsController@form');
+    $router->resource('organizations', OrganizationController::class);
 });
+

+ 8 - 1
app/Community/Controllers/ApiController.php

xqd
@@ -4,7 +4,14 @@
 namespace App\Community\Controllers;
 
 
-class ApiController
+use App\Http\Controllers\Controller;
+use App\Models\Docter;
+
+class ApiController extends Controller
 {
+    public function getDocter()
+    {
+        return Docter::get(['name as text','id'])->toArray();
+    }
 
 }

+ 10 - 0
app/Community/Controllers/AuthController.php

xqd
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use Encore\Admin\Controllers\AuthController as BaseAuthController;
+
+class AuthController extends BaseAuthController
+{
+
+}

+ 140 - 0
app/Community/Controllers/DocterController.php

xqd
@@ -0,0 +1,140 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Models\Docter;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class DocterController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '用户管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Docter());
+
+        $grid->column('id', __('Id'));
+        $grid->column('type', __('Type'));
+        $grid->column('name', __('Name'));
+        $grid->column('phone', __('Phone'));
+        $grid->column('sex', __('Sex'));
+        $grid->column('birthday', __('Birthday'));
+        $grid->column('avatar', __('Avatar'));
+        $grid->column('status', __('Status'));
+        $grid->column('label', __('Label'));
+        $grid->column('sign', __('Sign'));
+        $grid->column('intro', __('Intro'));
+        $grid->column('office_id', __('Office id'));
+        $grid->column('qualification_id', __('Qualification id'));
+        $grid->column('score', __('Score'));
+        $grid->column('service_persons', __('Service persons'));
+        $grid->column('eva_num', __('Eva num'));
+        $grid->column('service_days', __('Service days'));
+        $grid->column('phone_minutes', __('Phone minutes'));
+        $grid->column('chat_price', __('Chat price'));
+        $grid->column('phone_price', __('Phone price'));
+        $grid->column('appoint_price', __('Appoint price'));
+        $grid->column('is_chat', __('Is chat'));
+        $grid->column('is_phone', __('Is phone'));
+        $grid->column('is_appoint', __('Is appoint'));
+        $grid->column('latitude', __('Latitude'));
+        $grid->column('longitude', __('Longitude'));
+        $grid->column('created_at', __('Created at'));
+        $grid->column('updated_at', __('Updated at'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Docter::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('type', __('Type'));
+        $show->field('name', __('Name'));
+        $show->field('phone', __('Phone'));
+        $show->field('sex', __('Sex'));
+        $show->field('birthday', __('Birthday'));
+        $show->field('avatar', __('Avatar'));
+        $show->field('status', __('Status'));
+        $show->field('label', __('Label'));
+        $show->field('sign', __('Sign'));
+        $show->field('intro', __('Intro'));
+        $show->field('office_id', __('Office id'));
+        $show->field('qualification_id', __('Qualification id'));
+        $show->field('score', __('Score'));
+        $show->field('service_persons', __('Service persons'));
+        $show->field('eva_num', __('Eva num'));
+        $show->field('service_days', __('Service days'));
+        $show->field('phone_minutes', __('Phone minutes'));
+        $show->field('chat_price', __('Chat price'));
+        $show->field('phone_price', __('Phone price'));
+        $show->field('appoint_price', __('Appoint price'));
+        $show->field('is_chat', __('Is chat'));
+        $show->field('is_phone', __('Is phone'));
+        $show->field('is_appoint', __('Is appoint'));
+        $show->field('latitude', __('Latitude'));
+        $show->field('longitude', __('Longitude'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Docter());
+
+        $form->switch('type', __('Type'));
+        $form->text('name', __('Name'));
+        $form->mobile('phone', __('Phone'));
+        $form->switch('sex', __('Sex'));
+        $form->text('birthday', __('Birthday'));
+        $form->image('avatar', __('Avatar'));
+        $form->switch('status', __('Status'))->default(1);
+        $form->text('label', __('Label'));
+        $form->text('sign', __('Sign'));
+        $form->text('intro', __('Intro'));
+        $form->number('office_id', __('Office id'));
+        $form->number('qualification_id', __('Qualification id'));
+        $form->decimal('score', __('Score'))->default(0.0);
+        $form->number('service_persons', __('Service persons'));
+        $form->number('eva_num', __('Eva num'));
+        $form->number('service_days', __('Service days'));
+        $form->number('phone_minutes', __('Phone minutes'));
+        $form->number('chat_price', __('Chat price'));
+        $form->number('phone_price', __('Phone price'));
+        $form->number('appoint_price', __('Appoint price'));
+        $form->switch('is_chat', __('Is chat'))->default(1);
+        $form->switch('is_phone', __('Is phone'))->default(1);
+        $form->switch('is_appoint', __('Is appoint'))->default(1);
+        $form->decimal('latitude', __('Latitude'))->default(0.0000000);
+        $form->decimal('longitude', __('Longitude'))->default(0.0000000);
+
+        return $form;
+    }
+}

+ 81 - 0
app/Community/Controllers/DocterOrgController.php

xqd
@@ -0,0 +1,81 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Models\Docter;
+use App\Models\DocterOrganization;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class DocterOrgController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '用户管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new DocterOrganization());
+
+        $grid->disableCreateButton(false);
+        $grid->column('id', __('Id'));
+        $grid->column('docter.name', __('成员名称'));
+        $grid->column('docter.sex', __('性别'))->display(function ($w){
+            return $w==1?'男':'女';
+        });;
+        $grid->column('docter.phone', __('联系方式'));
+        $grid->column('docter.email', __('邮箱'));
+        $grid->column('docter.name', __('身份证号'));
+        $grid->column('docter.name', __('成员身份'));
+        $grid->column('docter.office_id', __('所属部门'));
+        $grid->column('docter.qualification_id', __('认证资质'));
+        $grid->column('updated_at', __('权限设置'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(DocterOrganization::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('docter_id', __('Docter id'));
+        $show->field('organization_id', __('Organization id'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new DocterOrganization());
+
+        $form->select('docter_id', __('姓名'))->options(function (){
+            return Docter::pluck('name','id');
+        });
+
+        return $form;
+    }
+}

+ 67 - 0
app/Community/Controllers/ExampleController.php

xqd
@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class ExampleController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = 'Example controller';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new ExampleModel);
+
+        $grid->column('id', __('ID'))->sortable();
+        $grid->column('created_at', __('Created at'));
+        $grid->column('updated_at', __('Updated at'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed   $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(ExampleModel::findOrFail($id));
+
+        $show->field('id', __('ID'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new ExampleModel);
+
+        $form->display('id', __('ID'));
+        $form->display('created_at', __('Created At'));
+        $form->display('updated_at', __('Updated At'));
+
+        return $form;
+    }
+}

+ 34 - 0
app/Community/Controllers/HomeController.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Http\Controllers\Controller;
+use Encore\Admin\Controllers\Dashboard;
+use Encore\Admin\Layout\Column;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Layout\Row;
+
+class HomeController extends Controller
+{
+    public function index(Content $content)
+    {
+        return $content
+            ->title('Dashboard')
+            ->description('Description...')
+            ->row(Dashboard::title())
+            ->row(function (Row $row) {
+
+                $row->column(4, function (Column $column) {
+                    $column->append(Dashboard::environment());
+                });
+
+                $row->column(4, function (Column $column) {
+                    $column->append(Dashboard::extensions());
+                });
+
+                $row->column(4, function (Column $column) {
+                    $column->append(Dashboard::dependencies());
+                });
+            });
+    }
+}

+ 77 - 0
app/Community/Controllers/NurseController.php

xqd
@@ -0,0 +1,77 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Models\Nurse;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class NurseController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '用户管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Nurse());
+        $grid->disableCreateButton(false);
+        $grid->column('id', __('ID'));
+        $grid->column('name', __('项目名称'))->editable();
+        $grid->column('stock','库存')->editable();
+        $grid->column('used', __('已使用'))->display(function ($w){
+            return $w??0;
+        });
+        $grid->column('today', __('今日预约'));
+        $grid->column('price', __('价格'))->editable();
+        $grid->column('remark', __('备注'))->editable('textarea');
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Nurse::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('price', __('Price'));
+        $show->field('remark', __('Remark'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Nurse());
+
+        $form->text('name', __('项目名称'));
+        $form->text('price', __('价格'));
+        $form->textarea('remark', __('备注'));
+        $form->setWidth(6);
+
+        return $form;
+    }
+}

+ 70 - 0
app/Community/Controllers/OfficeController.php

xqd
@@ -0,0 +1,70 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Models\Office;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OfficeController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '用户管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Office());
+
+        $grid->disableCreateButton(false);
+        $grid->column('id', __('Id'));
+        $grid->column('name', __('名称'));
+        $grid->column('created_at', __('创建时间'));
+        $grid->column('updated_at', __('更新时间'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Office::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('name', __('Name'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Office());
+
+        $form->text('name', __('名称'));
+        $form->setWidth(6);
+
+        return $form;
+    }
+}

+ 111 - 0
app/Community/Controllers/OrderController.php

xqd
@@ -0,0 +1,111 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Models\Order;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrderController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '门诊预约';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Order());
+        $grid->model()->where(['product_type'=>1]);
+        $grid->column('id', __('Id'));
+        $grid->column('orderUser.nickname', __('预约用户'));
+        $grid->column('orderPatient.appoint_start_time', __('预约时间'))->display(function ($w){
+            return date('Y-m-d H:i:s',$w);
+        });
+        $grid->column('orderPatient.appoint_end_time', __('门诊时间'))->display(function ($w){
+            if(empty($w)) return '';
+            return date('Y-m-d H:i:s',$w);
+        });;
+        $grid->column('orderPatient.name', __('预约患者'))->display(function ($w){
+            return $w==1?'男':'女';
+        });;
+        $grid->column('orderPatient.sex', __('患者性别'));
+        $grid->column('orderPatient.birthday', __('患者年龄'))->display(function ($w){
+            return birthday_to_age($w);
+        });;
+        $grid->column('docter.name', __('预约医生'));
+//        $grid->column('organization_id', __('Organization id'));
+
+        //查询
+        $grid->quickSearch(function ($model, $query) {
+            $model->whereHas('patients',function ($model) use ($query) {
+                $model->where('name', 'like', "{$query}%");
+            });
+        })->placeholder('请输入用户姓名');
+
+        $grid->filter(function (Grid\Filter $filter){
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('docter_id','排班医生')->select('/cdms/api/getDocter');
+                $filter->equal('order_status','订单状态')->select(Order::$_order_status);
+                $filter->between('orderPatient.appoint_start_time','预约时间')->datetime();
+            });
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Order::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('user_id', __('User id'));
+        $show->field('docter_id', __('Docter id'));
+        $show->field('patient_id', __('Patient id'));
+        $show->field('organization_id', __('Organization id'));
+        $show->field('order_sn', __('Order sn'));
+        $show->field('payment_type', __('Payment type'));
+        $show->field('product_type', __('Product type'));
+        $show->field('order_status', __('Order status'));
+        $show->field('payment_status', __('Payment status'));
+        $show->field('total_amount', __('Total amount'));
+        $show->field('payment_amount', __('Payment amount'));
+        $show->field('discount_amount', __('Discount amount'));
+        $show->field('payment_time', __('Payment time'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Order());
+
+        $form->display('orderUser.nickename', __('用户'));
+        $form->display('docter_id', __('医生'));
+        $form->number('payment_time', __('Payment time'));
+
+        return $form;
+    }
+}

+ 125 - 0
app/Community/Controllers/OrderNurseController.php

xqd
@@ -0,0 +1,125 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Admin\Actions\Commuinity\Nurse\DelNurse;
+use App\Admin\Actions\Commuinity\Nurse\Finished;
+use App\Models\Docter;
+use App\Models\Order;
+use App\Models\OrderNurse;
+use App\User;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrderNurseController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '儿保预约';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new OrderNurse());
+
+        $grid->column('id', __('ID'));
+        $grid->column('orders.user_id', __('预约用户'))->display(function($w){
+            return User::where('id',$w)->value('nickname');
+        });
+        $grid->column('patients.appoint_start_time', __('预约时间'))->display(function ($w){
+            return date('Y-m-d H:i:s',$w);
+        });
+        $grid->column('patients.appoint_end_time', __('儿保时间'))->display(function ($w){
+            return date('Y-m-d H:i:s',$w);
+        });
+        $grid->column('patients.name', __('儿保患者'));
+        $grid->column('patients.sex', __('患者性别'))->display(function ($w){
+            return $w==1?'男':'女';
+        });
+        $grid->column('patients.birthday', __('患者年龄'))->display(function ($w){
+            return birthday_to_age($w);
+        });
+        $grid->column('orders.docter_id', __('排班医生'))->display(function ($w){
+            return Docter::where('id',$w)->value('name');
+        });
+        $grid->column('nurse_name', __('项目名称'));
+
+        //查询
+        $grid->quickSearch(function ($model, $query) {
+            $model->whereHas('patients',function ($model) use ($query) {
+                $model->where('name', 'like', "{$query}%");
+            });
+        })->placeholder('请输入用户姓名');
+
+        $grid->filter(function (Grid\Filter $filter){
+            $filter->disableIdFilter();
+            $filter->column(1/2, function ($filter) {
+                $filter->equal('orders.docter_id','排班医生')->select('/cdms/api/getDocter');
+                $filter->equal('orders.order_status','订单状态')->select(Order::$_order_status);
+                $filter->between('patients.appoint_start_time','预约时间')->datetime();
+            });
+        });
+
+        $grid->actions(function ($actions) {
+            if($actions->row->orders->order_status  < 2 ){
+                $actions->add(new Finished());
+            }
+            $actions->add(new DelNurse());
+            $actions->disableView();
+            $actions->disableDelete();
+        });
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(OrderNurse::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('order_id', __('Order id'));
+        $show->field('order_patient_id', __('Order patient id'));
+        $show->field('nurse_id', __('Nurse id'));
+        $show->field('nurse_name', __('Nurse name'));
+        $show->field('nurse_price', __('Nurse price'));
+        $show->field('nurse_remark', __('Nurse remark'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new OrderNurse());
+
+        $form->display('order_id', __(' 订单id'));
+        $form->display('patients.name', __('预约用户'));
+        $form->display('nurse_name', __('项目名称'));
+        $form->text('nurse_price', __('订单价格'));
+        $form->textarea('nurse_remark', __('备注'))->rows(5);
+        $form->setWidth(6);
+
+        return $form;
+    }
+}

+ 91 - 0
app/Community/Controllers/OrderVaccinesController.php

xqd
@@ -0,0 +1,91 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Models\OrderVaccine;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class OrderVaccinesController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '用户管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new OrderVaccine());
+
+        $grid->column('id', __('Id'));
+        $grid->column('patients.name', __('预约用户'));
+        $grid->column('vaccine_id', __('预约时间'));
+        $grid->column('vaccine_type', __('接种时间'));
+        $grid->column('patients.name', __('接种患者'));
+        $grid->column('patients.sex', __('患者性别'))->display(function ($w){
+            return $w==1?'男':'女';
+        });
+        $grid->column('patients.birthday', __('患者年龄'))->display(function ($w){
+            return birthday_to_age($w);
+        });
+        $grid->column('vaccine_name', __('接种疫苗'));
+        $grid->column('docters.name', __('排班医生'));
+
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(OrderVaccine::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('order_id', __('Order id'));
+        $show->field('order_patient_id', __('Order patient id'));
+        $show->field('vaccine_id', __('Vaccine id'));
+        $show->field('vaccine_type', __('Vaccine type'));
+        $show->field('vaccine_price', __('Vaccine price'));
+        $show->field('vaccine_name', __('Vaccine name'));
+        $show->field('vaccine_remark', __('Vaccine remark'));
+        $show->field('vaccine_supplier', __('Vaccine supplier'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new OrderVaccine());
+
+        $form->number('order_id', __('Order id'));
+        $form->number('order_patient_id', __('Order patient id'));
+        $form->number('vaccine_id', __('Vaccine id'));
+        $form->switch('vaccine_type', __('Vaccine type'));
+        $form->number('vaccine_price', __('Vaccine price'));
+        $form->text('vaccine_name', __('Vaccine name'));
+        $form->text('vaccine_remark', __('Vaccine remark'));
+        $form->text('vaccine_supplier', __('Vaccine supplier'));
+
+        return $form;
+    }
+}

+ 94 - 0
app/Community/Controllers/VaccineController.php

xqd
@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Community\Controllers;
+
+use App\Models\Vaccine;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Form;
+use Encore\Admin\Grid;
+use Encore\Admin\Show;
+
+class VaccineController extends AdminController
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title = '用户管理';
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        $grid = new Grid(new Vaccine());
+
+        $grid->column('id', __('ID'));
+        $grid->column('name', __('疫苗名称'));
+        $grid->column('type', __('类别'))->editable('select',[1=>'一类',2=>'二类']);
+        $grid->column('num', __('剩余库存'));
+        $grid->column('num', __('已使用量'));
+        $grid->column('num', __('今日预约'));
+        $grid->column('price', __('价格'))->editable();
+        $grid->column('remark', __('备注'))->editable('textarea');
+        $grid->column('supplier', __('厂家'));
+//        $grid->column('created_at', __('Created at'));
+//        $grid->column('updated_at', __('Updated at'));
+        $grid->filter(function ($fliter){
+            $fliter->equal('type','类别')->select([1=>'一类',2=>'二类']);
+//            $fliter->equal('type','类别')->select([1=>'一类',2=>'二类']);
+        });
+        $grid->actions(function ($actions) {
+
+            // append一个操作
+            $actions->append('<a href=""><i class="fa fa-header">跳转</i></a>');
+
+            // prepend一个操作
+            $actions->prepend('<a href="http://www.baidu.com" target="_blank"><i class="fa fa-cab"></i></a>');
+        });
+        return $grid;
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        $show = new Show(Vaccine::findOrFail($id));
+
+        $show->field('id', __('Id'));
+        $show->field('type', __('Type'));
+        $show->field('price', __('Price'));
+        $show->field('name', __('Name'));
+        $show->field('remark', __('Remark'));
+        $show->field('supplier', __('Supplier'));
+        $show->field('created_at', __('Created at'));
+        $show->field('updated_at', __('Updated at'));
+
+        return $show;
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        $form = new Form(new Vaccine());
+
+        $form->select('type', __('类型'))->options([1=>'一类',2=>'二类']);
+        $form->number('price', __('价格'));
+        $form->text('name', __('疫苗名称'));
+        $form->textarea('remark', __('备注'));
+        $form->text('supplier', __('厂家'));
+
+        return $form;
+    }
+}

+ 2 - 0
app/Community/routes.php

xqd
@@ -8,4 +8,6 @@ Route::resource('vaccines', VaccineController::class);
 Route::resource('order_vaccines', OrderVaccinesController::class);
 Route::resource('docters', DocterController::class);
 Route::resource('offices', OfficeController::class);
+Route::resource('orders', OrderController::class);
+Route::resource('docter_org', DocterOrgController::class);
 

+ 1 - 0
app/Exceptions/Handler.php

xqd
@@ -47,6 +47,7 @@ class Handler extends ExceptionHandler
      */
     public function render($request, Exception $exception)
     {
+        return parent::render($request, $exception);
         //如果路由中含有“api/”,则说明是一个 api 的接口请求
         if ($request->is("api/*")) {
             //如果错误是 ValidationException的一个实例,说明是一个验证的错误

+ 15 - 0
app/Models/DocterOrganization.php

xqd
@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class DocterOrganization extends Model
+{
+    protected $table = 'docter_organization';
+
+    public function docter()
+    {
+        return $this->hasOne(Docter::class,'id','docter_id');
+    }
+}

+ 5 - 0
app/Models/Order.php

xqd
@@ -48,4 +48,9 @@ class Order extends BaseModel
     {
         return $this->hasOne(OrderVaccine::class);
     }
+
+    public function orderUser()
+    {
+        return $this->hasOne(User::class,'id','user_id');
+    }
 }

+ 12 - 0
app/Models/Organization.php

xqd
@@ -10,6 +10,18 @@ namespace App\Models;
 
 class Organization extends BaseModel
 {
+    CONST HOSPITOAL = 1, ORGANIZATION = 2, CLINC = 3;
+
+    protected static $_getType = [
+        self::HOSPITOAL => '医院',
+        self::ORGANIZATION => '机构',
+        self::CLINC => '医院',
+    ];
+
+    public  static  function  getType()
+    {
+        return self::$_getType;
+    }
     public function docter()
     {
         return $this->belongsToMany(Docter::class);