group("name")->field("name")->select(); return $this->fetch('index', ['examClassList' => $examClassList, 'institutionLis' => $institutionLis ,'examcla' => $examclaData ]); } public function getDatas() { $model = new TemplateModel; $param = Request::instance()->param(); $examcla = isset($param['examcla']) ? $param['examcla'] : false; $exam_class_id = isset($param['exam_class_id']) ? $param['exam_class_id'] : false; $userid = isset($param['userid']) ? $param['userid'] : false; $is_public = isset($param['is_public']) ? $param['is_public'] : false; $page = isset($param['page']) ? $param['page'] : 1; $pageSize = isset($param['rows']) ? $param['rows'] : 10; $data = array(); $wheres=array(); if ($examcla){ $wheres["templates.exam_class_id"]=$examcla; } if($userid){ $wheres["templates.create_user"]=$userid; } if($is_public){ $wheres["templates.is_public"]=$is_public; } //echo json_encode($wheres) . "
"; $data["total"] = $model->queryAllCount( $wheres, $page, $pageSize); $data["rows"] = $model->queryAll( $wheres, $page, $pageSize); echo json_encode($data); } public function goEdit() { $param = Request::instance()->param(); $model = new TemplateModel; $obj = false; if (isset($param['id'])) { $id = $param['id']; $obj = TemplateModel::get($id); } if (!$obj) { $obj = [ 'id' => '', 'title' => '', 'is_public' => '1', 'exam_class_id' => '', 'impression' => '', 'description' => '', 'create_user' => '', 'parent_id' => '' ]; } $examclaData = Db::table("exam_class")->group("name")->field("name")->select(); return $this->fetch('edit', ['obj' => $obj, 'allExamClass' => $examclaData]); } public function save() { $param = Request::instance()->param(); if (isset($param['id']) && $param['id']) { $id = $param['id']; //更新 $template = TemplateModel::get($id); if (!$template) { return "faile"; } $template->title = $param['title']; $template->is_public = $param['is_public']; $template->exam_class_id = $param['exam_class_id']; $template->impression = $param['impression']; $template->description = $param['description']; $template->save(); SysLogs::log("template", "U", json_encode($template)); } else { $user = Session::get("session_manager"); //修改 $template = new TemplateModel; $template->id = UUIDs::uuid16(); $template->title = $param['title']; $template->is_public = $param['is_public']; $template->exam_class_id = $param['exam_class_id']; $template->impression = $param['impression']; $template->description = $param['description']; $template->createdAt = date("Y-m-d H:i:s", time()); $template->create_user = $user ? $user['id'] : ''; $template->save(); SysLogs::log("template", "C", json_encode($template)); } return "success"; } public function del() { $param = Request::instance()->param(); $id = $param['id']; $device = TemplateModel::get($id); $device->delete(); SysLogs::log("template", "D", $id); return "delete_ok"; } }