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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * @Author: zhangchunxu
 * @Date: 2023-07-19 13:22:53
 * @LastEditors: zhangchunxu
 * @LastEditTime: 2023-09-11 20:27:22
 * 
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference ,NavigationMixin} from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import  init  from '@salesforce/apex/NewLeadFromContact2.NewLeadFromContact2';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
 
export default class LexNewLeadFromContact2 extends NavigationMixin(LightningElement) {
    @api recordId;//当前这条数据的id
    id;//返回值的id  Tender_information__c招标项目的id
    IsLoading = true;
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
             let str = `${urlValue}`;
             this.recordId = str;
           }
         }
     }
     // 客户人员 新建购买意向  (意向 中的 “新建购买意向”)
     connectedCallback(){
        console.log('recordID:'+ this.recordId);
        init({
            recordId: this.recordId
        }).then(result => {
                // this.IsLoading = false;
                // console.log(result,"xu111111111111");
                // this.id = result.Id;
                // /00Q/e?retURL=%2F00Q%2Fo&
                // RecordType=01210000000QiRf
                // &ent=Lead
                // &CF00N10000006ps6f={!HTMLENCODE(Contact.Name)} 客户姓名 contact_Name__c
                // &CF00N10000006ps6f_lkid={!HTMLENCODE(Contact.Id)} 客户id contact_Name__c
                // &CF00N10000002CvC5={!HTMLENCODE(Account.Name)} 医院名 Hospital_Name__c
                // &CF00N10000002CvC5_lkid={!HTMLENCODE(Account.Id)}医院id Hospital_Name__c
                // &lea3=%e4%b8%8d%e7%94%a8%e5%a1%ab%e5%86%99
                // &name_lastlea2=%e4%b8%8d%e7%94%a8%e5%a1%ab%e5%86%99
                // &CF00N10000006qNtt_lkid = {!HTMLENCODE(Account.Department_Class__c)} 战略科室分类id epartment_Class__c
                // &CF00N10000006qNtt={!HTMLENCODE(Account.Department_Class__c)} 战略科室分类 epartment_Class__c
                // var url = "/00Q/e?retURL=%2F00Q%2Fo&RecordType=01210000000QiRf&ent=Lead&CF00N10000006ps6f="+result.Name+"&CF00N10000006ps6f_lkid="+result.Id+"&CF00N10000002CvC5="+result.accountName+"&CF00N10000002CvC5_lkid="+result.accountIds+"&lea3=%e4%b8%8d%e7%94%a8%e5%a1%ab%e5%86%99&name_lastlea2=%e4%b8%8d%e7%94%a8%e5%a1%ab%e5%86%99&CF00N10000006qNtt_lkid ="+result.accountDepartmentClass+"&CF00N10000006qNtt="+result.accountDepartmentClass ;
                // window.open(url);
                console.log('LexNewLeadFromContact2 result = ' + JSON.stringify(result))
                const defaultValues = encodeDefaultFieldValues({
                    //2023/ 7/25 update by 王雪琴 PIPL Start
                    contactName : result.Name,
                    accountName:result.accountName,
                    //2023/ 7/25 update by 王雪琴 PIPL END
                    RecordType :result.NewDailyReport,
                    contact_Name__c:result.Id,
                    Hospital_Name__c:result.accountIds,
                    lea3:"",//不用填写
                    name_lastlea2:"",//不用填写
                    Department_Class__c:result.accountDepartmentClass,
                    awsDataId:result.AWSDataId
                });
                this[NavigationMixin.Navigate]({
                    type: 'standard__objectPage',
                    attributes: {
                        objectApiName: 'Lead',
                        actionName: 'new'
                    },
                    state:{
                        // nooverride: '1',
                        defaultFieldValues: defaultValues
                    }
                }); 
            this.dispatchEvent(new CloseActionScreenEvent());               
        }).catch(error=>{
            console.log(error)
        })       
    }
}