123
chenjingwu
2024-04-11 d29f75b84fccd06917fb8e2c2ee70e9d76f868cd
force-app/main/default/lwc/lexOTHCreate/lexOTHCreate.js
@@ -1,3 +1,57 @@
import { LightningElement } from 'lwc';
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-06-29 15:55:05
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-06-30 11:28:58
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/lexAccountController.initForOTHCreateButton';
export default class LexOTHCreate extends LightningElement {}
export default class LexOTHCreate extends LightningElement {
    @api recordId;
    recordTypeId;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            console.log(currentPageReference);
        if (currentPageReference) {
          const urlValue = currentPageReference.state.recordId;
          if (urlValue) {
            let str = `${urlValue}`;
            console.log("str");
            console.log(str);
            this.recordId = str;
          }
        }
    }
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result=>{
            this.recordTypeId = result.recordTypeId;
            this.OTHCreate();
        });
    }
    OTHCreate(){
        const defaultValues = encodeDefaultFieldValues({
            Account__c: this.recordId
        });
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account_Number_of_case__c',
                actionName: 'new'
            },
            state: {
                nooverride: '1',
                defaultFieldValues: defaultValues,
                RecordTypeId: this.recordTypeId
            }
        });
    }
}