import { LightningElement,wire,track,api} from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { NavigationMixin } from 'lightning/navigation';
|
import init from '@salesforce/apex/OppLoseController.init';
|
|
export default class OppLoseButton extends LightningElement {
|
@api
|
taskId;
|
opp;
|
stageName;
|
SAP_Send_OK;
|
Cnt_Lost_cancel_report;
|
Name;
|
Sales_assistant_name;
|
Sales_assistant_ID;
|
Manager_name;
|
Sales_manager_departmentID;
|
Sales_owner_buchang;
|
Sales_owner_buchangID;
|
OpportunityId;
|
task;
|
|
connectedCallback(){
|
console.log(this.taskId);
|
init({
|
taskId: this.taskId
|
}).then(result => {
|
console.log(result);
|
if (result != null) {
|
|
this.IsLoading = false;
|
this.opp = result.opp;
|
this.stageName = result.stageName;
|
this.SAP_Send_OK = result.SAP_Send_OK;
|
this.Cnt_Lost_cancel_report = result.Cnt_Lost_cancel_report;
|
this.Name = result.Name;
|
this.Sales_assistant_name = result.Sales_assistant_name;
|
this.Sales_assistant_ID = result.Sales_assistant_ID;
|
this.Manager_name = result.Manager_name;
|
this.Sales_manager_departmentID = result.Sales_manager_departmentID;
|
this.Sales_owner_buchang = result.Sales_owner_buchang;
|
this.Sales_owner_buchangID = result.Sales_owner_buchangID;
|
this.OpportunityId = result.OpportunityId;
|
this.task = result.task;
|
|
this.changeContractType();
|
this.dispatchEvent(new CloseActionScreenEvent());
|
// window.location.reload();
|
}
|
}).catch(error => {
|
console.log("error");
|
console.log(error);
|
}).finally(() => {
|
|
});
|
}
|
|
changeContractType(){
|
if(this.StageName != '引合' && this.StageName != '询价'){
|
alert('状态1: '+ this.StageName + '、不能做 失单 了!');
|
}
|
else if(this.SAP_Send_OK == '1'){
|
alert('已经上传SAP、不能做 失单 了!');
|
}
|
else if(this.Cnt_Lost_cancel_report__c > 0){
|
alert('询价已经有 取消/失单报告 了!');
|
// window.location.reload();
|
}else{
|
location.href =
|
'/a1U/e?retURL=%2F' + this.OpportunityId +
|
'&RecordType=01210000000R4hM' +
|
'&CF00N10000004lbGT={!URLENCODE('+this.Name+')}' +
|
'&CF00N10000004lbGT_lkid=' + this.OpportunityId +
|
|
'&CF00N10000006QShg={!URLENCODE('+this.Sales_assistant_name+')}' +
|
'&CF00N10000006QShg_lkid={!URLENCODE('+this.Sales_assistant_ID+')}' +
|
'&CF00N10000006QShq={!URLENCODE('+this.Manager_name+')}' +
|
'&CF00N10000006QShq_lkid={!URLENCODE('+this.Sales_manager_departmentID+')}' +
|
'&CF00N10000006QShb={!URLENCODE('+this.Sales_owner_buchang+')}' +
|
'&CF00N10000006QShb_lkid={!URLENCODE('+this.Sales_owner_buchangID+')}' +
|
'';
|
}
|
}
|
|
}
|