From 4661adc43f549036f4e6e44debe92521c5793083 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期二, 06 六月 2023 11:06:36 +0800
Subject: [PATCH] 修改页面以及按钮

---
 force-app/main/default/classes/lexPCLLostReportLwcController.cls |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/force-app/main/default/classes/lexPCLLostReportLwcController.cls b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
index 6adf98b..3a4b157 100644
--- a/force-app/main/default/classes/lexPCLLostReportLwcController.cls
+++ b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
@@ -494,7 +494,7 @@
 	}
 	// 鏁版嵁褰曞叆
 	@AuraEnabled
-	public static Map<String,String> dataEntry(String report1){
+	public static Map<String,String> dataEntry(String report1,List<Id> deleteBrandIdList,List<Id> deleteProductIdList){
 		LostReport report = (LostReport)JSON.deserialize(report1, LostReport.class);
 		Map<String,String> messageMap = new Map <String,String>();
 		system.debug('save---start:');
@@ -543,30 +543,32 @@
 			map<string,PCLLostProduct__c> upsertLostProductMap = new map<string,PCLLostProduct__c>();
 			// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
 			list<PCLLostProduct__c> deleteLostProductList = new list<PCLLostProduct__c>();
+			Integer lineNo = 0;
 			for(LostBrand tempLostBrand : report.LostBrands ) {
 				// 濡傛灉鏈夊け鍗曞搧鐗岋紝閭d箞灏辫鎻掑叆鏇存柊锛�
 				system.debug('tempLostBrand.lostBrand.Lost_By_Company__c:'+tempLostBrand.lostBrand.Lost_By_Company__c);
 				if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
-					upsertLostBrandMap.put(tempLostBrand.lineNo,tempLostBrand.lostBrand);
-					tempLostBrand.lostBrand.Lost_cancel_report__c = report.lostReport.id;
+					upsertLostBrandMap.put(lineNo,tempLostBrand.lostBrand);
+					tempLostBrand.lostBrand.Lost_cancel_report__c = report.lostReport.Id;
 					tempLostBrand.lostBrand.Name = tempLostBrand.lostBrand.Lost_By_Company__c;
 					integer tempNo = 0;
 					for( PCLLostProducts tempLostProduct : tempLostBrand.LostProducts) {
 						system.debug('Name:'+ tempLostProduct.LostProductss.Name );
 						if(tempLostProduct.LostProductss.Quantity__c !=null && tempLostProduct.LostProductss.Quantity__c >0) {
 							tempLostProduct.LostProductss.Name = tempLostBrand.lostBrand.Name + tempLostProduct.LostProductss.Quantity__c;
-							upsertLostProductMap.put(tempLostBrand.lineNo +':'+ tempNo,tempLostProduct.LostProductss);
-						}else if(string.isNotBlank(tempLostProduct.LostProductss.id)) {
+							upsertLostProductMap.put(lineNo +':'+ tempNo,tempLostProduct.LostProductss);
+						}else if(string.isNotBlank(tempLostProduct.LostProductss.Id)) {
 							deleteLostProductList.add(tempLostProduct.LostProductss);
 						}
 						tempNo++;
 					}
 				}
 				// 濡傛灉娌℃湁鍝佺墝锛屼絾鏄湁id锛� 杩欐牱鏁版嵁闇�瑕佸垹闄�
-				else if(string.isNotBlank(tempLostBrand.lostBrand.id)) {
-					deleteLostBrandMap.put(tempLostBrand.lineNo,tempLostBrand.lostBrand);
+				else if(string.isNotBlank(tempLostBrand.lostBrand.Id )) {
+					deleteLostBrandMap.put(lineNo,tempLostBrand.lostBrand);
 					// 杩欓噷鍙兘闇�瑕佷篃鍒ゆ柇涓�涓嬪け鍗曞瀷鍙锋湁娌℃湁闇�瑕佸垹鎺�
 				}
+				lineNo++;
 			}
 			if(upsertLostBrandMap.size()>0) {
 				upsert upsertLostBrandMap.values();
@@ -574,7 +576,7 @@
 			for( string productNo :upsertLostProductMap.keyset()) {
 				PCLLostProduct__c tempLostProduct = upsertLostProductMap.get(productNo);
 				integer brandNo = integer.valueof(productNo.split(':')[0]);
-				tempLostProduct.PCLLostBrand__c = upsertLostBrandMap.get(brandNo).id;
+				tempLostProduct.PCLLostBrand__c = upsertLostBrandMap.get(brandNo).Id;
 			}
 			if(upsertLostProductMap.size()>0) {
 				upsert upsertLostProductMap.values();
@@ -582,13 +584,20 @@
 			if(deleteLostBrandMap.size()>0) {
 				delete deleteLostBrandMap.values();
 				for(PCLLostBrand__c pcl: deleteLostBrandMap.values()) {
-					pcl.id = null;
+					pcl.Id = null;
 				}
+			}
+			if (deleteProductIdList.size()>0) {
+				database.delete(deleteProductIdList);
+				
+			}
+			if (deleteBrandIdList.size()>0) {
+				database.delete(deleteBrandIdList);
 			}
 			if(deleteLostProductList.size()>0) {
 				delete deleteLostProductList;
 				for(PCLLostProduct__c pclp: deleteLostProductList) {
-					pclp.id = null;
+					pclp.Id = null;
 				}
 			}
 			if(deleteBrandIDSet.size() > 0) {

--
Gitblit v1.9.1