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/LexSIAbortBtnController.init'; import setAbortSI from '@salesforce/apex/LexSIAbortBtnController.setAbortSI'; import LightningPrompt from 'lightning/prompt'; //SI项目需求表 终止SI需求表 export default class lexSIAbortBtn extends NavigationMixin(LightningElement) { @api recordId; @api rentalApplyIds; IsLoading=true; //提示信息 msg; hasError; rentalApplyIds; decideFLG; connectedCallback(){ init({recordId:this.recordId}).then(res=>{ console.log(1); console.log(res); this.decideFLG=res; this.main().then(res=>{ this.IsLoading=false; if(this.msg==""){ this.dispatchEvent(new CloseActionScreenEvent()); this.closeAction(); } }) }) } async main(){ // let rentalApplyIds = {!GETRECORDIDS($ObjectType.IS_Opportunity_Demand__c)}; // //alert(rentalApplyIds ); // let decideFLG ='{!Opportunity.Estimation_Decision__c}'; let hasError ='0'; let decideFLG=this.decideFLG; let str; if(decideFLG ==true){ // alert('报价已决定,不能终止'); this.msg="报价已决定,不能终止"; hasError ='1'; }else{ // str=prompt("请输入终止理由"," "); await LightningPrompt.open({ message: '请输入终止理由', //theme defaults to "default" label: '', // this is the header text defaultValue: '', //this is optional }).then((result) => { str=result; }); } if (this.rentalApplyIds.length == 0) { // alert("请选择一个需求表。"); this.msg="请选择一个需求表。"; hasError = '1'; } else if (this.rentalApplyIds.length > 1) { // alert("只能选择一个需求表。"); this.msg="只能选择一个需求表。"; hasError = '1'; } console.log("ttt1"); let ids= ''; if (hasError == '0') { ids+= this.rentalApplyIds[0]; let id = this.rentalApplyIds[0]; try{ console.log("ttt1.1"); let rtn='Fin'; await setAbortSI({isoID:ids,AbortReason:str}).then(res=>{ rtn=res; }); console.log(rtn); console.log("ttt1.2"); if(rtn!='Fin'){ // alert(rtn); this.msg=rtn; console.log("ttt2"); }else{ this.msg=''; // window.top.location.reload(); console.log("ttt3"); } }catch(e){ // alert(e); console.log(e.message); this.msg=e; console.log("ttt4"); } } } closeAction() { //返回当前的备品申请 window.open("/"+this.recordId,'_self'); } }