moonsflyer il y a 8 mois
Parent
commit
4d95765859
1 fichiers modifiés avec 16 ajouts et 2 suppressions
  1. 16 2
      app/api/logic/ServiceLogic.php

+ 16 - 2
app/api/logic/ServiceLogic.php

@@ -189,9 +189,23 @@ class ServiceLogic extends BaseLogic
          if(isset($get['title'])){
              $where[]=['title','like','%'.$get['title'].'%'];
          }
-         $area_list = AssetArea::where($where)->field('id,title')->order('sort desc,id asc')->select()->toArray();
+         $area_list = AssetArea::where($where)->field('id,level,pid,title')->order('sort desc,id asc')->select()->toArray();
+
+        if($get['is_tree'] ==1){
+
+
+            $treeList = linear_to_tree($area_list, 'children');
+            if (empty($treeList) && !empty($area_list)) {
+                foreach ($area_list as &$v) {
+                    $v['children'] = [];
+                }
+                return $area_list;
+            }
+            return $treeList;
+        }else{
+            return $area_list;
+        }
 
-        return $area_list;
     }
     /**
      * @notes 地址列表