zhangzhengmei
2023-04-17 256deea77ed43c414c927e6d8c8d455bc643196e
调拨申请—》调拨明细确认单PDF 按钮修改
6个文件已添加
155 ■■■■■ 已修改文件
force-app/main/default/classes/TransferApplyController.cls 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/TransferApplyController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.css 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.html 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.js 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.js-meta.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/TransferApplyController.cls
New file
@@ -0,0 +1,31 @@
public with sharing class TransferApplyController {
    public TransferApplyController() {
    }
    @AuraEnabled
    public static list<TransferApplySummary__c> transferApplyPDF(string transferApplyId) {
        try {
            // var sql = "select Id from TransferApplySummary__c where TransferApply__c =
            //'{!TransferApply__c.Id}' and ApprovalDetails__c > 0 and TAS_Status__c != '取消'";
            list<TransferApplySummary__c> reports = [
                select id from TransferApplySummary__c
                where TransferApply__c = :transferApplyId
                and ApprovalDetails__c > 0
                and TAS_Status__c != '取消'];
            return reports;
        }catch ( Exception e) {
            System.debug(LoggingLevel.ERROR,'TransferApplySummary__c TransferApplyPDF Error : ' + e);
        }
        return null;
    }
    @AuraEnabled
    public static Boolean applyPermission()
    {
        Schema.DescribeSobjectResult schemaMap = Schema.describeSObjects(new String[]{'TransferApply__c'})[0];
        return schemaMap.isCreateable();
    }
}
force-app/main/default/classes/TransferApplyController.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>51.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.css
New file
@@ -0,0 +1,11 @@
.Holder{
    position: relative;
    display: inline-block;
    width: 80px;
    height: 80px;
    text-align: center;
}
.container .uiContainerManager{
    display : none !important;
}
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.html
New file
@@ -0,0 +1,5 @@
<template>
    <div class="Holder" if:true={IsLoading}>
        <lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
    </div>
</template>
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.js
New file
@@ -0,0 +1,92 @@
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();
*/
force-app/main/default/lwc/lexTransferApplyPDF/lexTransferApplyPDF.js-meta.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexTransferApplyPDF">
    <apiVersion>51.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordAction</target>
    </targets>
</LightningComponentBundle>