buli
2023-04-20 f0bccccbb88d93ac05010c17d4b2e0cb22a2ce9a
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForRequestDBButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
export default class LexRequestDB extends LightningElement {
    @api recordId;
    stageName;
    sapSendOK;
    cntLostCancelReport;
    cntLostCancelDraft;
    agency1;
    agency1Id;
    name;
    bidPlannedDate;
    salesAssistantName;
    salesAssistantID;
    profileId;
    @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.stageName = result.stageName;
            this.sapSendOK = result.sapSendOK;
            this.cntLostCancelReport = result.cntLostCancelReport;
            this.cntLostCancelDraft = result.cntLostCancelDraft;
            this.agency1 = result.agency1;
            this.agency1Id = result.agency1Id;
            this.name = result.name;
            this.bidPlannedDate = result.bidPlannedDate;
            this.salesAssistantName = result.salesAssistantName;
            this.salesAssistantID = result.salesAssistantID;
            this.profileId = result.profileId;
            this.requestDB();
        })
    }
    requestDB(){
        var profileId = this.profileId;
        if (profileId != '00e10000000Y3o5' && profileId != '00e10000000xnp2' &&
        profileId != '00e10000000xnpH') {
            this.showToast("您没有授权委托的权限。请联系系统管理员。","error");
        }
        // jsの場合、翻訳された値がでるので、要注意
        else if (this.stageName != '引合'
        && this.stageName != '询价'
        ) {
            this.showToast("状态1:" + this.stageName + "、不能做授权申请!","");
        }
        else if (this.sapSendOK == '1') {
            this.showToast("已经上传SAP、不能做授权申请了!","error");
        }
        else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) {
            this.showToast("询价已经有取消/失单报告了!","error");
        }
        else {
        location.href = '/a2C/e?retURL=%2F' + 
            encodeURI(this.recordId) +
            '&RecordType=01210000000RNXi' +
            '&CF00N10000006QdJz=' +
            encodeURI(this.agency1) +
            '&CF00N10000006QdJz_lkid=' +
            encodeURI(this.agency1Id) +
            '&CF00N10000006QdKn=' +
            encodeURI(this.name) +
            '&CF00N10000006QdKn_lkid=' +
            encodeURI(this.recordId) +
            '&00N10000006QdK4=' +
            encodeURI(this.name) +
            '&00N10000006QdYB=' +
            encodeURI(this.bidPlannedDate) +
            '&CF00N10000006QdZT=' +
            encodeURI(this.salesAssistantName) +
            '&CF00N10000006QdZT_lkid=' +
            encodeURI(this.salesAssistantID) +
            '';
        };
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    showToast(msg,type) {
      const event = new ShowToastEvent({
          title: '',
          message: msg,
          variant: type
      });
      this.dispatchEvent(event);
    }
    updateRecordView(recordId) {
      updateRecord({fields: { Id: recordId }});
    }
}