Kaynağa Gözat

fix: 为请托审批按钮添加加载状态并优化异步处理逻辑

liujt 6 ay önce
ebeveyn
işleme
6bfc268357

+ 23 - 10
src/views/bpm/handleTask/components/inspectionProjectRequest/submit.vue

@@ -19,6 +19,7 @@
     </el-form>
     <div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
       <el-button
+        :loading="loading"
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
@@ -27,6 +28,7 @@
       </el-button>
 
       <el-button
+        :loading="loading"
         icon="el-icon-circle-close"
         type="danger"
         size="mini"
@@ -66,7 +68,8 @@
       return {
         form:{
           reason:''
-        }
+        },
+        loading: false
       };
     },
     created() {},
@@ -80,7 +83,8 @@
         this.$emit('handleBackList');
       },
 
-      async handleAudit(status) {
+      handleAudit(status) {
+        this.loading = true;
         let API = !!status ? approveTaskWithVariables : rejectTask;
         API({
           id: this.taskId,
@@ -88,23 +92,32 @@
           variables: {
             pass: !!status
           }
-        });
-        this.$emit('handleAudit', {
-          status,
-          title: status === 0 ? '驳回' : ''
+        }).then((res) => {
+          if (res.data.code != '-1') {
+            this.$emit('handleAudit', {
+              status,
+              title: '驳回'
+            });
+          }
+          this.loading = false;
         });
       },
       rejectTask(status) {
+        this.loading = true;
         rejectTask({
           id: this.taskId,
           reason: this.form.reason,
           variables: {
             pass: !!status
           }
-        });
-        this.$emit('handleAudit', {
-          status,
-          title: status === 0 ? '驳回' : ''
+        }).then((res) => {
+          if (res.data.code != '-1') {
+            this.$emit('handleAudit', {
+              status,
+              title: status === 0 ? '驳回' : ''
+            });
+          }
+          this.loading = false;
         });
       },