import { LightningElement, wire, api} from 'lwc';
|
import { CurrentPageReference} from "lightning/navigation";
|
import LightningConfirm from 'lightning/confirm';
|
import { CloseActionScreenEvent} from 'lightning/actions';
|
import init from '@salesforce/apex/otherButtonMaintenanceContractCtl.init';
|
// import initCopyData from '@salesforce/apex/otherButtonMaintenanceContractCtl.initCustomNewCopy2';
|
import { ShowToastEvent} from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
|
import TradeComplianceStatusFlagFW from '@salesforce/label/c.TradeComplianceStatusFlagFW';
|
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
import IFTradeComplianceAlert2 from '@salesforce/label/c.IFTradeComplianceAlert2'; //sx 贸易合规2期 add
|
import accSendEmailFW from '@salesforce/apex/OpportunityWebService.accSendEmailFW';
|
import accSendEmailFW2 from "@salesforce/apex/lexSelectAssetEstimateVMController.accSendEmailFW"; // WYL 贸易合规2期 add
|
import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName';// WYL 贸易合规2期 add
|
export default class LexCustomNewCopy2 extends NavigationMixin(LightningElement) {
|
@api recordId;
|
str;
|
IsLoading = true;
|
flag;
|
Id;
|
notRenewC;
|
Name;
|
accDealerBlacklist;
|
Hospital;
|
a=IFTradeComplianceAlert;
|
b=TradeComplianceStatusFlagFW;
|
|
Dealer;
|
Department_Class;
|
Department;
|
Service_Contract_Staff;
|
Estimate_Target;
|
recordtypeId;
|
|
|
Service_contract_target_number;
|
PB_Contrant_Cnt;
|
PA_Contrant_Cnt;
|
Contract_Conclusion_Date;
|
Contract_Start_Date;
|
Estimate_Trial_Money;
|
Contract_End_Date;
|
Receipt_Date;
|
Recycling_Predetermined_Day;
|
Contract_Amount;
|
Collect_Date;
|
Recoverable_Amount;
|
Not_collect_money;
|
Sum_repair_price;
|
invoice_amount;
|
Total_not_collect_amount;
|
Description;
|
OCM_Print_request;
|
HP_Dealer_print;
|
Contract_print_completed;
|
Submit_contract_to_Financial_dept;
|
Received_Date;
|
Repair_Cost_Sum;
|
Maintenance_Contract_No;
|
Last_year_service_contract;
|
UserType;
|
|
dateF;
|
|
//20231120 sx 贸易合规2期 add
|
hosTradeComplianceStatus;
|
deaTradeComplianceStatus;
|
proTradeComplianceStatus;
|
violationName;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback() {
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
|
console.log('测试0');
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
|
console.log(result);
|
if (result != null) {
|
this.IsLoading = false;
|
this.Id = result.Id;
|
this.notRenewC = result.notRenewC;
|
this.Name = result.Name;
|
this.Dealer = result.Dealer;
|
this.Hospital = result.hospital;
|
this.accDealerBlacklist = result.accDealerBlacklist;
|
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.EstimateTargetC;
|
this.recordtypeId = result.newMcRecordType;
|
|
//sx 贸易合规 add start
|
this.hosTradeComplianceStatus = result.TradeComplianceStatus__c;
|
this.deaTradeComplianceStatus = result.TradeComplianceStatus__c;
|
this.proTradeComplianceStatus = result.proTradeComplianceStatus;
|
this.violationName = result.violationName;
|
//sx 贸易合规 add end
|
|
// this.Service_contract_target_number=result.Service_contract_target_number;
|
// this.PB_Contrant_Cnt=result.PB_Contrant_Cnt;
|
// this.PA_Contrant_Cnt=result.PA_Contrant_Cnt;
|
// this.Contract_Conclusion_Date=result.Contract_Conclusion_Date;
|
// this.Contract_Start_Date=result.Contract_Start_Date;
|
// this.Estimate_Trial_Money=result.Estimate_Trial_Money;
|
// this.Contract_End_Date=result.Contract_End_Date;
|
// this.Receipt_Date=result.Receipt_Date;
|
// this.Recycling_Predetermined_Day=result.Recycling_Predetermined_Day;
|
// this.Contract_Amount=result.Contract_Amount;
|
// this.Collect_Date=result.Collect_Date;
|
// this.Recoverable_Amount=result.Recoverable_Amount;
|
// this.Not_collect_money=result.Not_collect_money;
|
// this.Sum_repair_price=result.Sum_repair_price;
|
// this.invoice_amount=result.invoice_amount;
|
// this.Total_not_collect_amount=result.Total_not_collect_amount;
|
// this.Description=result.Description;
|
// this.OCM_Print_request=result.OCM_Print_request;
|
// this.HP_Dealer_print=result.HP_Dealer_print;
|
// this.Contract_print_completed=result.Contract_print_completed;
|
// this.Submit_contract_to_Financial_dept=result.Submit_contract_to_Financial_dept;
|
// this.Received_Date=result.Received_Date;
|
// this.Repair_Cost_Sum=result.Repair_Cost_Sum;
|
// this.Maintenance_Contract_No=result.Maintenance_Contract_No;
|
// this.Last_year_service_contract=result.Last_year_service_contract;
|
// this.UserType=result.UserType;
|
this.invid();
|
// this.CustomNewCopy2();
|
// this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}).catch(error => {
|
console.log(error);
|
})
|
}
|
|
navigateToNewObjectPage() {
|
|
/* const defaultFieldValues =encodeDefaultFieldValues({
|
|
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,
|
|
// Service_contract_target_number__c:this.Service_contract_target_number,
|
// PB_Contrant_Cnt__c:this.PB_Contrant_Cnt,
|
// PA_Contrant_Cnt__c:this.PA_Contrant_Cnt,
|
// Contract_Conclusion_Date__c:this.Contract_Conclusion_Date,
|
// Contract_Start_Date__c:this.Contract_Start_Date,
|
// Estimate_Trial_Money__c:this.Estimate_Trial_Money,
|
// Contract_End_Date__c:this.Contract_End_Date,
|
// Receipt_Date__c:this.Receipt_Date,
|
// Recycling_Predetermined_Day__c:this.Recycling_Predetermined_Day,
|
// Contract_Amount__c:this.Contract_Amount,
|
// Collect_Date__c:this.Collect_Date,
|
// Recoverable_Amount__c:this.Recoverable_Amount,
|
// Not_collect_money__c:this.Not_collect_money,
|
// Sum_repair_price__c:this.Sum_repair_price,
|
// invoice_amount__c:this.invoice_amount,
|
// Total_not_collect_amount__c:this.Total_not_collect_amount,
|
// Description__c:this.Description,
|
// OCM_Print_request__c:this.OCM_Print_request,
|
// HP_Dealer_print__c:this.HP_Dealer_print,
|
// Contract_print_completed__c:this.Contract_print_completed,
|
// Submit_contract_to_Financial_dept__c:this.Submit_contract_to_Financial_dept,
|
// Received_Date__c:this.Received_Date,
|
// Repair_Cost_Sum__c:this.Repair_Cost_Sum,
|
// Maintenance_Contract_No__c:this.Maintenance_Contract_No,
|
// UserType__c:this.UserType,
|
|
});*/
|
const datas =encodeDefaultFieldValues({
|
Name: '',
|
CopyFlg__c : true,
|
copyOfMc__c:this.recordId,
|
Service_contract_target_number__c:'',
|
PB_Contrant_Cnt__c:'',
|
PA_Contrant_Cnt__c:'',
|
Contract_Conclusion_Date__c:'',
|
Contract_Start_Date__c:'',
|
Estimate_Trial_Money__c:'',
|
Contract_End_Date__c:'',
|
Receipt_Date__c:'',
|
Recycling_Predetermined_Day__c:'',
|
Contract_Amount__c:'',
|
Collect_Date__c:'',
|
Recoverable_Amount__c:'',
|
Not_collect_money__c:'',
|
Sum_repair_price__c:'',
|
invoice_amount__c:'',
|
Total_not_collect_amount__c:'',
|
Description__c:'',
|
OCM_Print_request__c:'',
|
HP_Dealer_print__c:'',
|
Contract_print_completed__c:'',
|
Submit_contract_to_Financial_dept__c:'',
|
Received_Date__c:'',
|
Repair_Cost_Sum__c:'',
|
Maintenance_Contract_No__c:'',
|
Last_year_service_contract__c:''
|
|
});
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Maintenance_Contract__c', // 要新建的对象API
|
actionName: 'clone',
|
recordId: this.recordId
|
},
|
state:{
|
nooverride: '1',
|
defaultFieldValues:datas
|
// +','+defaultFieldValues
|
}
|
});
|
// initCopyData({
|
// recordId: this.recordId
|
// }).then(result => {
|
// console.log('initCopyData:');
|
// console.log(this.dateF+","+result);
|
// this.dateF = result;
|
|
|
// });
|
|
|
}
|
// 继续新服务合同
|
CustomNewCopy2() {
|
console.log('测试3=='+this.notRenewC);
|
if (this.notRenewC) {
|
this.showToast("请联系服务商品部!", "error");
|
} else {
|
console.log('测试2');
|
// 获取协议部分(http、https等)
|
const protocol = window.location.protocol;
|
|
// 获取主机名部分(域名)
|
const hostname = window.location.hostname;
|
|
// 获取端口号部分
|
const port = window.location.port;
|
const urlPrefix = `${protocol}//${hostname}${port ? ':' + port : ''}`;
|
// window.open("/" + this.Id + "/e?clone=1&Name=&00N10000002Dx5D=&00N10000002Dx5S=%e5%bc%95%e5%90%88%e4%b8%ad&00NO00000010sDc=&CF00NO00000010hyI=&CF00NO00000010hyI_lkid=&CF00NO00000010hyX=&CF00NO00000010hyX_lkid=&CF00NO00000010hyN=&CF00NO00000010hyN_lkid=&RecordType=01210000000gTYq&00N10000002pmOp=&00N10000006gZDd=&00N10000006gZDe=&00NO00000010hy4=&00N10000002Dx4j=&00N10000002Dx4m=&00N10000002Dx4w=&00N10000002Dx4k=&00N10000002Dx5J=&00N10000002Dx5M=&00N10000002Dx4i=&00N10000002Dx4h=&00N10000002Dx5K=&00N10000003OXdT=&00N100000048zfn=&00N10000002FMsq=&00N10000003OlGF=&00N10000002Dx4r=&00N100000047AY1=&00N100000047AYB=&00N100000047AY6=&00N10000003PCeB=&00N10000005HBNe=&00N10000006plAl=&00N10000002Dx5C=&retURL=%2F{!Maintenance_Contract__c.Id}&saveURL=%2Fapex/SaveMaintenanceByCopy?mid=" + this.Id + "&CF00N100000048Paw=" + this.Name + "&CF00N100000048Paw_lkid=" + this.Id, "_blank");
|
// window.open("/" + this.Id + "/e?clone=1&Name=&Management_Code__c=&Status__c=%e5%bc%95%e5%90%88%e4%b8%ad&RecordType=01210000000gTYq&retURL=%2F{!Maintenance_Contract__c.Id}&saveURL=%2Fapex/SaveMaintenanceByCopy?mid=" + this.Id , "_blank");
|
var pageurl = '/lightning/cmp/c__LexMaintenanceContractAura?c__isClone=true&c__recordId=' + this.recordId;
|
|
console.log('测试3='+urlPrefix+pageurl);
|
window.open(urlPrefix+pageurl,'_self');
|
|
}
|
}
|
|
// 弹窗
|
showToast(msg, type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}
|
}
|
|
invid() {
|
console.log('IFTradeComplianceAlert=='+this.a);
|
console.log('TradeComplianceStatusFlagFW=='+this.b);
|
console.log('accDealerBlacklist=='+this.accDealerBlacklist);
|
debugger;
|
|
if(this.b=='true'){
|
var oppflag=false;
|
var oppflag2 = 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;
|
this.flag=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;
|
this.flag=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;
|
this.flag=true;
|
}
|
// else if(this.accDealerBlacklist==5){
|
// oppflag2 = true;
|
// LightningConfirm.open({
|
// message: '您所选择的医院存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
|
// variant: 'headerless',
|
// label: 'this is the aria-label value',
|
|
// }).then(cancel=>{
|
// if(cancel) {
|
// console.log('执行');
|
// // this.navigateToNewObjectPage();
|
// this.CustomNewCopy2();
|
|
// this.flag=true;
|
// } else {
|
// this.IsLoading=false;
|
// this.dispatchEvent(new CloseActionScreenEvent());
|
// this.flag = false;
|
// return;
|
// }
|
|
// });
|
// }else if(this.accDealerBlacklist==6){
|
// LightningConfirm.open({
|
// message: '您所选择的经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
|
// variant: 'headerless',
|
// label: 'this is the aria-label value',
|
|
// }).then(cancel=>{
|
// console.log('6')
|
// if(cancel) {
|
// // this.navigateToNewObjectPage();
|
// this.CustomNewCopy2();
|
// this.flag=true;
|
// } else {
|
// this.IsLoading=false;
|
// this.dispatchEvent(new CloseActionScreenEvent());
|
// this.flag=false;
|
// 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();
|
// this.CustomNewCopy2();
|
// } else {
|
// this.IsLoading=false;
|
// this.dispatchEvent(new CloseActionScreenEvent());
|
// this.flag=false;
|
// return;
|
// }
|
|
// });
|
// //sx 贸易合规2期 add start
|
// }
|
//sx 贸易合规2期 add start
|
else if(this.accDealerBlacklist==5 || this.accDealerBlacklist==6 || this.accDealerBlacklist==56 ||this.hosTradeComplianceStatus == '警示名单' || this.deaTradeComplianceStatus == '警示名单'){
|
if(this.proTradeComplianceStatus == '0'){
|
oppflag2 = true;
|
LightningConfirm.open({
|
message: '您此次申请的业务可能存在贸易合规风险,请联系法务本部贸易合规窗口'+IFTradeComplianceAlertName+'进一步评估(一般需5-10个工作日)',
|
variant: 'headerless',
|
label: 'this is the aria-label value',
|
}).then(confirm=>{
|
if(confirm){
|
this.navigateToNewObjectPage();
|
}else{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
}).catch(err=>{
|
console.log('贸易合规2err====='+err.getMessage());
|
})
|
}// WYl 贸易合规2期 update 2024/1/30 start
|
else{
|
this.CustomNewCopy2();
|
}// WYl 贸易合规2期 update 2024/1/30 end
|
}
|
else{
|
// this.navigateToNewObjectPage();
|
this.CustomNewCopy2();
|
}
|
|
//sx 贸易合规2期 add end
|
console.log('oppflag=='+oppflag);
|
console.log('oppflag2=='+oppflag2);
|
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);
|
})
|
}
|
//wyl 贸易合规2期 add start
|
if (oppflag2) {
|
console.info('ID='+this.recordId);
|
accSendEmailFW2({
|
mcid : this.recordId,
|
titles :'【贸易合规】--服务合同继续新服务合同涉及警示产品',
|
type :'2',
|
violationName:this.violationName.slice(0, -1)
|
})
|
.then(result=>{
|
return;
|
}).catch(err=>{
|
console.log(err);
|
})
|
}
|
//wyl 贸易合规2期 add end
|
}
|
else {
|
this.CustomNewCopy2();
|
// this.navigateToNewObjectPage();
|
|
}
|
|
}
|
}
|