From f75de810f3d85e4408f4d5be871daf1c3d1d9325 Mon Sep 17 00:00:00 2001
From: pyt <626651354@qq.com>
Date: 星期四, 20 三月 2025 16:31:55 +0800
Subject: [PATCH] Merge branch 'main' of http://120.76.84.145:10101/gitblit/r/H5/chongzhouResettle

---
 src/views/applicationBatchList/components/UploadDialog.vue |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/views/applicationBatchList/components/UploadDialog.vue b/src/views/applicationBatchList/components/UploadDialog.vue
index adb48ab..cf9fe71 100644
--- a/src/views/applicationBatchList/components/UploadDialog.vue
+++ b/src/views/applicationBatchList/components/UploadDialog.vue
@@ -17,11 +17,12 @@
           :auto-upload="false"
           :on-change="handleFileChange"
           :limit="1"
+          :accept="'.xlsx,.xls'"
         >
           <i class="el-icon-upload"></i>
           <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
           <div class="el-upload__tip" slot="tip">
-            支持扩展名:.doc .docx .xlsx .xls
+            支持扩展名:.xlsx .xls
           </div>
         </el-upload>
       </el-form-item>
@@ -51,12 +52,8 @@
         file: null
       },
       rules: {
-        batchNumber: [
-          { required: true, message: '请输入批次号', trigger: 'blur' }
-        ],
-        file: [
-          { required: true, message: '请选择上传文件', trigger: 'change' }
-        ]
+        batchNumber: [{ required: true, message: '请输入批次号', trigger: 'blur' }],
+        file: [ { required: true, message: '请选择上传文件', trigger: 'change' }]
       }
     }
   },
@@ -73,10 +70,17 @@
       this.form.batchNumber = '';
       this.form.file = null;
       this.$refs.uploadForm && this.$refs.uploadForm.resetFields();
+      this.dialogVisible = false;
     },
     handleFileChange(file) {
+      const isExcel = file.raw.type === 'application/vnd.ms-excel' || 
+                      file.raw.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
+      if (!isExcel) {
+        this.$message.error('只能上传Excel文件!');
+        this.form.file = null;
+        return;
+      }
       this.form.file = file.raw;
-      // 手动触发文件字段验证
       this.$refs.uploadForm.validateField('file');
     },
     submitUpload() {
@@ -85,15 +89,19 @@
           return;
         }
         
-        // 这里添加实际的上传逻辑
         const formData = new FormData();
-        formData.append('file', this.form.file);
-        // 模拟上传
-        this.$message.info('正在上传,请稍候...');
-        setTimeout(() => {
-          this.$emit('success');
-          this.handleClose();
-        }, 1000);
+        formData.append('file',this.form.file);
+        formData.append('batchNumber',this.form.batchNumber);
+        // console.log('22222222222222222',formData)
+        importBatch(formData)
+          .then(res => {
+            this.$message.success('导入成功');
+            this.$emit('success');
+            this.handleClose();
+          })
+          .catch(error => {
+            this.$message.error(error.message || '导入失败');
+          });
       });
     }
   }

--
Gitblit v1.7.1