Sfoglia il codice sorgente

王子文 生产日报 批量导入

wangggziwen 2 anni fa
parent
commit
8b6e6cf5d0

+ 2 - 2
master/src/main/java/com/ruoyi/project/production/controller/TDailyProductionReportController.java

@@ -64,8 +64,8 @@ public class TDailyProductionReportController extends BaseController
     @PostMapping("/importData")
     public AjaxResult importData(MultipartFile file) throws Exception
     {
-        String message = tDailyProductionReportService.importData(file);
-        return AjaxResult.success(message);
+        tDailyProductionReportService.importData(file);
+        return AjaxResult.success("文件上传成功!");
     }
 
     /**

+ 39 - 4
ui/src/views/production/daily/index.vue

@@ -2799,7 +2799,7 @@
     <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
       <el-upload
         ref="upload"
-        :limit="1"
+        :limit="31"
         accept=".xlsx, .xls"
         :headers="upload.headers"
         :action="upload.url + '?updateSupport=' + upload.updateSupport"
@@ -2808,7 +2808,11 @@
         :on-success="handleFileSuccess"
         :auto-upload="false"
         drag
-        multiple="true"
+        :file-list="fileList"
+        :multiple="true"
+        :show-file-list="true"
+        :on-change="handleChange"
+        :on-remove="handleRemove"
       >
         <i class="el-icon-upload"></i>
         <div class="el-upload__text">
@@ -2879,6 +2883,10 @@ export default {
   components: { Treeselect },
   data() {
     return {
+      fileList: [], // 上传文件列表
+      uploading: false,  // 是否正在上传文件
+
+
       // 选中的对比指标
       chemicalChosen: null,
       // 对比指标下拉框
@@ -4067,6 +4075,28 @@ export default {
   // },
   mixins: [echartMixins],
   methods: {
+    // 选择文件改变
+    handleChange(files, fileList) {
+      this.fileList = fileList
+    },
+    // 移除文件
+    handleRemove(file, fileList) {
+      this.fileList = fileList
+    },
+    // 上传文件
+    submitUpload() {
+      console.log('---> ', this.fileList)
+      this.isUploading = true
+      setTimeout(() => {
+        this.isUploading = false
+        this.fileList = []
+        this.$message({
+          message: '文件上传成功!',
+          type: 'success'
+        });
+      }, 5000)
+    },
+
     /** 校验用户输入是否为数字 */
     isNumberInput() {
       let flag = true;
@@ -4498,8 +4528,11 @@ export default {
     handleFileSuccess(response, file, fileList) {
       this.upload.open = false;
       this.upload.isUploading = false;
-      this.$refs.upload.clearFiles();
-      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
+      if (file == fileList[fileList.length - 1]) {
+        this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
+        // 清空上传文件列表,否则影响上传文件数限制判断
+        this.$refs.upload.clearFiles();
+      }
       this.getReport();
     },
     // 提交上传文件
@@ -4517,6 +4550,8 @@ export default {
   .triangle-top{
     height:8px;
     width:8px;
+
+
     border-color:transparent transparent black transparent;
     border-style:solid;
     border-width:8px;