import { LightningElement,wire,track,api } from 'lwc';
|
import { CurrentPageReference,NavigationMixin } from "lightning/navigation";
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import init from '@salesforce/apex/OpportunityLightingButtonController.initForLexQuoteEntryNewbotton';
|
import describeSObjectCommon from '@salesforce/apex/OpportunityLightingButtonController.describeSObjectCommon';
|
import selectQuoteById from '@salesforce/apex/LexQuoteSelectbottonController.selectQuoteById';
|
import Error_Message9 from '@salesforce/label/c.Error_Message9';
|
import SIopprecordTypeId from '@salesforce/label/c.SIopprecordTypeId';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader'
|
|
|
export default class LexReQuotebotton extends NavigationMixin(LightningElement) {
|
@api recordId;
|
agencyIsDeletec;
|
accountIsActivec;
|
hospitalIsActivec;
|
estimationDecisionc;
|
recordTypeId;
|
IsLoading = true;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
console.log(currentPageReference);
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
console.warn("str");
|
console.warn(str);
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
console.warn('recordId'+this.recordId);
|
this.loseReport();
|
}
|
loseReport(){
|
selectQuoteById({recordId:this.recordId}).then(result=>{
|
var oppid = result.OpportunityId;
|
init({
|
recordId: oppid
|
}).then(result=>{
|
this.agencyIsDeletec = result.agencyIsDeletec;
|
this.accountIsActivec = result.accountIsActivec;
|
this.hospitalIsActivec = result.hospitalIsActivec;
|
this.estimationDecisionc = result.estimationDecisionc;
|
if(result.recordTypeId){
|
this.recordTypeId = result.recordTypeId.substring(0,15);
|
}
|
describeSObjectCommon({objname:"Quote"}).then(result=>{
|
debugger
|
if (!result) {
|
this.showToast("没有新建报价的权限。","error");
|
} else if (this.agencyIsDeletec == "√") {
|
this.showToast("经销商处于无效状态,不能新建报价。","error");
|
} else if (this.accountIsActivec == "無効") {
|
this.showToast("科室处于无效状态,不能新建报价。","error");
|
} else if (this.hospitalIsActivec == "無効") {
|
this.showToast("医院处于无效状态,不能新建报价。","error");
|
} else {
|
if (!this.estimationDecisionc){
|
if(this.recordTypeId ==SIopprecordTypeId){
|
window.open('/lightning/n/lexSINewQuoteEntry#oppid='+oppid+'©id=' + this.recordId,"_top");
|
}else{
|
window.open('/lightning/n/lexNewQuoteEntry#oppid='+oppid+'©id=' + this.recordId,"_top");
|
}
|
} else {
|
this.showToast(Error_Message9,"error");
|
}
|
}
|
});
|
})
|
});
|
|
}
|
showToast(msg,type) {
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode : "sticky"
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|