|
@@ -35,10 +35,10 @@ class FolderController extends Controller
|
|
|
'object_type' => $objectType,
|
|
|
'object_id' => $objectId,
|
|
|
])
|
|
|
-// ->when(request("parent_id", 0) > 0, function ($query) {
|
|
|
-// return $query->where("path", "like", "%," . \request("parent_id") . ",%")->where("id", "!=", \request("parent_id"));
|
|
|
-// })
|
|
|
-// 文件夹树暂时显示一层
|
|
|
+ // ->when(request("parent_id", 0) > 0, function ($query) {
|
|
|
+ // return $query->where("path", "like", "%," . \request("parent_id") . ",%")->where("id", "!=", \request("parent_id"));
|
|
|
+ // })
|
|
|
+ // 文件夹树暂时显示一层
|
|
|
->where('parent_id',0)
|
|
|
->orderByDesc("sequence")
|
|
|
->get([
|
|
@@ -270,13 +270,12 @@ class FolderController extends Controller
|
|
|
|
|
|
$objectWhere = ['object_type' => $objectType, 'object_id' => $objectId,];
|
|
|
$folders = Folder::query()
|
|
|
- ->select(['id', 'name'])
|
|
|
->where($objectWhere)
|
|
|
->when($folderId, fn($query) => $query->where("parent_id", $folderId))
|
|
|
->when(! $folderId, fn($query) => $query->where("parent_id", 0))
|
|
|
->orderBy('updated_at', $orderBy)
|
|
|
- ->paginate($pageSize);
|
|
|
- $folders_total = $folders->total();
|
|
|
+ ->get(['id', 'name']);
|
|
|
+
|
|
|
$sonFolderCount=Folder::query()
|
|
|
->where($objectWhere)
|
|
|
->whereIn('parent_id',$folders->pluck('id'))
|
|
@@ -292,7 +291,6 @@ class FolderController extends Controller
|
|
|
->groupBy("folder_id")
|
|
|
->pluck("cut", "folder_id");
|
|
|
|
|
|
-
|
|
|
$index=1;
|
|
|
$folders = $folders->map(function (Folder $folder) use ($sonFolderCount,$sonFileCount,&$index) {
|
|
|
$folder->itemCount =$sonFolderCount->get($folder->id, 0)+$sonFileCount->get($folder->id, 0);
|
|
@@ -302,42 +300,19 @@ class FolderController extends Controller
|
|
|
return $folder;
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+
|
|
|
$files = File::query()->where($objectWhere)
|
|
|
->with('bimFile')
|
|
|
->where("folder_id", $folderId)
|
|
|
->where("is_latest_version", 1)
|
|
|
->orderBy('updated_at', $orderBy)
|
|
|
->get();
|
|
|
-
|
|
|
- $files_total = $files->count();
|
|
|
-
|
|
|
- $total = $files_total + $folders_total;
|
|
|
- //分页
|
|
|
- if ($folders_total < $pageSize * $page){
|
|
|
- $offset = $pageSize * $page - $folders_total < $pageSize ? 0 : $pageSize * $page - $total - $folders_total; // 查看当前页面是否有包含文件夹
|
|
|
- $pageSize = $pageSize * $page - $folders_total > $pageSize ? $pageSize : $pageSize * $pageSize - $folders_total;
|
|
|
-
|
|
|
- $files = File::query()->where($objectWhere)
|
|
|
- ->with('bimFile')
|
|
|
- ->where("folder_id", $folderId)
|
|
|
- ->where("is_latest_version", 1)
|
|
|
- ->orderBy('updated_at', $orderBy)
|
|
|
- ->offset($offset)
|
|
|
- ->limit($pageSize)
|
|
|
- ->get();
|
|
|
- //因为要接着文件夹进行文件id递增
|
|
|
- $folderCount=$folders->count()+1;
|
|
|
- $files->map(function (File $file) use (&$folderCount) {
|
|
|
- $file->display_id=$folderCount++;
|
|
|
- });
|
|
|
- }else{
|
|
|
- //目录的总数 大于 显示数 时,不显示文件列表
|
|
|
- $files = [];
|
|
|
- $files_total = 0;
|
|
|
- }
|
|
|
-
|
|
|
//因为要接着文件夹进行文件id递增
|
|
|
-
|
|
|
+ $folderCount=$folders->count()+1;
|
|
|
+ $files->map(function (File $file) use (&$folderCount) {
|
|
|
+ $file->display_id=$folderCount++;
|
|
|
+ });
|
|
|
|
|
|
$container=[
|
|
|
'id'=>$object->id,
|
|
@@ -354,7 +329,6 @@ class FolderController extends Controller
|
|
|
'object'=>$container,
|
|
|
'data' => [
|
|
|
'folders' => $folders,
|
|
|
- 'total' => $folders_total + $files_total,
|
|
|
'files' => FileByObjectResource::collection($files),
|
|
|
'folder_parent_id'=>$folderId>0?$folder->parent_id:$folderId,
|
|
|
]
|
|
@@ -380,7 +354,7 @@ class FolderController extends Controller
|
|
|
|
|
|
/**
|
|
|
* 基于容器文件夹改名字
|
|
|
- */
|
|
|
+ */
|
|
|
public function changeName(UpdateRequest $request,string $id){
|
|
|
$newName=$request->name;
|
|
|
$folder=Folder::query()->findOrFail($id);
|