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

72 lines
2.9 KiB
PHP

<?php
namespace App\Admin\Controllers;
use App\Admin\Services\TotalProfitService;
use App\Models\Keyword;
use Slowlyo\OwlAdmin\Controllers\AdminController;
use Slowlyo\OwlAdmin\Services\AdminUserService;
/**
* 提成统计
*/
class TotalProfitController extends AdminController
{
protected string $serviceName = TotalProfitService::class;
protected $adminUserOptions;
protected $typeOptions;
public function list()
{
$crud = $this->baseCRUD()
->filterTogglable(false)
->columnsTogglable(false)
->alwaysShowPagination()
->headerToolbar([])
->filter($this->baseFilter()->actions()->body([
amisMake()->SelectControl()->options($this->getAdminUserOptions())->searchable()->name('id')->label(__('total-profit.id'))->clearable()->size('md'),
amisMake()->SelectControl()->options($this->getTypeOptions())->name('type_id')->label(__('total-profit.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('name')->label(__('total-profit.id')),
amisMake()->Column()->name('records_count')->label(__('total-profit.records_count')),
amisMake()->Column()->name('doctor_money')->label(__('total-profit.doctor_money')),
amisMake()->Column()->name('inviter_money')->label(__('total-profit.inviter_money')),
amisMake()->Column()->name('saler_money')->label(__('total-profit.saler_money')),
])
->affixRowClassName('text-info-dk')
->affixRow([
['type' => 'text', 'text' => '总计: ${total}'],
['type' => 'text', 'text' => __('total-profit.records_count'). ': ${records_count}'],
['type' => 'text', 'text' => __('total-profit.doctor_money'). ': ${doctor_money}'],
['type' => 'text', 'text' => __('total-profit.inviter_money'). ': ${inviter_money}'],
['type' => 'text', 'text' => __('total-profit.saler_money'). ': ${saler_money}'],
]);
return $this->baseList($crud);
}
public function getAdminUserOptions()
{
if (!$this->adminUserOptions) {
$this->adminUserOptions = AdminUserService::make()->query()->select(['id as value', 'name as label'])->get();
}
return $this->adminUserOptions;
}
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;
}
}