|
@@ -50,18 +50,27 @@
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<el-breadcrumb-item :key="item.id" :to="{ path: `/docs/${item.id}/list` }">
|
|
|
- <span>{{ item.fileName }}</span>
|
|
|
+ <span>{{ item.fileName | crumbFormat }}</span>
|
|
|
</el-breadcrumb-item>
|
|
|
</template>
|
|
|
</template>
|
|
|
</el-breadcrumb>
|
|
|
<!-- 列表 -->
|
|
|
- <el-table :data="list" style="width: 100%" @selection-change="onSelectionChange">
|
|
|
+ <el-table
|
|
|
+ :data="list"
|
|
|
+ style="width: 100%"
|
|
|
+ :row-style="{ cursor: 'pointer' }"
|
|
|
+ @selection-change="onSelectionChange"
|
|
|
+ @row-dblclick="onRowClick"
|
|
|
+ >
|
|
|
<el-table-column type="selection" align="center" width="50" />
|
|
|
<el-table-column label="文件名">
|
|
|
<template slot-scope="{ row }">
|
|
|
<doc-icon v-if="!listLoading" :type="row.fileType" :src="row.screenshot" />
|
|
|
- <span class="file-name" @click.stop="onRowClick(row)">{{ row.fileName }}</span>
|
|
|
+ <span v-if="row.fileType === 'article'" class="file-name" @click.stop="onRowClick(row)">{{
|
|
|
+ row.fileName | fileNameFormat
|
|
|
+ }}</span>
|
|
|
+ <span v-else class="file-name" @click.stop="onRowClick(row)">{{ row.fileName }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="createTime" label="时间" width="160">
|
|
@@ -81,7 +90,7 @@
|
|
|
<el-dialog :title="editText" :visible.sync="editDialog" width="30%" :close-on-click-modal="false" @close="onCancel">
|
|
|
<el-form ref="ruleForm" :model="formData" :rules="rules" label-width="80">
|
|
|
<el-form-item prop="fileName" label="名称:">
|
|
|
- <el-input v-model="formData.fileName" placeholder="请输入文件名" />
|
|
|
+ <el-input v-model="formData.fileName" placeholder="请输入文件名" @keyup.enter.native="onSubmit" />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
@@ -96,9 +105,11 @@
|
|
|
<el-button icon="el-icon-arrow-right" :disabled="nextDisabled" size="mini" @click="currentIndex++" />
|
|
|
<el-table
|
|
|
:data="filterSameDir(moveCurrentDir.childList)"
|
|
|
+ :row-style="{ cursor: 'pointer' }"
|
|
|
style="width: 100%"
|
|
|
- height="300"
|
|
|
+ :height="300"
|
|
|
empty-text="该目录为空"
|
|
|
+ @row-dblclick="onMoveRowClick"
|
|
|
>
|
|
|
<el-table-column label="文件名">
|
|
|
<template slot-scope="{ row }">
|
|
@@ -139,9 +150,26 @@ export default {
|
|
|
size = Math.round(size / 1024)
|
|
|
if (size < 1024) return size + 'MB'
|
|
|
return Math.round(size / 1024) + 'GB'
|
|
|
+ },
|
|
|
+ crumbFormat(name) {
|
|
|
+ if (name.length < 12) return name
|
|
|
+ return name.substring(0, 10) + '…'
|
|
|
+ },
|
|
|
+ fileNameFormat(name) {
|
|
|
+ return name.replace(/(.+)(.txt$)/, (match, $1, $2) => {
|
|
|
+ return $1
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
+ const fileNameValidate = (rule, value, callback) => {
|
|
|
+ if (/[\\\/\[\]\|^%&',;=?$\x22]+/g.test(value)) {
|
|
|
+ callback(new Error("文件名不能包含|\/\\^%&',;=?$等特殊字符"))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return {
|
|
|
selectionList: [], // 选中列表
|
|
|
list: [],
|
|
@@ -154,13 +182,17 @@ export default {
|
|
|
fileId: ''
|
|
|
},
|
|
|
rules: {
|
|
|
- fileName: [{ required: true, message: '文件名不能为空', trigger: ['blur'] }]
|
|
|
+ fileName: [
|
|
|
+ { required: true, message: '文件名不能为空', trigger: ['blur'] },
|
|
|
+ { validator: fileNameValidate, trigger: ['blur'] }
|
|
|
+ ]
|
|
|
},
|
|
|
editType: '',
|
|
|
current: null,
|
|
|
crumbList: [],
|
|
|
currentDirStack: [],
|
|
|
- currentIndex: 0
|
|
|
+ currentIndex: 0,
|
|
|
+ message: null
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -189,7 +221,8 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
// 排除相同文件夹
|
|
|
- filterSameDir(dirList = []) {
|
|
|
+ filterSameDir(dirList) {
|
|
|
+ if (!dirList) dirList = []
|
|
|
return dirList.filter((item) => {
|
|
|
return !this.selectionList.find((file) => file.id === item.id)
|
|
|
})
|
|
@@ -253,7 +286,8 @@ export default {
|
|
|
try {
|
|
|
await saveFile(data)
|
|
|
this.fetchDocsList()
|
|
|
- this.$message.success('文件上传成功')
|
|
|
+ if (this.message) this.message.close()
|
|
|
+ this.message = this.$message.success('文件上传成功')
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
}
|
|
@@ -371,6 +405,7 @@ export default {
|
|
|
// 下载文件
|
|
|
async onDownload() {
|
|
|
const confirmText = '文件'
|
|
|
+ let fileName = '文件'
|
|
|
const filedIds = this.selectionList.map((file) => file.id).join(',')
|
|
|
const text = await this.$confirm(`确认下载所选${confirmText}?`, '提示', {
|
|
|
confirmButtonText: '确定',
|
|
@@ -391,16 +426,21 @@ export default {
|
|
|
let downUrl = ''
|
|
|
if (this.selectionList.length === 1) {
|
|
|
const target = this.selectionList[0]
|
|
|
+ fileName = target.fileName
|
|
|
if (target.packageType > 0) {
|
|
|
- downUrl = `${process.env.VUE_APP_BASE_API}/download/file?ossName=${target.ossName}&fileName=${target.fileName}`
|
|
|
+ downUrl = `${process.env.VUE_APP_BASE_API}/download/file?ossName=${
|
|
|
+ target.ossName
|
|
|
+ }&fileName=${encodeURIComponent(target.fileName)}`
|
|
|
} else {
|
|
|
- downUrl = `${process.env.VUE_APP_BASE_API}/database/path/package/zip?fileId=${target.id}&fileName=${target.fileName}`
|
|
|
+ downUrl = `${process.env.VUE_APP_BASE_API}/database/path/package/zip?fileId=${
|
|
|
+ target.id
|
|
|
+ }&fileName=${encodeURIComponent(target.fileName)}`
|
|
|
}
|
|
|
} else {
|
|
|
// 使用a链接下载
|
|
|
downUrl = `${process.env.VUE_APP_BASE_API}/database/path/chose/zip?fileId=${filedIds}`
|
|
|
}
|
|
|
- downloadWithUrl(downUrl, confirmText, {
|
|
|
+ downloadWithUrl(downUrl, fileName, {
|
|
|
headers: {
|
|
|
'X-Token': this.$store.getters.token
|
|
|
}
|
|
@@ -447,12 +487,17 @@ export default {
|
|
|
},
|
|
|
// 文件点击
|
|
|
onRowClick(row) {
|
|
|
- if (row.packageType === 1) {
|
|
|
+ if (row.fileType === 'article') {
|
|
|
+ // 文章
|
|
|
+ const url = `/docs/article-edit?parentId=${row.parentId}&articleId=${row.articleId}`
|
|
|
+ this.$router.push(url)
|
|
|
+ } else if (row.packageType === 1) {
|
|
|
// 其它文件
|
|
|
console.log('详情')
|
|
|
this.$router.push(`/docs/detail?id=${row.id}`)
|
|
|
} else {
|
|
|
this.$router.push(`/docs/${row.id}/list`)
|
|
|
+ this.$store.dispatch('tagsView/delView', this.$route)
|
|
|
}
|
|
|
},
|
|
|
// 移动位置点击
|