|
@@ -1,6 +1,6 @@
|
|
|
<!-- 左侧文件夹结构 -->
|
|
|
<template>
|
|
|
- <div class="left-folder">
|
|
|
+ <div class="left-folder" v-loading="loading">
|
|
|
<el-scrollbar style="height: 100%">
|
|
|
<el-row style="padding: 6px 12px; margin-top: 10px">
|
|
|
<span style="font-size: 12px; color: #646c73">文件夹</span>
|
|
@@ -22,7 +22,6 @@
|
|
|
</li>
|
|
|
<li
|
|
|
class="folder-item"
|
|
|
- v-loading="loading"
|
|
|
:class="{ 'folder-select': folder.checked }"
|
|
|
v-for="folder in folderData"
|
|
|
:key="folder.id"
|
|
@@ -80,54 +79,27 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取文件夹数据
|
|
|
- async getFolderData(folderId) {
|
|
|
+ async getFolderData(folder) {
|
|
|
this.loading = true;
|
|
|
- const res = await folderQuery({});
|
|
|
+ const params = {
|
|
|
+ pageNumber: 1,
|
|
|
+ pageSize: 1000,
|
|
|
+ orders: "name asc, createTime desc"
|
|
|
+ }
|
|
|
+ const res = await folderQuery(params);
|
|
|
this.folderData = res.content.map((folder) => {
|
|
|
folder.updateName = folder.name;
|
|
|
folder.checked = false;
|
|
|
folder.showInput = false;
|
|
|
return folder;
|
|
|
});
|
|
|
- if (folderId) {
|
|
|
- // 如果参数传入文件夹Id,则选中对应的文件夹
|
|
|
- this.handleCheckFolder(folderId);
|
|
|
+ // 如果参数传入文件夹,则选中对应的文件夹,否则默认选中第一个文件夹
|
|
|
+ if (folder) {
|
|
|
+ // this.handleCheckFolder(folder);
|
|
|
+ } else {
|
|
|
+ this.handleCheckFolder(this.folderData[0].id);
|
|
|
}
|
|
|
this.loading = false;
|
|
|
- // setTimeout(() => {
|
|
|
- // const res = [
|
|
|
- // {
|
|
|
- // id: 1,
|
|
|
- // name: "能源系统",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // id: 2,
|
|
|
- // name: "排水系统",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // id: 3,
|
|
|
- // name: "消防水系统",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // id: 4,
|
|
|
- // name: "公共照明系统",
|
|
|
- // },
|
|
|
- // {
|
|
|
- // id: 5,
|
|
|
- // name: "暖通空调系统",
|
|
|
- // },
|
|
|
- // ];
|
|
|
- // this.folderData = res.map(folder => {
|
|
|
- // folder.updateName = folder.name;
|
|
|
- // folder.checked = false;
|
|
|
- // folder.showInput = false;
|
|
|
- // return folder
|
|
|
- // })
|
|
|
- // if (folderId) {// 如果参数传入文件夹Id,则选中对应的文件夹
|
|
|
- // this.handleCheckFolder(folderId)
|
|
|
- // }
|
|
|
- // this.loading = false;
|
|
|
- // }, 1000);
|
|
|
},
|
|
|
// 点击添加文件夹icon打开弹窗
|
|
|
handleShowAddFolder() {
|
|
@@ -147,9 +119,9 @@ export default {
|
|
|
) {
|
|
|
this.$message({ showClose: true, message: "您输入的文件夹已存在!" });
|
|
|
} else {
|
|
|
- const res = await folderCreate({content: [{name: this.folderName}]});
|
|
|
+ const res = await folderCreate({ content: [{ name: this.folderName }] });
|
|
|
if (res.result === "success" && res.entityList.length) {
|
|
|
- res.forEach(item => {
|
|
|
+ res.entityList.forEach((item) => {
|
|
|
this.folderData.unshift({
|
|
|
id: item.id,
|
|
|
name: item.name,
|
|
@@ -157,26 +129,13 @@ export default {
|
|
|
checked: false,
|
|
|
showInput: false,
|
|
|
});
|
|
|
- })
|
|
|
+ });
|
|
|
this.$message.success("添加文件夹成功!");
|
|
|
this.handleRevokeAddFolder();
|
|
|
this.handleCheckFolder(res.entityList[res.entityList.length - 1].id);
|
|
|
} else {
|
|
|
this.$message.error(res.message);
|
|
|
}
|
|
|
- // setTimeout(() => {
|
|
|
- // const folderId = Math.floor(Math.random() * 1000);
|
|
|
- // this.folderData.unshift({
|
|
|
- // id: folderId,
|
|
|
- // name: this.folderName,
|
|
|
- // updateName: this.folderName,
|
|
|
- // checked: false,
|
|
|
- // showInput: false,
|
|
|
- // });
|
|
|
- // this.$message.success("添加文件夹成功!");
|
|
|
- // this.handleRevokeAddFolder();
|
|
|
- // this.handleCheckFolder(folderId);
|
|
|
- // }, 1000);
|
|
|
}
|
|
|
},
|
|
|
// 撤销添加文件夹
|
|
@@ -227,21 +186,21 @@ export default {
|
|
|
) {
|
|
|
this.$message({ showClose: true, message: "您输入的文件夹已存在!" });
|
|
|
} else {
|
|
|
- const res = await folderUpdate({content: [{
|
|
|
- id: folder.id,
|
|
|
- name: folder.updateName
|
|
|
- }]});
|
|
|
- console.log(res)
|
|
|
- // if () {
|
|
|
-
|
|
|
- // } else {
|
|
|
-
|
|
|
- // }
|
|
|
- // setTimeout(() => {
|
|
|
- // folder.name = folder.updateName;
|
|
|
- // this.$message.success("文件夹重命名成功!");
|
|
|
- // folder.showInput = false;
|
|
|
- // }, 1000);
|
|
|
+ const res = await folderUpdate({
|
|
|
+ content: [
|
|
|
+ {
|
|
|
+ id: folder.id,
|
|
|
+ name: folder.updateName,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ if (res.result === "success") {
|
|
|
+ folder.name = folder.updateName;
|
|
|
+ this.$message.success("文件夹重命名成功!");
|
|
|
+ folder.showInput = false;
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
// 撤销重命名
|
|
@@ -257,23 +216,18 @@ export default {
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning",
|
|
|
}).then(async () => {
|
|
|
- const res = await folderDelete([{id: this.rightClickFolder.id}]);
|
|
|
+ const res = await folderDelete([{ id: this.rightClickFolder.id }]);
|
|
|
if (res.result === "success") {
|
|
|
this.folderData.splice(
|
|
|
this.folderData.findIndex((item) => {
|
|
|
return item.id === this.rightClickFolder.id;
|
|
|
- }), 1);
|
|
|
+ }),
|
|
|
+ 1
|
|
|
+ );
|
|
|
this.$message.success("删除成功!");
|
|
|
} else {
|
|
|
this.$message.error(res.message);
|
|
|
}
|
|
|
- // setTimeout(() => {
|
|
|
- // this.folderData.splice(
|
|
|
- // this.folderData.findIndex((item) => {
|
|
|
- // return item.id === this.rightClickFolder.id;
|
|
|
- // }), 1);
|
|
|
- // this.$message({ type: "success", message: "删除成功!" });
|
|
|
- // }, 1000);
|
|
|
});
|
|
|
}
|
|
|
},
|