unknown
2023-08-24 ddb0231ef7c5cf2bad9d3f1afc2f733674ad38a5
force-app/main/default/lwc/lexOCSMNoToReportRepair/lexOCSMNoToReportRepair.js
@@ -14,6 +14,7 @@
import {
    ShowToastEvent
} from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
export default class LexOCSMNoToReportRepair extends LightningElement {
    @api recordId;
@@ -42,52 +43,21 @@
        }).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;
        }
        this.handleConfirmClick("不要报告后无法撤回,是否继续?");
    }
    // 弹窗
@@ -99,4 +69,41 @@
        });
        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.OCSMAdministrativeReportNumberC != undefined ||
                this.OCSMAdministrativeReportDateC != undefined) {
                this.ShowToastEvent("已经报告的QIS,不可以点击OCSM不要报告。", "error");
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
            if (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;
                    }
                    window.location.reload();
                })
            } else {
                this.ShowToastEvent("没有AwareDate或已经OCSM行政报告,请确认。", "error");
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
        } else {
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
}