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';
|
|
export default class rentalApplyEquipmentRentalPDF extends LightningElement {
|
@api recordId;
|
IsLoading = true;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
console.log(currentPageReference);
|
|
if(currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if(urlValue) {
|
let str = `${urlValue}`;
|
console.log("str");
|
console.log(str);
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback() {
|
console.log('this.recordId' + this.recordId);
|
init({
|
recordId : this.recordId
|
}).then(result => {
|
if(result != null) {
|
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 =>{
|
console.log(error);
|
})
|
}
|
|
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 }});
|
}
|
}
|