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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * @Description: 
 * @version: 
 * @Author: chen jing wu
 * @Date: 2023-04-14 10:16:19
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-14 10:41:46
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init  from '@salesforce/apex/OpportunityLightingButtonController.initForLostReportButton';
export default class LexLoseReport extends LightningElement {
    @api recordId;
    stageName;
    sapSendOK;
    cntLostCancelReport;
    name;
    salesAssistantName;
    salesAssistantID;
    managerName;
    salesManagerDepartmentID;
    salesOwnerBuchang;
    salesOwnerBuchangID;
    IsLoading = true;
    @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.name = result.name;
            this.salesAssistantID = result.salesAssistantID;
            this.salesAssistantName = result.salesAssistantName;
            this.managerName = result.managerName;
            this.salesManagerDepartmentID = result.salesManagerDepartmentID;
            this.salesOwnerBuchang = result.salesOwnerBuchang;
            this.salesOwnerBuchangID = result.salesOwnerBuchangID;
            this.loseReport();
        })
    }
    loseReport(){
        // jsの場合、翻訳された値がでるので、要注意
        if (this.stageName != '引合'
        && this.stageName != '询价'
        ) {
            this.showToast("状态1:" + this.stageName + "、不能做 失单 了!","error");
        }
        else if (this.sapSendOK == '1') {
            this.showToast("已经上传SAP、不能做 失单 了!","error");
        }
        else if (this.cntLostCancelReport > 0) {
            this.showToast("询价已经有 取消/失单报告 了!","error");
        }
        //else if({!Not(ISBLANK(Opportunity.Bidding_Project_Name_Bid__c))} && //'{!Opportunity.InfoTypeBid__c}' != '3:结果' ){
        //alert("关联招投标项目的询价,只能在有结果后做失单报告!");
        //}
        else {
            location.href = '/a1U/e?retURL=%2F' + this.recordId +
            '&RecordType=01210000000R4hM' +
            '&CF00N10000004lbGT=' + this.name +
            '&CF00N10000004lbGT_lkid=' + this.recordId +
            '&CF00N10000006QShg=' + this.salesAssistantName +
            '&CF00N10000006QShg_lkid=' + this.salesAssistantID +
            '&CF00N10000006QShq=' + this.managerName +
            '&CF00N10000006QShq_lkid=' + this.salesManagerDepartmentID +
            '&CF00N10000006QShb=' + this.salesOwnerBuchang +
            '&CF00N10000006QShb_lkid=' + this.salesOwnerBuchangID +
            '';
        }
        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 }});
    }
}