|
@@ -1,11 +1,13 @@
|
|
|
import crumbs from "@/components/crumbs";
|
|
|
|
|
|
-import { nodeIdList2nodeInfoListByNodeTree, preOrderTraversalSearch } from "@/utils/other.js";
|
|
|
import {
|
|
|
- getFolderTree,
|
|
|
-} from "@/api";
|
|
|
+ nodeIdList2nodeInfoListByNodeTree,
|
|
|
+ preOrderTraversalSearch,
|
|
|
+ debounce,
|
|
|
+} from "@/utils/other.js";
|
|
|
+import { getFolderTree } from "@/api";
|
|
|
|
|
|
-import {i18n} from "@/lang"
|
|
|
+import { i18n } from "@/lang";
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
@@ -15,76 +17,101 @@ export default {
|
|
|
return {
|
|
|
folderTree: null,
|
|
|
folderPath: [],
|
|
|
- }
|
|
|
+ };
|
|
|
},
|
|
|
computed: {
|
|
|
currentFolderId() {
|
|
|
- return this.folderPath[this.folderPath.length - 1]?.id
|
|
|
+ return this.folderPath[this.folderPath.length - 1]?.id;
|
|
|
},
|
|
|
},
|
|
|
methods: {
|
|
|
onClickPath(idx) {
|
|
|
- this.$emit('need-clear-filter')
|
|
|
- this.folderPath = this.folderPath.slice(0, idx + 1)
|
|
|
+ this.$emit("need-clear-filter");
|
|
|
+ this.folderPath = this.folderPath.slice(0, idx + 1);
|
|
|
},
|
|
|
- onClickFolder(folder) {
|
|
|
- if (this.materialType === '3D') {
|
|
|
+ onClickFolder: function (folder) {
|
|
|
+ if (this.materialType === "3D") {
|
|
|
// 搜索三维场景得不到匹配的文件夹,所以素材是三维场景时如果调用此方法,不会是因为点击了搜索结果中的文件夹,因此可以在当前路径基础上进行跳转。
|
|
|
+ const cam_list = ["kankan", "kanjian", "siweiSS", "siweiSG"];
|
|
|
+ let level = 0;
|
|
|
+ level =
|
|
|
+ folder.id === "root"
|
|
|
+ ? 0
|
|
|
+ : cam_list.includes(folder.id)
|
|
|
+ ? 1
|
|
|
+ : level < 2
|
|
|
+ ? 2
|
|
|
+ : level + 1;
|
|
|
+
|
|
|
this.folderPath.push({
|
|
|
name: folder.name,
|
|
|
- id: folder.id
|
|
|
- })
|
|
|
+ id: folder.id,
|
|
|
+ level: level,
|
|
|
+ });
|
|
|
} else {
|
|
|
getFolderTree({
|
|
|
type: this.currentMaterialType,
|
|
|
}).then((res) => {
|
|
|
- this.folderTree = res.data
|
|
|
- const targetPathIdList = folder.ancestors.split(',').map((item) => {
|
|
|
- return Number(item)
|
|
|
- })
|
|
|
- targetPathIdList.push(folder.id)
|
|
|
- this.folderPath = nodeIdList2nodeInfoListByNodeTree(targetPathIdList, this.folderTree)
|
|
|
- this.$emit('need-clear-filter')
|
|
|
- })
|
|
|
+ this.folderTree = res.data;
|
|
|
+ const targetPathIdList = folder.ancestors.split(",").map((item) => {
|
|
|
+ return Number(item);
|
|
|
+ });
|
|
|
+ targetPathIdList.push(folder.id);
|
|
|
+ this.folderPath = nodeIdList2nodeInfoListByNodeTree(
|
|
|
+ targetPathIdList,
|
|
|
+ this.folderTree
|
|
|
+ );
|
|
|
+ this.$emit("need-clear-filter");
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
onClickParentFolder(clickedItem) {
|
|
|
// 搜索三维场景得到的结果没有所在路径信息,所以不显示其父级目录也不提供点击跳转到父级目录的方法,因此素材是三维场景时不会调用此方法,因此此方法不许考虑三维场景这种特殊情况。
|
|
|
getFolderTree({
|
|
|
type: this.currentMaterialType,
|
|
|
}).then((res) => {
|
|
|
- this.folderTree = res.data
|
|
|
- if (clickedItem.type === 'dir') {
|
|
|
- const targetPathIdList = clickedItem.ancestors.split(',').map((item) => {
|
|
|
- return Number(item)
|
|
|
- })
|
|
|
- this.folderPath = nodeIdList2nodeInfoListByNodeTree(targetPathIdList, this.folderTree)
|
|
|
+ this.folderTree = res.data;
|
|
|
+ if (clickedItem.type === "dir") {
|
|
|
+ const targetPathIdList = clickedItem.ancestors
|
|
|
+ .split(",")
|
|
|
+ .map((item) => {
|
|
|
+ return Number(item);
|
|
|
+ });
|
|
|
+ this.folderPath = nodeIdList2nodeInfoListByNodeTree(
|
|
|
+ targetPathIdList,
|
|
|
+ this.folderTree
|
|
|
+ );
|
|
|
} else {
|
|
|
// 在folderTree里找到id等于clickedItem.dirId的那个文件夹,从而确定folderPath
|
|
|
- let targetNodePath = []
|
|
|
- preOrderTraversalSearch(this.folderTree, (node) => {
|
|
|
- if (node.id === clickedItem.dirId) {
|
|
|
- return true
|
|
|
- } else {
|
|
|
- return false
|
|
|
- }
|
|
|
- }, targetNodePath)
|
|
|
+ let targetNodePath = [];
|
|
|
+ preOrderTraversalSearch(
|
|
|
+ this.folderTree,
|
|
|
+ (node) => {
|
|
|
+ if (node.id === clickedItem.dirId) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ targetNodePath
|
|
|
+ );
|
|
|
this.folderPath = targetNodePath.map((item) => {
|
|
|
return {
|
|
|
name: item.name,
|
|
|
id: item.id,
|
|
|
- }
|
|
|
- })
|
|
|
+ };
|
|
|
+ });
|
|
|
}
|
|
|
- this.$emit('need-clear-filter')
|
|
|
- })
|
|
|
- }
|
|
|
+ this.$emit("need-clear-filter");
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
currentFolderId: {
|
|
|
handler: function (v1, v2) {
|
|
|
if (v2 !== undefined) {
|
|
|
- this.refreshMaterialList(this.currentMaterialType)
|
|
|
+ this.refreshMaterialList(this.currentMaterialType);
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@@ -92,7 +119,7 @@ export default {
|
|
|
created() {
|
|
|
this.folderPath.push({
|
|
|
name: i18n.t(`gather.${this.currentMaterialType}`),
|
|
|
- id: this.materialType === '3D' ? 'root' : 1,
|
|
|
- })
|
|
|
- }
|
|
|
-}
|
|
|
+ id: this.materialType === "3D" ? "root" : 1,
|
|
|
+ });
|
|
|
+ },
|
|
|
+};
|