unknown
2023-07-20 bac2a731433a38cb262e7f38a98c9522481752ec
button-all_received_fse

现场统一收货
1个文件已修改
2个文件已添加
119 ■■■■ 已修改文件
force-app/main/default/classes/LexAllReceivedFseController.cls 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexAllReceivedFseController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/lwc/lexAllReceivedFse/lexAllReceivedFse.js 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/LexAllReceivedFseController.cls
New file
@@ -0,0 +1,58 @@
/**
 * *
    ODescription:
    GAuthor: sun xia
    @Date: 2023-07-11 15:31:56
    GIastEditors: sun xia
    @IastEditTime: 2023-07-11 15:31:56
 * */
public with sharing class LexAllReceivedFseController {
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new InitData();
        try{
            List<Rental_Apply__c> raList = [SELECT Id, Loaner_received_ng_num__c from Rental_Apply__c where Id = :recordId];
            if(raList.size()>0){
                Rental_Apply__c ra = raList[0];
                res.id = ra.Id;
                res.loanerReceivedNgNum = Integer.valueOf(ra.Loaner_received_ng_num__c);
            }
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '****e:' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String getRaeSet(String recordId){
        List<Rental_Apply_Equipment_Set__c> raeList = [SELECT Id, RAES_Status__c, Loaner_received_time__c from Rental_Apply_Equipment_Set__c WHERE Rental_Apply__c = :recordId];
        List<Rental_Apply_Equipment_Set__c> updateList = new List<Rental_Apply_Equipment_Set__c>();
        for(Integer i=0; i<raeList.size(); i++){
            if(raeList[i].Loaner_received_time__c == null && raeList[i].RAES_Status__c == '已出库'){
                Rental_Apply_Equipment_Set__c tempRAE = new Rental_Apply_Equipment_Set__c();
                tempRAE.Id = raeList[i].Id;
                tempRAE.Received_Confirm__c = 'OK';
                updateList.add(tempRAE);
            }
        }
        if(updateList.size()>0){
            try {
                Update updateList;
                return 'SUCCESS';
            }
            catch (Exception e) {
                return e.getMessage();
            }
        }
        return '不存在更新明细';
    }
    public Class InitData{
        @AuraEnabled
        public String id;
        @AuraEnabled
        public Integer loanerReceivedNgNum;
    }
}
force-app/main/default/classes/LexAllReceivedFseController.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>50.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/lwc/lexAllReceivedFse/lexAllReceivedFse.js
@@ -4,8 +4,8 @@
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { updateRecord } from 'lightning/uiRecordApi';
import init from '@salesforce/apex/AllReceivedFseController.init';
import getRaeSet from '@salesforce/apex/AllReceivedFseController.getRaeSet';
import init from '@salesforce/apex/LexAllReceivedFseController.init';
import getRaeSet from '@salesforce/apex/LexAllReceivedFseController.getRaeSet';
export default class lexAllReceivedFse extends LightningElement {
    @api recordId;
@@ -26,31 +26,33 @@
        init({
            recordId: this.recordId
        }).then(res=>{
            console.log('loanerReceivedNgNum==='+ res.loanerReceivedNgNum);
            if(res.loanerReceivedNgNum == 0){
                const evt = new ShowToastEvent({
                        title : '现场已经全部收到实物了',
                        message: '',
                        variant: 'error'
                    });
                this.dispatchEvent(evt);
                this.dispatchEvent(new CloseActionScreenEvent());
            }else{
                getRaeSet({
                    recordId: this.recordId
                }).then(res=>{
                    if(res == 'SUCCESS'){
                        this.showToast('现场已全部收货','success');
                        return;
                    }else{
                        this.showToast(res,'warning');
                        return;
                    }
                })
                .catch(err=>{
                    console.log('getRaeSet==='+err);
                })
            console.log('loanerReceivedNgNum==='+ JSON.stringify(res));
            if(res){
                if(res.loanerReceivedNgNum == 0){
                    const evt = new ShowToastEvent({
                            title : '现场已经全部收到实物了',
                            message: '',
                            variant: 'error'
                        });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                }else{
                    getRaeSet({
                        recordId: this.recordId
                    }).then(res=>{
                        if(res == 'SUCCESS'){
                            this.showToast('现场已全部收货','success');
                            return;
                        }else{
                            this.showToast(res,'warning');
                            return;
                        }
                    })
                    .catch(err=>{
                        console.log('getRaeSet==='+err);
                    })
                }
            }
        }).catch(err=>{
            console.log('init==='+err);