init
This commit is contained in:
@@ -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 => '报警'];
|
||||
|
||||
Reference in New Issue
Block a user