123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- namespace App\Community\Controllers;
- use App\Admin\Actions\Community\Docter\Chat;
- use App\Admin\Actions\Community\Notice\sendNotice;
- use App\Admin\Actions\Community\Order\Detail;
- use App\Models\Docter;
- use App\Models\DocterOrganization;
- use App\Models\Order;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Facades\Admin;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Layout\Content;
- use Encore\Admin\Show;
- use App\Models\User;
- class DocterChatController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = '咨询订单';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new Order());
- $user = Admin::user();
- $org_id = $user->org_id;
- $docter_id = $user->docter_id;
- $grid->model()->orderByDesc('id');
- $is_admin = Admin::user()->inRoles(['administrator','devloper']);
- $grid->batchActions(function ($batch) {
- $batch->add(new sendNotice());
- });
- $where['product_type'] = 2;
- if(!$is_admin){
- if($docter_id){
- $where['docter_id'] = $docter_id;
- }
- }
- if (empty($docter_id)) {
- $docter_ids = DocterOrganization::where('organization_id', $org_id)->pluck('docter_id')->toArray();
- $grid->model()->where($where)->whereIn('id', $docter_ids);
- }
- else {
- $grid->model()->where($where);
- }
- $grid->column('order_sn', __('订单号'));
- $grid->column('docter.name', __('医生'));
- $grid->column('orderUser.nickname', __('咨询用户'));
- $grid->column('orderPatient.name', __('咨询患者'));
- $grid->column('patient.phone', __('电话'));
- $grid->column('orderPatient.birthday', __('患者年龄'))->display(function ($w){
- return birthday_to_age($w);
- });
- $grid->actions(function ($actions) use($docter_id) {
- if($docter_id){
- $actions->add( new Chat());
- }
- $actions->add(new Detail());
- $actions->disableDelete();
- $actions->disableView();
- $actions->disableEdit();
- });
- $grid->filter(function (Grid\Filter $filter){
- $filter->disableIdFilter();
- $filter->column(1/2, function ($filter) {
- $filter->like('order_sn','订单号');
- $filter->like('patient.phone','电话');
- $filter->like('patient.name','患者名称');
- $filter->equal('order_status','订单状态')->select(Order::$_order_status);
- $filter->timestampBetween('orderPatient.appoint_start_time','预约时间')->datetime();
- });
- });
- $status_arr = Order::getStatus();
- $grid->column('order_status', __('订单状态'))->display(function ($w) use ($status_arr) {
- $info = $status_arr[intval($w)];
- if($w == 1 || $w == 2){
- return '<span class="label label-warning">'.$info.'</span>';
- } else if( $w == 4 ){
- return '<span class="label label-success">'.$info.'</span>';
- } else if($w == 7 || $w == 3 ){
- return '<span class="label label-info">'.$info.'</span>';
- } else if($w == 6){
- return '<span class="label label-danger">'.$info.'</span>';
- } else {
- return '<span class="label label-default">'.$info.'</span>';
- }
- });
- $grid->column('created_at', __('下单时间'));
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- return '';
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return '';
- }
- function chats(Content $content){
- $content->title('咨询订单 ');
- $content->description('医生用户可以接受预约');
- $user = Admin::user();
- $org_id = $user->org_id;
- $docter_id = $user->docter_id;
- Admin::js('jquery-3.5.1.min.js');
- $url = '/cdms/chat_view?docter_id='.$docter_id;
- // $content->body('<iframe src="/cdms/chat_view?docter_id='.$docter_id.'" style="width: 100%;height:800px;border: none"></iframe>');
- $content->body('<iframe src="/cdms/chat_view?docter_id='.$docter_id.'" style="width: 100%;height:800px;border: none"></iframe>');
- return $content;
- }
- public function chat_view()
- {
- return view('cdms.chat');
- }
- }
|