zhangzhengmei
2023-08-05 d77b6353ca9b59a6398df3eae9912f9fd766946d
force-app/main/default/lwc/lexSubmitApprovalProcess/lexSubmitApprovalProcess.js
@@ -13,6 +13,7 @@
   @api recordId;
   transferApplyPermission;
   IsLoading=true;
   cancelResult;
   @wire(CurrentPageReference)
   getStateParameters(currentPageReference) {
@@ -35,15 +36,6 @@
      applyPermission().then(result => {
         console.log(result);
         this.transferApplyPermission = result;         
         this.cancelSubmit();
      }).catch( error =>{
         console.log(error);
      });
   }
   cancelSubmit(){
      if (this.transferApplyPermission == false) {
         this.showToast('','没有提交申请的权限','warning');
         this.IsLoading=false;
@@ -56,26 +48,59 @@
           }).then(cancel=>{
              if(cancel) {
                submitApply({taId:this.recordId}).then(submitRes=>{
                  if(submitRes == '1'){
                     this.showToast('','提交成功','success');
                   console.log(submitRes);
                   this.cancelResult = submitRes;
                  this.cancelSubmit().then(res=>{
                     this.IsLoading=false;
                     this.dispatchEvent(new CloseActionScreenEvent());
                  });
               }).catch( error =>{
                  this.showToast("",submitRes,"error");
               });
               // this.IsLoading=false;
               // this.dispatchEvent(new CloseActionScreenEvent());
              } else{
                 this.IsLoading=false;
               this.dispatchEvent(new CloseActionScreenEvent());
              }
           });
      }
      }).catch( error =>{
         console.log(error);
      });
   }
    async cancelSubmit(){
       console.log(this.cancelResult);
      if(this.cancelResult == '1') {
         console.log(this.cancelResult);
         this.dispatchEvent(
            new ShowToastEvent({
                  message:'提交成功',
                  variant: "success"
              })
         );
                     setTimeout(function(){
                        window.location.href = window.location;
                     }, 1500 );
         }, 1500 )
                  }else{
                     this.showToast("",submitRes,"warning");
         this.dispatchEvent(
            new ShowToastEvent({
                  message:this.cancelResult,
                  variant: "warning"
              })
         );
         console.log("result:",this.cancelResult);
         // await this.showToast("",this.cancelResult,"warning");
                  }
                  
               });
               this.IsLoading=false;
               this.dispatchEvent(new CloseActionScreenEvent());
              } else{
                 this.IsLoading=false;
               this.dispatchEvent(new CloseActionScreenEvent());
              }
           });
      }
    }
    
    showToast(_title,_message,_variant) {