浏览代码

按钮的上传加载状态

Reiskuchen 5 年之前
父节点
当前提交
679b0b55c2
共有 1 个文件被更改,包括 17 次插入8 次删除
  1. 17 8
      ys_vue/src/views/mold/moldDetail.vue

+ 17 - 8
ys_vue/src/views/mold/moldDetail.vue

@@ -86,7 +86,7 @@
 
             <!-- 上传 模具0 时 -->
             <el-dropdown trigger="click" style="float: right;" v-show="activeTab == 0 && update == 1">
-                <el-button size="mini" type="primary" :loading="uploading[0]">
+                <el-button size="mini" type="primary" :loading="uploading">
                     上传
                     <i class="el-icon-arrow-down el-icon--right"></i>
                 </el-button>
@@ -134,7 +134,7 @@
                 :limit="5"
                 style="float:right;"
             >
-                <el-button size="mini" type="primary" :loading="uploading[1]">上传</el-button>
+                <el-button size="mini" type="primary" :loading="uploading">上传</el-button>
             </el-upload>
 
             <!-- 更新4 -->
@@ -453,7 +453,7 @@
                 <div v-if="this.activeFileName != null">
                     申请单:<a :href="this.fileUrl" :download="this.activeFileName"><el-link type="primary">{{this.activeFileName}}</el-link></a>
                 </div>
-                </br>
+                <br>
                 <div v-if="this.fileUrl2 != null">
                     报废单:<a :href="this.fileUrl2" :download="this.fileUrl2Name"><el-link type="primary">{{this.fileUrl2Name}}</el-link></a>
                 </div>
@@ -462,7 +462,7 @@
                 <div v-if="this.part2dFile != null">
                     2D:<a :href="this.part2dFile.fileUrl" :download="this.part2dFile.fileName"><el-link type="primary">{{this.part2dFile.fileName}}</el-link></a>
                 </div>
-                </br>
+                <br>
                 <div v-if="this.part2dFile != null">
                     3D:<a :href="this.part3dFile.fileUrl" :download="this.part3dFile.fileName"><el-link type="primary">{{this.part3dFile.fileName}}</el-link></a>
                 </div>
@@ -488,7 +488,7 @@
                 </el-upload>
             </p>
             <span slot="footer" class="dialog-footer">
-                <el-button @click="discardUpload" :loading="uploading[3]">确定</el-button>
+                <el-button @click="discardUpload" :loading="uploading">确定</el-button>
             </span>
         </el-dialog>
 
@@ -496,10 +496,10 @@
         <el-dialog title="零件文档上传" v-if="centerDialog4Visible" :visible.sync="centerDialog4Visible" width="450px" :before-close="clearFileRecord2">
             <p style="color:#ccc;">文件命名规则:零件编号+2D/3D  如 LJ001+2D.dwg</p>
             <el-upload ref="upload4" action="uploadFile" :http-request="uploadPartFile" :show-file-list="true" :before-remove="beforeRemove" multiple>
-                <el-button size="small" type="primary" :loading="uploading[2]">上传</el-button>
+                <el-button size="small" type="primary" :loading="uploading">上传</el-button>
             </el-upload>
             <span slot="footer" class="dialog-footer">
-                <el-button @click="uploadFilePart">确定</el-button>
+                <el-button @click="uploadFilePart" :loading="uploading">确定</el-button>
             </span>
         </el-dialog>
 
@@ -602,7 +602,7 @@
                     name: "",
                     life: ""
                 },
-                uploading:[false, false, false, false],
+                uploading: false,
                 editParts: {
                     id: 0,
                     number: "",
@@ -1088,6 +1088,7 @@
 
             //文件上传
             uploadFile(params) {
+                this.uploading = true;
                 var fileObj = params.file;
                 var form = new FormData();
                 form.append("file", fileObj);
@@ -1111,12 +1112,14 @@
                             type: "error"
                         });
                     }
+                    this.uploading = false;
                 },
                 error => {
                     this.$message({
                         message: error,
                         type: "error"
                     });
+                    this.uploading = false;
                 });
             },
 
@@ -1336,6 +1339,7 @@
             },
 
             uploadFilePart() {
+                this.uploading = true;
                 var fileObj = this.files;
                 var form = new FormData();
                 for(var i in fileObj){
@@ -1358,6 +1362,7 @@
                             type: "error"
                         });
                     }
+                    this.uploading = false;
                 },
                 error => {
                     this.centerDialog4Visible = false;
@@ -1365,12 +1370,14 @@
                         message: error,
                         type: "error"
                     });
+                    this.uploading = false;
                 });
             },
 
             //报废文件上传
             discardUpload() {
                 if (this.files2[0] != null && this.files2[1] != null) {
+                    this.uploading = true;
                     var form = new FormData();  
                     form.append("file", this.files2[0]);
                     form.append("file2", this.files2[1]);
@@ -1395,12 +1402,14 @@
                                 type: "error"
                             });
                         }
+                        this.uploading = false;
                     },
                     error => {
                         this.$message({
                             message: error,
                             type: "error"
                         });
+                        this.uploading = false;
                     });
                 } else {
                     console.log(this.files2);