更新功能
This commit is contained in:
@@ -76,6 +76,7 @@ class Database extends Admin {
|
||||
$this->assign('list', $list);
|
||||
return $this->fetch($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 优化表
|
||||
* @param String $tables 表名
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\admin;
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
use app\controller\Admin;
|
||||
use app\model\Form as FormM;
|
||||
|
||||
/**
|
||||
* @title 自定义表单
|
||||
@@ -16,33 +17,20 @@ use app\common\controller\Admin;
|
||||
*/
|
||||
class Form extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->model = model('Form');
|
||||
$this->Fattr = model('FormAttr');
|
||||
//遍历属性列表
|
||||
foreach (get_attribute_type() as $key => $value) {
|
||||
$this->attr[$key] = $value[0];
|
||||
}
|
||||
$this->field = $this->getField();
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 表单列表
|
||||
*/
|
||||
public function index() {
|
||||
$map = array();
|
||||
$map = [];
|
||||
|
||||
$order = "id desc";
|
||||
$list = $this->model->where($map)->order($order)->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
|
||||
$data = array(
|
||||
$list = FormM::where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
|
||||
$this->data = [
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->setMeta('自定义表单');
|
||||
$this->assign($data);
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class Index extends Admin {
|
||||
\think\Log::clear();
|
||||
}
|
||||
}
|
||||
return $this->success("更新成功!", url('admin/index/index'));
|
||||
return $this->success("更新成功!", url('/admin/index/index'));
|
||||
} else {
|
||||
$keylist = array(
|
||||
array('name' => 'clear', 'title' => '更新缓存', 'type' => 'checkbox', 'help' => '', 'option' => array(
|
||||
|
||||
@@ -43,7 +43,9 @@ class Menu extends Admin {
|
||||
/**
|
||||
* @title 编辑菜单字段
|
||||
*/
|
||||
public function editable($name = null, $value = null, $pk = null) {
|
||||
public function editable() {
|
||||
$data = $this->request->param();
|
||||
|
||||
if ($name && ($value != null || $value != '') && $pk) {
|
||||
db('Menu')->where(array('id' => $pk))->setField($name, $value);
|
||||
}
|
||||
@@ -67,18 +69,20 @@ class Menu extends Admin {
|
||||
return $this->error('新增失败');
|
||||
}
|
||||
} else {
|
||||
$this->assign('info', array('pid' => input('pid')));
|
||||
$menus = db('Menu')->select();
|
||||
$tree = new \com\Tree();
|
||||
$menus = MenuM::select()->toArray();
|
||||
|
||||
$tree = new \sent\tree\Tree();
|
||||
$menus = $tree->toFormatTree($menus);
|
||||
|
||||
if (!empty($menus)) {
|
||||
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
|
||||
} else {
|
||||
$menus = array(0 => array('id' => 0, 'title_show' => '顶级菜单'));
|
||||
}
|
||||
|
||||
$this->assign('Menus', $menus);
|
||||
$this->setMeta('新增菜单');
|
||||
$this->data = [
|
||||
'info' => ['pid' => $this->request->param('pid', 0)],
|
||||
'Menus' => $menus
|
||||
];
|
||||
return $this->fetch('edit');
|
||||
}
|
||||
}
|
||||
@@ -89,31 +93,34 @@ class Menu extends Admin {
|
||||
*/
|
||||
public function edit($id = 0) {
|
||||
if ($this->request->isPost()) {
|
||||
$Menu = model('Menu');
|
||||
$data = input('post.');
|
||||
if ($Menu->save($data, array('id' => $data['id'])) !== false) {
|
||||
session('admin_menu_list', null);
|
||||
//记录行为
|
||||
action_log('update_menu', 'Menu', $data['id'], session('user_auth.uid'));
|
||||
return $this->success('更新成功', Cookie('__forward__'));
|
||||
$data = $this->request->post();
|
||||
|
||||
$result = MenuM::update($data, ['id' => $data['id']]);
|
||||
|
||||
if (false !== $result) {
|
||||
return $this->success('更新成功', '/admin/menu/index');
|
||||
} else {
|
||||
return $this->error('更新失败');
|
||||
}
|
||||
} else {
|
||||
$info = array();
|
||||
$info = [];
|
||||
/* 获取数据 */
|
||||
$info = db('Menu')->field(true)->find($id);
|
||||
$menus = db('Menu')->field(true)->select();
|
||||
$tree = new \com\Tree();
|
||||
$info = MenuM::find($id);
|
||||
|
||||
$menus = MenuM::select()->toArray();
|
||||
|
||||
$tree = new \sent\tree\Tree();
|
||||
$menus = $tree->toFormatTree($menus);
|
||||
|
||||
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
|
||||
$this->assign('Menus', $menus);
|
||||
if (false === $info) {
|
||||
return $this->error('获取后台菜单信息错误');
|
||||
}
|
||||
$this->assign('info', $info);
|
||||
$this->setMeta('编辑后台菜单');
|
||||
|
||||
$this->data = [
|
||||
'Menus' => $menus,
|
||||
'info' => $info
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,41 +6,32 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\SeoRule;
|
||||
use app\model\Rewrite;
|
||||
|
||||
/**
|
||||
* @title SEO管理
|
||||
*/
|
||||
class Seo extends Admin {
|
||||
|
||||
protected $seo;
|
||||
protected $rewrite;
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->seo = model('SeoRule');
|
||||
$this->rewrite = model('Rewrite');
|
||||
}
|
||||
|
||||
/**
|
||||
* @title SEO列表
|
||||
*/
|
||||
public function index($page = 1, $r = 20) {
|
||||
$map = [];
|
||||
|
||||
//读取规则列表
|
||||
$map = array('status' => array('EGT', 0));
|
||||
$map[] = ['status', '>=', 0];
|
||||
|
||||
$list = $this->seo->where($map)->order('sort asc')->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$list = SeoRule::where($map)->order('sort asc')->paginate($this->request->pageConfig);
|
||||
|
||||
$data = array(
|
||||
$this->data = [
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("规则列表");
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -111,14 +102,14 @@ class Seo extends Admin {
|
||||
* @title 伪静态列表
|
||||
*/
|
||||
public function rewrite() {
|
||||
$list = db('Rewrite')->paginate(10);
|
||||
$map = [];
|
||||
|
||||
$data = array(
|
||||
$list = Rewrite::where($map)->paginate($this->request->pageConfig);
|
||||
|
||||
$this->data = [
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("路由规则");
|
||||
];
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user