unknown
2023-08-23 8749760be3e1ba64edd4ada506bdf628e5bee852
force-app/main/default/lwc/lexOCSMToReportRepair/lexOCSMToReportRepair.js
@@ -14,7 +14,7 @@
import {
    ShowToastEvent
} from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
export default class LexOCSMToReportRepair extends LightningElement {
    @api recordId;
@@ -42,13 +42,11 @@
        }).then(result => {
            console.log(result);
            if (result != null) {
                this.IsLoading = false;
                this.Id = result.Id;
                this.AwareDateC = result.AwareDateC;
                this.OCSMAdministrativeReportStatusC = result.OCSMAdministrativeReportStatusC;
                
                this.OCSMToReport();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
@@ -59,25 +57,7 @@
    // OCSM要报告
    OCSMToReport() {
        if (!confirm("报告后无法撤回,是否继续?")) {
            return;
        }
        if (this.OCSMAdministrativeReportStatusC == undefined && this.AwareDateC != undefined) {
            updateRepair({
                recordId: this.Id
            }).catch(error => {
                if (error.body.pageErrors.length > 0) {
                    // alert(messages.join("\n"));
                    var errmsg = error.body.pageErrors[0].message.toString();
                    this.ShowToastEvent(errmsg.join("\n"), "error")
                    return;
                }
            })
            window.location.reload();
        } else {
            this.ShowToastEvent("没有AwareDate或已经OCSM行政报告,请确认。", "error")
            return;
        }
        this.handleConfirmClick("报告后无法撤回,是否继续?");
    }
    // 弹窗
@@ -89,4 +69,35 @@
        });
        this.dispatchEvent(event);
    }
    async handleConfirmClick(msg) {
        const result = await LightningConfirm.open({
            message: msg,
            variant: 'headerless',
            label: 'this is the aria-label value'
        });
        if(result){
            if (this.OCSMAdministrativeReportStatusC == undefined && this.AwareDateC != undefined) {
                updateRepair({
                    recordId: this.Id
                }).then(result => {
                    console.log(result);
                    if (result.length > 0) {
                        var split = result.split(", ");
                        this.ShowToastEvent(split[1], "error");
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                    }
                    location.reload();
                })
            } else {
                this.ShowToastEvent("没有AwareDate或已经OCSM行政报告,请确认。", "error");
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
        }
        else{
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
}