buli
2023-05-23 07390e2fcb4adf27c928335bf27ae7939c5a80ad
force-app/main/default/lwc/lexEquipmentRentalPDF/lexEquipmentRentalPDF.js
@@ -1,10 +1,12 @@
import { LightningElement, track, wire, api } from 'lwc';
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { updateRecord } from 'lightning/uiRecordApi';
import init from '@salesforce/apex/rentalApplyEquipmentRentalPDFController.initJumptoPDFButton';
import init from '@salesforce/apex/RentalApplyEquipmentRentalPDFController.initJumptoPDFButton';
export default class rentalApplyEquipmentRentalPDF extends LightningElement {
export default class lexEquipmentRentalPDF extends LightningElement {
   @api recordId;
   IsLoading = true;
@@ -29,11 +31,14 @@
         recordId : this.recordId
      }).then(result => {
         if(result != null) {
            this.IsLoading = false;
            let num = result.pageLength;
            console.log("======"+this.recordId + '   ' +num);
            console.log("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/FixtureRentalPDF?raid=" + this.recordId + "&page=" + num)
            window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/apex/FixtureRentalPDF?raid=" + this.recordId + "&page=" + num);
            console.log('shipmentRequestedCnt'+ result.shipmentRequestedCnt);
            if(result.shipmentRequestedCnt > 0){
               this.IsLoading = false;
               let num = result.pageLength;
               window.open("https://ocsm--partial.sandbox.lightning.force.com/apex/FixtureRentalPDF?raid=" + this.recordId + "&page=" + num);
            }else{
               this.showToast('当前的申请单中没有已出库指示的配套。','error');
            }
         }
      })
      .catch( error =>{
@@ -41,4 +46,20 @@
      })
   }
   showToast(msg,type) {
        const event = new ShowToastEvent({
            message: msg,
            variant: type
        });
        if(type == 'success'){
            this.updateRecordView();
        }
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
}