/* * @Description: * @version: * @Author: chen jing wu * @Date: 2023-04-14 11:09:28 * @LastEditors: chen jing wu * @LastEditTime: 2023-10-10 17:40:30 */ import { api, wire,LightningElement } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import queryForQuotationRequestButton from '@salesforce/apex/OpportunityLightingButtonController.queryForQuotationRequestButton'; import init from '@salesforce/apex/OpportunityLightingButtonController.initForQuotationRequestButton'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; export default class LexQuotationRequest extends LightningElement { @api recordId; biddingProjectNameBidId; estimationId; @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(){ Promise.all([ loadStyle(this, lwcCSS) ]); init({ recordId: this.recordId }).then(result=>{ this.biddingProjectNameBidId = result.biddingProjectNameBidId == undefined ? '' : result.biddingProjectNameBidId; this.estimationId = result.estimationId == undefined ? '' : result.estimationId; this.quotationRequest(); }) } quotationRequest(){ queryForQuotationRequestButton({ recordId: this.recordId }).then(result=>{ var records = result; var size =records.length; if(size > 1){ this.showToast("有2个或者2个以上的草案中报价委托,请确认。","error"); }else if(size == 1){ var raes = records[0].Id; location.href = "/apex/NewQuoteIrai?id="+ raes+"&tenderid=" + this.biddingProjectNameBidId; }else{ location.href = "/apex/NewQuoteIrai?oppid=" + this.recordId + "&oppquoid=" + this.estimationId + "&tenderid=" + this.biddingProjectNameBidId; } this.dispatchEvent(new CloseActionScreenEvent()); }) } showToast(msg,type) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type, }); this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode: 'sticky' }); this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } } updateRecordView(recordId) { updateRecord({fields: { Id: recordId }}); } }