buli
2023-05-23 07390e2fcb4adf27c928335bf27ae7939c5a80ad
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import  init  from '@salesforce/apex/OppLoseController.init';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class OppLoseButton extends LightningElement {
    @api recordId;
    opp;
    StageName; //阶段
    SAP_Send_OK;//SAP上传(WIN)
    Cnt_Lost_cancel_report;//累计汇总 (COUNT 询价失单/取消报告)
    Name;//    业务机会名
    Sales_assistant_name;//询价助理
    Sales_assistant_ID;//询价助理ID
    Manager_name;//询价所有人的CL6 经理级
    Sales_manager_departmentID;//询价所有人的CL6 经理级ID
    Sales_owner_buchang;//询价所有人的 CL5 总监级
    Sales_owner_buchangID;//询价所有人的CL5 经理级ID
    OpportunityId; //任务 询价
    task;
 
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        if(currentPageReference){
            const urlValue=currentPageReference.state.recordId;
            if(urlValue){
                let str=`${urlValue}`;
                this.recordId=str;
            }
        }
    }
    connectedCallback(){
        console.log(this.recordId);
        init({
            taskId: this.recordId
        }).then(result => {
            console.log(result);
            this.IsLoading = false;
            this.opp = result.opp;
            this.StageName = result.StageName;
            this.SAP_Send_OK = result.SAP_Send_OK;
            this.Cnt_Lost_cancel_report = result.Cnt_Lost_cancel_report;
            this.Name = result.Name;
            this.Sales_assistant_name = result.Sales_assistant_name;
            this.Sales_assistant_ID = result.Sales_assistant_ID;
            this.Manager_name = result.Manager_name;
            this.Sales_manager_departmentID = result.Sales_manager_departmentID;
            this.Sales_owner_buchang = result.Sales_owner_buchang;
            this.Sales_owner_buchangID = result.Sales_owner_buchangID;
            this.OpportunityId = result.OpportunityId;
            this.task = result.task;
            this.changeContractType();
        })      
    }
 
    changeContractType(){
        if(this.StageName != '引合' && this.StageName != '询价'){
            // alert('状态1: '+ this.StageName + '、不能做 失单 了!');
            this.showToast("状态1:" + this.StageName + "、不能做 失单 了!","error");
            return;
        }
        else if(this.SAP_Send_OK == '1'){
            // alert('已经上传SAP、不能做 失单 了!');
            this.showToast("已经上传SAP、不能做 失单 了!","error");
            return;
        }
        else if(this.Cnt_Lost_cancel_report__c > 0){
            // alert('询价已经有 取消/失单报告 了!');
            this.showToast("询价已经有 取消/失单报告 了!","error");
            return;
             // window.location.reload();
        }else{
            location.href =
            '/a1U/e?retURL=%2F' + this.OpportunityId + 
            '&RecordType=01210000000R4hM' +
            '&CF00N10000004lbGT='+ this.Name +
            '&CF00N10000004lbGT_lkid=' + this.OpportunityId + 
            '&CF00N10000006QShg='+this.Sales_assistant_name+
            '&CF00N10000006QShg_lkid='+this.Sales_assistant_ID +
            '&CF00N10000006QShq='+this.Manager_name +
            '&CF00N10000006QShq_lkid='+this.Sales_manager_departmentID +
            '&CF00N10000006QShb='+this.Sales_owner_buchang +
            '&CF00N10000006QShb_lkid='+this.Sales_owner_buchangID +
            '';
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}
 
 
 
// var sql = "select Sales_owner_buchangID__c,Manager_name__c,Sales_owner_buchang__c,Sales_manager_departmentID__c,name,Sales_assistant_name__c,Sales_assistant_ID__c,id,StageName,SAP_Send_OK__c,Cnt_Lost_cancel_report__c,Bidding_Project_Name_Bid__c from Opportunity where id = '{!task__c.OpportunityIdId__c}'";
// var opp_recourd = sforce.connection.query(sql);
// var opp = opp_recourd.getArray("records")[0];
// if (opp.StageName != '引合'
// && opp.StageName != '询价'
// ) {
// alert("状态1:" + opp.StageName + "、不能做 失单 了!");
// }
// else if (opp.SAP_Send_OK__c == '1') {
// alert("已经上传SAP、不能做 失单 了!");
// }
// else if (opp.Cnt_Lost_cancel_report__c > 0) {
// alert("询价已经有 取消/失单报告 了!");
// }
 
 
// else {
// location.href =
// '/a1U/e?retURL=%2F{!task__c.OpportunityIdId__c}' +
// '&RecordType=01210000000R4hM' +
// '&CF00N10000004lbGT={!URLENCODE('+opp.name+')}' +
// '&CF00N10000004lbGT_lkid={!task__c.OpportunityIdId__c}' +
 
// '&CF00N10000006QShg={!URLENCODE('+opp.Sales_assistant_name__c+')}' +
// '&CF00N10000006QShg_lkid={!URLENCODE('+opp.Sales_assistant_ID__c+')}' +
// '&CF00N10000006QShq={!URLENCODE('+opp.Manager_name__c+')}' +
// '&CF00N10000006QShq_lkid={!URLENCODE('+opp.Sales_manager_departmentID__c+')}' +
// '&CF00N10000006QShb={!URLENCODE('+opp.Sales_owner_buchang__c+')}' +
// '&CF00N10000006QShb_lkid={!URLENCODE('+opp.Sales_owner_buchangID__c+')}' +
// '';
// }