75 lines
1.8 KiB
PHP
75 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace plugin\admin\app\controller;
|
|
|
|
use plugin\admin\app\model\OpmMwHospital;
|
|
use plugin\admin\app\repository\HospitalRepository;
|
|
use plugin\admin\app\service\HospitalService;
|
|
use support\Request;
|
|
use support\Response;
|
|
|
|
/**
|
|
* 医院管理
|
|
*/
|
|
class HospitalController extends Crud
|
|
{
|
|
use WithDataPermission;
|
|
|
|
/**
|
|
* @var OpmMwHospital
|
|
*/
|
|
protected $model = null;
|
|
|
|
private HospitalService $service;
|
|
private HospitalRepository $repository;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->model = new OpmMwHospital;
|
|
$this->service = new HospitalService();
|
|
$this->repository = HospitalRepository::new();
|
|
}
|
|
|
|
public function index(): Response
|
|
{
|
|
return raw_view('hospital/index');
|
|
}
|
|
|
|
public function insert(Request $request): Response
|
|
{
|
|
if ($request->method() === 'POST') {
|
|
return parent::insert($request);
|
|
}
|
|
return raw_view('hospital/insert');
|
|
}
|
|
|
|
public function update(Request $request): Response
|
|
{
|
|
if ($request->method() === 'POST') {
|
|
return parent::update($request);
|
|
}
|
|
return raw_view('hospital/update');
|
|
}
|
|
|
|
protected function afterQuery($items)
|
|
{
|
|
$levelMap = [0 => '未定级', 1 => '一级', 2 => '二级', 3 => '三级'];
|
|
$gradeMap = [0 => '未定级', 1 => '甲等', 2 => '乙等'];
|
|
|
|
foreach ($items as &$item) {
|
|
$level = $levelMap[$item->organ_level] ?? '未知';
|
|
$grade = $gradeMap[$item->grade] ?? '未知';
|
|
$item->level_grade_text = $level . $grade;
|
|
}
|
|
return $items;
|
|
}
|
|
|
|
/**
|
|
* 医院下拉选项(供其他页面使用)
|
|
*/
|
|
public function options(): Response
|
|
{
|
|
return $this->json(0, 'ok', $this->service->getHospitalOptions());
|
|
}
|
|
}
|