buli
2023-05-23 07390e2fcb4adf27c928335bf27ae7939c5a80ad
force-app/main/default/lwc/lexCustomSubmit/lexCustomSubmit.js
@@ -6,6 +6,7 @@
import updateRaesc from '@salesforce/apex/SelectSubstituteControllerLWT.updateRaesc';
import selectRacById from '@salesforce/apex/SelectSubstituteControllerLWT.selectRacById';
import postponeCheck from '@salesforce/apex/SelectSubstituteControllerLWT.postponeCheck';
import submitApprovalRequest from '@salesforce/apex/SelectSubstituteControllerLWT.submitApprovalRequest';
import { loadScript } from 'lightning/platformResourceLoader';
import { submitForApproval } from 'lightning/uiRecordApi';
@@ -72,15 +73,16 @@
      }
      console.log("hhh2");
      let rtn;
      let d=-5;
      await postponeCheck({
         endDate:this.Rental_Apply_Equipment_Set__c.Rental_End_Date__c,
         d:-5
         i:d
      }).then(res=>{
         console.log(res);
         rtn=res;
      }).catch(err=>{
         console.log("err:",err.message);
      })
      });
      console.log(rtn);
      if (rtn != "OK") {
@@ -115,44 +117,28 @@
               message:result.errors[0].split(",")[1]
           });
           this.dispatchEvent(event);
           return;
      }
      console.log("hhh7");
      // let request = new sforce.ProcessSubmitRequest();
      // request.objectId = this.recordId;
      // let processResults = sforce.connection.process([request]);
      console.log("hhh8");
      // submitForApproval(this.Rental_Apply_Equipment_Set__c.Id).then(result => {
        //    console.log(result);
        //    if (processResults[0].errors != null) {
      //       alert(processResults[0].errors.message);
      //       return;
      //    }
      //    console.log("hhh9");
      //    window.location.reload();
        // })
        // .catch(error => {
        //   console.error('Error submitting record for approval:', error.message);
        // });
        // await submitForApproval(this.recordId);
       const fields = {}
       const recordInput = { fields };
      updateRecord({ fields: recordInput, recordId: this.recordId })
         .then(() => {
           console.log("更新成功");
         })
         .catch(error => {
            console.log(error.message);
            console.log(error);
            // alert(error.body.message);
         const event = new ShowToastEvent({
               title: '提示信息',
               message:error.body.message
           });
           this.dispatchEvent(event);
         return;
           // 处理异常情况
         });
        await submitApprovalRequest({recordId:this.recordId}).then(res=>{
           console.log(res);
           if(res!=null&&res!=''){
              const event = new ShowToastEvent({
                  title: '提示信息',
                  message:res
              });
              this.dispatchEvent(event);
            return;
           }else{
              const event = new ShowToastEvent({
                  title: '提示信息',
                  message:"更新成功"
              });
              this.dispatchEvent(event);
            return;
           }
        })
   }
}