zhangqian
2023-07-31 ca743be68ec263a6d9d6c70410f894ed2bb1d293
force-app/main/default/lwc/lexEquipmentSetRental_Order/lexEquipmentSetRental_Order.js
@@ -3,6 +3,19 @@
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;
@@ -10,35 +23,35 @@
    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);
          }
       }
    }
   // @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();
         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);
          var a="没进distribution";
          console.log(a);
       }
    }).catch(error =>{
       console.log("error");
@@ -60,7 +73,8 @@
         this.Rental_Apply__c.demo_purpose2__c == '培训中心'
         )
         && this.Rental_Apply__c.Status__c == '草案中') {
         alert("不能引当,请确认申请的状态");
         this.dispatchEvent(event1);
         this.dispatchEvent(new CloseActionScreenEvent());
      } else if(
         (this.Rental_Apply__c.demo_purpose2__c == '试用(无询价)' ||
         this.Rental_Apply__c.demo_purpose2__c == '试用(有询价)' || 
@@ -72,12 +86,20 @@
         && this.Rental_Apply__c.Status__c != '批准完了'
         && this.Rental_Apply__c.Status__c != '引当完了'
         && this.Rental_Apply__c.Status__c != '出库指示完了') {
            alert("不能引当,请确认申请的状态");
            this.dispatchEvent(event1);
            this.dispatchEvent(new CloseActionScreenEvent());
      } else if(rtn == 'Fin') {
         window.open("/apex/EquipmentRentalApply?raid="+URLENCODE(this.Rental_Apply__c.Id));
         this.closeAction();
      } else{
         alert(rtn);
         this.dispatchEvent(event2);
         this.dispatchEvent(new CloseActionScreenEvent());
      }     
    }
   closeAction() {
        //返回当前的备品申请
      window.open("/"+this.recordId,'_self');
    }
}