import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import all_received_fse from '@salesforce/apex/ConsumApplyWebService.all_received_fse'; import { NavigationMixin } from 'lightning/navigation'; export default class LexAllReceivedBtns extends NavigationMixin(LightningElement) { @api raid; IsLoading = true; @wire(CurrentPageReference) getStateParameters(currentPageReference) { console.log(111); console.log(currentPageReference); if (currentPageReference) { const urlValue = currentPageReference.state.raid; if (urlValue) { let str = `${urlValue}`; console.log("str"); console.log(str); this.raid = str; } } } connectedCallback(){ this.IsLoading = false; this.submit() } showToast(msg,type) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type, }); this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode: 'sticky' }); this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } } updateRecordView(raid) { updateRecord({fields: { Id: raid }}); } submit(){ all_received_fse({caId:this.raid}) .then(res=>{ this.showToast(res,'error') if(res =='现场已全部收货'){ var url = '/'+this.raid; // window.location.href=url; const config = { type: 'standard__webPage', attributes: { url: url } }; this[NavigationMixin.Navigate](config); } }) .catch(e=>{ console.log(e) }) } }