正在显示
3 个修改的文件
包含
59 行增加
和
0 行删除
| @@ -86,6 +86,17 @@ class CategoryController extends BaseController | @@ -86,6 +86,17 @@ class CategoryController extends BaseController | ||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| 89 | + * @name :(添加/编辑时获取顶级分类)topList | ||
| 90 | + * @author :lyh | ||
| 91 | + * @method :post | ||
| 92 | + * @time :2023/6/13 9:03 | ||
| 93 | + */ | ||
| 94 | + public function categoryTopList(CategoryLogic $logic){ | ||
| 95 | + $list = $logic->categoryTopList(); | ||
| 96 | + $this->response('success',Code::SUCCESS,$list); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 89 | * @remark :获取详情 | 100 | * @remark :获取详情 |
| 90 | * @name :info | 101 | * @name :info |
| 91 | * @author :lyh | 102 | * @author :lyh |
| @@ -42,6 +42,53 @@ class CategoryLogic extends BaseLogic | @@ -42,6 +42,53 @@ class CategoryLogic extends BaseLogic | ||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | + * @name :(添加/编辑分类时获取级分类)categoryTopList | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2023/6/13 9:09 | ||
| 49 | + */ | ||
| 50 | + public function categoryTopList(){ | ||
| 51 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 52 | + $this->param['status'] = 0; | ||
| 53 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 54 | + $str = []; | ||
| 55 | + //排序掉当前id下所有子集 | ||
| 56 | + $str = $this->getAllSub($this->param['id'],$str); | ||
| 57 | + $str[] = (int)$this->param['id']; | ||
| 58 | + $this->param['id'] = ['not in',$str]; | ||
| 59 | + } | ||
| 60 | + $menu = array(); | ||
| 61 | + $list = $this->model->list($this->param); | ||
| 62 | + if(!empty($list)){ | ||
| 63 | + foreach ($list as $k => $v){ | ||
| 64 | + if($v['pid'] == 0){ | ||
| 65 | + $v['sub'] = _get_child($v['id'],$list); | ||
| 66 | + $menu[] = $v; | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + return $this->success($menu); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * @remark :获取当前id下所有子集 | ||
| 75 | + * @name :getAllSub | ||
| 76 | + * @author :lyh | ||
| 77 | + * @method :post | ||
| 78 | + * @time :2023/10/18 15:10 | ||
| 79 | + */ | ||
| 80 | + public function getAllSub($id,&$str = []){ | ||
| 81 | + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']); | ||
| 82 | + if(!empty($list)){ | ||
| 83 | + foreach ($list as $v){ | ||
| 84 | + $str[] = $v['id']; | ||
| 85 | + $this->getAllSub($v['id'],$str); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + return $str; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 45 | * @remark :获取详情 | 92 | * @remark :获取详情 |
| 46 | * @name :getInfo | 93 | * @name :getInfo |
| 47 | * @author :lyh | 94 | * @author :lyh |
| @@ -193,6 +193,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -193,6 +193,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 193 | //产品分类 | 193 | //产品分类 |
| 194 | Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category'); | 194 | Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category'); |
| 195 | Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info'); | 195 | Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info'); |
| 196 | + Route::get('category/categoryTopList', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'categoryTopList'])->name('product_category_categoryTopList'); | ||
| 196 | Route::post('category/save', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'save'])->name('product_category_save'); | 197 | Route::post('category/save', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'save'])->name('product_category_save'); |
| 197 | Route::post('category/sort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'sort'])->name('product_category_sort'); | 198 | Route::post('category/sort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'sort'])->name('product_category_sort'); |
| 198 | Route::any('category/delete', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'delete'])->name('product_category_delete'); | 199 | Route::any('category/delete', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'delete'])->name('product_category_delete'); |
-
请 注册 或 登录 后发表评论