import { LightningElement, wire, api } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import init from '@salesforce/apex/buttonCampaignCtl.init'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class LexCreateInstructReport extends LightningElement { @api recordId; str; IsLoading = true; Id; Status; @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; this.recordId = str; } } } connectedCallback() { init({ recordId: this.recordId }).then(result => { console.log(result); if (result != null) { this.IsLoading = false; this.Id = result.Id; this.Status = result.Status; this.CreateInstructReport(); this.dispatchEvent(new CloseActionScreenEvent()); } }).catch(error => { console.log(error); }) } // 新建带教报告 CreateInstructReport() { var status = this.Status; if (status == '公开中') { window.open("/apex/InstructReport?camid="+this.Id, "_top"); } else { this.ShowToastEvent("只有批准后才能创建报告!", "error") // alert("只有批准后才能创建报告!"); } } ShowToastEvent(msg, type) { const event = new ShowToastEvent({ title: '', message: msg, variant: type }); this.dispatchEvent(event); } }