附件浏览组件统一
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" :on-remove="handleRemoveFile2"
:show-file-list="true" :show-file-list="true"
:limit="1" :limit="1"
accept=".pdf"
:file-list="fileList" :file-list="fileList"
> >
<el-button <el-button
@ -265,6 +266,7 @@
:disabled="fileList.length > 0" :disabled="fileList.length > 0"
>{{ $t('common:button:upload') }}</el-button >{{ $t('common:button:upload') }}</el-button
> >
<span>{{ $t('system:tip:file:pdf') }}</span>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item :label="$t('system:Agreements:label:Remark')"> <el-form-item :label="$t('system:Agreements:label:Remark')">
@ -368,6 +370,7 @@ export default {
], ],
}, },
fileList: [], fileList: [],
accept: '.pdf',
} }
}, },
watch: { watch: {
@ -414,41 +417,66 @@ export default {
this.form.FilePath = null this.form.FilePath = null
this.fileList = [] this.fileList = []
}, },
beforeUpload() { beforeUpload(row) {
if (this.fileList.length > 0) { if (this.fileList.length > 0) {
this.$alert('最多只能传一个附件') this.$alert('最多只能传一个附件')
return return
} }
if (!this.checkFileSuffix(row.name)) {
this.$message.warning(`Must be in .pdf format`)
return false
}
}, },
handlePreview3(row) { handlePreview3(row) {
return this.$preview({
path: row.FilePath,
type: 'pdf',
title: row.FileName,
})
if (row.FilePath) { if (row.FilePath) {
window.open(this.OSSclientConfig.basePath + row.FilePath, '_blank') window.open(this.OSSclientConfig.basePath + row.FilePath, '_blank')
} }
}, },
handlePreview2(row, r2) { handlePreview2(row, r2) {
return this.$preview({
path: row.fullPath,
type: 'pdf',
title: row.FileName,
})
if (row.fullPath) { if (row.fullPath) {
window.open(this.OSSclientConfig.basePath + row.fullPath, '_blank') window.open(this.OSSclientConfig.basePath + row.fullPath, '_blank')
} }
}, },
async handleUploadFile(param) { checkFileSuffix(fileName) {
this.btnLoading = true var index = fileName.lastIndexOf('.')
var fileName = param.file.name var suffix = fileName.substring(index + 1, fileName.length)
let file = await this.fileToBlob(param.file) return (
let res = await this.OSSclient.put( this.accept.toLocaleLowerCase().search(suffix.toLocaleLowerCase()) === 1
`/SystemData/reviewer/${
this.form.FileType === 0 ? '既往阅片情况声明' : '入项资格确认书'
}/${this.doctorId}/${fileName}`,
file
) )
this.form.FileName = param.file.name },
this.form.FilePath = this.$getObjectName(res.url) async handleUploadFile(param) {
this.fileList[0] = { try {
name: this.$getObjectName(res.url), this.btnLoading = true
path: this.$getObjectName(res.url), var fileName = param.file.name
fullPath: this.$getObjectName(res.url), let file = await this.fileToBlob(param.file)
url: res.url, let res = await this.OSSclient.put(
`/SystemData/reviewer/${
this.form.FileType === 0 ? '既往阅片情况声明' : '入项资格确认书'
}/${this.doctorId}/${fileName}`,
file
)
this.form.FileName = param.file.name
this.form.FilePath = this.$getObjectName(res.url)
this.fileList[0] = {
name: this.$getObjectName(res.url),
path: this.$getObjectName(res.url),
fullPath: this.$getObjectName(res.url),
url: res.url,
}
this.btnLoading = false
} catch (err) {
console.log(err)
} }
this.btnLoading = false
}, },
handleCancle() { handleCancle() {
this.model_cfg.visible = false this.model_cfg.visible = false
@ -499,6 +527,12 @@ export default {
}) })
}, },
handlePreview(row) { handlePreview(row) {
console.log(row)
return this.$preview({
path: row.FullPath,
type: 'pdf',
title: row.FileName,
})
if (row.FullPath) { if (row.FullPath) {
window.open(this.OSSclientConfig.basePath + row.FullPath, '_blank') window.open(this.OSSclientConfig.basePath + row.FullPath, '_blank')
} }

View File

@ -107,6 +107,7 @@
:on-remove="handleRemoveFile2" :on-remove="handleRemoveFile2"
:show-file-list="true" :show-file-list="true"
:limit="1" :limit="1"
:accept="accept"
:file-list="fileList" :file-list="fileList"
> >
<el-button <el-button
@ -115,6 +116,7 @@
:disabled="fileList.length > 0" :disabled="fileList.length > 0"
>{{ $t('common:button:upload') }}</el-button >{{ $t('common:button:upload') }}</el-button
> >
<span>{{ $t('system:tip:file:pdf') }}</span>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item :label="$t('system:Agreements:label:Remark')"> <el-form-item :label="$t('system:Agreements:label:Remark')">
@ -226,6 +228,7 @@ export default {
], ],
}, },
fileList: [], fileList: [],
accept: '.pdf',
} }
}, },
watch: { watch: {
@ -285,19 +288,40 @@ export default {
this.form.FilePath = null this.form.FilePath = null
this.fileList = [] this.fileList = []
}, },
beforeUpload() { beforeUpload(row) {
if (this.fileList.length > 0) { if (this.fileList.length > 0) {
// this.$alert('') // this.$alert('')
this.$alert(this.$t('upload:rule:maxFile1')) this.$alert(this.$t('upload:rule:maxFile1'))
return 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) { handlePreview3(row) {
return this.$preview({
path: row.FilePath,
type: 'pdf',
title: row.FileName,
})
if (row.FilePath) { if (row.FilePath) {
window.open(this.OSSclientConfig.basePath + row.FilePath, '_blank') window.open(this.OSSclientConfig.basePath + row.FilePath, '_blank')
} }
}, },
handlePreview2(row, r2) { handlePreview2(row, r2) {
return this.$preview({
path: row.FullPath,
type: 'pdf',
title: row.FileName,
})
if (row.fullPath) { if (row.fullPath) {
window.open(this.OSSclientConfig.basePath + row.fullPath, '_blank') window.open(this.OSSclientConfig.basePath + row.fullPath, '_blank')
} }