附件浏览组件统一
continuous-integration/drone/push Build is passing Details

uat_us
wangxiaoshuang 2024-11-11 13:24:28 +08:00
parent 286ce9656c
commit 34267bc007
2 changed files with 77 additions and 19 deletions

View File

@ -257,6 +257,7 @@
:on-remove="handleRemoveFile2"
:show-file-list="true"
:limit="1"
accept=".pdf"
:file-list="fileList"
>
<el-button
@ -265,6 +266,7 @@
:disabled="fileList.length > 0"
>{{ $t('common:button:upload') }}</el-button
>
<span>{{ $t('system:tip:file:pdf') }}</span>
</el-upload>
</el-form-item>
<el-form-item :label="$t('system:Agreements:label:Remark')">
@ -368,6 +370,7 @@ export default {
],
},
fileList: [],
accept: '.pdf',
}
},
watch: {
@ -414,23 +417,45 @@ export default {
this.form.FilePath = null
this.fileList = []
},
beforeUpload() {
beforeUpload(row) {
if (this.fileList.length > 0) {
this.$alert('最多只能传一个附件')
return
}
if (!this.checkFileSuffix(row.name)) {
this.$message.warning(`Must be in .pdf format`)
return false
}
},
handlePreview3(row) {
return this.$preview({
path: row.FilePath,
type: 'pdf',
title: row.FileName,
})
if (row.FilePath) {
window.open(this.OSSclientConfig.basePath + row.FilePath, '_blank')
}
},
handlePreview2(row, r2) {
return this.$preview({
path: row.fullPath,
type: 'pdf',
title: row.FileName,
})
if (row.fullPath) {
window.open(this.OSSclientConfig.basePath + row.fullPath, '_blank')
}
},
checkFileSuffix(fileName) {
var index = fileName.lastIndexOf('.')
var suffix = fileName.substring(index + 1, fileName.length)
return (
this.accept.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) === 1
)
},
async handleUploadFile(param) {
try {
this.btnLoading = true
var fileName = param.file.name
let file = await this.fileToBlob(param.file)
@ -449,6 +474,9 @@ export default {
url: res.url,
}
this.btnLoading = false
} catch (err) {
console.log(err)
}
},
handleCancle() {
this.model_cfg.visible = false
@ -499,6 +527,12 @@ export default {
})
},
handlePreview(row) {
console.log(row)
return this.$preview({
path: row.FullPath,
type: 'pdf',
title: row.FileName,
})
if (row.FullPath) {
window.open(this.OSSclientConfig.basePath + row.FullPath, '_blank')
}

View File

@ -107,6 +107,7 @@
:on-remove="handleRemoveFile2"
:show-file-list="true"
:limit="1"
:accept="accept"
:file-list="fileList"
>
<el-button
@ -115,6 +116,7 @@
:disabled="fileList.length > 0"
>{{ $t('common:button:upload') }}</el-button
>
<span>{{ $t('system:tip:file:pdf') }}</span>
</el-upload>
</el-form-item>
<el-form-item :label="$t('system:Agreements:label:Remark')">
@ -226,6 +228,7 @@ export default {
],
},
fileList: [],
accept: '.pdf',
}
},
watch: {
@ -285,19 +288,40 @@ export default {
this.form.FilePath = null
this.fileList = []
},
beforeUpload() {
beforeUpload(row) {
if (this.fileList.length > 0) {
// this.$alert('')
this.$alert(this.$t('upload:rule:maxFile1'))
return
}
if (!this.checkFileSuffix(row.name)) {
this.$message.warning(`Must be in .pdf format`)
return false
}
},
checkFileSuffix(fileName) {
var index = fileName.lastIndexOf('.')
var suffix = fileName.substring(index + 1, fileName.length)
return (
this.accept.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) === 1
)
},
handlePreview3(row) {
return this.$preview({
path: row.FilePath,
type: 'pdf',
title: row.FileName,
})
if (row.FilePath) {
window.open(this.OSSclientConfig.basePath + row.FilePath, '_blank')
}
},
handlePreview2(row, r2) {
return this.$preview({
path: row.FullPath,
type: 'pdf',
title: row.FileName,
})
if (row.fullPath) {
window.open(this.OSSclientConfig.basePath + row.fullPath, '_blank')
}