import { LightningElement, track, wire,api } from 'lwc';
|
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
|
|
|
import transferApplyPDF from '@salesforce/apex/TransferApplyController.transferApplyPDF';
|
export default class lexTransferApplyPDF extends LightningElement {
|
@api recordId;
|
transferApplyPDFRes;
|
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.transferApplyId:' + this.recordId);
|
transferApplyPDF({
|
transferApplyId : this.recordId
|
}).then(result => {
|
console.log(result);
|
this.transferApplyPDFRes = result;
|
this.cancelSubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
|
}).catch( error =>{
|
console.log(error);
|
});
|
}
|
async cancelSubmit(){
|
let records = new Array();
|
records = this.transferApplyPDFRes;
|
var size =records.length;
|
if(size>0){
|
var length = size%10 ==0? size/10 : parseInt(size/10) +1;
|
for(var i =0;i<length;i++){
|
window.open('/apex/TransferApplyPDF?raid='+this.recordId+'&page=' + i);
|
}
|
}else{
|
this.showToast('','当前的申请单中没有已批准备品。','warning');
|
}
|
}
|
|
showToast(_title,_message,_variant) {
|
const event = new ShowToastEvent({
|
title: _title,
|
message:_message,
|
variant: _variant,
|
});
|
this.dispatchEvent(event);
|
}
|
|
}
|
|
//old js'
|
/*
|
{!RequireScript("/soap/ajax/51.0/connection.js")}
|
{!RequireScript("/soap/ajax/51.0/apex.js")}
|
var foo = function() {
|
|
var sql = "select Id from TransferApplySummary__c where TransferApply__c = '{!TransferApply__c.Id}' and ApprovalDetails__c > 0 and TAS_Status__c != '取消'";
|
//Yi_StockDown__c->ApprovalDetails__c 20210805 ljh SFDC-C56D3K 已下架->已批准
|
var sqlResult = sforce.connection.query(sql);
|
var records = sqlResult.getArray("records");
|
var size =records.length;
|
if(size>0){
|
var length = size%10 ==0? size/10 : parseInt(size/10) +1;
|
for(var i =0;i<length;i++){
|
window.open('/apex/TransferApplyPDF?raid={!TransferApply__c.Id}&page=' + i);
|
}
|
}else{
|
alert('当前的申请单中没有已批准备品。');
|
}
|
}
|
foo();
|
*/
|