import {
|
LightningElement,
|
wire,
|
api
|
} from 'lwc';
|
import {
|
CurrentPageReference
|
} from "lightning/navigation";
|
import {
|
CloseActionScreenEvent
|
} from 'lightning/actions';
|
import init from '@salesforce/apex/otherButtonRepairController.init';
|
import updateRepair from '@salesforce/apex/otherButtonRepairController.updateRepair';
|
import {
|
ShowToastEvent
|
} from 'lightning/platformShowToastEvent';
|
|
export default class LexOCSMNoToReportRepair extends LightningElement {
|
@api recordId;
|
str;
|
IsLoading = true;
|
Id;;
|
OCSMAdministrativeReportNumberC;
|
OCSMAdministrativeReportDateC;
|
AwareDateC;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback() {
|
console.log(this.recordId);
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
console.log(result);
|
if (result != null) {
|
this.IsLoading = false;
|
this.Id = result.Id;
|
this.OCSMAdministrativeReportNumberC = result.OCSMAdministrativeReportNumberC;
|
this.OCSMAdministrativeReportDateC = result.OCSMAdministrativeReportDateC;
|
this.AwareDateC = result.AwareDateC;
|
|
this.OCSMNoToReport();
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}).catch(error => {
|
console.log(error);
|
}).finally(() => {
|
|
});
|
}
|
|
// OCSM不要报告
|
OCSMNoToReport() {
|
if (!confirm("不要报告后无法撤回,是否继续?")) {
|
return;
|
}
|
|
if (this.OCSMAdministrativeReportNumberC != undefined ||
|
this.OCSMAdministrativeReportDateC != undefined) {
|
this.ShowToastEvent("已经报告的QIS,不可以点击OCSM不要报告。", "error")
|
// alert("已经报告的QIS,不可以点击OCSM不要报告。");
|
return;
|
}
|
|
if (this.AwareDateC != undefined) {
|
updateRepair({
|
recordId: this.Id
|
}).catch(error => {
|
if (error.body.pageErrors.length > 0) {
|
var errmsg = error.body.pageErrors[0].message.toString();
|
this.ShowToastEvent(errmsg.join("\n"), "error")
|
// alert(errmsg.join("\n"));
|
return;
|
}
|
})
|
window.location.reload();
|
} else {
|
this.ShowToastEvent("没有AwareDate或已经OCSM行政报告,请确认。", "error")
|
// alert("没有AwareDate或已经OCSM行政报告,请确认。");
|
return;
|
}
|
}
|
|
// 弹窗
|
ShowToastEvent(msg, type) {
|
const event = new ShowToastEvent({
|
title: '',
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}
|
}
|