fetch(); } public function datas() { $page = empty($_GET["page"]) ? 1 : $_GET["page"]; $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"]; if (empty($page) || $page < 1) { $page = 1; } if (empty($pagesize) || $pagesize < 1) { $pagesize = 30; } $info = DB::table('doctor_class')->page($page, $pagesize)->select(); foreach ($info as $k => $v) { $doctorname = DB::table('doctors')->where('id', $v['doctor_id'])->field('realname')->find(); $info[$k]['doctor_name'] = $doctorname['realname']; $departmentname = DB::table('department')->where('id', $v['department_id'])->field('department_name')->find(); $info[$k]['department_name'] = $departmentname['department_name']; } $num = DB::table('doctor_class')->count(); $data = array(); $data['total'] = $num; $data['rows'] = $info; echo json_encode($data); } public function edit() { if (isset($_GET["id"])) { $id = $_GET["id"]; if ($id != null) { $doctorclass = Db::table("doctor_class")->where("id", $id)->find(); if (count($doctorclass) > 0) { if (empty($doctorclass['doctor_class'])) { $doctorclass['doctor_class'] = array(); } else { $doctorclass['doctor_class'] = explode(',', $doctorclass['doctor_class']); } $this->assign("doctorclass", $doctorclass); } } } $doctors = DB::table('doctors')->select(); $this->assign('doctors', $doctors); $department = DB::table('department')->select(); $this->assign('department', $department); return $this->fetch('edit'); } public function save() { $info = $_GET; $info['doctor_class'] = implode(',', $_GET['doctor_class']); if (empty($_GET['id'])) { unset($_GET['id']); $id = UUIDs::uuid16(); $info['id'] = $id; $a = DB::table('doctor_class')->insert($info); SysLogs::log("doctorclass", "C", json_encode($info)); return 'insert_ok;' . $id; } else { $a = DB::table('doctor_class')->where('id', $_GET['id'])->update($info); SysLogs::log("doctorclass", "U", $_GET['id'] . " --> " . $info); return 'update_ok'; } } /** * 软删除记录 */ public function delete() { if (isset($_GET["ids"])) { $ids = $_GET["ids"]; if (!empty($ids)) { $idArr = explode(",", $ids); if (count($idArr) > 0) { Db::table("doctor_class")->where("id", "in", $idArr)->delete(); } SysLogs::log("doctorclass", "D", $ids ); echo "delete_ok"; return; } } echo "fail"; } }