mirror of https://gitee.com/karson/fastadmin.git
selectpage支持返回树形
parent
201f789076
commit
a65a63373c
|
|
@ -8,6 +8,7 @@ use think\Controller;
|
|||
use think\Hook;
|
||||
use think\Lang;
|
||||
use think\Session;
|
||||
use fast\Tree;
|
||||
|
||||
/**
|
||||
* 后台控制器基类
|
||||
|
|
@ -124,6 +125,10 @@ class Backend extends Controller
|
|||
Hook::listen('admin_nologin', $this);
|
||||
$url = Session::get('referer');
|
||||
$url = $url ? $url : $this->request->url();
|
||||
if ($url == '/') {
|
||||
$this->redirect('index/login', [], 302, ['referer' => $url]);
|
||||
exit;
|
||||
}
|
||||
$this->error(__('Please login first'), url('index/login', ['url' => $url]));
|
||||
}
|
||||
// 判断是否需要验证权限
|
||||
|
|
@ -431,6 +436,12 @@ class Backend extends Controller
|
|||
$searchfield = (array) $this->request->request("searchField/a");
|
||||
//自定义搜索条件
|
||||
$custom = (array) $this->request->request("custom/a");
|
||||
//是否返回树形结构
|
||||
$istree = $this->request->request("isTree", 0);
|
||||
if($istree) {
|
||||
$word = [];
|
||||
$pagesize = 99999;
|
||||
}
|
||||
$order = [];
|
||||
foreach ($orderby as $k => $v)
|
||||
{
|
||||
|
|
@ -481,6 +492,15 @@ class Backend extends Controller
|
|||
->field("{$primarykey},{$field}")
|
||||
->field("password,salt", true)
|
||||
->select();
|
||||
if($istree) {
|
||||
$tree = Tree::instance();
|
||||
$tree->init(collection($list)->toArray(), 'pid');
|
||||
$list = $tree->getTreeList($tree->getTreeArray(0), 'name');
|
||||
foreach ($list as &$item) {
|
||||
$item = str_replace(' ', ' ', $item);
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
}
|
||||
//这里一定要返回有list这个字段,total是可选的,如果total<=list的数量,则会隐藏分页按钮
|
||||
return json(['list' => $list, 'total' => $total]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue