提交 2c86b025 authored 作者: 龙菲's avatar 龙菲

完成文件移动和复制

上级 1d351b1a
...@@ -60,6 +60,16 @@ export const getFoldTree = (params) => { ...@@ -60,6 +60,16 @@ export const getFoldTree = (params) => {
}) })
} }
// 获取文件目录树by path
export const getFoldTreeByPath = (params) => {
return request({
url: baseUrl + '/file/getfiletreeByPath',
method: 'get',
params
})
}
/** /**
* 单文件操作相关接口 * 单文件操作相关接口
*/ */
......
...@@ -344,7 +344,7 @@ export default { ...@@ -344,7 +344,7 @@ export default {
getFileDetail({ userFileId: this.activeFileObj.userFileId }) getFileDetail({ userFileId: this.activeFileObj.userFileId })
.then((res) => { .then((res) => {
this.loading = false; this.loading = false;
if (res.success) { if (res.code == 200) {
this.audioInfo = { this.audioInfo = {
...res.data.music, ...res.data.music,
duration: res.data.music.trackLength, duration: res.data.music.trackLength,
......
...@@ -260,7 +260,7 @@ export default { ...@@ -260,7 +260,7 @@ export default {
}) })
.then((res) => { .then((res) => {
this.codeMirrorLoading = false; this.codeMirrorLoading = false;
if (res.success) { if (res.code == 200) {
this.$message.success("已保存"); this.$message.success("已保存");
this.getCodeText(); this.getCodeText();
} else { } else {
......
...@@ -213,7 +213,7 @@ export default { ...@@ -213,7 +213,7 @@ export default {
}) })
.then((res) => { .then((res) => {
this.markdownLoading = false; this.markdownLoading = false;
if (res.success) { if (res.code == 200) {
this.$message.success("已保存"); this.$message.success("已保存");
this.getMarkdownText(); this.getMarkdownText();
} else { } else {
......
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
) { ) {
console.log("getWeChatAuthStateData", getWeChatAuthStateData); console.log("getWeChatAuthStateData", getWeChatAuthStateData);
// getWeChatAuthState().then((res) => { // getWeChatAuthState().then((res) => {
// if (res.success) { // if (res.code == 200) {
// if (res.data) { // if (res.data) {
// this.callback("go"); // this.callback("go");
// } else { // } else {
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
</template> </template>
<script> <script>
import { getFoldTree, copyFile } from "@/api/qwFile.js"; import { getFoldTreeByPath, copyFile } from "@/api/qwFile.js";
export default { export default {
name: "CopyFileDialog", name: "CopyFileDialog",
...@@ -90,11 +90,37 @@ export default { ...@@ -90,11 +90,37 @@ export default {
* 初始化文件目录树 * 初始化文件目录树
*/ */
initFileTree(id) { initFileTree(id) {
// this.loading = true;
// getFoldTree().then((res) => {
// this.loading = false;
// if (res.code == 200) {
// this.fileTree = [res.data];
// this.defaultExpandedKeys = id ? [id] : [this.fileTree[0].id];
// } else {
// this.$message.error(res.message);
// }
// });
this.loading = true; this.loading = true;
getFoldTree().then((res) => { // 通过当前路由判断传入参数
const { pathname } = window.location;
let path = "/我的创作";
if (pathname.includes("myCreate")) {
path = "/我的创作";
} else if (pathname.includes("myTemplate")) {
path = "/我的模板";
} else if (pathname.includes("myCollect")) {
path = "/我的收藏";
} else if (pathname.includes("myNote")) {
path = "/我的笔记";
} else if (pathname.includes("myShare")) {
path = "/我的共享";
}
this.targetPath = path;
const params = { path };
getFoldTreeByPath(params).then((res) => {
this.loading = false; this.loading = false;
if (res.code == 200) { if (res.code == 200) {
this.fileTree = [res.data]; this.fileTree = res.data.children; //隐藏掉根目录
this.defaultExpandedKeys = id ? [id] : [this.fileTree[0].id]; this.defaultExpandedKeys = id ? [id] : [this.fileTree[0].id];
} else { } else {
this.$message.error(res.message); this.$message.error(res.message);
...@@ -135,7 +161,7 @@ export default { ...@@ -135,7 +161,7 @@ export default {
copyFile(data) copyFile(data)
.then((res) => { .then((res) => {
this.sureBtnLoading = false; this.sureBtnLoading = false;
if (res.success) { if (res.code == 200) {
this.$message.success("复制成功"); this.$message.success("复制成功");
this.visible = false; this.visible = false;
this.callback("confirm"); this.callback("confirm");
......
...@@ -100,7 +100,7 @@ export default { ...@@ -100,7 +100,7 @@ export default {
} }
} }
} }
if (res.success) { if (res.code == 200) {
this.sureBtnLoading = false; this.sureBtnLoading = false;
this.$message.success("删除成功"); this.$message.success("删除成功");
this.visible = false; this.visible = false;
......
...@@ -58,14 +58,19 @@ ...@@ -58,14 +58,19 @@
</template> </template>
<script> <script>
import { getFoldTree, moveFile, batchMoveFile } from "@/api/qwFile.js"; import {
getFoldTree,
getFoldTreeByPath,
moveFile,
batchMoveFile,
} from "@/api/qwFile.js";
export default { export default {
name: "MoveFileDialog", name: "MoveFileDialog",
data() { data() {
return { return {
visible: false, // 对话框是否可见 visible: false, // 对话框是否可见
targetPath: "/", // 目标路径 targetPath: "/我的创作", // 目标路径
fileTree: [], // 文件夹目录树 fileTree: [], // 文件夹目录树
loading: false, // 文件夹目录树 loading 状态 loading: false, // 文件夹目录树 loading 状态
defaultExpandedKeys: [], defaultExpandedKeys: [],
...@@ -86,15 +91,38 @@ export default { ...@@ -86,15 +91,38 @@ export default {
handleDialogOpen() { handleDialogOpen() {
this.initFileTree(); this.initFileTree();
}, },
getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return r[2];
return null;
},
/** /**
* 初始化文件目录树 * 初始化文件目录树
*/ */
initFileTree(id) { initFileTree(id) {
this.loading = true; this.loading = true;
getFoldTree().then((res) => { // 通过当前路由判断传入参数
const { pathname } = window.location;
let path = "/我的创作";
if (pathname.includes("myCreate")) {
path = "/我的创作";
} else if (pathname.includes("myTemplate")) {
path = "/我的模板";
} else if (pathname.includes("myCollect")) {
path = "/我的收藏";
} else if (pathname.includes("myNote")) {
path = "/我的笔记";
} else if (pathname.includes("myShare")) {
path = "/我的共享";
}
this.targetPath = path;
const params = { path };
getFoldTreeByPath(params).then((res) => {
this.loading = false; this.loading = false;
if (res.code == 200) { if (res.code == 200) {
this.fileTree = [res.data]; this.fileTree = res.data.children; //隐藏掉根目录
this.defaultExpandedKeys = id ? [id] : [this.fileTree[0].id]; this.defaultExpandedKeys = id ? [id] : [this.fileTree[0].id];
} else { } else {
this.$message.error(res.message); this.$message.error(res.message);
...@@ -141,7 +169,7 @@ export default { ...@@ -141,7 +169,7 @@ export default {
batchMoveFile(data) batchMoveFile(data)
.then((res) => { .then((res) => {
this.sureBtnLoading = false; this.sureBtnLoading = false;
if (res.success) { if (res.code == 200) {
this.$message.success("移动成功"); this.$message.success("移动成功");
this.visible = false; this.visible = false;
this.fileInfo = {}; this.fileInfo = {};
...@@ -162,7 +190,7 @@ export default { ...@@ -162,7 +190,7 @@ export default {
moveFile(data) moveFile(data)
.then((res) => { .then((res) => {
this.sureBtnLoading = false; this.sureBtnLoading = false;
if (res.success) { if (res.code == 200) {
this.$message.success("移动成功"); this.$message.success("移动成功");
this.visible = false; this.visible = false;
this.callback("confirm"); this.callback("confirm");
......
...@@ -34,7 +34,7 @@ export default { ...@@ -34,7 +34,7 @@ export default {
deleteBatchNum: this.deleteBatchNum, deleteBatchNum: this.deleteBatchNum,
filePath: this.filePath, filePath: this.filePath,
}).then((res) => { }).then((res) => {
if (res.success) { if (res.code == 200) {
this.$message.success("文件已还原"); this.$message.success("文件已还原");
this.visible = false; this.visible = false;
this.callback("confirm"); this.callback("confirm");
......
...@@ -135,7 +135,7 @@ export default { ...@@ -135,7 +135,7 @@ export default {
}) })
.then((res) => { .then((res) => {
this.sureBtnLoading = false; this.sureBtnLoading = false;
if (res.success) { if (res.code == 200) {
this.visible = false; this.visible = false;
this.$message.success("保存成功"); this.$message.success("保存成功");
} else { } else {
......
...@@ -274,9 +274,6 @@ export default { ...@@ -274,9 +274,6 @@ export default {
} else if (this.form.shareType == 2) { } else if (this.form.shareType == 2) {
this.form.shareTo = this.userIdsParams; this.form.shareTo = this.userIdsParams;
} }
// console.log("this.form.shareTo", this.form.shareTo);
// return;
this.sureBtnLoading = true; this.sureBtnLoading = true;
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
......
...@@ -155,7 +155,7 @@ export default { ...@@ -155,7 +155,7 @@ export default {
} }
unzipFile(reqData).then((res) => { unzipFile(reqData).then((res) => {
this.sureBtnLoading = false; this.sureBtnLoading = false;
if (res.success) { if (res.code == 200) {
this.$message.success("解压成功"); this.$message.success("解压成功");
this.visible = false; this.visible = false;
this.callback("confirm"); this.callback("confirm");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论