twysparks
2023-06-26 a8628cfe2640797ba9265e9be46c42430d9e7eba
force-app/main/default/lwc/lexCreateRepairFromQIS/lexCreateRepairFromQIS.js
@@ -12,8 +12,17 @@
import init from '@salesforce/apex/buttonQISReportCtl.init';
import initUserName from '@salesforce/apex/buttonQISReportCtl.initUserName';
import selecctAccountByAccountId from '@salesforce/apex/buttonQISReportCtl.selecctAccountByAccountId';
import {
    NavigationMixin
} from 'lightning/navigation';
import {
    encodeDefaultFieldValues
} from 'lightning/pageReferenceUtils';
import {
    ShowToastEvent
} from 'lightning/platformShowToastEvent';
export default class LexCreateRepairFromQIS extends LightningElement {
export default class LexCreateRepairFromQIS extends NavigationMixin(LightningElement) {
    @api recordId;
    str;
    IsLoading = true;
@@ -55,7 +64,6 @@
        }).then(result => {
            console.log(result);
            if (result != null) {
                this.IsLoading = false;
                this.Id = result.Id;
                this.Name = result.Name;
                this.SourceOnCallId = result.SourceOnCallId == undefined ? "" : result.SourceOnCallId;
@@ -86,7 +94,6 @@
                    this.CreateRepairFromQIS();
                })
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
@@ -95,7 +102,6 @@
    //新建修理QIS   
    CreateRepairFromQIS() {
        console.log("开始");
        var newflag = false;
        if ((this.OCMJudgementC == '质量问题' && this.nextAction == '无偿维修' && this.SpecialFollow == '0') || (this.OCMJudgementC == '非质量问题' && this.nextAction == '无偿维修' && this.SpecialFollow == '1') || (this.OCMJudgementC == '非质量问题' && this.nextAction == '有偿维修' && this.SpecialFollow == '0') || (this.OCMJudgementC == '质量问题+非质量问题' && this.nextAction == '无偿维修' && this.SpecialFollow == '1') || (this.OCMJudgementC == '质量问题+非质量问题' && this.nextAction == '有偿维修+无偿维修' && this.SpecialFollow == '0')) {
            newflag = true;
@@ -110,6 +116,7 @@
                var Incharge_Staff = '';
                var Incharge_Staff_id = '';
                var Work_Location = '';
                if (List.length > 0) {
                if (List[0]['ParentId'] != null) {
                    RecordTypeId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
                    console.log(RecordTypeId);
@@ -171,12 +178,58 @@
                        Incharge_Staff_id = FSE_SP_Main_Leader__id;
                    }
                }
                }
                window.open("/a0J/e?CF00N10000002FIJU_lkid=" + this.SourceOnCallId + "&CF00N10000002FIJU=" + this.SourceOnCall + "&CF00N10000002FIJZ_lkid=" + this.Id + "&CF00N10000002FIJZ=" + this.Name + "&CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.Hospital + "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClass + "&CF00N10000002Dx5n_lkid=" + this.HospitalDepartmentId + "&CF00N10000002Dx5n=" + this.HospitalDepartment + "&CF00N10000002Dx1X_lkid=" + this.nonyushohinId + "&CF00N10000002Dx1X=" + this.nonyushohin + "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + "&00N10000002Dx5y=" + this.TrableOccurDaYCollect + "&00N10000006P6SM=" + encodeURI(Work_Location) + "&00N10000002FH86=" + this.sourceForRepair + "&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC + "&retURL=%2F" + this.Id);
                const url = encodeDefaultFieldValues({
                    On_Call_ID__c: this.SourceOnCall,
                    QIS_ID__c: this.Id,
                    Hospital__c: this.Hospital,
                    Department_Class__c: this.DepartmentClass,
                    Account__c: this.HospitalDepartment,
                    Delivered_Product__c: this.nonyushohin,
                    Incharge_Staff__c: Incharge_Staff_id,
                    Failure_Occurrence_Date__c: this.TrableOccurDaYCollect,
                    SalesOfficeCode_selection__c: encodeURI(Work_Location),
                    Repair_Source__c: this.sourceForRepair,
                    work_location_select__c: this.RepairSalesPointProvinceChinaC
                });
                this[NavigationMixin.Navigate]({
                    type: 'standard__objectPage',
                    attributes: {
                        objectApiName: 'Repair__c',
                        actionName: 'new'
                    },
                    state: {
                        nooverride: '1',
                        defaultFieldValues: url
                    }
                });
                this.dispatchEvent(new CloseActionScreenEvent());
                // window.open("/a0J/e?CF00N10000002FIJU_lkid=" + this.SourceOnCallId + "&CF00N10000002FIJU=" + this.SourceOnCall +
                // "&CF00N10000002FIJZ_lkid=" + this.Id + "&CF00N10000002FIJZ=" + this.Name +
                // "&CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.Hospital +
                // "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClass +
                // "&CF00N10000002Dx5n_lkid=" + this.HospitalDepartmentId + "&CF00N10000002Dx5n=" + this.HospitalDepartment +
                // "&CF00N10000002Dx1X_lkid=" + this.nonyushohinId + "&CF00N10000002Dx1X=" + this.nonyushohin +
                // "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff +
                // "&00N10000002Dx5y=" + this.TrableOccurDaYCollect + "&00N10000006P6SM=" + encodeURI(Work_Location) +
                // "&00N10000002FH86=" + this.sourceForRepair + "&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC +
                // "&retURL=%2F" + this.Id);
            })
        } else {
            alert("不能新建修理");
            this.ShowToastEvent("不能新建修理", "error");
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
    ShowToastEvent(msg, type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
    }
}