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: {