import { LightningElement, wire, api } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import init from '@salesforce/apex/buttonQISSCReportCtl.init'; import updateQISSCReport from '@salesforce/apex/buttonQISSCReportCtl.updateQISSCReport'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class LexSCSubmit extends LightningElement { @api recordId; str; IsLoading = true; Id; StatusC; @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.StatusC = result.StatusC; this.SCSubmit(); this.dispatchEvent(new CloseActionScreenEvent()); } }).catch(error => { console.log(error); }) } // 提交待审批 SCSubmit() { if (this.StatusC != '草案中') { this.ShowToastEvent("已经提交审批", "error") return; } if (!confirm("一旦OCM提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) { return; } updateQISSCReport({ QId: this.Id }).then(result => { console.log(result); if (result.length > 0) { var split = result.split(", "); alert(split[1]); } else { this.ShowToastEvent("已提交", "success") window.location.reload(); } }) } ShowToastEvent(msg, type) { const event = new ShowToastEvent({ title: '', message: msg, variant: type }); this.dispatchEvent(event); } }