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();