From 7687b7bd101f0fb43342e95344d143a12d3e6d3d Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期三, 19 七月 2023 17:55:08 +0800
Subject: [PATCH] button-lexEquipmentRentalPicturePDF

---
 force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls-meta.xml      |    5 ++
 force-app/main/default/lwc/lexEquipmentRentalPicturePDF/lexEquipmentRentalPicturePDF.js |   21 ++++++----
 force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls               |   42 +++++++++++++++++++++
 3 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls b/force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls
new file mode 100644
index 0000000..295f6d7
--- /dev/null
+++ b/force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls
@@ -0,0 +1,42 @@
+/**
+ * *
+    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 LexEquipmentRentalPicturePDFController {
+    @AuraEnabled
+    public static InitData init(String recordId){
+        InitData res = new InitData();
+        try {
+            List<Rental_Apply__c> raList = [SELECT Id, Shipment_requested_cnt__c from Rental_Apply__c where Id = :recordId];
+            if(raList.size()>0){
+                Rental_Apply__c ra = raList[0];
+                if(ra.Shipment_requested_cnt__c > 0){
+                    List<Rental_Apply_Equipment_Set__c> raeSet = [select Id from Rental_Apply_Equipment_Set__c where Rental_Apply__c = :recordId and Yi_Shipment_request__c > 0 and RAES_Status__c != '鍙栨秷'];
+                    Integer setLength = raeSet.size();
+                    res.pageLength = Math.mod(setLength,10)== 0 ? setLength/10 : (setLength/10) +1 ;
+                    res.raesList = raeSet;
+                } 
+                res.shipmentRequestedCnt = Integer.valueOf(ra.Shipment_requested_cnt__c);   
+            }
+        }
+        catch (Exception e) {
+            System.debug(LoggingLevel.INFO, '****e:' + e);
+        }
+        return res;
+    }
+
+    public class InitData{
+        @AuraEnabled
+        public String id;
+        @AuraEnabled
+        public Integer pagelength;
+        @AuraEnabled
+        public Integer shipmentRequestedCnt;
+        @AuraEnabled
+        public List<Rental_Apply_Equipment_Set__c> raesList;
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls-meta.xml b/force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls-meta.xml
new file mode 100644
index 0000000..9662499
--- /dev/null
+++ b/force-app/main/default/classes/LexEquipmentRentalPicturePDFController.cls-meta.xml
@@ -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>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexEquipmentRentalPicturePDF/lexEquipmentRentalPicturePDF.js b/force-app/main/default/lwc/lexEquipmentRentalPicturePDF/lexEquipmentRentalPicturePDF.js
index 2d24bf8..30c6e36 100644
--- a/force-app/main/default/lwc/lexEquipmentRentalPicturePDF/lexEquipmentRentalPicturePDF.js
+++ b/force-app/main/default/lwc/lexEquipmentRentalPicturePDF/lexEquipmentRentalPicturePDF.js
@@ -4,7 +4,7 @@
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 import { updateRecord } from 'lightning/uiRecordApi';
 
-import init from '@salesforce/apex/EquipmentRentalPicturePDFController.init';
+import init from '@salesforce/apex/LexEquipmentRentalPicturePDFController.init';
 export default class lexEquipmentRentalPicturePDF extends LightningElement {
 	@api recordId;
 		IsLoading = true;
@@ -25,15 +25,20 @@
 		init({
 			recordId: this.recordId
 		}).then(result=>{
-			//console.log('result.shipmentRequestedCnt===' + result.shipmentRequestedCnt)
-			if( result.shipmentRequestedCnt > 0){
-				console.log(result.pagelength);
-				for(var i =0; i<result.pagelength; i++){
-					this.dispatchEvent(new CloseActionScreenEvent());
-					window.open('/apex/FixtureRentalPicturePDF?raid='+ this.recordId +'&page=' + i); 
+			console.log('result==='+JSON.stringify(result));
+			if(result){
+				//console.log('result.shipmentRequestedCnt===' + result.shipmentRequestedCnt)
+				if( result.shipmentRequestedCnt > 0){
+					console.log(result.pagelength);
+					for(var i =0; i<result.pagelength; i++){
+						this.dispatchEvent(new CloseActionScreenEvent());
+						window.open('/apex/FixtureRentalPicturePDF?raid='+ this.recordId +'&page=' + i); 
+					}
+				}else{
+					this.showToast('褰撳墠鐨勭敵璇峰崟涓病鏈夊凡鍑哄簱鎸囩ず鐨勯厤濂椼��','error');
 				}
 			}else{
-				this.showToast('褰撳墠鐨勭敵璇峰崟涓病鏈夊凡鍑哄簱鎸囩ず鐨勯厤濂椼��','error');
+				this.showToast("鏈煡鍒版暟鎹�", 'error');
 			}
 		}).catch(err=>{
 			this.dispatchEvent(new CloseActionScreenEvent());

--
Gitblit v1.9.1