This commit is contained in:
zimoyin
2026-04-06 20:48:32 +08:00
parent 76e9f24aa7
commit 13fd9c5f0a
77 changed files with 6034 additions and 42 deletions
@@ -0,0 +1,75 @@
<?php
namespace plugin\admin\app\controller;
use plugin\admin\app\model\OpmMwDepartment;
use plugin\admin\app\model\OpmMwHospital;
use plugin\admin\app\repository\DepartmentRepository;
use plugin\admin\app\service\DepartmentService;
use support\Request;
use support\Response;
/**
* 科室管理
*/
class DepartmentController extends Crud
{
use WithDataPermission;
/**
* @var OpmMwDepartment
*/
protected $model = null;
private DepartmentService $service;
private DepartmentRepository $repository;
public function __construct()
{
$this->model = new OpmMwDepartment;
$this->service = new DepartmentService();
$this->repository = DepartmentRepository::new();
}
public function index(): Response
{
return raw_view('department/index');
}
public function insert(Request $request): Response
{
if ($request->method() === 'POST') {
return parent::insert($request);
}
return raw_view('department/insert');
}
public function update(Request $request): Response
{
if ($request->method() === 'POST') {
return parent::update($request);
}
return raw_view('department/update');
}
protected function afterQuery($items)
{
foreach ($items as &$item) {
$hospital = OpmMwHospital::find($item->organ_id);
$item->hospital_name = $hospital->organ_name ?? '未知';
}
return $items;
}
/**
* 获取指定医院下科室选项
*/
public function options(Request $request): Response
{
$hospitalId = (int)$request->get('hospital_id', 0);
if ($hospitalId <= 0) {
return $this->json(1, '缺少医院ID参数');
}
return $this->json(0, 'ok', $this->service->getDepartmentOptions($hospitalId));
}
}