/*
|
* @Description:
|
* @version:
|
* @Author: chen jing wu
|
* @Date: 2023-04-14 11:09:28
|
* @LastEditors: chen jing wu
|
* @LastEditTime: 2023-04-14 11:21:24
|
*/
|
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';
|
|
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(){
|
init({
|
recordId: this.recordId
|
}).then(result=>{
|
this.biddingProjectNameBidId = result.biddingProjectNameBidId;
|
this.estimationId = 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) {
|
const event = new ShowToastEvent({
|
title: '',
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}
|
updateRecordView(recordId) {
|
updateRecord({fields: { Id: recordId }});
|
}
|
}
|