import { LightningElement,api, track, wire } from 'lwc'; import {CurrentPageReference} from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import LightningConfirm from 'lightning/confirm'; import init from '@salesforce/apex/LexTaskCloseController.init'; import getProfileId from '@salesforce/apex/LexTaskCloseController.getProfileId'; import updateQuoteIraic from '@salesforce/apex/LexTaskCloseController.updateQuoteIraic'; import updateTask from '@salesforce/apex/LexTaskCloseController.updateTask'; import getQuoteIraic from '@salesforce/apex/LexTaskCloseController.getQuoteIraic'; export default class lexTaskClose extends LightningElement { @api recordId; @api isDoneRendering; IsLoading=true; QuoteIraiId; @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(){ this.dispatchEvent(new CloseActionScreenEvent()); init({recordId:this.recordId}).then(result=>{ this.QuoteIraiId=result.Id; this.cancelSubmit().then(res=>{ this.IsLoading=false; const passOneEvent = new CustomEvent('closem', {     detail: '111'   });   this.dispatchEvent(passOneEvent); }); }).catch(err=>{ // console.log("error:"); // console.log(err.message); }).finally(()=>{ this.dispatchEvent(new CloseActionScreenEvent()); }); } async cancelSubmit(){ var re = await getQuoteIraic({recordId:this.QuoteIraiId}); if(re!=null&&re.Lead__c){ // Lead作成 var Id = re.Lead__c; if(this.QuoteIraiId != '') { var LatestQuotationEntrustment__c=this.QuoteIraiId; // Lead更新 await updateLead({ recordId:Id, LatestQuotationEntrustmentc:LatestQuotationEntrustment__c }).then(res=>{ console.log(res); if(res!=null&&res.success==false){ var messages=res.errors[0]; if (messages!=null&&messages!="") { const event = new ShowToastEvent({ title: '提示信息', message:"操作失败,提示信息:"+messages, }); this.dispatchEvent(event); return; } } }).catch(err=>{ // console.log("updateLead error:"); // console.log(err.message); }); } } if(this.QuoteIraiId != '') { var id =this.QuoteIraiId; var QuoteIrai_Status__c = '更新完毕'; await updateQuoteIraic({ recordId:Id, QuoteIraiStatusc:QuoteIrai_Status__c }).then(res=>{ console.log(res); if(res!=null&&res.success==false){ var messages=res.errors[0]; if (messages!=null&&messages!="") { const event = new ShowToastEvent({ title: '提示信息', message:"操作失败,提示信息:"+messages, }); this.dispatchEvent(event); return; } } }).catch(err=>{ // console.log("updateLead error:"); // console.log(err.message); }); } var Id = this.recordId; var Status = "完了"; await updateTask({ recordId:Id, Status:Status }).then(res=>{ console.log(res); if(res!=null&&res.success==false){ var message=res.errors[0]; if (messages!=null&&messages!="") { const event = new ShowToastEvent({ title: '提示信息', message:"操作失败,提示信息:"+messages, }); this.dispatchEvent(event); return; } } }).catch(err=>{ // console.log("updateLead error:"); // console.log(err.message); }); window.location.reload(); } }