|
@@ -3,6 +3,7 @@
|
|
namespace app\admin\controller;
|
|
namespace app\admin\controller;
|
|
|
|
|
|
use app\admin\common\AdminController;
|
|
use app\admin\common\AdminController;
|
|
|
|
+use app\common\api\MenuApi;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Description of Menu
|
|
* Description of Menu
|
|
@@ -11,28 +12,86 @@ use app\admin\common\AdminController;
|
|
*/
|
|
*/
|
|
class Menu extends AdminController {
|
|
class Menu extends AdminController {
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @auth {{/menu}}
|
|
|
|
+ * @return type
|
|
|
|
+ */
|
|
function index() {
|
|
function index() {
|
|
return view();
|
|
return view();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @auth {{/menu/list}}
|
|
|
|
+ * @return type
|
|
|
|
+ */
|
|
|
|
+ function list() {
|
|
|
|
+ if ($this->request->isPost()) {
|
|
|
|
+
|
|
|
|
+ return json([]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @auth {{/menu/add}}
|
|
|
|
+ * @return type
|
|
|
|
+ */
|
|
function add() {
|
|
function add() {
|
|
if ($this->request->isPost()) {
|
|
if ($this->request->isPost()) {
|
|
-
|
|
|
|
|
|
+ try {
|
|
|
|
+ $params = $this->request->param();
|
|
|
|
+ validate(\app\admin\validate\Menu::class)->check($params);
|
|
|
|
+ if (MenuApi::save($this->request->param())) {
|
|
|
|
+ return json(["msg" => "添加成功"]);
|
|
|
|
+ }
|
|
|
|
+ return json(["msg" => "添加失败"]);
|
|
|
|
+ } catch (\think\Exception $e) {
|
|
|
|
+ return json(["msg" => $e->getMessage()]);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return view();
|
|
return view();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @auth {{/menu/edit}}
|
|
|
|
+ * @return type
|
|
|
|
+ */
|
|
function edit() {
|
|
function edit() {
|
|
if ($this->request->isPost()) {
|
|
if ($this->request->isPost()) {
|
|
-
|
|
|
|
|
|
+ try {
|
|
|
|
+ $params = $this->request->param();
|
|
|
|
+ if (!$params["id"])
|
|
|
|
+ return json(["msg" => "没有选择菜单"]);
|
|
|
|
+ validate(\app\admin\validate\Menu::class)->check($params);
|
|
|
|
+ if (MenuApi::save($this->request->param())) {
|
|
|
|
+ return json(["msg" => "修改成功"]);
|
|
|
|
+ }
|
|
|
|
+ return json(["msg" => "修改失败"]);
|
|
|
|
+ } catch (\think\Exception $e) {
|
|
|
|
+ return json(["msg" => $e->getMessage()]);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return view();
|
|
return view();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @auth {{/menu/remove}}
|
|
|
|
+ * @return type
|
|
|
|
+ */
|
|
function delete() {
|
|
function delete() {
|
|
if ($this->request->isPost()) {
|
|
if ($this->request->isPost()) {
|
|
-
|
|
|
|
|
|
+ return json([]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function selectMenuTreeList() {
|
|
|
|
+ $list = \app\common\api\MenuApi::getAllMenus("id,code,pcode,name,num,levels,ismenu");
|
|
|
|
+ foreach ($list as $key => $item) {
|
|
|
|
+ if ($item["pcode"] == "0") {
|
|
|
|
+ $list[$key]["open"] = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ $format_list[] = ["code" => 0, "pcode" => "", "name" => "顶级", "open" => true, "children" => $list];
|
|
|
|
+ return $format_list;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|