import { LightningElement , wire, api} from 'lwc'; import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import submitApply from '@salesforce/apex/AssetMaintainHeaderWebService.submitApply'; import applyPermission from '@salesforce/apex/AssetMaintainHeaderWebService.applyPermission'; export default class LexAssetMaintainHeaderSubmitApprovalProcess extends LightningElement { @api recordId; IsLoading = true; @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.log("str:"+str); this.recordId = str; } } } connectedCallback(){ applyPermission().then(res=>{ this.IsLoading = false; if(res=='false'){ this.showToast('没有提交申请的权限','error'); }else if(confirm('一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?')){ submitApply({ amhId: this.recordId }).then(result=>{ if(result=='1'){ this.showToast('已提交','success'); }else{ this.showToast(result,'error'); } }) }else{ this.IsLoading = false; this.showToast('已取消','error'); } }) } updateRecordView() { updateRecord({fields: { Id: this.recordId }}); } showToast(msg,type) { const event = new ShowToastEvent({ message: msg, variant: type }); if(type == 'success'){ this.updateRecordView(); } this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } }