Ver código fonte

提交保存按钮增加防重复点击限制

jingshuyong 11 meses atrás
pai
commit
29c602cbc8

+ 25 - 8
src/views/salesServiceManagement/demandList/components/addDialog.vue

@@ -15,16 +15,28 @@
     <SubmitDialog ref="submitRef" @savExit="savExit" />
     <dispatchDialog ref="dispatchRef" @savExit="savExit" />
     <div slot="footer" class="footer">
-      <el-button type="primary" @click="submitAdd" v-if="type != 'view'"
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="submitAdd"
+        v-if="type != 'view'"
         >保存</el-button
       >
-      <el-button type="primary" @click="submit" v-if="type != 'view'"
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="submit"
+        v-if="type != 'view'"
         >提交</el-button
       >
-      <el-button type="primary" @click="dispatch" v-if="type != 'view'"
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="dispatch"
+        v-if="type != 'view'"
         >派单</el-button
       >
-      <el-button @click="handleClose">返回</el-button>
+      <el-button @click="handleClose" :loading="loading">返回</el-button>
     </div>
   </ele-modal>
 </template>
@@ -63,7 +75,8 @@
         addRepairNotesDialog: false,
         type: 'add',
         form: {},
-        demandList: []
+        demandList: [],
+        loading: false
       };
     },
     created() {
@@ -176,10 +189,10 @@
               return item;
             }),
             contactInfoVOS: data.contactInfoVOS,
-            associationType:data.associationType
+            associationType: data.associationType
           };
           // 如果选的销售订单并且 没有售后对象数据
-          if(pData.associationType == '2' && pData.productDetail.length == 0){
+          if (pData.associationType == '2' && pData.productDetail.length == 0) {
             delete pData.productDetail;
             pData.faultDetailList = data.faultDetailList;
           }
@@ -197,15 +210,19 @@
           if (!pData) {
             return;
           }
+          this.loading = true;
           let requestname =
             this.title === '新增' ? saveSalesDemand : updateSalesDemand;
           const res = await requestname(pData);
+          this.loading = false;
           if (res) {
             this.$message.success('操作成功!');
             this.$emit('refresh');
             this.handleClose();
           }
-        } catch (error) {}
+        } catch (error) {
+          this.loading = false;
+        }
       }
     }
   };

+ 21 - 5
src/views/salesServiceManagement/toDoList/components/addOrUpdateDialog.vue

@@ -186,14 +186,26 @@
       </el-tabs>
     </div>
     <template v-slot:footer>
-      <el-button @click="handleClose">取消</el-button>
-      <el-button type="primary" @click="save('')" v-if="type != 'view'"
+      <el-button @click="handleClose" :loading="loading">取消</el-button>
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="save('')"
+        v-if="type != 'view'"
         >保存</el-button
       >
-      <el-button type="primary" @click="save('派单')" v-if="type == 'edit'"
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="save('派单')"
+        v-if="type == 'edit'"
         >派单</el-button
       >
-      <el-button type="primary" @click="save('')" v-if="isDispatch"
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="save('')"
+        v-if="isDispatch"
         >派单</el-button
       >
     </template>
@@ -382,14 +394,18 @@
               // *** 新增参数
               let obj = this.infoData(data);
               this.addForm.salesDemandUpdatePO = obj;
+              this.loading = true;
               const res = await requestName(this.addForm);
+              this.loading = false;
               if (!res) return;
               this.$message.success('操作成功');
               this.visible = false;
               this.$emit('reload');
             }
           });
-        } catch (error) {}
+        } catch (error) {
+          this.loading = false;
+        }
       },
       // *** 需求信息参数
       infoData(data) {

+ 39 - 18
src/views/salesServiceManagement/workOrder/components/declarationDialog.vue

@@ -279,14 +279,22 @@
     </el-form>
 
     <div slot="footer" class="footer">
-      <el-button type="primary" @click="submitAdd" v-if="type != 'view'">{{
-        type == 'edit' ? '保存' : '报工'
-      }}</el-button>
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="submitAdd"
+        v-if="type != 'view'"
+        >{{ type == 'edit' ? '保存' : '报工' }}</el-button
+      >
 
-      <el-button type="primary" @click="saveAdd" v-if="type == 'report'"
+      <el-button
+        type="primary"
+        :loading="loading"
+        @click="saveAdd"
+        v-if="type == 'report'"
         >保存</el-button
       >
-      <el-button @click="handleClose">取消</el-button>
+      <el-button @click="handleClose" :loading="loading">取消</el-button>
     </div>
   </ele-modal>
 </template>
@@ -363,7 +371,8 @@
           dispatchUserName: '',
           dispatchTime: ''
         },
-        detailList: []
+        detailList: [],
+        loading: false
       };
     },
     created() {},
@@ -546,12 +555,18 @@
             // let api = this.type == 'edit' ? updateScheme : reportWorkingSalesWorkOrder;
             let api =
               type == 'edit' ? updateScheme : reportWorkingSalesWorkOrder;
-            await api(data).then((res) => {
-              if (!res) return;
-              this.$message.success('操作成功');
-              this.visibleDialog = false;
-              this.$emit('reload');
-            });
+            this.loading = true;
+            await api(data)
+              .then((res) => {
+                this.loading = false;
+                if (!res) return;
+                this.$message.success('操作成功');
+                this.visibleDialog = false;
+                this.$emit('reload');
+              })
+              .catch((err) => {
+                this.loading = false;
+              });
           } else {
             return false;
           }
@@ -597,12 +612,18 @@
               };
               data.accessoryApply = accessoryApply;
             }
-            await updateScheme(data).then((res) => {
-              if (!res) return;
-              this.$message.success('操作成功');
-              this.visibleDialog = false;
-              this.$emit('reload');
-            });
+            this.loading = true;
+            await updateScheme(data)
+              .then((res) => {
+                this.loading = false;
+                if (!res) return;
+                this.$message.success('操作成功');
+                this.visibleDialog = false;
+                this.$emit('reload');
+              })
+              .catch((err) => {
+                this.loading = false;
+              });
           }
         });
       },