This commit is contained in:
zimoyin
2026-04-09 13:55:39 +08:00
parent 13fd9c5f0a
commit 398e014128
12 changed files with 360 additions and 47 deletions
@@ -50,6 +50,21 @@ class DeviceController extends Crud
return raw_view('device/update');
}
/**
* 设备下拉选项(可按 hospital_id 筛选)
*/
public function options(Request $request): Response
{
$query = $this->repository->scopedQuery();
if ($hospitalId = $request->get('hospital_id')) {
$query->where('hospital_id', $hospitalId);
}
$data = $query->select(['id', 'name'])->get()
->map(fn($item) => ['id' => $item->id, 'name' => $item->name])
->toArray();
return json(['code' => 0, 'msg' => 'ok', 'data' => $data]);
}
protected function afterQuery($items)
{
$statusMap = [1 => '正常', 2 => '离线', 3 => '报警'];