twysparks
2023-06-26 a8628cfe2640797ba9265e9be46c42430d9e7eba
force-app/main/default/lwc/lexCreateNewServiceContract/lexCreateNewServiceContract.js
@@ -10,8 +10,14 @@
    CloseActionScreenEvent
} from 'lightning/actions';
import init from '@salesforce/apex/buttonAccountCtl.init';
import {
    NavigationMixin
} from 'lightning/navigation';
import {
    encodeDefaultFieldValues
} from 'lightning/pageReferenceUtils';
export default class LexCreateNewServiceContract extends LightningElement {
export default class LexCreateNewServiceContract extends NavigationMixin(LightningElement) {
    @api recordId;
    str;
    IsLoading = true;
@@ -57,21 +63,31 @@
    // 新建新服务合同   
    CreateNewServiceContract() {
        var Hospital = this.HospitalC;
        var Hospitalid = this.HospitalIdC;
        var Department = this.DepartmentClassC;
        var Departmentid = this.DepartmentClassIdC;
        var accountname = this.Name;
        var accountid = this.Id;
        const url = encodeDefaultFieldValues({
            Hospital__c: this.HospitalC,
            Department_Class__c: this.DepartmentClassC,
            Department__c: this.Id
        });
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Maintenance_Contract__c',
                actionName: 'new'
            },
            state: {
                nooverride: '1',
                defaultFieldValues: url
            }
        });
        this.dispatchEvent(new CloseActionScreenEvent());
        // var url = 'a0H/e?CF00N10000002Dx56=' + Hospital + '&CF00N10000002Dx56_lkid=' +
        //     Hospitalid + '&CF00N10000002Dx4p=' + Department + '&CF00N10000002Dx4p_lkid=' +
        //     Departmentid + '&CF00N10000002Dx4q=' + accountname + '&CF00N10000002Dx4q_lkid=' +
        //     accountid + '&RecordType=01210000000gTYq';
        var url = 'a0H/e?CF00N10000002Dx56=' + Hospital + '&CF00N10000002Dx56_lkid=' +
            Hospitalid + '&CF00N10000002Dx4p=' + Department + '&CF00N10000002Dx4p_lkid=' +
            Departmentid + '&CF00N10000002Dx4q=' + accountname + '&CF00N10000002Dx4q_lkid=' +
            accountid + '&RecordType=01210000000gTYq';
        //     console.log(url);
            console.log(url);
        window.top.location.href = url;
        // window.top.location.href = url;
    }
}