From 031dac36e60c8b2803c25c2b1cc2d553798cefa4 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 27 Apr 2022 08:03:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=A7=BB=E5=8A=A8=E5=88=B0=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=86=85=E5=85=B1=E4=BA=AB=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E9=94=99=E4=B9=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/FileController.php | 23 +++++++++++++-------- resources/assets/js/pages/manage/file.vue | 13 +++++++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php index ad4fe241d..4d473d331 100755 --- a/app/Http/Controllers/Api/FileController.php +++ b/app/Http/Controllers/Api/FileController.php @@ -351,24 +351,29 @@ class FileController extends AbstractController if (count($ids) > 100) { return Base::retError('一次最多只能移动100个文件或文件夹'); } + $toShareFile = false; if ($pid > 0) { - File::permissionFind($pid, 1); + $tmpFile = File::permissionFind($pid, 1); + $toShareFile = $tmpFile->getShareInfo(); } // $files = []; - AbstractModel::transaction(function() use ($pid, $ids, &$files) { + AbstractModel::transaction(function() use ($pid, $ids, $toShareFile, &$files) { foreach ($ids as $id) { $file = File::permissionFind($id, 1000); // if ($pid > 0) { - $arr = []; - $tid = $pid; - while ($tid > 0) { - $arr[] = $tid; - $tid = intval(File::whereId($tid)->value('pid')); + $tmpId = $pid; + while ($tmpId > 0) { + if ($id == $tmpId) { + throw new ApiException('移动位置错误'); + } + $tmpId = intval(File::whereId($tmpId)->value('pid')); } - if (in_array($id, $arr)) { - throw new ApiException('移动位置错误'); + if ($file->share && $toShareFile) { + $file->share = 0; + $file->save(); + FileUser::deleteFileAll($file->id, $file->userid); } } // diff --git a/resources/assets/js/pages/manage/file.vue b/resources/assets/js/pages/manage/file.vue index 8aa53fa50..c9604f562 100644 --- a/resources/assets/js/pages/manage/file.vue +++ b/resources/assets/js/pages/manage/file.vue @@ -1164,10 +1164,21 @@ export default { this.$refs.linkInput.focus({cursor:'all'}); }, - shearTo() { + shearTo(force = false) { if (this.shearIds.length == 0) { return; } + if (force !== true + && this.isParentShare + && this.files.findIndex(({id, share}) => share && this.shearIds.includes(id)) > -1) { + $A.modalConfirm({ + content: '剪切板含有共享文件,粘贴到共享文件夹中原共享属性将失效。', + onOk: () => { + this.shearTo(true) + } + }); + return; + } this.$store.dispatch("call", { url: 'file/move', data: {