import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import init from '@salesforce/apex/StartTradingController2.init';
|
import start from '@salesforce/apex/StartTradingController2.start';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
|
export default class LexStartTrading extends NavigationMixin(LightningElement) {
|
@api recordId;
|
IsLoading=true;
|
Hospital_Name__c;
|
Close_Forecasted_Date__c;
|
Opp_Name_Search__c;
|
begin_opp_name__c;
|
Status;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference){
|
console.log("进入页面");
|
console.log(currentPageReference);
|
if(currentPageReference){
|
const urvalue=currentPageReference.state.recordId;
|
if(urvalue){
|
let str=`${urvalue}`;
|
this.recordId=str;
|
}
|
}
|
}
|
|
connectedCallback(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
init({Id:this.recordId}).then(result=>{
|
console.log('init result==========',result);
|
if(result!=null){
|
// 给参数赋值
|
this.Hospital_Name__c = result.Hospital_Name__c;
|
this.Close_Forecasted_Date__c = result.Close_Forecasted_Date__c;
|
this.Opp_Name_Search__c = result.Opp_Name_Search__c;
|
this.begin_opp_name__c = result.begin_opp_name__c;
|
this.Status = result.Status;
|
// 执行判断
|
this.InquiryJudgment();
|
}
|
});
|
// .catch(err=>{
|
// console.log("init error:");
|
// console.log(err);
|
// }).finally(()=>{});
|
}
|
|
InquiryJudgment(){
|
console.log('InquiryJudgment check');
|
let status_list = ['完毕','无需求','已有询价','確認済み','不要','开始询价'];
|
let lead_status = this.Status;
|
let that = this;
|
if(this.Hospital_Name__c == ''){
|
this.showToast('病院名称を設定してください','error');
|
} else if (this.comparDate(this.Close_Forecasted_Date__c)) {
|
this.showToast('预测OCSM签约日不能小于今天','error');
|
} else if (this.Opp_Name_Search__c == '' || !this.begin_opp_name__c == '' || status_list.indexOf(lead_status) !== -1) {
|
this.showToast('已存在转化的询价或不需要转化询价','error');
|
} else{
|
console.log('start at: ' + this.recordId);
|
start({Id:this.recordId}).then(result=>{
|
console.log('start result==========',result);
|
if(result!=null){
|
this.showToast('已成功转化询价','success');
|
console.log(result);
|
// window.location = '/lightning/r/Opportunity/'+result+'/view';
|
this[NavigationMixin.Navigate]({
|
type: "standard__recordPage",
|
attributes: {
|
recordId: result,
|
actionName:"edit"
|
},
|
state: {
|
nooverride: '1',
|
backgroundContext: '/lightning/r/Opportunity/'+result+'/view'
|
}
|
});
|
}
|
}).catch(error=>{
|
console.log('error');
|
console.log(error);
|
});
|
// .catch(err=>{
|
// console.log("start error:");
|
// console.log(err);
|
// }).finally(()=>{});
|
}
|
|
}
|
comparDate(dateValue) {
|
return new Date().getTime() >= new Date(dateValue).getTime() + 3600 * 1000 * 24;
|
}
|
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
}
|