添加日志功能
This commit is contained in:
@@ -6,15 +6,19 @@
|
||||
v-model:file-list="reportPath"
|
||||
ref="uploadRef"
|
||||
action=""
|
||||
accept=""
|
||||
:limit="1"
|
||||
accept=".xml"
|
||||
:on-exceed="handleExceed"
|
||||
:auto-upload="false"
|
||||
:on-remove="removeFile"
|
||||
:on-change="choose"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-button type="primary">上传文件</el-button>
|
||||
</template>
|
||||
<template #tip>
|
||||
<div>请上传xml文件</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -64,9 +68,37 @@ const open = (text: string, data?: any) => {
|
||||
form.id = data?.id
|
||||
form.filePath = data?.path
|
||||
}
|
||||
// 上传报告
|
||||
const uploadRef = ref()
|
||||
/**
|
||||
* 选择待上传文件
|
||||
*/
|
||||
const choose = (e: any) => {
|
||||
const file = e.raw
|
||||
if (!isValidFile(file)) {
|
||||
uploadRef.value!.clearFiles()
|
||||
form.filePath = []
|
||||
return
|
||||
}
|
||||
form.filePath.file = file
|
||||
}
|
||||
/**
|
||||
* 文件校验函数
|
||||
*/
|
||||
const isValidFile = (file: UploadRawFile) => {
|
||||
const validExtensions = ['.xml']
|
||||
const fileExtension = file.name.slice(((file.name.lastIndexOf('.') - 1) >>> 0) + 2)
|
||||
if (!validExtensions.includes(`.${fileExtension}`)) {
|
||||
ElMessage.error('文件类型不支持,请选择 .xml')
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
// 上传报告
|
||||
|
||||
const handleExceed: UploadProps['onExceed'] = files => {
|
||||
console.log('🚀 ~ files:', files)
|
||||
|
||||
uploadRef.value!.clearFiles()
|
||||
const file = files[0] as UploadRawFile
|
||||
file.uid = genFileId()
|
||||
@@ -89,8 +121,8 @@ const submit = async () => {
|
||||
form.fileName = res.data.fileName.split('.')[0]
|
||||
form.filePath = res.data.name
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (title.value == '新增icd文件') {
|
||||
await addIcdPath(form).then(res => {
|
||||
ElMessage.success('新增成功!')
|
||||
|
||||
Reference in New Issue
Block a user