import { LightningElement, track, wire, api } from 'lwc'; import { CloseActionScreenEvent } from 'lightning/actions'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { CurrentPageReference } from 'lightning/navigation'; import init from '@salesforce/apex/LexRentalApplyFaultController.init'; import updateRentalApplyFaultStatus from '@salesforce/apex/LexRentalApplyFaultController.updateRentalApplyFaultStatus'; export default class lexFeedbackReport extends LightningElement { @api recordId; @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(res=>{ if(res){ if(res.status__c!='已发送'){ this.showToast('只有已发送的检测分析报告才能发送','warning'); return; } updateRentalApplyFaultStatus({ recordId: this.recordId, updateStatus: '已反馈' }).then(result=>{ if(result=='SUCCESS'){ this.showToast('报告已反馈','success'); }else{ this.showToast(res,'error'); } }) }else{ this.showToast('未查询到数据','warning'); } }) } showToast(msg,type) { const event = new ShowToastEvent({ message: msg, variant: type }); if(type == 'success'){ this.updateRecordView(); } this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } }