import { api, wire,LightningElement } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import init from '@salesforce/apex/ReportController.initForOCSMNoToReportButton'; import updateForOCSMNoToReportButton from '@salesforce/apex/ReportController.updateForOCSMNoToReportButton'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class LexOCSMNoToReportForReport extends LightningElement { @api recordId; IsLoading = true; OCSMAdministrativeReportNumber; OCSMAdministrativeReportDate; AwareDate; connectedCallback(){ init({ recordId: this.recordId }).then(result=>{ this.OCSMAdministrativeReportDate = result.OCSMAdministrativeReportDate; this.OCSMAdministrativeReportNumber = result.OCSMAdministrativeReportNumber; this.AwareDate = result.awareDate; this.noToReport(); }); } updateRecordView(recordId) { updateRecord({fields: { Id: recordId }}); } showToast(msg,type) { const event = new ShowToastEvent({ title: '', message: msg, variant: type }); this.dispatchEvent(event); } noToReport(){ if (!confirm("不要报告后无法撤回,是否继续?")) { this.dispatchEvent(new CloseActionScreenEvent()); return; } if(this.OCSMAdministrativeReportNumber != undefined || this.OCSMAdministrativeReportDate != undefined ){ this.showToast("已经报告的QIS,不可以点击OCSM不要报告。","error"); this.dispatchEvent(new CloseActionScreenEvent()); return; } if(this.AwareDate != undefined ){ updateForOCSMNoToReportButton({ recordId: this.recordId }).then(result=>{ this.showToast("OCSM不要报告成功","success"); this.updateRecordView(this.recordId); this.dispatchEvent(new CloseActionScreenEvent()); }); }else{ this.showToast("没有AwareDate或已经OCSM行政报告,请确认。","error"); this.dispatchEvent(new CloseActionScreenEvent()); return; } } }