wugg 8 달 전
부모
커밋
a4d7a4b128
2개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 1
      app/admin/controller/Cate.php
  2. 1 1
      app/admin/model/Cat.php

+ 5 - 1
app/admin/controller/Cate.php

@@ -30,16 +30,20 @@ class Cate extends Base{
     * @throws \think\db\exception\ModelNotFoundException
      */
     public function list(){
-      $param=$this->request->param(["pid"=>0,"cat_name"=>"","status"=>"","page"=>1,"size"=>10],"post","trim");
+      $param=$this->request->param(["pid"=>0,"cat_name"=>"","status"=>"","level"=>"","search"=>"","page"=>1,"size"=>10],"post","trim");
       $where=[["is_del","=",0]];
       if($param["pid"]!=="")$where[]=["pid","=",$param["pid"]];
       if($param["cat_name"]!=="")$where[]=["cat_name","like","%".$param["cat_name"]."%"];
       if($param["status"]!=="")$where[]=["status","=",$param["status"]];
+      if($param["level"]!=="")$where[]=["level","=",$param["level"]];
+      if($param["search"]!=="")$where[]=["search","like","%".$param["search"]."%"];
       $data=$this->model->where($where)->order("id","desc")->paginate(['page'=>$param['page'],'list_rows'=>$param['size']])
       ->each(function(&$item){
         $item["im"]=CatSpecs::with(["specs"])->where("cat_id",$item["id"])->field(["specs_id"])->select();
         $depart = \app\user\model\AccountItem::with(["ItemName"])->where(["account_id"=>$item["createrid"]])->findOrEmpty();
         $item["company_name"]=$depart->depart_name??"";
+        $search_arr= Cat::GetCatListByChildId($item['id']);
+        $item['item'] = array_column($search_arr,"id") ;
       });
       return success("获取成功",["list"=>$data->items(),"count"=>$data->total()]);
     }

+ 1 - 1
app/admin/model/Cat.php

@@ -56,7 +56,7 @@ class Cat extends Base
 	public static function GetCatListByChildId($cat_id,&$catArr=[]){
         $cat = self::where(['id'=>$cat_id,'is_del'=>0])->field("id,cat_name,pid,status")->findOrEmpty();
         if($cat->isEmpty())return [];
-        array_unshift($catArr,$cat );
+        array_unshift($catArr,$cat->toArray() );
         if($cat->pid>0){
             self::GetCatListByChildId($cat->pid,$catArr);
         }