黄千龙
2023-08-09 626f3c3bb25e204568019e8d568e2d7547d1037a
force-app/main/default/lwc/lexRentalApplyDiscountApproval/lexRentalApplyDiscountApproval.js
@@ -11,12 +11,12 @@
} from 'lightning/actions';
import init from '@salesforce/apex/buttonRepairQuotationCtl.init';
import updateRepairQuotation03 from '@salesforce/apex/buttonRepairQuotationCtl.updateRepairQuotation03';
import initSelectProfile from '@salesforce/apex/buttonRepairQuotationCtl.initSelectProfile';
import {
    ShowToastEvent
} from 'lightning/platformShowToastEvent';
export default class LexRentalApplyDiscountApproval extends LightningElement {
export default class lexRentalApplyDiscountApproval extends LightningElement {
    @api recordId;
    str;
    IsLoading = true;
@@ -24,6 +24,7 @@
    RentalApplyDiscountStatusC;
    LoanerRepairSysC;
    profileId;
    profileName;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
@@ -49,8 +50,17 @@
                this.RentalApplyDiscountStatusC = result.RentalApplyDiscountStatusC;
                this.LoanerRepairSysC = result.LoanerRepairSysC;
                this.RentalApplyDiscountApproval();
                this.dispatchEvent(new CloseActionScreenEvent());
                initSelectProfile({
                    profileId: this.profileId
                }).then(result => {
                    console.log(result);
                    if (result != null) {
                        this.IsLoading = false;
                        this.profileName = result[0].Name;
                        this.RentalApplyDiscountApproval();
                    }
                })
            }
        }).catch(error => {
            console.log(error);
@@ -59,23 +69,23 @@
    // 备品减价申请   
    RentalApplyDiscountApproval() {
        var power = this.profileId;
        // 2B2_备品中心检测&仓库管理 00e10000000xnoY
        if (power != '00e10000000xnoY') {
        var power = this.profileName;
        if (power != '2B2_备品中心检测&仓库管理') {
            this.ShowToastEvent("对不起,您没有权限提交此申请!", "error");
            // alert('对不起,您没有权限提交此申请!');
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        var status = this.RentalApplyDiscountStatusC;
        if (status == '审批中') {
            this.ShowToastEvent("审批提交成功,当前正在审批请勿再提交!", "error");
            // alert("审批提交成功,当前正在审批请勿再提交!");
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        if (status == '批准') {
            this.ShowToastEvent("审批已批准,请勿再提交!", "error");
            // alert("审批已批准,请勿再提交!");
            this.dispatchEvent(new CloseActionScreenEvent());
            return;
        }
        if (status == '草案中' || status == undefined || status == '驳回') {
@@ -86,17 +96,20 @@
                    console.log(result);
                    if (result.length > 0) {
                        var split = result.split(", ");
                        alert("提交失败 " + split[1]);
                        this.ShowToastEvent("提交失败 " + split[1], "error");
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
                    }else{
                        this.ShowToastEvent("提交成功!", "success");
                        this.dispatchEvent(new CloseActionScreenEvent());
                    }
                })
            } else {
                this.ShowToastEvent("请先填写备品减价金额!", "error");
                // alert("请先填写备品减价金额!");
                this.ShowToastEvent("提交失败", "error");
                this.dispatchEvent(new CloseActionScreenEvent());
                return;
            }
        }
        location.reload();
    }
    // 弹窗