import { LightningElement, wire, api } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import init from '@salesforce/apex/buttonQISReportCtl.init'; import updateOSHNogoods from '@salesforce/apex/buttonQISReportCtl.updateOSHNogoods'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class LexOSHNogoods extends LightningElement { @api recordId; str; IsLoading = true; Id; QISStatusC; userId; email; @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.QISStatusC = result.QISStatusC; this.userId = result.userId; this.email = result.email; this.OSHNogoods(); this.dispatchEvent(new CloseActionScreenEvent()); } }).catch(error => { console.log(error); }) } // 减价申请 OSHNogoods() { if (this.QISStatusC != 'OSH检测申请' && this.QISStatusC != '完毕') { this.ShowToastEvent("OSH已经收到实物", "error") // alert('OSH已经收到实物'); } else { updateOSHNogoods({ Id: this.Id, email: this.email, userId: this.userId }).then(result => { console.log(result); if (result.length > 0) { var split = result.split(", "); alert(split[1]); } location.reload(); }).catch(error => { console.log(error); }) } } // 弹窗 ShowToastEvent(msg, type) { const event = new ShowToastEvent({ title: '', message: msg, variant: type }); this.dispatchEvent(event); } }