yumenghui
2023-08-11 d533f39b6fa798e238810d17e928dee75d5b1af7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import recordTypeId from '@salesforce/apex/toBatchOwnerController.TypeId';
 
export default class LexAssignTaskButtonAccount extends NavigationMixin(LightningElement) {
    @api recordId;
    IsLoading=true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        console.log(currentPageReference);
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                console.log('str');
                console.log(str);
                this.recordId=str;
            }
        }
    }
    connectedCallback(){
        recordTypeId().then(res => {
            const defaultValues = encodeDefaultFieldValues({
                account__c: this.recordId,
                taskStatus__c: '01 分配',
                taskDifferent__c: '上级分配任务'
            });
            this[NavigationMixin.Navigate]({
                type: 'standard__objectPage',
                attributes: {
                    objectApiName: 'task__c',
                    actionName: 'new'
                },
                state: {
                    nooverride: '1',
                    defaultFieldValues: defaultValues,
                    recordTypeId: res.recordTypeId
                }
            });
        }).catch(err => {
            console.log('err======>',err)
        })
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}