瀏覽代碼

管理中心-我的素材-素材列表:删除文件夹功能(等接口)

任一存 2 年之前
父節點
當前提交
3ea51125e6

+ 9 - 5
packages/qjkankan-editor/src/api/index.js

@@ -500,13 +500,13 @@ export function uploadMaterial(data, ok, no, onProgress) {
 }
 
 /**
- * 删除素材
+ * 删除素材或文件夹
  * @param {*} data 
  * @param {*} ok 
  * @param {*} no 
  */
- export function delMaterial(data, ok, no) {
-    return http.postJson(`${URL_FILL}/manage/fodder/remove/${data}`, {}, ok, no)
+export function delMaterial(id, ok, no) {
+  return http.postJson(`${URL_FILL}/manage/fodder/remove/${id}`, {}, ok, no)
 }
 
 /**
@@ -515,8 +515,8 @@ export function uploadMaterial(data, ok, no, onProgress) {
  * @param {*} ok 
  * @param {*} no 
  */
- export function editMaterial(data, ok, no) {
-    return http.postJson(`${URL_FILL}/manage/fodder/update`, data, ok, no)
+export function editMaterial(data, ok, no) {
+  return http.postJson(`${URL_FILL}/manage/fodder/update`, data, ok, no)
 }
 
 /**
@@ -583,6 +583,10 @@ export function moveToFolder(list, targetId) {
   return http.postJson(`${URL_FILL}/manage/dir/move`, param)
 }
 
+export function delFolder(id) {
+  return http.postJson(`${URL_FILL}/manage/dir/move/${id}`)
+}
+
 /**
  * end of 文件夹相关
  */

+ 4 - 2
packages/qjkankan-editor/src/lang/_en.json

@@ -636,13 +636,15 @@
     "delete_material": "Delete material",
     "comfirm_delete_material": "Confirm to delete the material?",
 
+    "can_not_delete_folder_when_uploading": "正在上传素材,请不要删除文件夹。",
+    "delete_folder": "删除文件夹",
+    "comfirm_delete_folder": "确定要删除文件夹以及包含的素材吗?",
+
     "save_done": "Save successfully",
 
     "nothing_edit": "You haven't created any content yet",
     "at_least_one_scene": "At least one scene can be previewed. Please go to \"Scene Navigation\" to add",
     "exitVr": "Exit VR"
-
-
   },
   "personal_center": {
     "personal_center": "Personal Center",

+ 4 - 4
packages/qjkankan-editor/src/lang/_zh.json

@@ -639,16 +639,16 @@
 
     "delete_material": "删除素材",
     "comfirm_delete_material": "确定要删除素材吗?",
+
+    "can_not_delete_folder_when_uploading": "正在上传素材,请不要删除文件夹。",
+    "delete_folder": "删除文件夹",
+    "comfirm_delete_folder": "确定要删除文件夹以及包含的素材吗?",
     
     "save_done": "保存成功",
 
     "nothing_edit": "您还未创建任何内容哦",
     "at_least_one_scene": "至少添加一个场景才可预览,请前往“场景导航”添加",
     "exitVr": "退出VR模式"
-
-    
-
-
   },
   "personal_center": {
     "personal_center": "个人中心",

+ 85 - 45
packages/qjkankan-editor/src/views/material/audio/index.vue

@@ -311,53 +311,93 @@ export default {
       }
     },
     del(item) {
-      this.$confirm({
-        title: i18n.t("gather.delete_material"),
-        content: i18n.t("gather.comfirm_delete_material"),
-        okText: i18n.t("gather.delete"),
-        ok: () => {
-          delMaterial(item.id, () => {
-            this.$msg.success(i18n.t("gather.delete_success"));
-            this.isRequestingMoreData = true
-            const lastestUsedSearchKey = this.searchKey
-            getMaterialList(
-              {
-                dir: this.currentFolderId,
-                pageNum: this.list.length + 1,
-                pageSize: 1,
-                searchKey: this.searchKey,
-                type: TYPE,
-              },
-              (data) => {
-                const index = this.list.findIndex((eachItem) => {
-                  return eachItem.id === item.id
-                })
-                if (index >= 0) {
-                  this.list.splice(index, 1)
-                  const newData = data.data.list.map((i) => {
-                    i.fileSize = changeByteUnit(Number(i.fileSize));
-                    return i;
-                  });
-                  this.list = this.list.concat(newData)
-                  if (this.list.length === data.data.total) {
-                    this.hasMoreData = false
-                  }
-                  this.$bus.emit('deletedAudio') // 各个Audio组件需要重新初始化
-                } else {
-                  console.error('在素材列表里没找到要删除的那一项!');
+      if (item.type === 'dir') {
+        this.delFolder(item.id, (lastestUsedSearchKey) => {
+          getMaterialList(
+            {
+              dir: this.currentFolderId,
+              pageNum: this.list.length + 1,
+              pageSize: 1,
+              searchKey: this.searchKey,
+              type: TYPE,
+            },
+            (data) => {
+              const index = this.list.findIndex((eachItem) => {
+                return eachItem.id === item.id
+              })
+              if (index >= 0) {
+                this.list.splice(index, 1)
+                const newData = data.data.list.map((i) => {
+                  i.fileSize = changeByteUnit(Number(i.fileSize));
+                  return i;
+                });
+                this.list = this.list.concat(newData)
+                if (this.list.length === data.data.total) {
+                  this.hasMoreData = false
                 }
-
-                this.isRequestingMoreData = false
-                this.lastestUsedSearchKey = lastestUsedSearchKey
-              },
-              () => {
-                this.isRequestingMoreData = false
-                this.lastestUsedSearchKey = lastestUsedSearchKey
+                this.$bus.emit('deletedAudio') // 各个Audio组件需要重新初始化
+              } else {
+                console.error('在素材列表里没找到要删除的那一项!');
               }
-            )
-          });
-        },
-      });
+
+              this.isRequestingMoreData = false
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+            },
+            () => {
+              this.isRequestingMoreData = false
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+            }
+          )
+        })
+      } else {
+        this.$confirm({
+          title: i18n.t("gather.delete_material"),
+          content: i18n.t("gather.comfirm_delete_material"),
+          okText: i18n.t("gather.delete"),
+          ok: () => {
+            delMaterial(item.id, () => {
+              this.$msg.success(i18n.t("gather.delete_success"));
+              this.isRequestingMoreData = true
+              const lastestUsedSearchKey = this.searchKey
+              getMaterialList(
+                {
+                  dir: this.currentFolderId,
+                  pageNum: this.list.length + 1,
+                  pageSize: 1,
+                  searchKey: this.searchKey,
+                  type: TYPE,
+                },
+                (data) => {
+                  const index = this.list.findIndex((eachItem) => {
+                    return eachItem.id === item.id
+                  })
+                  if (index >= 0) {
+                    this.list.splice(index, 1)
+                    const newData = data.data.list.map((i) => {
+                      i.fileSize = changeByteUnit(Number(i.fileSize));
+                      return i;
+                    });
+                    this.list = this.list.concat(newData)
+                    if (this.list.length === data.data.total) {
+                      this.hasMoreData = false
+                    }
+                    this.$bus.emit('deletedAudio') // 各个Audio组件需要重新初始化
+                  } else {
+                    console.error('在素材列表里没找到要删除的那一项!');
+                  }
+
+                  this.isRequestingMoreData = false
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                },
+                () => {
+                  this.isRequestingMoreData = false
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                }
+              )
+            });
+          }
+        })
+      }
     },
     onFileChange(e) {
       e.files.forEach((eachFile, i) => {

+ 23 - 0
packages/qjkankan-editor/src/views/material/folderMixinFactory.js

@@ -8,6 +8,7 @@ import {
   createFolder as createFolderApi,
   renameFolder as renameFolderApi,
   moveToFolder,
+  delFolder,
 } from "@/api";
 import {i18n} from "@/lang"
 
@@ -171,6 +172,28 @@ export default function(materialType) {
           this.refreshListDebounced()
         })
       },
+      delFolder(id, onSuccess) {
+        if (this.uploadListForUI.length > 0) {
+          this.$confirm({
+            title: i18n.t('tips.title'),
+            content: i18n.t('gather.can_not_delete_folder_when_uploading'),
+          })
+        } else {
+          this.$confirm({
+            title: i18n.t("gather.delete_folder"),
+            content: i18n.t("gather.comfirm_delete_folder"),
+            okText: i18n.t("gather.delete"),
+            ok: () => {
+              delFolder(id, () => {
+                this.$msg.success(i18n.t("gather.delete_success"));
+                this.isRequestingMoreData = true
+                const lastestUsedSearchKey = this.searchKey
+                onSuccess(lastestUsedSearchKey)
+              });
+            },
+          })
+        }
+      },
       onClickPath(idx) {
         this.folderPath = this.folderPath.slice(0, idx + 1)
         this.selectedList = []

+ 90 - 47
packages/qjkankan-editor/src/views/material/image/index.vue

@@ -187,6 +187,7 @@ import {
   uploadMaterial,
   editMaterial,
   delMaterial,
+  delFolder,
   checkUserSize
 } from "@/api";
 
@@ -304,55 +305,97 @@ export default {
       }
     },
     del(item) {
-      this.$confirm({
-        title: i18n.t("gather.delete_material"),
-        content: i18n.t("gather.comfirm_delete_material"),
-        okText: i18n.t("gather.delete"),
-        ok: () => {
-          delMaterial(item.id, () => {
-            this.$msg.success(i18n.t("gather.delete_success"));
-            this.isRequestingMoreData = true
-            const lastestUsedSearchKey = this.searchKey
-            getMaterialList(
-              {
-                dirId: this.currentFolderId,
-                pageNum: this.list.length + 1,
-                pageSize: 1,
-                searchKey: this.searchKey,
-                type: TYPE,
-              },
-              (data) => {
-                const index = this.list.findIndex((eachItem) => {
-                  return eachItem.id === item.id
-                })
-                if (index >= 0) {
-                  this.list.splice(index, 1)
-                  const newData = data.data.list.map((i) => {
-                    i.fileSize = changeByteUnit(Number(i.fileSize));
-                    return i;
-                  });
-                  this.list = this.list.concat(newData)
-                  if (this.list.length === data.data.total) {
-                    this.hasMoreData = false
-                  }
-                  if (this.list.length === 0) {
-                    this.$refs['image-previewer'].onClickClose()
-                  }
-                } else {
-                  console.error('在素材列表里没找到要删除的那一项!');
+      if (item.type === 'dir') {
+        this.delFolder(item.id, (lastestUsedSearchKey) => {
+          getMaterialList(
+            {
+              dirId: this.currentFolderId,
+              pageNum: this.list.length + 1,
+              pageSize: 1,
+              searchKey: this.searchKey,
+              type: TYPE,
+            },
+            (data) => {
+              const index = this.list.findIndex((eachItem) => {
+                return eachItem.id === item.id
+              })
+              if (index >= 0) {
+                this.list.splice(index, 1)
+                const newData = data.data.list.map((i) => {
+                  i.fileSize = changeByteUnit(Number(i.fileSize));
+                  return i;
+                });
+                this.list = this.list.concat(newData)
+                if (this.list.length === data.data.total) {
+                  this.hasMoreData = false
                 }
-
-                this.isRequestingMoreData = false
-                this.lastestUsedSearchKey = lastestUsedSearchKey
-              },
-              () => {
-                this.isRequestingMoreData = false
-                this.lastestUsedSearchKey = lastestUsedSearchKey
+                if (this.list.length === 0) {
+                  this.$refs['image-previewer'].onClickClose()
+                }
+              } else {
+                console.error('在素材列表里没找到要删除的那一项!');
               }
-            )
-          });
-        },
-      });
+
+              this.isRequestingMoreData = false
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+            },
+            () => {
+              this.isRequestingMoreData = false
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+            }
+          )
+        })
+      } else {
+        this.$confirm({
+          title: i18n.t("gather.delete_material"),
+          content: i18n.t("gather.comfirm_delete_material"),
+          okText: i18n.t("gather.delete"),
+          ok: () => {
+            delMaterial(item.id, () => {
+              this.$msg.success(i18n.t("gather.delete_success"));
+              this.isRequestingMoreData = true
+              const lastestUsedSearchKey = this.searchKey
+              getMaterialList(
+                {
+                  dirId: this.currentFolderId,
+                  pageNum: this.list.length + 1,
+                  pageSize: 1,
+                  searchKey: this.searchKey,
+                  type: TYPE,
+                },
+                (data) => {
+                  const index = this.list.findIndex((eachItem) => {
+                    return eachItem.id === item.id
+                  })
+                  if (index >= 0) {
+                    this.list.splice(index, 1)
+                    const newData = data.data.list.map((i) => {
+                      i.fileSize = changeByteUnit(Number(i.fileSize));
+                      return i;
+                    });
+                    this.list = this.list.concat(newData)
+                    if (this.list.length === data.data.total) {
+                      this.hasMoreData = false
+                    }
+                    if (this.list.length === 0) {
+                      this.$refs['image-previewer'].onClickClose()
+                    }
+                  } else {
+                    console.error('在素材列表里没找到要删除的那一项!');
+                  }
+  
+                  this.isRequestingMoreData = false
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                },
+                () => {
+                  this.isRequestingMoreData = false
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                }
+              )
+            });
+          },
+        });
+      }
     },
     previewImage(targetItem) {
       const index = this.list.findIndex((eachItem) => {

+ 90 - 47
packages/qjkankan-editor/src/views/material/pano/index.vue

@@ -207,6 +207,7 @@ import {
   uploadMaterial,
   editMaterial,
   delMaterial,
+  delFolder,
   uploadCover,
   checkMStatus,
   checkUserSize
@@ -435,55 +436,97 @@ export default {
       }
     },
     del(item) {
-      this.$confirm({
-        title: i18n.t("gather.delete_material"),
-        content: i18n.t("gather.comfirm_delete_material"),
-        okText: i18n.t("gather.delete"),
-        ok: () => {
-          delMaterial(item.id, () => {
-            this.$msg.success(i18n.t("gather.delete_success"));
-            this.isRequestingMoreData = true
-            const lastestUsedSearchKey = this.searchKey
-            getMaterialList(
-              {
-                dir: this.currentFolderId,
-                pageNum: this.list.length + 1,
-                pageSize: 1,
-                searchKey: this.searchKey,
-                type: TYPE,
-              },
-              (data) => {
-                const index = this.list.findIndex((eachItem) => {
-                  return eachItem.id === item.id
-                })
-                if (index >= 0) {
-                  this.list.splice(index, 1)
-                  const newData = data.data.list.map((i) => {
-                    i.fileSize = changeByteUnit(Number(i.fileSize));
-                    return i;
-                  });
-                  this.list = this.list.concat(newData)
-                  if (this.list.length === data.data.total) {
-                    this.hasMoreData = false
-                  }
-                  if (this.list.length === 0) {
-                    this.$refs['image-previewer'].onClickClose()
-                  }
-                } else {
-                  console.error('在素材列表里没找到要删除的那一项!');
+      if (item.type === 'dir') {
+        this.delFolder(item.id, (lastestUsedSearchKey) => {
+          getMaterialList(
+            {
+              dir: this.currentFolderId,
+              pageNum: this.list.length + 1,
+              pageSize: 1,
+              searchKey: this.searchKey,
+              type: TYPE,
+            },
+            (data) => {
+              const index = this.list.findIndex((eachItem) => {
+                return eachItem.id === item.id
+              })
+              if (index >= 0) {
+                this.list.splice(index, 1)
+                const newData = data.data.list.map((i) => {
+                  i.fileSize = changeByteUnit(Number(i.fileSize));
+                  return i;
+                });
+                this.list = this.list.concat(newData)
+                if (this.list.length === data.data.total) {
+                  this.hasMoreData = false
                 }
-
-                this.isRequestingMoreData = false
-                this.lastestUsedSearchKey = lastestUsedSearchKey
-              },
-              () => {
-                this.isRequestingMoreData = false
-                this.lastestUsedSearchKey = lastestUsedSearchKey
+                if (this.list.length === 0) {
+                  this.$refs['image-previewer'].onClickClose()
+                }
+              } else {
+                console.error('在素材列表里没找到要删除的那一项!');
               }
-            )
-          });
-        },
-      });
+
+              this.isRequestingMoreData = false
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+            },
+            () => {
+              this.isRequestingMoreData = false
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+            }
+          )
+        })
+      } else {
+        this.$confirm({
+          title: i18n.t("gather.delete_material"),
+          content: i18n.t("gather.comfirm_delete_material"),
+          okText: i18n.t("gather.delete"),
+          ok: () => {
+            delMaterial(item.id, () => {
+              this.$msg.success(i18n.t("gather.delete_success"));
+              this.isRequestingMoreData = true
+              const lastestUsedSearchKey = this.searchKey
+              getMaterialList(
+                {
+                  dir: this.currentFolderId,
+                  pageNum: this.list.length + 1,
+                  pageSize: 1,
+                  searchKey: this.searchKey,
+                  type: TYPE,
+                },
+                (data) => {
+                  const index = this.list.findIndex((eachItem) => {
+                    return eachItem.id === item.id
+                  })
+                  if (index >= 0) {
+                    this.list.splice(index, 1)
+                    const newData = data.data.list.map((i) => {
+                      i.fileSize = changeByteUnit(Number(i.fileSize));
+                      return i;
+                    });
+                    this.list = this.list.concat(newData)
+                    if (this.list.length === data.data.total) {
+                      this.hasMoreData = false
+                    }
+                    if (this.list.length === 0) {
+                      this.$refs['image-previewer'].onClickClose()
+                    }
+                  } else {
+                    console.error('在素材列表里没找到要删除的那一项!');
+                  }
+
+                  this.isRequestingMoreData = false
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                },
+                () => {
+                  this.isRequestingMoreData = false
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                }
+              )
+            });
+          },
+        });
+      }
     },
     previewImage(targetItem) {
       const index = this.list.findIndex((eachItem) => {

+ 86 - 45
packages/qjkankan-editor/src/views/material/video/index.vue

@@ -190,6 +190,7 @@ import {
   uploadMaterial,
   editMaterial,
   delMaterial,
+  delFolder,
   checkUserSize
 } from "@/api";
 
@@ -314,53 +315,93 @@ export default {
       }
     },
     del(item) {
-      this.$confirm({
-        title: i18n.t("gather.delete_material"),
-        content: i18n.t("gather.comfirm_delete_material"),
-        okText: i18n.t("gather.delete"),
-        ok: () => {
-          delMaterial(item.id, () => {
-            this.$msg.success(i18n.t("gather.delete_success"));
-            this.isRequestingMoreData = true
-            const lastestUsedSearchKey = this.searchKey
-            getMaterialList(
-              {
-                dir: this.currentFolderId,
-                pageNum: this.list.length + 1,
-                pageSize: 1,
-                searchKey: this.searchKey,
-                type: TYPE,
-              },
-              (data) => {
-                const index = this.list.findIndex((eachItem) => {
-                  return eachItem.id === item.id
-                })
-                if (index >= 0) {
-                  this.list.splice(index, 1)
-                  const newData = data.data.list.map((i) => {
-                    i.fileSize = changeByteUnit(Number(i.fileSize));
-                    i.icon = i.ossPath + this.$videoImg;
-                    return i;
-                  });
-                  this.list = this.list.concat(newData)
-                  if (this.list.length === data.data.total) {
-                    this.hasMoreData = false
-                  }
-                } else {
-                  console.error('在素材列表里没找到要删除的那一项!');
+      if (item.type === 'dir') {
+        this.delFolder(item.id, (lastestUsedSearchKey) => {
+          getMaterialList(
+            {
+              dir: this.currentFolderId,
+              pageNum: this.list.length + 1,
+              pageSize: 1,
+              searchKey: this.searchKey,
+              type: TYPE,
+            },
+            (data) => {
+              const index = this.list.findIndex((eachItem) => {
+                return eachItem.id === item.id
+              })
+              if (index >= 0) {
+                this.list.splice(index, 1)
+                const newData = data.data.list.map((i) => {
+                  i.fileSize = changeByteUnit(Number(i.fileSize));
+                  i.icon = i.ossPath + this.$videoImg;
+                  return i;
+                });
+                this.list = this.list.concat(newData)
+                if (this.list.length === data.data.total) {
+                  this.hasMoreData = false
                 }
-
-                this.isRequestingMoreData = false
-                this.lastestUsedSearchKey = lastestUsedSearchKey
-              },
-              () => {
-                this.lastestUsedSearchKey = lastestUsedSearchKey
-                this.isRequestingMoreData = false
+              } else {
+                console.error('在素材列表里没找到要删除的那一项!');
               }
-            )
-          });
-        },
-      });
+
+              this.isRequestingMoreData = false
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+            },
+            () => {
+              this.lastestUsedSearchKey = lastestUsedSearchKey
+              this.isRequestingMoreData = false
+            }
+          )
+        })
+      } else {
+        this.$confirm({
+          title: i18n.t("gather.delete_material"),
+          content: i18n.t("gather.comfirm_delete_material"),
+          okText: i18n.t("gather.delete"),
+          ok: () => {
+            delMaterial(item.id, () => {
+              this.$msg.success(i18n.t("gather.delete_success"));
+              this.isRequestingMoreData = true
+              const lastestUsedSearchKey = this.searchKey
+              getMaterialList(
+                {
+                  dir: this.currentFolderId,
+                  pageNum: this.list.length + 1,
+                  pageSize: 1,
+                  searchKey: this.searchKey,
+                  type: TYPE,
+                },
+                (data) => {
+                  const index = this.list.findIndex((eachItem) => {
+                    return eachItem.id === item.id
+                  })
+                  if (index >= 0) {
+                    this.list.splice(index, 1)
+                    const newData = data.data.list.map((i) => {
+                      i.fileSize = changeByteUnit(Number(i.fileSize));
+                      i.icon = i.ossPath + this.$videoImg;
+                      return i;
+                    });
+                    this.list = this.list.concat(newData)
+                    if (this.list.length === data.data.total) {
+                      this.hasMoreData = false
+                    }
+                  } else {
+                    console.error('在素材列表里没找到要删除的那一项!');
+                  }
+
+                  this.isRequestingMoreData = false
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                },
+                () => {
+                  this.lastestUsedSearchKey = lastestUsedSearchKey
+                  this.isRequestingMoreData = false
+                }
+              )
+            });
+          },
+        });
+      }
     },
     onFileChange(e) {
       e.files.forEach((eachFile, i) => {