Browse Source

修改文件名判断bug

master
lihua 5 years ago
parent
commit
abcec44612
  1. 15
      src/views/material/warehouse/index.vue

15
src/views/material/warehouse/index.vue

@ -288,14 +288,15 @@ export default {
},
methods: {
beforeUpload(file) {
console.log(file)
const extension = file.name.split('.')[1] === 'xls'
const extension2 = file.name.split('.')[1] === 'xlsx'
if (!extension && !extension2) {
this.$message.error('上传文件只能是excel')
return false
const extension = file.name.split('.')
if (extension && extension.length > 1) {
const ext = extension[extension.length - 1]
if (ext === 'xlsx' || ext === 'xls') {
return true
}
}
return true
this.$message.error('上传文件只能是excel')
return false
},
uploadImportFile(file) {
uploadImport(file.file).then(response => {

Loading…
Cancel
Save