作者 lyh

gx

@@ -21,11 +21,11 @@ class NavController extends BaseController @@ -21,11 +21,11 @@ class NavController extends BaseController
21 21
22 22
23 /** 23 /**
24 - * 列表数据  
25 - * @throws \Psr\Container\ContainerExceptionInterface  
26 - * @throws \Psr\Container\NotFoundExceptionInterface  
27 - * @author:dc  
28 - * @time 2023/5/8 16:37 24 + * @remark :获取列表数据
  25 + * @name :index
  26 + * @author :lyh
  27 + * @method :post
  28 + * @time :2023/12/4 15:00
29 */ 29 */
30 public function index(BNav $nav){ 30 public function index(BNav $nav){
31 $this->map['project_id'] = $this->user['project_id']; 31 $this->map['project_id'] = $this->user['project_id'];
@@ -42,6 +42,24 @@ class NavController extends BaseController @@ -42,6 +42,24 @@ class NavController extends BaseController
42 } 42 }
43 43
44 44
  45 +
  46 + /**
  47 + * @remark :获取当前id下的所有子集
  48 + * @name :getSubList
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2023/12/4 15:04
  52 + */
  53 + public function getSubList(NavLogic $logic){
  54 + $this->request->validate([
  55 + 'id'=>'required',
  56 + ],[
  57 + 'id.required' => '产品ID不能为空',
  58 + ]);
  59 + $data = $logic->getSubList();
  60 + $this->response('success',Code::SUCCESS,$data);
  61 + }
  62 +
45 /** 63 /**
46 * @remark :保存数据 64 * @remark :保存数据
47 * @name :save 65 * @name :save
@@ -26,6 +26,49 @@ class NavLogic extends BaseLogic @@ -26,6 +26,49 @@ class NavLogic extends BaseLogic
26 $this->model = new BNav(); 26 $this->model = new BNav();
27 } 27 }
28 28
  29 + /**
  30 + * @remark :获取当前id下所有子集
  31 + * @name :getSubList
  32 + * @author :lyh
  33 + * @method :post
  34 + * @time :2023/12/4 15:11
  35 + */
  36 + public function getSubList(){
  37 + $str = [];
  38 + //排序掉当前id下所有子集
  39 + $str = $this->getAllSub($this->param['id'],$str);
  40 + $str[] = $this->param['id'];
  41 + $this->param['id'] = ['not in',$str];
  42 + $this->param['project_id'] = $this->user['project_id'];
  43 + $list = $this->model->list($this->param);
  44 + $data = array();
  45 + foreach ($list as $v){
  46 + $v = (array)$v;
  47 + if ($v['pid'] == 0) {
  48 + $v['sub'] = _get_child($v['id'], $list);
  49 + $data[] = $v;
  50 + }
  51 + }
  52 + return $this->success($data);
  53 + }
  54 +
  55 + /**
  56 + * @remark :获取当前id下所有子集
  57 + * @name :getAllSub
  58 + * @author :lyh
  59 + * @method :post
  60 + * @time :2023/10/18 15:10
  61 + */
  62 + public function getAllSub($id,&$str = []){
  63 + $list = $this->model->list(['pid'=>$id,'status'=>1],['id','pid']);
  64 + if(!empty($list)){
  65 + foreach ($list as $v){
  66 + $str[] = $v['id'];
  67 + $this->getAllSub($v['id'],$str);
  68 + }
  69 + }
  70 + return $str;
  71 + }
29 72
30 /** 73 /**
31 * @remark :保存数据 74 * @remark :保存数据
@@ -71,10 +114,10 @@ class NavLogic extends BaseLogic @@ -71,10 +114,10 @@ class NavLogic extends BaseLogic
71 if($this->param['pid'] == $info['id']){ 114 if($this->param['pid'] == $info['id']){
72 $this->fail('不允许成为自己的上级'); 115 $this->fail('不允许成为自己的上级');
73 } 116 }
74 - $pid_info = $this->model->read(['pid'=>$this->param['id']]);  
75 - if(($pid_info !== false) && $this->param['pid'] != $info['pid']){  
76 - $this->fail('当前菜单拥有子集不允许修改上级');  
77 - } 117 +// $pid_info = $this->model->read(['pid'=>$this->param['id']]);
  118 +// if(($pid_info !== false) && $this->param['pid'] != $info['pid']){
  119 +// $this->fail('当前菜单拥有子集不允许修改上级');
  120 +// }
78 return $this->success(); 121 return $this->success();
79 } 122 }
80 123
@@ -363,6 +363,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -363,6 +363,7 @@ Route::middleware(['bloginauth'])->group(function () {
363 // 导航栏编辑 363 // 导航栏编辑
364 Route::prefix('nav')->group(function () { 364 Route::prefix('nav')->group(function () {
365 Route::get('/', [\App\Http\Controllers\Bside\Nav\NavController::class, 'index'])->name('nav'); 365 Route::get('/', [\App\Http\Controllers\Bside\Nav\NavController::class, 'index'])->name('nav');
  366 + Route::any('/get', [\App\Http\Controllers\Bside\Nav\NavController::class, 'getSubList'])->name('nav_getSubList');
366 Route::post('/create', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_create'); 367 Route::post('/create', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_create');
367 Route::post('/update', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_update'); 368 Route::post('/update', [\App\Http\Controllers\Bside\Nav\NavController::class, 'save'])->name('nav_update');
368 Route::delete('/delete', [\App\Http\Controllers\Bside\Nav\NavController::class, 'delete'])->name('nav_delete'); 369 Route::delete('/delete', [\App\Http\Controllers\Bside\Nav\NavController::class, 'delete'])->name('nav_delete');