|
...
|
...
|
@@ -19,7 +19,7 @@ class NavLogic extends BaseLogic |
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->param = $this->requestAll;
|
|
|
|
$this->model = new BNav();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -33,41 +33,35 @@ class NavLogic extends BaseLogic |
|
|
|
if(!empty($this->requestAll['location'])){
|
|
|
|
$where[] = ['location','=',$this->requestAll['location']];
|
|
|
|
}
|
|
|
|
|
|
|
|
$lists = $this->getList($where,['sort'=>'asc'],['*'],false);
|
|
|
|
|
|
|
|
$isTree = $this->requestAll['tree']??false;
|
|
|
|
|
|
|
|
if($isTree){
|
|
|
|
$lists = list_to_tree($lists);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $lists;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function save($data)
|
|
|
|
public function navSave()
|
|
|
|
{
|
|
|
|
if($data['pid']){
|
|
|
|
// 验证是否存在上级
|
|
|
|
$all = BNav::_all($this->user['project_id'],$data['location']);
|
|
|
|
if(!$all->where('id',$data['pid'])->count()){
|
|
|
|
$this->fail('上级栏目不存在');
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($this->param['pid'] == $info['id']){
|
|
|
|
$this->fail('不允许成为自己的上级');
|
|
|
|
}
|
|
|
|
// 上级不允许是自己的下级
|
|
|
|
if(!empty($data['id'])){
|
|
|
|
$all = list_to_tree($all->toArray(),$data['id']);
|
|
|
|
$all = tree_to_list($all);
|
|
|
|
if(in_array($data['pid'],array_column($all,'id'))){
|
|
|
|
$this->fail('上级栏目不允许为本身的下级');
|
|
|
|
}
|
|
|
|
$pid_info = $this->model->read(['pid'=>$this->param['id']]);
|
|
|
|
if(($pid_info !== false) && $this->param['pid'] != $info['pid']){
|
|
|
|
$this->fail('当前菜单拥有子集不允许修改上级');
|
|
|
|
}
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
$rs = $this->model->add($this->param);
|
|
|
|
}
|
|
|
|
$data['url'] = $data['url'] ?: '';
|
|
|
|
// 保存
|
|
|
|
$id = parent::save($data);
|
|
|
|
|
|
|
|
return $this->getInfo($id['id']);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|