import { LightningElement,wire,track,api } from 'lwc';
|
import { CurrentPageReference,NavigationMixin } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import init from '@salesforce/apex/OpportunityLightingButtonController.initForLexQuoteEntryNewbotton';
|
import describeSObjectCommon from '@salesforce/apex/OpportunityLightingButtonController.describeSObjectCommon';
|
import setQuote from '@salesforce/apex/ControllerUtil.setQuote';
|
import getStatusForISO from '@salesforce/apex/ControllerUtil.getStatusForISO';
|
import Error_Message9 from '@salesforce/label/c.Error_Message9';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader'
|
import SIopprecordTypeId from '@salesforce/label/c.SIopprecordTypeId';
|
|
|
export default class LexQuoteEntryNewbottonLwc 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(){
|
console.warn('recordId'+this.recordId);
|
init({
|
recordId: this.recordId
|
}).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);
|
}
|
console.warn('111');
|
this.loseReport();
|
console.warn('222');
|
})
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
}
|
loseReport(){
|
debugger
|
var oppid = this.recordId ;
|
describeSObjectCommon({objname:"Quote"}).then(result=>{
|
getStatusForISO({opporID:oppid}).then(excuteRs=>{
|
debugger
|
if (!result) {
|
this.showToast("没有新建报价的权限。","error");
|
// alert('没有新建报价的权限。');
|
} else if (this.agencyIsDeletec == "√") {
|
// alert('经销商处于无效状态,不能新建报价。');
|
this.showToast("经销商处于无效状态,不能新建报价。","error");
|
} else if (this.accountIsActivec == "無効") {
|
// alert('科室处于无效状态,不能新建报价。');
|
this.showToast("科室处于无效状态,不能新建报价。","error");
|
} else if (this.hospitalIsActivec == "無効") {
|
// alert('医院处于无效状态,不能新建报价。');
|
this.showToast("医院处于无效状态,不能新建报价。","error");
|
}
|
else if ((excuteRs !='CommitCode')&&this.recordTypeId ==SIopprecordTypeId) {
|
// alert('没有批准的需求表,不能报价。');
|
this.showToast("没有批准的需求表,不能报价。","error");
|
} else {
|
if (!this.estimationDecisionc){
|
if(this.recordTypeId ==SIopprecordTypeId){
|
setQuote({oppid:oppid}).then(ite=>{
|
window.open('/lightning/n/lexSINewQuoteEntry#oppid='+oppid,"_self");
|
});
|
}else{
|
window.open('/lightning/n/lexNewQuoteEntry#oppid='+oppid,"_self");
|
}
|
} else {
|
// alert(Error_Message9);
|
this.showToast(Error_Message9,"error");
|
}
|
}
|
this.IsLoading = false;
|
})
|
});
|
|
}
|
showToast(msg,type) {
|
const event = new ShowToastEvent({
|
message: msg,
|
variant : type,
|
mode : 'sticky'
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|