fix: 修复共享文件移动到共享文件夹内共享属性错乱的问题

This commit is contained in:
kuaifan 2022-04-27 08:03:17 +08:00
parent dc3b666635
commit 031dac36e6
2 changed files with 26 additions and 10 deletions

View File

@ -351,24 +351,29 @@ class FileController extends AbstractController
if (count($ids) > 100) { if (count($ids) > 100) {
return Base::retError('一次最多只能移动100个文件或文件夹'); return Base::retError('一次最多只能移动100个文件或文件夹');
} }
$toShareFile = false;
if ($pid > 0) { if ($pid > 0) {
File::permissionFind($pid, 1); $tmpFile = File::permissionFind($pid, 1);
$toShareFile = $tmpFile->getShareInfo();
} }
// //
$files = []; $files = [];
AbstractModel::transaction(function() use ($pid, $ids, &$files) { AbstractModel::transaction(function() use ($pid, $ids, $toShareFile, &$files) {
foreach ($ids as $id) { foreach ($ids as $id) {
$file = File::permissionFind($id, 1000); $file = File::permissionFind($id, 1000);
// //
if ($pid > 0) { if ($pid > 0) {
$arr = []; $tmpId = $pid;
$tid = $pid; while ($tmpId > 0) {
while ($tid > 0) { if ($id == $tmpId) {
$arr[] = $tid; throw new ApiException('移动位置错误');
$tid = intval(File::whereId($tid)->value('pid')); }
$tmpId = intval(File::whereId($tmpId)->value('pid'));
} }
if (in_array($id, $arr)) { if ($file->share && $toShareFile) {
throw new ApiException('移动位置错误'); $file->share = 0;
$file->save();
FileUser::deleteFileAll($file->id, $file->userid);
} }
} }
// //

View File

@ -1164,10 +1164,21 @@ export default {
this.$refs.linkInput.focus({cursor:'all'}); this.$refs.linkInput.focus({cursor:'all'});
}, },
shearTo() { shearTo(force = false) {
if (this.shearIds.length == 0) { if (this.shearIds.length == 0) {
return; 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", { this.$store.dispatch("call", {
url: 'file/move', url: 'file/move',
data: { data: {