1
0
Fork 0
medical-record-server/app/Admin/Controllers/TotalRecordController.php

61 lines
2.6 KiB
PHP

<?php
namespace App\Admin\Controllers;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use App\Models\{Patient, PatientRecord};
use Illuminate\Support\Facades\DB;
use App\Admin\Services\TotalRecordService;
/**
* 财务统计
*/
class TotalRecordController extends AdminController
{
protected string $serviceName = TotalRecordService::class;
protected $patientOptions;
public function list()
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->columnsTogglable(false)
->headerToolbar([
// amis('reload')->align('right'),
])
->filter($this->baseFilter()->actions()->body([
amisMake()->SelectControl()->options($this->getPatientOptions())->searchable()->name('patient_id')->label(__('patient-record.patient_id'))->size('md')->clearable(),
amisMake()->DateRangeControl()->name('treat_range')->label(__('total-record.treat_at'))->clearable()->size('md'),
// amisMake()->Button()->label(__('admin.reset'))->actionType('clear-and-submit'),
amisMake()->Component()->setType('submit')->label(__('admin.search'))->level('primary'),
]))
->columns([
amisMake()->Column()->name('patient.name')->label(__('total-record.name')),
amisMake()->Date()->name('min_treat_at')->label(__('total-record.min_treat_at'))->sortable(true),
amisMake()->Date()->name('max_treat_at')->label(__('total-record.max_treat_at'))->sortable(true),
amisMake()->Column()->name('count')->label(__('total-record.count'))->sortable(true),
amisMake()->Column()->name('origin_price')->label(__('total-record.origin_price'))->sortable(true),
amisMake()->Column()->name('sell_price')->label(__('total-record.sell_price'))->sortable(true),
])->affixRowClassName('text-info-dk')->affixRow([
['type' => 'text', 'text' => '总计', 'colSpan' => 3],
['type' => 'text', 'text' => '记录数: ${total}'],
['type' => 'text', 'text' => __('total-record.origin_price') . ': ${origin_price}'],
['type' => 'text', 'text' => __('total-record.sell_price') . ': ${sell_price}'],
])
->alwaysShowPagination();
return $this->baseList($crud);
}
public function getPatientOptions()
{
if (!$this->patientOptions) {
$this->patientOptions = Patient::select(['id as value', 'name as label'])->sort()->get();
}
return $this->patientOptions;
}
}