import { LightningElement, track, wire, api } from 'lwc'; import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { updateRecord } from 'lightning/uiRecordApi'; import queueTop from '@salesforce/apex/ApplyJsCtl.queueTop'; export default class lexTopInQueue extends LightningElement { @api recordId; IsLoading = true; @wire(CurrentPageReference) getStateParameters(currentPageReference){ if(currentPageReference) { const urlValue = currentPageReference.state.recordId; if(urlValue) { let str = `${urlValue}`; this.recordId = str; } } } connectedCallback(){ queueTop({ applyId: this.recordId }).then(res=>{ this.IsLoading = false; if(res == 'Success'){ this.showToast('置顶成功','success'); return; }else{ this.showToast(res,'error'); return; } }).catch(err=>{ this.dispatchEvent(new CloseActionScreenEvent()); }) } showToast(msg,type) { const event = new ShowToastEvent({ message: msg, variant: type }); if(type == 'success'){ this.updateRecordView(this.recordId); } this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } updateRecordView(recordId) { updateRecord({fields: { Id: recordId }}); } }