|
@@ -68,6 +68,7 @@ |
|
|
:readOnly="!selectable" |
|
|
:readOnly="!selectable" |
|
|
:selectedKeyMap="selectedKeyMap" |
|
|
:selectedKeyMap="selectedKeyMap" |
|
|
@check="toggleCheck" |
|
|
@check="toggleCheck" |
|
|
|
|
|
@open-menu="openFileMenu" |
|
|
/> |
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
<div |
|
|
<div |
|
@@ -114,6 +115,16 @@ |
|
|
>确定转移</el-button> |
|
|
>确定转移</el-button> |
|
|
</span> |
|
|
</span> |
|
|
</el-dialog> |
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
|
|
<div |
|
|
|
|
|
class="contextmenu file-right-menu" |
|
|
|
|
|
v-if="fileMenuKey" |
|
|
|
|
|
:style="fileMenuStyle" |
|
|
|
|
|
> |
|
|
|
|
|
<ul class="rightMenu"> |
|
|
|
|
|
<li @click.stop="recoverFiles(fileMenuKey)">返回原处</li> |
|
|
|
|
|
</ul> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<script> |
|
|
<script> |
|
@@ -123,7 +134,11 @@ import CollapseUnit from "./components/collapse-unit.vue"; |
|
|
import ProjectCollapseUnit from "./components/project-collapse-unit"; |
|
|
import ProjectCollapseUnit from "./components/project-collapse-unit"; |
|
|
import ItemList from "./components/item-list"; |
|
|
import ItemList from "./components/item-list"; |
|
|
import { VirtualFolder } from "../workspace/helper"; |
|
|
import { VirtualFolder } from "../workspace/helper"; |
|
|
import { firstCharToLowerCase, firstCharToUpperCase, notify } from "@/utils/tool"; |
|
|
|
|
|
|
|
|
import { |
|
|
|
|
|
firstCharToLowerCase, |
|
|
|
|
|
firstCharToUpperCase, |
|
|
|
|
|
notify, |
|
|
|
|
|
} from "@/utils/tool"; |
|
|
import { wrapErrorHint } from "@/utils/request"; |
|
|
import { wrapErrorHint } from "@/utils/request"; |
|
|
export default { |
|
|
export default { |
|
|
components: { |
|
|
components: { |
|
@@ -134,6 +149,12 @@ export default { |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
this.fetchProjectList(); |
|
|
this.fetchProjectList(); |
|
|
|
|
|
document.body.addEventListener('click', this.closeFileMenu); |
|
|
|
|
|
document.body.addEventListener('contextmenu', this.closeFileMenu); |
|
|
|
|
|
}, |
|
|
|
|
|
destroyed() { |
|
|
|
|
|
document.body.removeEventListener('click', this.closeFileMenu); |
|
|
|
|
|
document.body.removeEventListener('contextmenu', this.closeFileMenu); |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
@@ -150,21 +171,25 @@ export default { |
|
|
|
|
|
|
|
|
chooseNodeModalVisible: false, |
|
|
chooseNodeModalVisible: false, |
|
|
choosedNode: {}, |
|
|
choosedNode: {}, |
|
|
|
|
|
fileMenuStyle: {}, |
|
|
|
|
|
fileMenuKey: undefined, |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
selectedProject(project) { |
|
|
selectedProject(project) { |
|
|
this.fetchProjectRemovedFiles(project.id); |
|
|
this.fetchProjectRemovedFiles(project.id); |
|
|
this.selectable = false; |
|
|
this.selectable = false; |
|
|
|
|
|
this.fileMenuKey = undefined; |
|
|
}, |
|
|
}, |
|
|
selectable() { |
|
|
selectable() { |
|
|
this.selectedKeyMap = {}; |
|
|
this.selectedKeyMap = {}; |
|
|
|
|
|
this.fileMenuKey = undefined; |
|
|
}, |
|
|
}, |
|
|
chooseNodeModalVisible(flag) { |
|
|
chooseNodeModalVisible(flag) { |
|
|
if(!flag) { |
|
|
|
|
|
|
|
|
if (!flag) { |
|
|
this.choosedNode = {}; |
|
|
this.choosedNode = {}; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
canShowButton() { |
|
|
canShowButton() { |
|
@@ -175,13 +200,29 @@ export default { |
|
|
searchForFile() { |
|
|
searchForFile() { |
|
|
debugger; |
|
|
debugger; |
|
|
}, |
|
|
}, |
|
|
|
|
|
openFileMenu(e, file) { |
|
|
|
|
|
if(this.selectable || this.selectedProject.deleted) { return; } |
|
|
|
|
|
console.log(e, file); |
|
|
|
|
|
this.fileMenuKey=file.id; |
|
|
|
|
|
const left = e.clientX - (window.innerWidth - e.clientX < 200 ? 100 : 0); |
|
|
|
|
|
const top = e.clientY - (window.innerHeight - e.clientY < 200 ? 100 : 0); |
|
|
|
|
|
this.fileMenuStyle = { |
|
|
|
|
|
left: `${left}px`, |
|
|
|
|
|
top: `${top}px`, |
|
|
|
|
|
}; |
|
|
|
|
|
}, |
|
|
|
|
|
closeFileMenu() { |
|
|
|
|
|
this.fileMenuKey = undefined; |
|
|
|
|
|
}, |
|
|
async fetchProjectList() { |
|
|
async fetchProjectList() { |
|
|
const res = await this.$fetchApi("project/queryAllProjectListByUserId", { |
|
|
const res = await this.$fetchApi("project/queryAllProjectListByUserId", { |
|
|
userId: this.userId, |
|
|
userId: this.userId, |
|
|
}); |
|
|
}); |
|
|
const [aliveProjectList, removedProjectList] = (res.Data || []).reduce( |
|
|
const [aliveProjectList, removedProjectList] = (res.Data || []).reduce( |
|
|
(arr, upperProject) => { |
|
|
(arr, upperProject) => { |
|
|
if(!upperProject.HasFile) { return arr; } |
|
|
|
|
|
|
|
|
if (!upperProject.HasFile) { |
|
|
|
|
|
return arr; |
|
|
|
|
|
} |
|
|
const project = firstCharToLowerCase(upperProject); |
|
|
const project = firstCharToLowerCase(upperProject); |
|
|
if (project.nodeFolder) { |
|
|
if (project.nodeFolder) { |
|
|
project.nodeFolder = project.nodeFolder.map(firstCharToLowerCase); |
|
|
project.nodeFolder = project.nodeFolder.map(firstCharToLowerCase); |
|
@@ -200,9 +241,11 @@ export default { |
|
|
: removedProjectList.length |
|
|
: removedProjectList.length |
|
|
? removedProjectList[0] |
|
|
? removedProjectList[0] |
|
|
: {}; |
|
|
: {}; |
|
|
if(sessionStorage.projId) { |
|
|
|
|
|
const mayExistProject = aliveProjectList.find(proj => proj.id === sessionStorage.projId); |
|
|
|
|
|
if(mayExistProject) { |
|
|
|
|
|
|
|
|
if (sessionStorage.projId) { |
|
|
|
|
|
const mayExistProject = aliveProjectList.find( |
|
|
|
|
|
(proj) => proj.id === sessionStorage.projId |
|
|
|
|
|
); |
|
|
|
|
|
if (mayExistProject) { |
|
|
this.selectedProject = mayExistProject; |
|
|
this.selectedProject = mayExistProject; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -216,15 +259,20 @@ export default { |
|
|
{ projectId } |
|
|
{ projectId } |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const [fileTreeList, fileList] = (res.Data || []).reduce((arr, topNode) => { |
|
|
|
|
|
if (topNode.ProjArchives) { |
|
|
|
|
|
arr[0] = arr[0].concat( |
|
|
|
|
|
resolveFileListToTree(topNode.ProjArchives, topNode.FolderName) |
|
|
|
|
|
); |
|
|
|
|
|
arr[1] = arr[1].concat(topNode.ProjArchives.map(firstCharToLowerCase)); |
|
|
|
|
|
} |
|
|
|
|
|
return arr; |
|
|
|
|
|
}, [[], []]); |
|
|
|
|
|
|
|
|
const [fileTreeList, fileList] = (res.Data || []).reduce( |
|
|
|
|
|
(arr, topNode) => { |
|
|
|
|
|
if (topNode.ProjArchives) { |
|
|
|
|
|
arr[0] = arr[0].concat( |
|
|
|
|
|
resolveFileListToTree(topNode.ProjArchives, topNode.FolderName) |
|
|
|
|
|
); |
|
|
|
|
|
arr[1] = arr[1].concat( |
|
|
|
|
|
topNode.ProjArchives.map(firstCharToLowerCase) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
return arr; |
|
|
|
|
|
}, |
|
|
|
|
|
[[], []] |
|
|
|
|
|
); |
|
|
this.currentFileList = fileList; |
|
|
this.currentFileList = fileList; |
|
|
this.rightPanelItemList = fileTreeList; |
|
|
this.rightPanelItemList = fileTreeList; |
|
|
}, |
|
|
}, |
|
@@ -247,9 +295,10 @@ export default { |
|
|
this.selectedKeyMap = { ...tempMap, ...stateMap }; |
|
|
this.selectedKeyMap = { ...tempMap, ...stateMap }; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
async recoverFiles() { |
|
|
|
|
|
|
|
|
async recoverFiles(fileId) { |
|
|
|
|
|
this.fileMenuKey = undefined; |
|
|
const project = this.selectedProject; |
|
|
const project = this.selectedProject; |
|
|
const fileIds = Object.keys(this.selectedKeyMap).filter((fileId) => { |
|
|
|
|
|
|
|
|
const fileIds = fileId ? [fileId]: Object.keys(this.selectedKeyMap).filter((fileId) => { |
|
|
return this.selectedKeyMap[fileId]; |
|
|
return this.selectedKeyMap[fileId]; |
|
|
}); |
|
|
}); |
|
|
const res = await this.$fetchApi("file/removeFromRecycleBin", { |
|
|
const res = await this.$fetchApi("file/removeFromRecycleBin", { |
|
@@ -266,22 +315,24 @@ export default { |
|
|
const { currentFileList, selectedKeyMap, choosedNode } = this; |
|
|
const { currentFileList, selectedKeyMap, choosedNode } = this; |
|
|
const { id: folderId, levelId: folderLevelId, projId } = choosedNode; |
|
|
const { id: folderId, levelId: folderLevelId, projId } = choosedNode; |
|
|
const createFileList = currentFileList.reduce((list, file) => { |
|
|
const createFileList = currentFileList.reduce((list, file) => { |
|
|
if(!selectedKeyMap[file.id]) return list; |
|
|
|
|
|
|
|
|
if (!selectedKeyMap[file.id]) return list; |
|
|
const iFile = { |
|
|
const iFile = { |
|
|
...file, |
|
|
|
|
|
|
|
|
...file, |
|
|
folderId, |
|
|
folderId, |
|
|
folderLevelId, |
|
|
folderLevelId, |
|
|
projId, |
|
|
projId, |
|
|
} |
|
|
|
|
|
|
|
|
}; |
|
|
delete iFile.id; |
|
|
delete iFile.id; |
|
|
list.push(firstCharToUpperCase(iFile)); |
|
|
list.push(firstCharToUpperCase(iFile)); |
|
|
return list; |
|
|
return list; |
|
|
}, []); |
|
|
}, []); |
|
|
const res = await this.$fetchApi('file/batchAddFile', { |
|
|
|
|
|
|
|
|
const res = await this.$fetchApi("file/batchAddFile", { |
|
|
ProjArchiveTbs: createFileList, |
|
|
ProjArchiveTbs: createFileList, |
|
|
}); |
|
|
}); |
|
|
wrapErrorHint(res); |
|
|
wrapErrorHint(res); |
|
|
if(res.Code !== 0) { return; } |
|
|
|
|
|
|
|
|
if (res.Code !== 0) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
notify.success("文件拷贝成功"); |
|
|
notify.success("文件拷贝成功"); |
|
|
this.fetchProjectRemovedFiles(this.selectedProject.id); |
|
|
this.fetchProjectRemovedFiles(this.selectedProject.id); |
|
|
this.chooseNodeModalVisible = false; |
|
|
this.chooseNodeModalVisible = false; |
|
@@ -347,12 +398,6 @@ function resolveFileListToTree(upperFileList, nodeName) { |
|
|
|
|
|
|
|
|
return headList; |
|
|
return headList; |
|
|
} |
|
|
} |
|
|
function recursionEvery(list, checkedMap) { |
|
|
|
|
|
return list.every((node) => { |
|
|
|
|
|
if (node.nodeType === "file") return checkedMap[node.id]; |
|
|
|
|
|
return recursionEvery(node.children, checkedMap); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
<style lang="scss" scoped> |
|
@@ -543,4 +588,9 @@ function recursionEvery(list, checkedMap) { |
|
|
overflow: auto; |
|
|
overflow: auto; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
.file-right-menu { |
|
|
|
|
|
position: fixed; |
|
|
|
|
|
width: 100px; |
|
|
|
|
|
text-align: center; |
|
|
|
|
|
} |
|
|
</style> |
|
|
</style> |