From c83dc56870037a7b5a10d07ef1154a33b6bf43ee Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期日, 23 四月 2023 17:44:40 +0800
Subject: [PATCH] 修改按钮以及页面所需controller

---
 force-app/main/default/classes/lexPCLLostReportLwcController.cls |  184 +++++++++++++++++----------------------------
 1 files changed, 71 insertions(+), 113 deletions(-)

diff --git a/force-app/main/default/classes/lexPCLLostReportLwcController.cls b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
index 6b5484f..9082354 100644
--- a/force-app/main/default/classes/lexPCLLostReportLwcController.cls
+++ b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
@@ -1,51 +1,31 @@
 public with sharing class lexPCLLostReportLwcController {
-    public static Product2 pro2;
-	public static string oppId;
-	public static string lostReportId;
+	public Product2 pro2 { get; set; }
+	public string oppId { get; set; }
+	public string lostReportId { get; set; }
 	// 褰撳墠椤甸潰鐘舵�� Create,View and Edit, MarketEdit
-	public static string pageStatus;
+	public string pageStatus { get; set; }
 	// 澶卞崟锛岄儴鍒嗗け鍗�
-	public static string lostType;
-	public static Set<ID> deleteBrandIDSet = new Set<ID>();
-	public static string submitFlag;
-	public static LostReport LostReport;
-	public static integer brandNo;
-	public static integer RemoveBrandNo;
-	public static integer setBrandNo;
-	public static integer brandCount;
+	public string lostType {get; set;}
+	public Set<ID> deleteBrandIDSet = new Set<ID>();
+	public string submitFlag {get; set;}
+	public LostReport LostReport {get; set;}
+	public integer brandNo {get; set;}
+	public integer RemoveBrandNo {get; set;}
+	public integer setBrandNo {get; set;}
+	public integer brandCount {get; set;}
 	// add tcm 20211122 start
-	public static integer topNum;
-	public static integer secondNum;
+	public integer topNum {get; set;}
+	public integer secondNum {get; set;}
 	// add tcm 20211122 end
-    
-    
-
-	// 绔炰簤瀵规墜瀵圭収鍏崇郴琛紝key鏄搧鐗屽悕瀛楋紝value鏄疘D
-	public static map<string,id> CompetitionMap;
-    
-	// public PCLLostReportController(ApexPages.StandardController controller) {
-	// 	this();
-	// }
-	// public PCLLostReportController(){
-	// 	oppId =
-	// 		ApexPages.currentPage().getParameters().get('oppId') == null ? ''
-	// 		: ApexPages.currentPage().getParameters().get('oppId');
-	// 	lostReportId =
-	// 		ApexPages.currentPage().getParameters().get('Id') == null ? ''
-	// 		: ApexPages.currentPage().getParameters().get('Id');
-	// 	pageStatus =
-	// 		ApexPages.currentPage().getParameters().get('pageStatus') == null ? ''
-	// 		: ApexPages.currentPage().getParameters().get('pageStatus');
-	// 	lostType =
-	// 		ApexPages.currentPage().getParameters().get('lostType') == null ? ''
-	// 		: ApexPages.currentPage().getParameters().get('lostType');
-	// 	submitFlag = ApexPages.currentPage().getParameters().get('submitFlag') == null ? ''
-	// 	    : ApexPages.currentPage().getParameters().get('submitFlag');
-
-	// }
 	// 鍒濆鍖�
-    @AuraEnabled
-	public static String init(){
+	public void initForApex(string oppId1,string lostReportId1,string pageStatus1,string lostType1,string submitFlag1){
+		oppId = oppId1;
+		lostReportId = lostReportId;
+		pageStatus = pageStatus1;
+		lostType = lostType1;
+		submitFlag = submitFlag1;
+	}
+	public String init(){
 		if(string.isblank(pageStatus)) {
 			// 杩欓噷闇�瑕佹姤閿欐病鏈変紶鍙傛暟
 			return '椤甸潰鍑洪敊锛岃鍒锋柊鍚庨噸璇曪紒';
@@ -176,13 +156,13 @@
 		// 璇诲彇绔炰簤瀵规墜鍝佺墝
 		// BrandmapSet();
 		if(string.isNotEmpty(submitFlag)) {
-            return '鎻愪氦鎴愬姛锛�';
+			return '鎻愪氦鎴愬姛锛�';
+
 		}
-        return null;
+		return null;
 	}
 	// 缂栬緫 鍙湁绯荤粺绠$悊鍛樻垨鑰呰崏妗堜腑鍙互缂栬緫
-    @AuraEnabled
-	public static String edit2(){
+	public String edit2(){
 		if( userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC' ||
 		    '鑽夋'.equals(LostReport.LostReport.Report_Status__c)
 		    ) {
@@ -190,13 +170,12 @@
 			init();
 		}
 		else{
-            return '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘杩涜缂栬緫锛�';
+			return '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘杩涜缂栬緫锛�';
 		}
 		return null;
 	}
 	// 璁剧疆鍝佺墝
-    @AuraEnabled
-	public static void setBrand(){
+	public void setBrand(){
 		list<LostBrand> LostBrandlist =  LostReport.LostBrands;
 		LostBrand tempBrand = LostBrandlist.get(setBrandNo);
 		string brandName = tempBrand.lostBrand.Lost_By_Company__c;
@@ -220,8 +199,7 @@
 		}
 	}
 	// 璁剧疆鍝佺墝
-    @AuraEnabled
-	public static void setbrandmannual(){
+	public void setbrandmannual(){
 		list<LostBrand> LostBrandlist =  LostReport.LostBrands;
 		LostBrand tempBrand = LostBrandlist.get(setBrandNo);
 		string brandName = tempBrand.lostBrand.Lost_By_Company__c;
@@ -243,8 +221,7 @@
 		}
 	}
 	// 淇濆瓨
-    @AuraEnabled
-	public static String save(){
+	public String save(){
 
 		if(!DataCheck()) {
 			return null;
@@ -268,8 +245,7 @@
 
 	// }
 	// 鏁版嵁妫�鏌�
-    @AuraEnabled
-	public static boolean DataCheck(){
+	public boolean DataCheck(){
 		boolean dataCheck = true;
 		if(string.isBlank(LostReport.LostReport.LostType__c))
 		{
@@ -347,8 +323,7 @@
 
 		return dataCheck;
 	}
-    @AuraEnabled
-	public static list<LostBrand> brandcopy(){
+	public list<LostBrand> brandcopy(){
 		list<LostBrand> tempbrands = new list<LostBrand>();
 		for(LostBrand tempbrand: LostReport.LostBrands) {
 			LostBrand LostBrand =
@@ -360,8 +335,7 @@
 		return tempbrands;
 	}
 	// 鏁版嵁褰曞叆
-    @AuraEnabled
-	public static boolean dataEntry(){
+	public boolean dataEntry(){
 		system.debug('save---start:');
 		Savepoint sp = Database.setSavepoint();
 		Lost_cancel_report__c templostReport = LostReport.lostReport.clone();
@@ -488,52 +462,47 @@
 			LostReport.lostReport = templostReport;
 			LostReport.LostBrands = tempBrands;
 			// 杩欓噷闇�瑕佸啓涓�浜涙姤閿欎俊鎭�
+			ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
 			return false;
 		}
 		return true;
 	}
 
-	// 鍙栨秷
-	// public PageReference cancel(){
-	// 	PageReference page = new PageReference('/'+oppId);
-	// 	page.setRedirect(true);
-	// 	return page;
-	// }
+	
 	// 鎻愪氦
-	// public PageReference submit(){
-	// 	if(!'鑽夋'.equals(LostReport.LostReport.Report_Status__c) ) {
-	// 		return '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘鎻愪氦鐢宠锛�';
-	// 	}
-
-	// 	Savepoint sp = Database.setSavepoint();
-	// 	try{
-	// 		LostReport.lostReport.Report_Status__c = '鎻愪氦';
-	// 		update LostReport.lostReport;
-	// 		Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
-	// 		psr.setObjectId(lostReportId);
-	// 		Approval.ProcessResult submitResult = Approval.process(psr);
-	// 		PageReference page = new PageReference('/apex/PCLLostReportPage');
-	// 		page.getParameters().put('Id', lostReportId);
-	// 		page.getParameters().put('pageStatus', 'View');
-	// 		page.getParameters().put('submitFlag', '1');
-
-	// 		page.setRedirect(true);
-	// 		return page;
-	// 	}catch(exception ex) {
-	// 		Database.rollback(sp);
-	// 		return ex.getMessage();
-	// 	}
-	// }
+	public Map<string,Object> submit(){
+		Map<string,string> messages = new Map<string,string>();
+		if(!'鑽夋'.equals(LostReport.LostReport.Report_Status__c) ) {
+			messages.put('error', '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘鎻愪氦鐢宠锛�');
+			return messages;
+		}
+		Map<string,Object> objs = new Map<string,Object>();
+		Savepoint sp = Database.setSavepoint();
+		try{
+			LostReport.lostReport.Report_Status__c = '鎻愪氦';
+			update LostReport.lostReport;
+			Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+			psr.setObjectId(lostReportId);
+			Approval.ProcessResult submitResult = Approval.process(psr);
+			objs.put('uri', '/apex/PCLLostReportPage');
+			objs.put('Id', lostReportId);
+			objs.put('pageStatus', 'View');
+			objs.put('submitFlag', '1');
+			return objs;
+		}catch(exception ex) {
+			Database.rollback(sp);
+			messages.put('error', ex.getMessage());
+			return messages;
+		}
+	}
 	// 娣诲姞鍝佺墝
-    @AuraEnabled
-	public static String addBrand(){
+	public String addBrand(){
 		LostReport.LostBrands.add(new LostBrand(LostReport.LostBrands.size()));
 		brandCount = LostReport.LostBrands.size();
 		return null;
 	}
 	// 鍒犻櫎鍝佺墝 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄垹闄ら偅涓搧鐗�
-    @AuraEnabled
-	public static String Remove(){
+	public String Remove(){
 		system.debug('RemoveBrandNo:'+RemoveBrandNo);
 		list<LostBrand> tempLostBrands = new List<lostBrand>();
 		Integer i = 0;
@@ -555,8 +524,7 @@
 	}
 	// 娣诲姞鍨嬪彿锛� 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄坊鍔犲埌閭d釜鍝佺墝
 	// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� start
-    @AuraEnabled
-	public static String addProduct(){
+	public String addProduct(){
 		system.debug('brandNo:'+brandNo);
 		LostBrand tempLostBrand = LostReport.LostBrands.get(brandNo);
 		// PCLLostProduct__c plp = new PCLLostProduct__c(Competitor__c=CompetitionMap.get(LostReport.LostBrands[brandNo].lostBrand.Lost_By_Company__c));
@@ -570,9 +538,7 @@
 	// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� end
 	// 椤甸潰鐨勬暟鎹粨鏋�
 	public class LostReport {
-        @AuraEnabled
 		public Lost_cancel_report__c lostReport { get; set; }
-        @AuraEnabled
 		public list<LostBrand> LostBrands { get; set; }
 		public LostReport(){
 			lostReport = new Lost_cancel_report__c();
@@ -589,14 +555,10 @@
 	}
 
 	public class LostBrand {
-        @AuraEnabled
-		public PCLLostBrand__c lostBrand;
-        @AuraEnabled
-		public Integer lineNo;
-        @AuraEnabled
-		public list<PCLLostProducts> LostProducts;
-        @AuraEnabled
-		public Integer ProductSize;
+		public PCLLostBrand__c lostBrand { get; set; }
+		public Integer lineNo { get; set; }
+		public list<PCLLostProducts> LostProducts { get; set; }
+		public Integer ProductSize {get; set;}
 		public LostBrand( integer lineNo ){
 			lostBrand = new PCLLostBrand__c();
 			this.lineNo = lineNo;
@@ -619,12 +581,9 @@
 	}
 	// add tcm 20211119 start
 	public class PCLLostProducts {
-        @AuraEnabled
-		public Integer lineNo2;
-        @AuraEnabled
-		public PCLLostProduct__c LostProductss;
-        @AuraEnabled
-		public Boolean bool;
+		public Integer lineNo2 { get; set; }
+		public PCLLostProduct__c LostProductss { get; set; }
+		public Boolean bool { get; set; }
 
 		public PCLLostProducts() {
 			this.lineNo2 = 0;
@@ -647,8 +606,7 @@
 	// add tcm 20211119 end
 
 	// add tcm 20211118 start
-    @AuraEnabled
-	public static void search() {
+	public void search() {
 		if (LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c==null) {
 			LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null;
 			LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=null;

--
Gitblit v1.9.1