evoxwht пре 2 година
родитељ
комит
0239ec3e25

+ 3 - 2
crmeb/app/adminapi/controller/v1/file/SystemAttachmentCategory.php

@@ -48,9 +48,10 @@ class SystemAttachmentCategory extends AuthController
     {
         $where = $this->request->getMore([
             ['name', ''],
-            ['pid', 0]
+            ['pid', 0],
+            ['all', 0]
         ]);
-        if ($where['name'] != '') $where['pid'] = '';
+        if ($where['name'] != '' || $where['all'] == 1) $where['pid'] = '';
         return app('json')->success($this->service->getAll($where));
     }
 

+ 6 - 4
crmeb/app/services/system/attachment/SystemAttachmentCategoryServices.php

@@ -49,11 +49,13 @@ class SystemAttachmentCategoryServices extends BaseServices
     public function getAll(array $where)
     {
         $list = $this->dao->getList($where);
-        foreach ($list as &$item) {
-            $item['title'] = $item['name'];
-            if ($where['name'] == '' && $this->dao->count(['pid' => $item['id']])) {
-                $item['loading'] = false;
+        if ($where['all'] == 1) {
+            $list = $this->tidyMenuTier($list);
+        } else {
+            foreach ($list as &$item) {
+                $item['title'] = $item['name'];
                 $item['children'] = [];
+                if ($where['name'] == '' && $this->dao->count(['pid' => $item['id']])) $item['loading'] = false;
             }
         }
         return compact('list');