71 lines
2.9 KiB
PHP
71 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use Slowlyo\OwlAdmin\Controllers\AdminController;
|
|
use App\Models\{Keyword, Patient, PatientRecord};
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Admin\Services\TotalRecordService;
|
|
|
|
/**
|
|
* 财务统计
|
|
*/
|
|
class TotalRecordController extends AdminController
|
|
{
|
|
protected string $serviceName = TotalRecordService::class;
|
|
|
|
protected $patientOptions;
|
|
|
|
protected $typeOptions;
|
|
|
|
public function list()
|
|
{
|
|
$crud = $this->baseCRUD()
|
|
->filterTogglable(false)
|
|
->columnsTogglable(false)
|
|
->headerToolbar([])
|
|
->filter($this->baseFilter()->actions()->body([
|
|
amisMake()->SelectControl()->options($this->getPatientOptions())->searchable()->name('patient_id')->label(__('patient-record.patient_id'))->size('md')->clearable(),
|
|
amisMake()->SelectControl()->options($this->getTypeOptions())->name('type_id')->label(__('patient-record.type_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()->Mapping()->map($this->getTypeOptions()->pluck('label', 'value'))->name('type_id')->label(__('patient-record.type_id')),
|
|
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('sell_price')->label(__('total-record.sell_price'))->sortable(true),
|
|
])
|
|
->affixRowClassName('text-info-dk')
|
|
->affixRow([
|
|
['type' => 'text', 'text' => '总计: ${total}', 'colSpan' => 4],
|
|
['type' => 'text', 'text' => '看病次数: ${count}'],
|
|
['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;
|
|
}
|
|
public function getTypeOptions()
|
|
{
|
|
if (!$this->typeOptions) {
|
|
$this->typeOptions = Keyword::where('type_key', 'treat_type')->select(['id as value', 'name as label'])->get();
|
|
}
|
|
|
|
return $this->typeOptions;
|
|
}
|
|
}
|
|
|