|
@@ -1,7 +1,7 @@
|
|
import { http,getToken } from '../utils/request'
|
|
import { http,getToken } from '../utils/request'
|
|
import config from '../config'
|
|
import config from '../config'
|
|
import { $waiting } from "@/components/shared/loading";
|
|
import { $waiting } from "@/components/shared/loading";
|
|
-
|
|
|
|
|
|
+import { postOrderTraversal } from "@/utils/other.js";
|
|
|
|
|
|
const number = function() {
|
|
const number = function() {
|
|
return config.projectNum
|
|
return config.projectNum
|
|
@@ -519,9 +519,40 @@ export function uploadMaterial(data, ok, no, onProgress) {
|
|
return http.postJson(`${URL_FILL}/manage/fodder/update`, data, ok, no)
|
|
return http.postJson(`${URL_FILL}/manage/fodder/update`, data, ok, no)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 文件夹相关
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+function folderTreeSortRoutine(folderList) {
|
|
|
|
+ if (folderList.children) {
|
|
|
|
+ folderList.children.sort((a, b) => {
|
|
|
|
+ const createTimeA = new Date(a.createTime)
|
|
|
|
+ const createTimeB = new Date(b.createTime)
|
|
|
|
+ if (createTimeA.getTime() > createTimeB.getTime()) {
|
|
|
|
+ return -1
|
|
|
|
+ } else if (createTimeA.getTime() === createTimeB.getTime()) {
|
|
|
|
+ return 0
|
|
|
|
+ } else {
|
|
|
|
+ return 1
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// 获取目录结构
|
|
// 获取目录结构
|
|
-export function getFolderTree(data, ok, no) {
|
|
|
|
- return http.getJson(`${URL_FILL}/manage/dir/getTree/${data.type}`, {}, ok, no)
|
|
|
|
|
|
+export function getFolderTree(data) {
|
|
|
|
+ return http.getJson(`${URL_FILL}/manage/dir/getTree/${data.type}`).then((res) => {
|
|
|
|
+ if (res.code === 0 && Array.isArray(res.data)) {
|
|
|
|
+ const temp = {
|
|
|
|
+ name: '根目录',
|
|
|
|
+ id: 1,
|
|
|
|
+ children: res.data
|
|
|
|
+ }
|
|
|
|
+ res.data = temp
|
|
|
|
+ postOrderTraversal(res.data, folderTreeSortRoutine)
|
|
|
|
+ }
|
|
|
|
+ return res
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
// 素材库中新增文件夹
|
|
// 素材库中新增文件夹
|
|
@@ -534,6 +565,28 @@ export function renameFolder(data, ok, no) {
|
|
return http.postJson(`${URL_FILL}/manage/dir/save`, data, ok, no)
|
|
return http.postJson(`${URL_FILL}/manage/dir/save`, data, ok, no)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 移动素材或文件夹到一个文件夹
|
|
|
|
+export function moveToFolder(list, targetId) {
|
|
|
|
+ const param = {
|
|
|
|
+ dirIds: list.filter((item) => {
|
|
|
|
+ return item.type === 'dir'
|
|
|
|
+ }).map((item) => {
|
|
|
|
+ return item.id
|
|
|
|
+ }).join(','),
|
|
|
|
+ fodderIds: list.filter((item) => {
|
|
|
|
+ return item.type !== 'dir'
|
|
|
|
+ }).map((item) => {
|
|
|
|
+ return item.id
|
|
|
|
+ }).join(','),
|
|
|
|
+ parentId: targetId,
|
|
|
|
+ }
|
|
|
|
+ return http.postJson(`${URL_FILL}/manage/dir/move`, param)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * end of 文件夹相关
|
|
|
|
+ */
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 添加我的作品
|
|
* 添加我的作品
|
|
* @param {*} data
|
|
* @param {*} data
|