Browse Source

bug修复,不能上传.csv文件格式

chenrui 3 years ago
parent
commit
3ed4c361a4
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/components/UploadFile/index.vue

+ 9 - 2
src/components/UploadFile/index.vue

@@ -214,12 +214,19 @@ export default {
         return true
       }
       const isType = this.fileType.indexOf(file.type) >= 0 && file.type != ''
-      if (!isType) {
+      // 文件格式限制为.xls、.xlsx时,上传.csv文件的type为application/vnd.ms-excel,与.xls一致,无法限制,因此更改为:
+      if (!isType || file.name.indexOf('.csv')>=0) {
         if (tip != 0) {
           this.$message.error('请上传正确的格式!')
         }
-        return isType
+        return isType && !(file.name.indexOf('.csv')>=0)
       }
+      // if (!isType) {
+      //   if (tip != 0) {
+      //     this.$message.error('请上传正确的格式!')
+      //   }
+      //   return isType
+      // }
 
       // 文件大小
       const isLt2M = file.size / 1024 / 1024 < this.fileSize