import { LightningElement, wire, api } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { NavigationMixin } from 'lightning/navigation'; import init from '@salesforce/apex/otherButtonRepairController.init'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader' export default class LexAddress extends NavigationMixin(LightningElement) { @api recordId; str; IsLoading = true; Id; RecordTypeId; partArrangementCompleteC; RepairShippedDateC; @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; this.recordId = str; } } } connectedCallback() { Promise.all([ loadStyle(this, lwcCSS) ]); init({ recordId: this.recordId }).then(result => { console.log(result); if (result != null) { this.IsLoading = false; this.Id = result.Id; this.RecordTypeId = result.RecordTypeId; this.RepairShippedDateC = result.RepairShippedDateC; this.partArrangementCompleteC = result.partArrangementCompleteC; this.Address(); this.dispatchEvent(new CloseActionScreenEvent()); } }).catch(error => { console.log(error); }) } //直返收货地址 Address() { if (this.partArrangementCompleteC != undefined) { this.ShowToastEvent('零件已齐备完毕,直返收货地址不能修改!',"error") } else if (this.RepairShippedDateC != undefined) { this.ShowToastEvent('RC修理品已返送,直返收货地址不能修改!',"error") } else { // this[NavigationMixin.Navigate]({ // type: 'standard__webPage', // attributes: { // url:"/apex/StraightBackAddress?id=" + this.recordId // } // }); window.open("/apex/StraightBackAddress?id=" + this.recordId, '_self'); } } //弹框 ShowToastEvent(msg,type) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type }); this.dispatchEvent(event); }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode:'Sticky' }); this.dispatchEvent(event); } } }