KKbes
2023-04-13 87861ae5f1ed5456685f97f8a8e7625e47b9576d
force-app/main/default/lwc/lexCreateReportMaintenanceContract/lexCreateReportMaintenanceContract.js
New file
@@ -0,0 +1,69 @@
import {
    LightningElement,
    wire,
    api
} from 'lwc';
import {
    CurrentPageReference
} from "lightning/navigation";
import {
    CloseActionScreenEvent
} from 'lightning/actions';
import init from '@salesforce/apex/otherButtonMaintenanceContractCtl.init';
export default class LexCreateReportMaintenanceContract extends LightningElement {
    @api recordId;
    str;
    IsLoading = true;
    Id;
    RecordTypeDeveloperNameC;
    EstimateTargetC;
    @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.RecordTypeDeveloperNameC = result.RecordTypeDeveloperNameC;
                this.EstimateTargetC = result.EstimateTargetC;
                this.CreateReport();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
        }).finally(() => {
        });
    }
    // 制作报告书
    CreateReport() {
        var MaintenanceContractId = this.Id;
        var RecordTypeName = this.RecordTypeDeveloperNameC;
        var EstimateTarget = this.EstimateTargetC;
        var url = '';
        if (EstimateTarget == "经销商" && (RecordTypeName == "NewMaintenance_Contract" || RecordTypeName == "VM_Contract")) {
            url = "/apex/MoreMaintenanceContractPop?Id=" + MaintenanceContractId + "&RecordTypeName=" + RecordTypeName;
        } else {
            url = "http://powerbi.olympus.com.cn/Home/Login";
        }
        window.open(url, '_bank');
    }
}