FUYU
2023-12-13 4488f711dbc01a8db6753907cae2ef4021dede68
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
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/TenderingButtonController.initTenderingController';
import  updateOpportunityInformation  from '@salesforce/apex/UpdateTenderInformationBatch.updateOpportunityInformation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class lexTenderingEnquiryButton extends LightningElement {
    @api recordId;//当前这条数据的id
    id;//返回值的id  Tender_information__c招标项目的id
    IsLoading = true;
    isRelateProject;//判断是否反应
 
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
             let str = `${urlValue}`;
             this.recordId = str;
           }
         }
     }
    
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result => {
            if (result != null) {
                this.IsLoading = false;
                this.id = result.Id;
                this.isRelateProject = result.isRelateProject;
                this.EnquiryButton();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log("error"+error);
        }).finally(() => {
            
        });        
    }
    //招标项目 反应询价状态
    EnquiryButton(){
        if(this.isRelateProject == "否"){
            this.showToast('招投标项目不相关后不能反应询价状态!','error');
            return;
        }
        var listss = [];
        listss.push(this.id);
        updateOpportunityInformation({TenderIdList : listss}).then(result=>{
            if(result != 'OK'){
                this.showToast(result,'error');
            }else {
                this.showToast('反映完了','success');
            }
        })
    }
 
    showToast(msg,type) {
        const event = new ShowToastEvent({
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}
 
// var foo = function(){
//     if('{!Tender_information__c.IsRelateProject__c}'== "否"){
//     alert('招投标项目不相关后不能反应询价状态!');
//     return;
//     }
//     var listss = [];
//     listss.push('{!Tender_information__c.Id}');
//     var rtn = sforce.apex.execute("UpdateTenderInformationBatch", "updateOpportunityInformation", {TenderIdList : listss } );
    
//     if(rtn != 'OK'){
//     alert(rtn);
//     }else {
//     alert('反映完了');
//     }
//     //重新加载页面
//     window.location.reload();
//     }
    
//     foo();