buli
2023-07-11 0c4796706fc9473d069b620321a54b20a119906c
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
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';
 
export default class OppLoseButton extends LightningElement {
    @api
    taskId;
    opp;
    stageName;
    SAP_Send_OK;
    Cnt_Lost_cancel_report;
    Name;
    Sales_assistant_name;
    Sales_assistant_ID;
    Manager_name;
    Sales_manager_departmentID;
    Sales_owner_buchang;
    Sales_owner_buchangID;
    OpportunityId;
    task;
 
    connectedCallback(){
        console.log(this.taskId);
        init({
            taskId: this.taskId
        }).then(result => {
            console.log(result);
            if (result != null) {
                
                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();
                this.dispatchEvent(new CloseActionScreenEvent());
                // window.location.reload();
            }
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
            
        });        
    }
 
    changeContractType(){
        if(this.StageName != '引合' && this.StageName != '询价'){
            alert('状态1: '+ this.StageName + '、不能做 失单 了!');
        }
        else if(this.SAP_Send_OK == '1'){
            alert('已经上传SAP、不能做 失单 了!');
        }
        else if(this.Cnt_Lost_cancel_report__c > 0){
            alert('询价已经有 取消/失单报告 了!');
             // window.location.reload();
        }else{
            location.href =
            '/a1U/e?retURL=%2F' + this.OpportunityId + 
            '&RecordType=01210000000R4hM' +
            '&CF00N10000004lbGT={!URLENCODE('+this.Name+')}' +
            '&CF00N10000004lbGT_lkid=' + this.OpportunityId + 
 
            '&CF00N10000006QShg={!URLENCODE('+this.Sales_assistant_name+')}' +
            '&CF00N10000006QShg_lkid={!URLENCODE('+this.Sales_assistant_ID+')}' +
            '&CF00N10000006QShq={!URLENCODE('+this.Manager_name+')}' +
            '&CF00N10000006QShq_lkid={!URLENCODE('+this.Sales_manager_departmentID+')}' +
            '&CF00N10000006QShb={!URLENCODE('+this.Sales_owner_buchang+')}' +
            '&CF00N10000006QShb_lkid={!URLENCODE('+this.Sales_owner_buchangID+')}' +
            '';
        }
    }
 
}