更新
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 菜单管理
|
||||
@@ -24,9 +23,9 @@ class Menu extends Admin {
|
||||
* @title 菜单列表
|
||||
*/
|
||||
public function index() {
|
||||
$map = array();
|
||||
$map = array();
|
||||
$title = trim(input('get.title'));
|
||||
$list = db("Menu")->where($map)->field(true)->order('sort asc,id asc')->column('*', 'id');
|
||||
$list = db("Menu")->where($map)->field(true)->order('sort asc,id asc')->column('*', 'id');
|
||||
int_to_string($list, array('hide' => array(1 => '是', 0 => '否'), 'is_dev' => array(1 => '是', 0 => '否')));
|
||||
|
||||
if (!empty($list)) {
|
||||
@@ -58,7 +57,7 @@ class Menu extends Admin {
|
||||
if ($this->request->isPost()) {
|
||||
$Menu = model('Menu');
|
||||
$data = input('post.');
|
||||
$id = $Menu->save($data);
|
||||
$id = $Menu->save($data);
|
||||
if ($id) {
|
||||
session('admin_menu_list', null);
|
||||
//记录行为
|
||||
@@ -70,7 +69,7 @@ class Menu extends Admin {
|
||||
} else {
|
||||
$this->assign('info', array('pid' => input('pid')));
|
||||
$menus = db('Menu')->select();
|
||||
$tree = new \com\Tree();
|
||||
$tree = new \com\Tree();
|
||||
$menus = $tree->toFormatTree($menus);
|
||||
if (!empty($menus)) {
|
||||
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
|
||||
@@ -103,9 +102,9 @@ class Menu extends Admin {
|
||||
} else {
|
||||
$info = array();
|
||||
/* 获取数据 */
|
||||
$info = db('Menu')->field(true)->find($id);
|
||||
$info = db('Menu')->field(true)->find($id);
|
||||
$menus = db('Menu')->field(true)->select();
|
||||
$tree = new \com\Tree();
|
||||
$tree = new \com\Tree();
|
||||
$menus = $tree->toFormatTree($menus);
|
||||
|
||||
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
|
||||
@@ -171,10 +170,10 @@ class Menu extends Admin {
|
||||
$add_pid = $menuModel->add(
|
||||
array(
|
||||
'title' => $value['title'],
|
||||
'url' => $value['url'],
|
||||
'pid' => $pid,
|
||||
'hide' => isset($value['hide']) ? (int) $value['hide'] : 0,
|
||||
'tip' => isset($value['tip']) ? $value['tip'] : '',
|
||||
'url' => $value['url'],
|
||||
'pid' => $pid,
|
||||
'hide' => isset($value['hide']) ? (int) $value['hide'] : 0,
|
||||
'tip' => isset($value['tip']) ? $value['tip'] : '',
|
||||
'group' => $value['group'],
|
||||
)
|
||||
);
|
||||
@@ -186,8 +185,8 @@ class Menu extends Admin {
|
||||
|
||||
public function import() {
|
||||
if ($this->request->isPost()) {
|
||||
$tree = input('post.tree');
|
||||
$lists = explode(PHP_EOL, $tree);
|
||||
$tree = input('post.tree');
|
||||
$lists = explode(PHP_EOL, $tree);
|
||||
$menuModel = db('Menu');
|
||||
if ($lists == array()) {
|
||||
return $this->error('请按格式填写批量导入的菜单,至少一个菜单');
|
||||
@@ -197,14 +196,14 @@ class Menu extends Admin {
|
||||
$record = explode('|', $value);
|
||||
if (count($record) == 4) {
|
||||
$menuModel->add(array(
|
||||
'title' => $record[0],
|
||||
'url' => $record[1],
|
||||
'pid' => $record[2],
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'tip' => '',
|
||||
'title' => $record[0],
|
||||
'url' => $record[1],
|
||||
'pid' => $record[2],
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'tip' => '',
|
||||
'is_dev' => 0,
|
||||
'group' => $record[3],
|
||||
'group' => $record[3],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user