admin total_illness_type
parent
7b71879fe4
commit
2943c9ea2e
|
|
@ -7,6 +7,8 @@ use App\Models\Keyword;
|
|||
use App\Models\PatientRecord;
|
||||
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
||||
use Slowlyo\OwlAdmin\Support\Excel\AdminExport;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* 病种统计
|
||||
|
|
@ -34,7 +36,58 @@ class TotalIllnessTypeController extends AdminController
|
|||
]))
|
||||
->columns([
|
||||
amisMake()->Column()->name('name')->label(__('total-illness-type.id')),
|
||||
amisMake()->Column()->name('patient_count')->label(__('total-illness-type.patient_count')),
|
||||
amisMake()->Column()
|
||||
->name('patient_count')
|
||||
->label(__('total-illness-type.patient_count'))
|
||||
->type('button')
|
||||
->body(amisMake()->Tpl()->tpl('${patient_count}')->className('text-primary underline'))
|
||||
->actionType('dialog')
|
||||
->dialog([
|
||||
'type' => 'dialog',
|
||||
'title' => '${name}',
|
||||
'actions' => [],
|
||||
'closeOnEsc' => true,
|
||||
'body' => [
|
||||
'type' => 'service',
|
||||
'api' => [
|
||||
'url' => '/api/total/illness-type/patient-count',
|
||||
'data' => [
|
||||
'illness_id' => '${id}'
|
||||
],
|
||||
],
|
||||
'body' => [
|
||||
'type' => 'table',
|
||||
'source' => '$list',
|
||||
'columns' => [
|
||||
amisMake()->Column()->name('name')->label(__('patient.name')),
|
||||
amisMake()->Column()->name('phone')->label(__('patient.phone')),
|
||||
amisMake()->Column()->name('count')->label(__('patient.count')),
|
||||
],
|
||||
]
|
||||
],
|
||||
])
|
||||
,
|
||||
// amisMake()->Column()->name('patient_count')->label(__('total-illness-type.patient_count'))
|
||||
// ->popOver([
|
||||
// 'body' => [
|
||||
// 'type' => 'service',
|
||||
// 'api' => [
|
||||
// 'url' => '/api/total/illness-type/patient-count',
|
||||
// 'data' => [
|
||||
// 'illness_id' => '${illness_type_id}'
|
||||
// ],
|
||||
// ],
|
||||
// 'body' => [
|
||||
// 'type' => 'table',
|
||||
// 'source' => '$list',
|
||||
// 'columns' => [
|
||||
// amisMake()->Column()->name('name')->label(__('patient.name')),
|
||||
// amisMake()->Column()->name('phone')->label(__('patient.phone')),
|
||||
// amisMake()->Column()->name('count')->label(__('patient.count')),
|
||||
// ],
|
||||
// ]
|
||||
// ],
|
||||
// ]),
|
||||
amisMake()->Column()->name('count')->label(__('total-illness-type.count')),
|
||||
])
|
||||
->affixRowClassName('text-info-dk')
|
||||
|
|
@ -114,4 +167,23 @@ class TotalIllnessTypeController extends AdminController
|
|||
|
||||
return $this->response()->success(compact('path'));
|
||||
}
|
||||
|
||||
public function listByPatient(Request $request)
|
||||
{
|
||||
$list = PatientRecord::with(['patient'])
|
||||
->select(['patient_id', DB::raw('count(`patient_id`) as `count`')])
|
||||
->groupBy('patient_id')
|
||||
->where('illness_type_id', $request->input('illness_id'))
|
||||
->get();
|
||||
|
||||
// $list = [
|
||||
// ['name' => '病人1', 'phone' => '001', 'count' => 1],
|
||||
// ['name' => '病人2', 'phone' => '002', 'count' => 2],
|
||||
// ];
|
||||
return $this->response()->success(['list' => $list->map(fn($item) => [
|
||||
'name' => $item->patient->name,
|
||||
'phone' => $item->patient->phone,
|
||||
'count' => $item->count,
|
||||
])]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ Route::group([
|
|||
$router->get('patient/options', '\App\Admin\Controllers\PatientController@getSelectOptions')->name('api.patient.options');
|
||||
$router->get('category/permission-list', '\App\Admin\Controllers\CategoryController@getPermissionList')->name('api.category.permission_list');
|
||||
$router->get('user/list', '\App\Admin\Controllers\UserController@getList');
|
||||
$router->get('total/illness-type/patient-count', '\App\Admin\Controllers\TotalIllnessTypeController@listByPatient');
|
||||
});
|
||||
$router->resource('user', \App\Admin\Controllers\UserController::class)->names('admin.user');
|
||||
// 字典表
|
||||
|
|
|
|||
|
|
@ -20,4 +20,5 @@ return [
|
|||
'created_at' => '录入时间',
|
||||
'images' => '图片资料',
|
||||
'user_id' => '客户',
|
||||
'count' => '次数',
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue