|
@@ -2,17 +2,7 @@
|
|
|
<div style="padding-right: 5px">
|
|
<div style="padding-right: 5px">
|
|
|
<el-row style="padding: 5px">
|
|
<el-row style="padding: 5px">
|
|
|
<el-dropdown style="padding-right: 5px">
|
|
<el-dropdown style="padding-right: 5px">
|
|
|
- <el-button size="small" type="primary" icon="el-icon-upload" round>上传</el-button>
|
|
|
|
|
- <el-dropdown-menu slot="dropdown">
|
|
|
|
|
- <el-dropdown-item
|
|
|
|
|
- icon="el-icon-files"
|
|
|
|
|
- @click.native="onUploadFile"
|
|
|
|
|
- >上传文件</el-dropdown-item>
|
|
|
|
|
- <el-dropdown-item
|
|
|
|
|
- icon="el-icon-folder"
|
|
|
|
|
- @click.native="onUploadFolder"
|
|
|
|
|
- >上传文件夹</el-dropdown-item>
|
|
|
|
|
- </el-dropdown-menu>
|
|
|
|
|
|
|
+ <el-button size="small" type="primary" icon="el-icon-upload" round @click="onClickUpload">上传</el-button>
|
|
|
</el-dropdown>
|
|
</el-dropdown>
|
|
|
<el-button size="small" type="primary" icon="el-icon-folder-add" round @click="onCreateFolder">新建文件夹</el-button>
|
|
<el-button size="small" type="primary" icon="el-icon-folder-add" round @click="onCreateFolder">新建文件夹</el-button>
|
|
|
<el-input
|
|
<el-input
|
|
@@ -84,6 +74,9 @@
|
|
|
label="修改时间"
|
|
label="修改时间"
|
|
|
/>
|
|
/>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
|
|
+ <div style="margin-top: 20px">
|
|
|
|
|
+ <el-button v-if="selectedTable.length !== 0" @click="addToAlbum">添加到相册</el-button>
|
|
|
|
|
+ </div>
|
|
|
<el-pagination
|
|
<el-pagination
|
|
|
background
|
|
background
|
|
|
:small="screenWidth <= 768"
|
|
:small="screenWidth <= 768"
|
|
@@ -99,7 +92,7 @@
|
|
|
|
|
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
:visible.sync="showPreviewDialog"
|
|
:visible.sync="showPreviewDialog"
|
|
|
- :before-close="handleClose"
|
|
|
|
|
|
|
+ :before-close="handlePreviewClose"
|
|
|
width="100%"
|
|
width="100%"
|
|
|
center
|
|
center
|
|
|
>
|
|
>
|
|
@@ -144,11 +137,73 @@
|
|
|
</div>
|
|
</div>
|
|
|
</el-card>
|
|
</el-card>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ :visible.sync="showCreateFolderDialog"
|
|
|
|
|
+ width="30%"
|
|
|
|
|
+ center
|
|
|
|
|
+ >
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <el-form ref="createFolderForm" :model="createFolderForm">
|
|
|
|
|
+ <el-form-item label="当前文件夹" label-width="120px" prop="title">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="createFolderForm.path"
|
|
|
|
|
+ style="margin-left: 5px"
|
|
|
|
|
+ readonly
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="新文件夹名" label-width="120px" prop="title">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="createFolderForm.folderName"
|
|
|
|
|
+ style="margin-left: 5px"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ plain
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
|
+ style="margin-left: 10px"
|
|
|
|
|
+ @click="createFolder"
|
|
|
|
|
+ >
|
|
|
|
|
+ 创建文件夹
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ :visible.sync="showUploadDialog"
|
|
|
|
|
+ :before-close="handleUploadClose"
|
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
|
+ width="50%"
|
|
|
|
|
+ center
|
|
|
|
|
+ >
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <uploader
|
|
|
|
|
+ v-if="options !== null"
|
|
|
|
|
+ class="uploader-example"
|
|
|
|
|
+ :options="options"
|
|
|
|
|
+ :auto-start="true"
|
|
|
|
|
+ @file-added="onFileAdded"
|
|
|
|
|
+ @file-success="onFileSuccess"
|
|
|
|
|
+ @file-progress="onFileProgress"
|
|
|
|
|
+ @file-error="onFileError"
|
|
|
|
|
+ >
|
|
|
|
|
+ <uploader-unsupport />
|
|
|
|
|
+ <uploader-drop>
|
|
|
|
|
+ <p>拖动文件到此处或</p>
|
|
|
|
|
+ <uploader-btn :attrs="attrs">选择文件</uploader-btn>
|
|
|
|
|
+ </uploader-drop>
|
|
|
|
|
+ <uploader-list />
|
|
|
|
|
+ </uploader>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { getDiskFile, getFileDetail } from '@/api/disk'
|
|
|
|
|
|
|
+import { addToAlbum, getAlbumKeyValues, getDiskChannelInfo, getDiskFile, getFileDetail } from '@/api/disk'
|
|
|
|
|
+import { hashFile } from '@/utils/functions'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'DiskFile',
|
|
name: 'DiskFile',
|
|
@@ -160,7 +215,7 @@ export default {
|
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
totalSize: 0,
|
|
totalSize: 0,
|
|
|
dataList: [],
|
|
dataList: [],
|
|
|
- // 所有文件的对话框被选中
|
|
|
|
|
|
|
+ // 对话框被选中的文件
|
|
|
selectedTable: [],
|
|
selectedTable: [],
|
|
|
inputData: '',
|
|
inputData: '',
|
|
|
showPreviewDialog: false,
|
|
showPreviewDialog: false,
|
|
@@ -176,8 +231,30 @@ export default {
|
|
|
queryForm: {
|
|
queryForm: {
|
|
|
pn: this.currentPage,
|
|
pn: this.currentPage,
|
|
|
path: '/',
|
|
path: '/',
|
|
|
- fileType: null,
|
|
|
|
|
- filename: null
|
|
|
|
|
|
|
+ fileType: null
|
|
|
|
|
+ },
|
|
|
|
|
+ // ****************************************************************************************************************
|
|
|
|
|
+ showCreateFolderDialog: false,
|
|
|
|
|
+ createFolderForm: {
|
|
|
|
|
+ path: '/',
|
|
|
|
|
+ folderName: null
|
|
|
|
|
+ },
|
|
|
|
|
+ // ****************************************************************************************************************
|
|
|
|
|
+ showAddToAlbumUploadDialog: false,
|
|
|
|
|
+ albumKeyValues: [],
|
|
|
|
|
+ // ****************************************************************************************************************
|
|
|
|
|
+ showUploadDialog: false,
|
|
|
|
|
+ options: {
|
|
|
|
|
+ target: '',
|
|
|
|
|
+ // 分块大小 10MB
|
|
|
|
|
+ chunkSize: 1024 * 1024 * 10,
|
|
|
|
|
+ // 失败自动重传次数
|
|
|
|
|
+ maxChunkRetries: 3,
|
|
|
|
|
+ fileParameterName: 'file',
|
|
|
|
|
+ testChunks: true
|
|
|
|
|
+ },
|
|
|
|
|
+ attrs: {
|
|
|
|
|
+ accept: '*'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -195,46 +272,121 @@ export default {
|
|
|
this.getData()
|
|
this.getData()
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- handleClose() {
|
|
|
|
|
- this.showPreviewDialog = false
|
|
|
|
|
- this.fileDetail = null
|
|
|
|
|
- this.fileType = 0
|
|
|
|
|
|
|
+ // ****************************************************************************************************************
|
|
|
|
|
+ onFileAdded(file) {
|
|
|
|
|
+ if (file.file.size > 1024 * 1024 * 1024 * 20) {
|
|
|
|
|
+ file.cancel()
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '文件应小于 20GB',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.setTitle(file.file.name)
|
|
|
|
|
+ this.processVideo(file.file)
|
|
|
|
|
+
|
|
|
|
|
+ file.pause()
|
|
|
|
|
+ hashFile(file.file).then(result => {
|
|
|
|
|
+ this.startUpload(result.sha256sum, file)
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
- handleCurrentChange(pageNumber) {
|
|
|
|
|
- this.currentPage = pageNumber
|
|
|
|
|
- this.queryForm.pn = this.currentPage
|
|
|
|
|
- this.getData()
|
|
|
|
|
- // 回到顶部
|
|
|
|
|
- scrollTo(0, 0)
|
|
|
|
|
|
|
+ startUpload(sha256sum, file) {
|
|
|
|
|
+ file.uniqueIdentifier = sha256sum
|
|
|
|
|
+ file.resume()
|
|
|
},
|
|
},
|
|
|
- getData() {
|
|
|
|
|
- getDiskFile(this.queryForm).then(resp => {
|
|
|
|
|
|
|
+ onFileProgress(rootFile, file, chunk) {
|
|
|
|
|
+ },
|
|
|
|
|
+ onFileSuccess(rootFile, file, response, chunk) {
|
|
|
|
|
+ const res = JSON.parse(response)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ const resData = res.data
|
|
|
|
|
+ this.form.videoFileId = resData.uploadId
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '视频已上传',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '视频文件上传失败',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ onFileError(rootFile, file, response, chunk) {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '视频文件上传错误',
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ handleUploadClose() {
|
|
|
|
|
+ this.showUploadDialog = false
|
|
|
|
|
+ },
|
|
|
|
|
+ onClickUpload() {
|
|
|
|
|
+ this.showUploadDialog = true
|
|
|
|
|
+ getDiskChannelInfo().then(resp => {
|
|
|
if (resp.code === 0) {
|
|
if (resp.code === 0) {
|
|
|
const respData = resp.data
|
|
const respData = resp.data
|
|
|
- this.pathList = respData.pathList
|
|
|
|
|
- this.dataList = respData.pageList.list
|
|
|
|
|
- this.totalSize = respData.pageList.totalSize
|
|
|
|
|
- if (this.pathList.length === 0) {
|
|
|
|
|
- this.pathList.push({ path: '/disk', name: '全部文件' })
|
|
|
|
|
|
|
+ this.form.channelCode = respData.channelCode
|
|
|
|
|
+ this.options = {
|
|
|
|
|
+ target: respData.ossUrl,
|
|
|
|
|
+ // 分块大小 10MB
|
|
|
|
|
+ chunkSize: 1024 * 1024 * 10,
|
|
|
|
|
+ // 失败自动重传次数
|
|
|
|
|
+ maxChunkRetries: 3,
|
|
|
|
|
+ fileParameterName: 'file',
|
|
|
|
|
+ testChunks: true,
|
|
|
|
|
+ // 服务器分片校验函数, 秒传及断点续传基础
|
|
|
|
|
+ checkChunkUploadedByResponse: function(chunk, message) {
|
|
|
|
|
+ const objMessage = JSON.parse(message)
|
|
|
|
|
+ const respData = objMessage.data
|
|
|
|
|
+ if (respData.skipUpload) {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ return (respData.uploaded || []).indexOf(chunk.offset + 1) >= 0
|
|
|
|
|
+ },
|
|
|
|
|
+ query: (file, chunk) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ channelCode: respData.channelCode,
|
|
|
|
|
+ multiparts: ''
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ Authorization: 'Bearer ' + respData.token
|
|
|
|
|
+ },
|
|
|
|
|
+ withCredentials: false
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ this.showUploadDialog = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: '获取 OSS 服务器地址失败, 暂时无法上传视频文件',
|
|
|
|
|
+ type: 'error',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '获取 OSS 服务器地址失败, 暂时无法上传视频文件',
|
|
|
|
|
+ message: error.message,
|
|
|
|
|
+ type: 'warning',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- // 处理表格被选中
|
|
|
|
|
- handleTableSectionChange(val) {
|
|
|
|
|
- this.selectedTable = val
|
|
|
|
|
- },
|
|
|
|
|
- onUploadFile() {
|
|
|
|
|
- this.$message.info('upload file')
|
|
|
|
|
- },
|
|
|
|
|
- onUploadFolder() {
|
|
|
|
|
- this.$message.info('upload folder')
|
|
|
|
|
- },
|
|
|
|
|
- onCreateFolder() {
|
|
|
|
|
- this.$message.info('create folder')
|
|
|
|
|
- },
|
|
|
|
|
- onSearchFile() {
|
|
|
|
|
- this.$message.info('search file')
|
|
|
|
|
|
|
+ // ****************************************************************************************************************
|
|
|
|
|
+ handlePreviewClose() {
|
|
|
|
|
+ this.showPreviewDialog = false
|
|
|
|
|
+ this.fileDetail = null
|
|
|
|
|
+ this.fileType = 0
|
|
|
},
|
|
},
|
|
|
onClickFilename(row) {
|
|
onClickFilename(row) {
|
|
|
this.fileType = row.fileType
|
|
this.fileType = row.fileType
|
|
@@ -259,6 +411,62 @@ export default {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
+ },
|
|
|
|
|
+ // ****************************************************************************************************************
|
|
|
|
|
+ onCreateFolder() {
|
|
|
|
|
+ this.showCreateFolderDialog = true
|
|
|
|
|
+ },
|
|
|
|
|
+ createFolder() {
|
|
|
|
|
+ console.log(this.createFolderForm)
|
|
|
|
|
+ this.showCreateFolderDialog = false
|
|
|
|
|
+ },
|
|
|
|
|
+ // ****************************************************************************************************************
|
|
|
|
|
+ handleCurrentChange(pageNumber) {
|
|
|
|
|
+ this.currentPage = pageNumber
|
|
|
|
|
+ this.queryForm.pn = this.currentPage
|
|
|
|
|
+ this.getData()
|
|
|
|
|
+ // 回到顶部
|
|
|
|
|
+ scrollTo(0, 0)
|
|
|
|
|
+ },
|
|
|
|
|
+ getData() {
|
|
|
|
|
+ getDiskFile(this.queryForm).then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ const respData = resp.data
|
|
|
|
|
+ const namePathList = respData.namePathList
|
|
|
|
|
+ const pageList = respData.pageList
|
|
|
|
|
+
|
|
|
|
|
+ this.dataList = pageList.list
|
|
|
|
|
+ this.totalSize = pageList.totalSize
|
|
|
|
|
+ if (this.pathList.length === 0) {
|
|
|
|
|
+ this.pathList.push({ path: '/disk', name: '全部文件' })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ for (const namePath of namePathList) {
|
|
|
|
|
+ this.pathList.push({ path: '/disk?path=' + namePath.path, name: namePath.name })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // 处理表格被选中
|
|
|
|
|
+ handleTableSectionChange(val) {
|
|
|
|
|
+ this.selectedTable = val
|
|
|
|
|
+ },
|
|
|
|
|
+ addToAlbum() {
|
|
|
|
|
+ this.$message.info('addToAlbum')
|
|
|
|
|
+ getAlbumKeyValues().then(resp => {
|
|
|
|
|
+ if (resp.code === 0) {
|
|
|
|
|
+ this.albumKeyValues = resp.data
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ console.log(this.selectedTable)
|
|
|
|
|
+ const jsonData = {}
|
|
|
|
|
+ addToAlbum(jsonData).then(resp => {
|
|
|
|
|
+ this.$message.info(resp.msg)
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ onSearchFile() {
|
|
|
|
|
+ this.$message.info('search file')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|