import { LightningElement,api, track, wire } from 'lwc'; import init from '@salesforce/apex/EquipmentSetRentalController.init'; import AssignBtn from '@salesforce/apex/RentalApplyWebService.AssignBtn'; import {CurrentPageReference} from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; const event1 = new ShowToastEvent({ title: '请检查申请状态', message: '不能引当,请确认申请的状态', }); const event2 = new ShowToastEvent({ title: 'Get Help', message: '方法错误,请联系管理员', }); export default class lexEquipmentSetRental_Order extends LightningElement { @api recordId; IsLoading; Rental_Apply__c; // @wire(CurrentPageReference) // getStateParameters(currentPageReference){ // if(currentPageReference){ // console.log(currentPageReference); // console.log("进入获取page参数") // const IdValue=currentPageReference.state.recordId; // if(IdValue){ // let str=`${IdValue}`; // this.recordId=str; // console.log("recordId="+str); // } // } // } connectedCallback(){ init({recordId:this.recordId}).then(res=>{ if(res!=null){ this.IsLoading=false; console.log("res"); console.log(res); console.log("进入初始化对象其他属性"); this.Rental_Apply__c=res; console.log(this.Rental_Apply__c); this.distribution(); } else{ var a="没进distribution"; console.log(a); } }).catch(error =>{ console.log("error"); console.log(error.message); }).finally(()=>{ }); } async distribution(){ var raid = this.Rental_Apply__c.Id; var rtn = await AssignBtn(raid); if(this.Rental_Apply__c.Status__c == '取消' && this.Rental_Apply__c.Rental_Apply_Equipment_Set_Cnt__c != '0') { window.open("/apex/EquipmentRentalApply?raid="+URLENCODE(this.Rental_Apply__c.Id)); } else if((this.Rental_Apply__c.demo_purpose2__c == '学会/展台' || this.Rental_Apply__c.demo_purpose2__c == '课题研究' || this.Rental_Apply__c.demo_purpose2__c == '培训中心' ) && this.Rental_Apply__c.Status__c == '草案中') { this.dispatchEvent(event1); } else if( (this.Rental_Apply__c.demo_purpose2__c == '试用(无询价)' || this.Rental_Apply__c.demo_purpose2__c == '试用(有询价)' || this.Rental_Apply__c.demo_purpose2__c == '动物实验' || this.Rental_Apply__c.demo_purpose2__c == '一般维修代用' || this.Rental_Apply__c.demo_purpose2__c == '保修合同用户维修代用' || this.Rental_Apply__c.demo_purpose2__c == '已购待货' ) && this.Rental_Apply__c.Status__c != '批准完了' && this.Rental_Apply__c.Status__c != '引当完了' && this.Rental_Apply__c.Status__c != '出库指示完了') { this.dispatchEvent(event1); } else if(rtn == 'Fin') { window.open("/apex/EquipmentRentalApply?raid="+URLENCODE(this.Rental_Apply__c.Id)); } else{ this.dispatchEvent(event2); } } }