twysparks
2023-06-26 a8628cfe2640797ba9265e9be46c42430d9e7eba
force-app/main/default/lwc/lexCustomDelete/lexCustomDelete.js
@@ -15,6 +15,7 @@
import {
    ShowToastEvent
} from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
export default class LexCustomDelete extends LightningElement {
    @api recordId;
@@ -45,13 +46,10 @@
                this.userID = result.userID;
                this.CustomDelete();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
        }).finally(() => {
        });
        })
    }
    // 删除
@@ -62,24 +60,34 @@
            if (repList != null && repList.length > 0) {
                var rp = repList[0];
                if (rp.Status__c != "草案中" && rp.Status__c != "1.受理完毕(SAP待发送)" && rp.Status__c != "4.修理品返送阶段") {
                    this.ShowToastEvent("不是草案中,不能删除", "error")
                    this.ShowToastEvent("不是草案中,不能删除", "error");
                    this.dispatchEvent(new CloseActionScreenEvent());
                    return;
                } else if (rp.Status__c == "4.修理品返送阶段" && (rp.SAP_Transfer_time__c != undefined || rp.Repair_Ordered_Date__c != undefined)) {
                    this.ShowToastEvent("已经发送过SAP,不能删除", "error")
                    this.ShowToastEvent("已经发送过SAP,不能删除", "error");
                    this.dispatchEvent(new CloseActionScreenEvent());
                    return;
                } else if (this.userID.substring(0, 15) != rp.CreatedById.substring(0, 15) && this.userID.substring(0, 15) != rp.Acc_OwnerId__c.substring(0, 15) && this.userID.substring(0, 15) != rp.FSE_ownerid__c.substring(0, 15)) {
                    this.ShowToastEvent("不是所有人、创建人或FSE主负责人,不能删除", "error")
                    this.ShowToastEvent("不是所有人、创建人或FSE主负责人,不能删除", "error");
                    this.dispatchEvent(new CloseActionScreenEvent());
                    return;
                } else {
                    if (confirm("是否确定?")) {
                        deleteRepair({
                            rid: rp.Id
                        }).then(rtn => {
                            if (rtn == "OK") {
                                window.location.href = "/a0J/o";
                            } else {
                                alert(rtn);
                            }
                        })
                    }
                    this.handleConfirmClick("是否确定?");
                }
            }
        })
    }
    ll() {
        deleteRepair({
            rid: this.Id
        }).then(rtn => {
            if (rtn == "OK") {
                window.location.href = "/a0J/o";
            } else {
                this.ShowToastEvent(rtn, "error");
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
        })
    }
@@ -92,4 +100,18 @@
        });
        this.dispatchEvent(event);
    }
    async handleConfirmClick(msg) {
        const result = await LightningConfirm.open({
            message: msg,
            variant: 'headerless',
            label: 'this is the aria-label value'
        });
        if (result) {
            this.ll();
        } else {
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
}