Browse Source

YT-844: 可以提交不符合格式要求文件问题解决

intex
ljlong_2630 1 week ago
parent
commit
dd1390d6f6
  1. 14
      src/components/ImportForm/src/ImportFormOnlyAdd.vue

14
src/components/ImportForm/src/ImportFormOnlyAdd.vue

@ -223,7 +223,19 @@ const submitForm = async () => {
message.error('请上传文件')
return
}
file.value = fileList.value[0].name
//
const fileName = fileList.value[0].name
const fileExtension = fileName.substring(fileName.lastIndexOf('.')).toLowerCase()
const acceptedTypes = accept.value.split(',').map(type => type.toLowerCase())
//
if (!acceptedTypes.some(type => type === fileExtension || type === `.*${fileExtension}`)) {
message.error(`只能上传 ${accept.value} 格式的文件`)
return
}
file.value = fileName
//
uploadHeaders.value = {
Authorization: 'Bearer ' + getAccessToken(),

Loading…
Cancel
Save