Quellcode durchsuchen

更新 disk 相关页面和接口

reghao vor 2 Jahren
Ursprung
Commit
ab0ee2f255
2 geänderte Dateien mit 44 neuen und 12 gelöschten Zeilen
  1. 5 0
      src/api/disk.js
  2. 39 12
      src/views/disk/FileList.vue

+ 5 - 0
src/api/disk.js

@@ -2,6 +2,7 @@ import { delete0, get, post } from '@/utils/request'
 
 const diskApi = {
   getFolderTreeApi: '/api/account/disk/folder/tree',
+  createFolderApi: '/api/account/disk/folder/add',
   addDiskFileApi: '/api/account/disk/file',
   deleteDiskFileApi: '/api/account/disk/file',
   getFileListApi: '/api/account/disk/list'
@@ -15,6 +16,10 @@ export function addDiskFile(jsonData) {
   return post(diskApi.addDiskFileApi, jsonData)
 }
 
+export function addDiskFolder(jsonData) {
+  return post(diskApi.createFolderApi, jsonData)
+}
+
 export function deleteDiskFile(fileIds) {
   return delete0(diskApi.addDiskFileApi, fileIds)
 }

+ 39 - 12
src/views/disk/FileList.vue

@@ -28,7 +28,7 @@
         <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
         <el-breadcrumb-item :to="{ path: '/1' }">图片</el-breadcrumb-item>
         <el-breadcrumb-item :to="{ path: '/1/2' }">照片</el-breadcrumb-item>
-        <el-breadcrumb-item v-text="this.$router.currentRoute.name"></el-breadcrumb-item>
+        <el-breadcrumb-item v-text="this.$router.currentRoute.name" />
       </el-breadcrumb>
       <el-table
         ref="multipleTable"
@@ -46,7 +46,8 @@
           width="400px"
         >
           <template slot-scope="scope">
-            <a :href="scope.row.filename" style="text-decoration-line: none" target="_blank">
+            <a href="javascript:void(0)" style="text-decoration-line: none" @click="handleFile(scope.row)">
+              <el-image :src="scope.row.icon" min-width="16" height="16" />
               <el-tooltip
                 :content="scope.row.filename"
                 raw-content
@@ -78,7 +79,7 @@
             <el-tag v-if="scope.row.fileType === 1000" :type="'warning'" disable-transitions>
               目录
             </el-tag>
-            <el-tag v-if="scope.row.fileType === 1001" :type="'warning'" disable-transitions>
+            <el-tag v-else-if="scope.row.fileType === 1001" :type="'warning'" disable-transitions>
               图片
             </el-tag>
             <el-tag v-else-if="scope.row.fileType === 1002" :type="'success'" disable-transitions>
@@ -133,14 +134,14 @@
     <el-dialog
       title="创建新目录"
       append-to-body
-      :visible.sync="newFolderDialog"
+      :visible.sync="createFolderDialog"
       width="30%"
       center
     >
-      <el-form ref="form" :model="newFolderForm">
+      <el-form ref="form" :model="createFolderForm">
         <el-form-item label="目录名">
           <el-input
-            v-model="newFolderForm.newFolderName"
+            v-model="createFolderForm.folderName"
             placeholder="新目录名"
             style="width: 70%; padding-right: 2px"
             clearable
@@ -149,7 +150,7 @@
         <el-form-item>
           <el-button
             type="primary"
-            @click.native="loginBtn"
+            @click="onCreateFolder"
           >创建</el-button>
         </el-form-item>
       </el-form>
@@ -158,7 +159,7 @@
 </template>
 
 <script>
-import { getFileList, deleteDiskFile } from '@/api/disk'
+import { getFileList, deleteDiskFile, addDiskFolder } from '@/api/disk'
 
 export default {
   name: 'FileList',
@@ -175,11 +176,13 @@ export default {
         fileType: '0',
         filename: null
       },
+      currentDir: '/',
       multipleSelection: [],
       parentDirs: ['图片', '照片', '2023'],
-      newFolderDialog: false,
-      newFolderForm: {
-        newFolderName: null
+      createFolderDialog: false,
+      createFolderForm: {
+        parent: null,
+        folderName: null
       }
     }
   },
@@ -290,8 +293,32 @@ export default {
         })
       })
     },
+    handleFile(item) {
+      const fileType = item.fileType
+      if (fileType === 1000) {
+        const filename = item.filename
+        console.log(filename)
+      } else {
+        const fileId = item.fileId
+        console.log(fileId)
+      }
+    },
     createNewFolder() {
-      this.newFolderDialog = true
+      this.createFolderDialog = true
+    },
+    onCreateFolder() {
+      this.createFolderForm.parent = this.currentDir
+      addDiskFolder(this.createFolderForm).then(resp => {
+        if (resp.code === 0) {
+          this.$router.go(0)
+        } else {
+          this.$notify({
+            message: resp.msg,
+            type: 'warning',
+            duration: 3000
+          })
+        }
+      })
     },
     move() {
       console.log('移动/复制文件')