fetch(); } public function datas() { $request = Request::instance(); $params = $request->param(); $page = empty($params["page"]) ? 1 : $params["page"]; $whereArr = array(); if (isset($params["status"])) { array_push($whereArr, array("status", $params["status"])); } if (isset($params["insId"])) { array_push($whereArr, array("institution_id", $params["insId"])); } if (isset($params["deptId"])) { array_push($whereArr, array("department_id", $params["deptId"])); } $pagesize = empty($params["rows"]) ? 1 : $params["rows"]; if (empty($page) || $page < 1) { $page = 1; } if (empty($pagesize) || $pagesize < 1) { $pagesize = 30; } $info = DB::table('messages')->where($whereArr)->page($page, $pagesize)->select(); foreach ($info as $k => $v) { $doctor = DB::table('doctors')->where('id', $v['doctor_id'])->field('realname')->find(); $info[$k]['doctor_name'] = $doctor['realname']; } $num = DB::table('messages')->where($whereArr)->count(); $data = array(); $data['total'] = $num; $data['rows'] = $info; echo json_encode($data); } /** * 编辑窗口 * @return type */ public function edit() { if (isset($_GET["id"])) { $id = $_GET["id"]; if ($id != null) { $messages = Db::table("messages")->where("id", $id)->select(); if (count($messages) > 0) { $this->assign("messages", $messages[0]); } } } return $this->fetch('edit'); } public function save() { $a = DB::table('messages')->where('id', $_GET['id'])->update($_GET); SysLogs::log("messages", "U", 'id = ' . $_GET['id'] . " --> " . json_encode($_GET)); if ($a) { return 'success'; } else { return 'fail'; } } /** * 软删除记录 */ public function delete() { if (isset($_GET["ids"])) { $ids = $_GET["ids"]; if (!empty($ids)) { $idArr = explode(",", $ids); if (count($idArr) > 0) { Db::table("messages")->where("id", "in", $idArr)->update(['status' => "0"]); SysLogs::log("messages", "U", 'id in ' . $ids . " --> status = 0"); } echo "delete_ok"; return; } } echo "fail"; } }