import { LightningElement, track, wire ,api} from 'lwc';
|
import LightningConfirm from 'lightning/confirm';
|
import jquery183minjs from '@salesforce/resourceUrl/jquery183minjs';
|
import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import { CurrentPageReference } from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import TradeComplianceStatusFlagFW from '@salesforce/label/c.TradeComplianceStatusFlagFW';
|
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';
|
|
import init from "@salesforce/apex/lexMaintenanceContractUrlController.lexCustomNewContract";
|
import accSendEmailFW from "@salesforce/apex/OpportunityWebService.accSendEmailFW";
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
|
export default class lexCustomNewContract extends NavigationMixin(LightningElement) {
|
@api recordId;
|
IsLoading=true;
|
name;
|
Hospital;
|
Department_Class;
|
Department;
|
Service_Contract_Staff;
|
Estimate_Target;
|
Dealer;
|
recordtypeId;
|
accDealerBlacklist;
|
a=IFTradeComplianceAlert;
|
b=TradeComplianceStatusFlagFW;
|
|
@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 => {
|
|
if (result != null) {
|
this.IsLoading = false;
|
this.name = result.name;
|
this.Hospital = result.hospital;
|
this.Department_Class = result.department_Class;
|
this.Service_Contract_Staff = result.service_Contract_Staff;
|
this.Department = result.department;
|
this.Estimate_Target = result.estimate_Target;
|
this.Dealer = result.dealer;
|
this.recordtypeId = result.recordtypeId;
|
this.accDealerBlacklist = result.accDealerBlacklist;
|
this.invid();
|
}
|
}).catch(error => {
|
console.log(error);
|
})
|
|
}
|
navigateToNewObjectPage() {
|
// console.log('RepairApplicantName=='+this.RepairApplicantName);
|
// console.log('this.id=='+this.id);
|
const defaultFieldValues =encodeDefaultFieldValues({
|
|
Name: 'Copy of '+this.name,
|
Hospital__c: this.Hospital,
|
Department_Class__c: this.Department_Class,
|
Service_Contract_Staff__c: this.Service_Contract_Staff,
|
Department__c: this.Department,
|
Estimate_Target__c:this.Estimate_Target,
|
Dealer__c:this.Dealer,
|
Last_year_service_contract__c:this.recordId,
|
CopyFlg__c : true,
|
NotUse_Oxygenated_Water__c : false,
|
copyOfMc__c:this.recordId
|
});
|
console.log('合同名='+this.name);
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Maintenance_Contract__c',
|
actionName: 'new'
|
},
|
state: {
|
nooverride: '1',
|
defaultFieldValues: defaultFieldValues,
|
recordTypeId: this.recordtypeId
|
}
|
});
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
invid() {
|
console.log('IFTradeComplianceAlert=='+this.a);
|
console.log('TradeComplianceStatusFlagFW=='+this.b);
|
console.log('accDealerBlacklist=='+this.accDealerBlacklist);
|
if(this.b=='true'){
|
var oppflag=false;
|
if(this.accDealerBlacklist==1){
|
const evt = new ShowToastEvent({
|
title : '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
|
message: '',
|
variant: 'error',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
oppflag=true;
|
}else if(this.accDealerBlacklist==2){
|
const evt = new ShowToastEvent({
|
title : '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
|
message: '',
|
variant: 'error',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
oppflag=true;
|
}else if(this.accDealerBlacklist==12){
|
const evt = new ShowToastEvent({
|
title : '您所选择的医院和经销商存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
|
message: '',
|
variant: 'error',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(evt);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
oppflag=true;
|
}else if(this.accDealerBlacklist==5){
|
LightningConfirm.open({
|
message: '您所选择的医院存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
|
variant: 'headerless',
|
label: 'this is the aria-label value',
|
|
}).then(cancel=>{
|
if(cancel) {
|
this.navigateToNewObjectPage();
|
} else {
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
|
});
|
}else if(this.accDealerBlacklist==6){
|
LightningConfirm.open({
|
message: '您所选择的经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
|
variant: 'headerless',
|
label: 'this is the aria-label value',
|
|
}).then(cancel=>{
|
if(cancel) {
|
this.navigateToNewObjectPage();
|
} else {
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
|
});
|
}else if(this.accDealerBlacklist==56){
|
LightningConfirm.open({
|
message: '您所选择的医院和经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
|
variant: 'headerless',
|
label: 'this is the aria-label value',
|
|
}).then(cancel=>{
|
if(cancel) {
|
this.navigateToNewObjectPage();
|
} else {
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
|
});
|
}else{
|
this.navigateToNewObjectPage();
|
}
|
console.log('oppflag=='+oppflag);
|
if(oppflag){
|
var FSEStr1 = new Array();
|
accSendEmailFW({
|
AccDealerBlacklist:this.accDealerBlacklist,
|
accname:this.Hospital,
|
angency:this.Dealer,
|
mcid:this.recordId,
|
sendalert:'Main_Con',
|
FSEStr:FSEStr1
|
})
|
.then(result=>{
|
return;
|
}).catch(err=>{
|
console.log(error);
|
})
|
}
|
} else {
|
this.navigateToNewObjectPage();
|
|
}
|
|
|
}
|
|
}
|