import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; 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 => { console.log(result); this.IsLoading = false; this.id = result.Id; this.isRelateProject = result.isRelateProject; this.EnquiryButton(); }) } //招标项目 反应询价状态 EnquiryButton(){ if(this.isRelateProject == "否"){ this.showToast('招投标项目不相关后不能反应询价状态!','error'); this.dispatchEvent(new CloseActionScreenEvent()); return; } var listss = []; listss.push(this.id); updateOpportunityInformation({TenderIdList : listss}).then(result=>{ if(result != 'OK'){ this.showToast(result,'error'); this.dispatchEvent(new CloseActionScreenEvent()); }else { this.showToast('反映完了','success'); this.dispatchEvent(new CloseActionScreenEvent()); } }) } showToast(msg,type) { console.log(msg,type); const event = new ShowToastEvent({ message: msg, variant: type }); this.dispatchEvent(event); } }