import { LightningElement,api, track, wire } from 'lwc'; import {CurrentPageReference} from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import getUserId from '@salesforce/apex/RentalApplyControllerLWT.getUserId'; import init from '@salesforce/apex/SelectSubstituteControllerLWT.initClearReturnDeliverySlipButton'; import updateRaescList from '@salesforce/apex/SelectSubstituteControllerLWT.updateRaescList'; import selectRacById from '@salesforce/apex/SelectSubstituteControllerLWT.selectRacById'; import selectRaesdcId from '@salesforce/apex/SelectSubstituteControllerLWT.selectRaesdcId'; import { loadScript } from 'lightning/platformResourceLoader'; import { submitForApproval } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class lexClearReturnDeliverySlip extends LightningElement { @api recordId; id; RentalApplyId; Status; IsLoading=true; @wire(CurrentPageReference) getStateParameters(currentPageReference){ console.log("进入页面"); console.log(currentPageReference); if(currentPageReference){ const urvalue=currentPageReference.state.recordId; if(urvalue){ let str=`${urvalue}`; console.log('str'); console.log(str); this.recordId=str; } } } connectedCallback(){ console.log(this.recordId); init({recordId:this.recordId}).then(result=>{ console.log(result); if(result!=null){ this.Rental_Apply_Equipment_Set__c=result; this.cancelSubmit().then(res=>{ this.IsLoading=false; this.dispatchEvent(new CloseActionScreenEvent()); }); } }).catch(err=>{ console.log("error:"); console.log(err); }).finally(()=>{ }); } async cancelSubmit(){ console.log("hhh1"); var raesId = this.recordId; console.log("hhh2"); var result = await selectRaesdcId({recordId:this.recordId}); console.log("hhh3"); var objs = result; if (objs.length< 1) { // alert('没有需要清空的一览明细'); const event = new ShowToastEvent({ title: '提示信息', message:'没有需要清空的一览明细' }); this.dispatchEvent(event); } else { console.log("hhh4"); var result; console.log("hhh5"); await updateRaescList({updateList:objs}) .then(res=>{ console.log(res); result=res; }); console.log("hhh6"); if (result.success==true) { console.log("hhh7"); // success // alert("回寄运输单信息已清空"); const event = new ShowToastEvent({ title: '提示信息', message:"回寄运输单信息已清空" }); this.dispatchEvent(event); setTimeout(function() { location.href = "/"+this.recordId; }, 100); } else { console.log("hhh8"); // alert("failed to update:" + result.errors.fields + " " + result[0].errors.message); const event = new ShowToastEvent({ title: '提示信息', message:"failed to update:" + result.errors.fields + " " + result[0].errors.message }); this.dispatchEvent(event); } } } }