From 5ce27d69c427ca16f37ff16d53758d0e877a88f9 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期三, 31 五月 2023 17:48:34 +0800
Subject: [PATCH] 修改页面以及更改跳转方式

---
 force-app/main/default/classes/lexPCLLostReportLwcController.cls |  472 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 317 insertions(+), 155 deletions(-)

diff --git a/force-app/main/default/classes/lexPCLLostReportLwcController.cls b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
index 6b5484f..6adf98b 100644
--- a/force-app/main/default/classes/lexPCLLostReportLwcController.cls
+++ b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
@@ -1,59 +1,155 @@
 public with sharing class lexPCLLostReportLwcController {
-    public static Product2 pro2;
-	public static string oppId;
-	public static string lostReportId;
+
+	public static Product2 pro2 { get; set; }
+
+	public static string oppId { get; set; }
+
+	public static string lostReportId { get; set; }
 	// 褰撳墠椤甸潰鐘舵�� Create,View and Edit, MarketEdit
-	public static string pageStatus;
+
+	public static 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 static string lostType {get; set;}
+	public  static Set<ID> deleteBrandIDSet = new Set<ID>();
+
+	public static string submitFlag {get; set;}
+
+	public static LostReport LostReport {get; set;}
+
+	public static integer brandNo {get; set;}
+
+	public static integer RemoveBrandNo {get; set;}
+
+	public static integer setBrandNo {get; set;}
+
+	public static integer brandCount {get; set;}
 	// add tcm 20211122 start
-	public static integer topNum;
-	public static integer secondNum;
+
+	public static integer topNum {get; set;}
+
+	public static 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 LostReport getLostReport(){
+		try {
+			return LostReport;
+		} catch (Exception e) {
+			throw new AuraHandledException(e.getMessage());
+		}
+	}
 
-	// }
+	@AuraEnabled( cacheable = true ) 
+    public static List< Account > getAccounts() { 
+      
+        return [ SELECT Id, Name, Industry FROM Account LIMIT 10 ]; 
+         
+    } 
+     
+    @AuraEnabled( cacheable = true )
+    public static void saveAccounts(List<Account> accList){
+        Insert accList;
+        /*if(accList.size()>0 && accList != null){
+            insert accList;
+        }*/
+    } 
+
+	@AuraEnabled
+    public static String getPickList(String objectName, String fieldName) {
+		List<Map<String, String>> lstPickvals = new List<Map<String, String>>();
+        List<Schema.DescribeSobjectResult> results = Schema.describeSObjects(new List<String>{objectName});
+        
+        for(Schema.DescribeSobjectResult res : results) {
+            for (Schema.PicklistEntry entry : res.fields.getMap().get(fieldName).getDescribe().getPicklistValues()) {
+                if (entry.isActive()) {
+                    lstPickvals.add(new Map<String, String>{'label' => entry.getValue(), 'value' => entry.getValue()});
+                }
+            }
+        }
+		Map<string,List<Map<String, String>>> pickList =  new Map<string,List<Map<String, String>>>();
+		List<Map<String, String>> zhuji = new List<Map<String, String>>();
+		List<Map<String, String>> jingzi = new List<Map<String, String>>();
+		List<Map<String, String>> xiaojingzhong = new List<Map<String, String>>();
+		List<Map<String, String>> nengliang = new List<Map<String, String>>();
+		List<Map<String, String>> qita = new List<Map<String, String>>();
+		Map<String, String> empty = new Map<String, String>{'label' => '--鏃�--', 'value' => ''};
+		zhuji.add(empty);
+		jingzi.add(empty);
+		xiaojingzhong.add(empty);
+		nengliang.add(empty);
+		qita.add(empty);
+		for (Integer i = 0; i < lstPickvals.size(); i++) {
+			if ((i >= 0 && i <= 6) || i == 36) {
+				zhuji.add(lstPickvals[i]);
+			}
+			if ((i >= 7 && i <= 23) || i == 36) {
+				jingzi.add(lstPickvals[i]);
+			}
+			if ((i >= 24 && i <= 29) || i == 35) {
+				xiaojingzhong.add(lstPickvals[i]);
+			}
+			if ((i >= 30 && i <= 34) || i == 36) {
+				nengliang.add(lstPickvals[i]);
+			}
+			if (i == 36) {
+				qita.add(lstPickvals[i]);
+			}
+		}
+		pickList.put('涓绘満', zhuji);
+		pickList.put('闀滃瓙', jingzi);
+		pickList.put('灏忛暅绉�', xiaojingzhong);
+		pickList.put('鑳介噺', nengliang);
+		pickList.put('鍏朵粬', qita);
+        return JSON.serialize(pickList);
+    }
+	@AuraEnabled
+	public static String getPickListByFilter(String objectName,String fieldName,String controlFieldName,String controlFieldValue){
+		try {
+			Schema.DescribeFieldResult fieldDescribe = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap().get(fieldName).getDescribe();
+			// 濡傛灉璇ュ瓧娈典负閫夐」鍒楄〃绫诲瀷锛屽垯鑾峰彇閫夐」鍒楄〃
+			List<Schema.PicklistEntry> picklistValues = fieldDescribe.getPicklistValues();
+			// 鏍规嵁鎺у埗瀛楁鐨勫�肩瓫閫夊嚭瀵瑰簲鐨勯�夐」
+			List<Map<String, Object>> lstPickvals = new List<Map<String, Object>>();
+			for (Schema.PicklistEntry entry : picklistValues) {
+				if (entry.isActive() && entry.getValue().startsWith(controlFieldValue)) {
+					lstPickvals.add(new Map<String, Object>{'label' => entry.getValue(), 'value' => entry.getValue()});
+				}
+			}
+			String jsonStr = JSON.serialize(lstPickvals);
+			return jsonStr;
+		} catch (Exception e) {
+			throw new AuraHandledException(e.getMessage());
+		}
+	}
+
+
+	@AuraEnabled
+	public static Map<string,object> init (string oppId1,string lostReportId1,string pageStatus1,string lostType1,string submitFlag1){
+		try {
+			oppId = oppId1;
+			lostReportId = lostReportId1;
+			pageStatus = pageStatus1;
+			lostType = lostType1;
+			submitFlag = submitFlag1;
+			return init1();
+		} catch (Exception e) {
+			throw new AuraHandledException(e.getMessage());
+		}
+	}
 	// 鍒濆鍖�
-    @AuraEnabled
-	public static String init(){
+	public static Map<string,object> init1(){
+		Map<string,object> maps = new Map<string,object>();
 		if(string.isblank(pageStatus)) {
 			// 杩欓噷闇�瑕佹姤閿欐病鏈変紶鍙傛暟
-			return '椤甸潰鍑洪敊锛岃鍒锋柊鍚庨噸璇曪紒';
+			maps.put('message', '椤甸潰鍑洪敊锛岃鍒锋柊鍚庨噸璇曪紒');
+			return maps;
 		}
 		else if(pageStatus.equals('Create')) {
 			if(string.isBlank(oppId)) {
 				// 杩欓噷鎶ラ敊鍒涘缓鏃跺�欏繀椤绘湁璇环
-				return '鍒涘缓澶卞崟鎶ュ憡鏃讹紝璇烽噸璇环椤甸潰鍒涘缓';
+				maps.put('message', '鍒涘缓澶卞崟鎶ュ憡鏃讹紝璇烽噸璇环椤甸潰鍒涘缓');
+				return maps;
 			}
 			list<opportunity> opplist =
 			[select id,Name,
@@ -64,11 +160,13 @@
 			            limit 1];
 			if( opplist.size() == 0) {
 				pageStatus = null;
-				return '鎮ㄦ病鏈夎浠风殑鏌ョ湅鏉冮檺锛屾棤娉曞垱寤哄け鍗曟姤鍛婏紒';
+				maps.put('message', '鎮ㄦ病鏈夎浠风殑鏌ョ湅鏉冮檺锛屾棤娉曞垱寤哄け鍗曟姤鍛婏紒');
+				return maps;
 			}
 			Schema.DescribeSObjectResult s = Lost_cancel_report__c.sObjectType.getDescribe();
 			if( !s.isCreateable()) {
-				return '鎮ㄤ笉鑳藉垱寤哄け鍗�/閮ㄥ垎澶卞崟鎶ュ憡锛�';
+				maps.put('message', '鎮ㄤ笉鑳藉垱寤哄け鍗�/閮ㄥ垎澶卞崟鎶ュ憡锛�');
+				return maps;
 			}
 			Lost_cancel_report__c tempLostReport =
 				new Lost_cancel_report__c(LostType__c= lostType,
@@ -85,7 +183,8 @@
 			system.debug('edit1');
 			if(string.isBlank(lostReportId)) {
 				pageStatus = null;
-				return '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒';
+				maps.put('message', '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒');
+				return maps;
 			}
 			system.debug('edit2');
 			list<Lost_cancel_report__c> lostReportList =
@@ -94,6 +193,7 @@
 			 Lost_Reason_Sub__c,Lost_By_Company__c,
 			 LostTotalAmount__c,LostType__c,
 			 Report_Status__c,Sales_assistant__c,
+			 InclusionUltrasound__c, //20230506 lt DB202304618804  鍖呭惈瓒呭0
 			 Opportunity__c, Opportunity__r.Sales_assistant_ID__c,
 			 Opportunity__r.Sales_manager_departmentID__c,
 			 Manager_sales__c,recordtypeid,recordtype.DeveloperName
@@ -102,7 +202,8 @@
 
 			if(lostReportList.size() == 0) {
 				pageStatus = null;
-				return '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒';
+				maps.put('message', '鎮ㄦ病鏈夋煡鐪嬭繖涓け鍗�/閮ㄥ垎澶卞崟鎶ュ憡鐨勬潈闄愶紒');
+				return maps;
 			}
 			lostReportList[0].Sales_assistant__c =
 				lostReportList[0].Opportunity__r.Sales_assistant_ID__c;
@@ -176,26 +277,34 @@
 		// 璇诲彇绔炰簤瀵规墜鍝佺墝
 		// BrandmapSet();
 		if(string.isNotEmpty(submitFlag)) {
-            return '鎻愪氦鎴愬姛锛�';
+			maps.put('message', '鎻愪氦鎴愬姛锛�');
+			maps.put('LostReport', LostReport);
+			return maps;
+
 		}
-        return null;
+		// List<Map<String,String>> col = new List<Map<String,String>>();
+		// Map<String,String> ele = new Map<String,String>();
+		// LostReport.LostBrands[0].columns.add();
+		maps.put('LostReport', LostReport);
+		return maps;
 	}
+	//鍐欏埌js
 	// 缂栬緫 鍙湁绯荤粺绠$悊鍛樻垨鑰呰崏妗堜腑鍙互缂栬緫
-    @AuraEnabled
+	@AuraEnabled
 	public static String edit2(){
 		if( userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC' ||
 		    '鑽夋'.equals(LostReport.LostReport.Report_Status__c)
 		    ) {
 			pageStatus = 'Edit';
-			init();
+			init1();
 		}
 		else{
-            return '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘杩涜缂栬緫锛�';
+			return '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘杩涜缂栬緫锛�';
 		}
 		return null;
 	}
 	// 璁剧疆鍝佺墝
-    @AuraEnabled
+	@AuraEnabled
 	public static void setBrand(){
 		list<LostBrand> LostBrandlist =  LostReport.LostBrands;
 		LostBrand tempBrand = LostBrandlist.get(setBrandNo);
@@ -220,7 +329,7 @@
 		}
 	}
 	// 璁剧疆鍝佺墝
-    @AuraEnabled
+	@AuraEnabled
 	public static void setbrandmannual(){
 		list<LostBrand> LostBrandlist =  LostReport.LostBrands;
 		LostBrand tempBrand = LostBrandlist.get(setBrandNo);
@@ -243,20 +352,20 @@
 		}
 	}
 	// 淇濆瓨
-    @AuraEnabled
-	public static String save(){
-
-		if(!DataCheck()) {
-			return null;
-		}
-		if(!dataEntry()) {
-			return null;
-		}
-
-		brandCount = LostReport.LostBrands.size();
-		pageStatus = 'View';
-		return '淇濆瓨鎴愬姛锛�';
-	}
+	// @AuraEnabled
+	// public static String save(LostReport report){
+	// 	try {
+	// 		if(!dataEntry(report)) {
+	// 			return null;
+	// 		}
+	
+	// 		// brandCount = LostReport.LostBrands.size();
+	// 		pageStatus = 'View';
+	// 		return '淇濆瓨鎴愬姛锛�';
+	// 	} catch (Exception e) {
+	// 		return e.getMessage();
+	// 	}
+	// }
 	//璇诲彇骞舵瀯寤虹珵浜夊鎵嬪搧鐗�
 	// public void BrandmapSet(){
 	// 	CompetitionMap = new map<string, id>();
@@ -268,8 +377,9 @@
 
 	// }
 	// 鏁版嵁妫�鏌�
-    @AuraEnabled
-	public static boolean DataCheck(){
+	@AuraEnabled
+	public static boolean DataCheck(LostReport report){
+		LostReport = report;
 		boolean dataCheck = true;
 		if(string.isBlank(LostReport.LostReport.LostType__c))
 		{
@@ -344,13 +454,36 @@
 			}
 			// 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 end
 		}
+		
 
 		return dataCheck;
 	}
-    @AuraEnabled
-	public static list<LostBrand> brandcopy(){
+	@AuraEnabled
+	public static String searchBrands(){
+		String ObjectApi_name = 'PCLLostBrand__c';
+		String Field_name = 'Lost_By_Company__c';
+        //From the Object Api name retrieving the SObject
+        Schema.SObjectType targetType = Schema.getGlobalDescribe().get(ObjectApi_name);
+        Sobject Object_name = targetType.newSObject();
+         //grab the sobject that was passed
+        Schema.sObjectType sobject_type = Object_name.getSObjectType();
+        //describe the sobject
+        Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe(); 
+         //get a map of fields for the passed sobject
+        Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
+        //grab the list of picklist values for the passed field on the sobject
+        List<Schema.PicklistEntry> pick_list_values = field_map.get(Field_name).getDescribe().getPickListValues(); 
+        List<Map<String, Object>> lstPickvals = new List<Map<String, Object>>();
+        for (Schema.PicklistEntry a : pick_list_values) 
+        { //for all values in the picklist list
+			lstPickvals.add(new Map<String, Object>{'label' => a.getValue(), 'value' => a.getValue()});
+        }
+		String jsonStr = JSON.serialize(lstPickvals);
+        return jsonStr;
+	}
+	public static list<LostBrand> brandcopy(LostReport report){
 		list<LostBrand> tempbrands = new list<LostBrand>();
-		for(LostBrand tempbrand: LostReport.LostBrands) {
+		for(LostBrand tempbrand: report.LostBrands) {
 			LostBrand LostBrand =
 				new LostBrand(tempbrand.lineNo,tempbrand.LostProducts );
 			LostBrand.lostBrand = tempbrand.lostBrand.clone();
@@ -360,47 +493,48 @@
 		return tempbrands;
 	}
 	// 鏁版嵁褰曞叆
-    @AuraEnabled
-	public static boolean dataEntry(){
+	@AuraEnabled
+	public static Map<String,String> dataEntry(String report1){
+		LostReport report = (LostReport)JSON.deserialize(report1, LostReport.class);
+		Map<String,String> messageMap = new Map <String,String>();
 		system.debug('save---start:');
 		Savepoint sp = Database.setSavepoint();
-		Lost_cancel_report__c templostReport = LostReport.lostReport.clone();
-		templostReport.id = LostReport.lostReport.id;
-		list<LostBrand> tempBrands = brandcopy();
 		try{
 			// 寰呭畬鎴愶紝杩欓噷闇�瑕佹妸绗竴涓搧鐗岀殑淇℃伅璧嬪�煎埌杩欎釜澶卞崟鎶ュ憡涓婂幓锛岃繕鏈夐渶瑕佹妸鍚勪釜鍝佺墝閲戦姹囨�诲姞璧锋潵锛�
 			//system.debug('LostReport.LostBrands:'+LostReport.LostBrands);
 			// 璁剧疆璁板綍绫诲瀷
-			LostReport.lostReport.recordTypeID  =  LostReport.lostReport.LostType__c== '澶卞崟'?Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_Lost_report').getRecordTypeId() : Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_PartLost_report').getRecordTypeId();
-			LostReport.lostReport.LostTotalAmount__c    = 0;
-			LostReport.lostReport.of_lost_system_processor__c   = 0;
-			LostReport.lostReport.Lost_reason_main__c = null;
-			LostReport.lostReport.Lost_Reason_Sub__c  = null;
-			LostReport.lostReport.Lost_By_Company__c = null;
-			for(LostBrand tempLostBrand : LostReport.LostBrands) {
+			report.lostReport.recordTypeID  =  report.lostReport.LostType__c== '澶卞崟'?Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_Lost_report').getRecordTypeId() : Schema.SObjectType.Lost_cancel_report__c.getRecordTypeInfosByDeveloperName().get('PCL_PartLost_report').getRecordTypeId();
+			report.lostReport.LostTotalAmount__c    = 0;
+			report.lostReport.of_lost_system_processor__c   = 0;
+			report.lostReport.Lost_reason_main__c = null;
+			report.lostReport.Lost_Reason_Sub__c  = null;
+			report.lostReport.Lost_By_Company__c = null;
+			for(LostBrand tempLostBrand : report.LostBrands) {
 				if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
-					LostReport.lostReport.LostTotalAmount__c += tempLostBrand.lostBrand.LostPrice__c;
-					LostReport.lostReport.Lost_reason_main__c =
-						LostReport.lostReport.Lost_reason_main__c == null
+					report.lostReport.LostTotalAmount__c += tempLostBrand.lostBrand.LostPrice__c;
+					report.lostReport.Lost_reason_main__c =
+					report.lostReport.Lost_reason_main__c == null
 						? tempLostBrand.lostBrand.Lost_reason_main__c
-						: LostReport.lostReport.Lost_reason_main__c;
-					LostReport.lostReport.Lost_Reason_Sub__c  =
-						LostReport.lostReport.Lost_Reason_Sub__c == null
+						: report.lostReport.Lost_reason_main__c;
+						report.lostReport.Lost_Reason_Sub__c  =
+						report.lostReport.Lost_Reason_Sub__c == null
 						? tempLostBrand.lostBrand.Lost_Reason_Sub__c
-						: LostReport.lostReport.Lost_Reason_Sub__c;
-					LostReport.lostReport.Lost_By_Company__c =
-						LostReport.lostReport.Lost_By_Company__c == null
+						: report.lostReport.Lost_Reason_Sub__c;
+						report.lostReport.Lost_By_Company__c =
+						report.lostReport.Lost_By_Company__c == null
 						? tempLostBrand.lostBrand.Lost_By_Company__c
-						: LostReport.lostReport.Lost_By_Company__c;
+						: report.lostReport.Lost_By_Company__c;
 
 					for( PCLLostProducts tempLostProduct : tempLostBrand.LostProducts) {
 						if(tempLostProduct.LostProductss.Quantity__c !=null && tempLostProduct.LostProductss.Quantity__c >0) {
-							LostReport.lostReport.of_lost_system_processor__c   += tempLostProduct.LostProductss.Quantity__c;
+							report.lostReport.of_lost_system_processor__c   += tempLostProduct.LostProductss.Quantity__c;
 						}
 					}
 				}
 			}
-			upsert LostReport.lostReport;
+			upsert report.lostReport;
+			String reportId = report.lostReport.Id;
+			messageMap.put('reportId', reportId);
 			// 闇�瑕佹彃鍏ユ洿鏂扮殑澶卞崟鍝佺墝
 			map<integer,PCLLostBrand__c> upsertLostBrandMap = new map<integer,PCLLostBrand__c>();
 			// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
@@ -409,12 +543,12 @@
 			map<string,PCLLostProduct__c> upsertLostProductMap = new map<string,PCLLostProduct__c>();
 			// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
 			list<PCLLostProduct__c> deleteLostProductList = new list<PCLLostProduct__c>();
-			for(LostBrand tempLostBrand : LostReport.LostBrands ) {
+			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 = LostReport.lostReport.id;
+					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) {
@@ -464,11 +598,11 @@
 
 			}
 
-			for(integer brandNumber =0; brandNumber< LostReport.LostBrands.size(); brandNumber++) {
+			for(integer brandNumber =0; brandNumber< report.LostBrands.size(); brandNumber++) {
 
-				LostBrand tempLostBrand = LostReport.LostBrands.get(brandNumber);
+				LostBrand tempLostBrand = report.LostBrands.get(brandNumber);
 				if(tempLostBrand.lostBrand.Id == null) {
-					LostReport.LostBrands.remove(brandNumber);
+					report.LostBrands.remove(brandNumber);
 					brandNumber--;
 					continue;
 				}
@@ -481,58 +615,63 @@
 					}
 				}
 			}
-			lostReportId = LostReport.lostReport.id;
+			// lostReportId = report.lostReport.id;
 			system.debug('save---end:');
+			messageMap.put('LostReport',JSON.serialize(report));
 		}catch (Exception ex) {
 			Database.rollback(sp);
-			LostReport.lostReport = templostReport;
-			LostReport.LostBrands = tempBrands;
 			// 杩欓噷闇�瑕佸啓涓�浜涙姤閿欎俊鎭�
-			return false;
+			messageMap.put('error', ex.getMessage());
+			return messageMap;
 		}
-		return true;
+		return messageMap;
 	}
 
-	// 鍙栨秷
-	// 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();
-	// 	}
-	// }
-	// 娣诲姞鍝佺墝
-    @AuraEnabled
-	public static String addBrand(){
-		LostReport.LostBrands.add(new LostBrand(LostReport.LostBrands.size()));
-		brandCount = LostReport.LostBrands.size();
-		return null;
+	@AuraEnabled
+	public static Map<string,Object> submit(String report1,String reportId){
+		LostReport report = (LostReport)JSON.deserialize(report1, LostReport.class);
+		Map<string,string> messages = new Map<string,string>();
+		if(!'鑽夋'.equals(report.lostReport.Report_Status__c) ) {
+			messages.put('error', '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘鎻愪氦鐢宠锛�');
+			return messages;
+		}
+		Map<string,Object> objs = new Map<string,Object>();
+		Savepoint sp = Database.setSavepoint();
+		try{
+			report.lostReport.Id = reportId;
+			report.lostReport.Report_Status__c = '鎻愪氦';
+			update report.lostReport;
+			Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+			psr.setObjectId(reportId);
+			Approval.ProcessResult submitResult = Approval.process(psr);
+			objs.put('uri', '/apex/PCLLostReportPage');
+			objs.put('Id', reportId);
+			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 LostBrand getNewLostBrand(Integer lineNo){
+		LostBrand lostBrand = null;
+		try {
+			//report.LostBrands.add(new LostBrand(report.LostBrands.size()));
+			lostBrand = new LostBrand(lineNo);
+		} catch (Exception e) {
+			System.debug(e.getMessage());
+		}
+		return lostBrand;
+	}
+
 	// 鍒犻櫎鍝佺墝 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄垹闄ら偅涓搧鐗�
-    @AuraEnabled
+	@AuraEnabled
 	public static String Remove(){
 		system.debug('RemoveBrandNo:'+RemoveBrandNo);
 		list<LostBrand> tempLostBrands = new List<lostBrand>();
@@ -555,7 +694,7 @@
 	}
 	// 娣诲姞鍨嬪彿锛� 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄坊鍔犲埌閭d釜鍝佺墝
 	// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� start
-    @AuraEnabled
+	@AuraEnabled
 	public static String addProduct(){
 		system.debug('brandNo:'+brandNo);
 		LostBrand tempLostBrand = LostReport.LostBrands.get(brandNo);
@@ -567,12 +706,21 @@
 		tempLostBrand.ProductSize = tempLostBrand.LostProducts.size();
 		return null;
 	}
+	@AuraEnabled
+	public static PCLLostProducts getLostProduct(){
+		try {
+			PCLLostProduct__c plp = new PCLLostProduct__c();
+			return new PCLLostProducts(0,plp);
+		} catch (Exception e) {
+			throw new AuraHandledException(e.getMessage());
+		}
+	}
 	// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� end
 	// 椤甸潰鐨勬暟鎹粨鏋�
 	public class LostReport {
-        @AuraEnabled
+		@AuraEnabled
 		public Lost_cancel_report__c lostReport { get; set; }
-        @AuraEnabled
+		@AuraEnabled
 		public list<LostBrand> LostBrands { get; set; }
 		public LostReport(){
 			lostReport = new Lost_cancel_report__c();
@@ -589,13 +737,13 @@
 	}
 
 	public class LostBrand {
-        @AuraEnabled
+		@AuraEnabled
 		public PCLLostBrand__c lostBrand;
-        @AuraEnabled
+		@AuraEnabled
 		public Integer lineNo;
-        @AuraEnabled
+		@AuraEnabled
 		public list<PCLLostProducts> LostProducts;
-        @AuraEnabled
+		@AuraEnabled
 		public Integer ProductSize;
 		public LostBrand( integer lineNo ){
 			lostBrand = new PCLLostBrand__c();
@@ -619,13 +767,16 @@
 	}
 	// add tcm 20211119 start
 	public class PCLLostProducts {
-        @AuraEnabled
+		@AuraEnabled
 		public Integer lineNo2;
-        @AuraEnabled
+		@AuraEnabled
 		public PCLLostProduct__c LostProductss;
-        @AuraEnabled
+		@AuraEnabled
 		public Boolean bool;
-
+		@AuraEnabled
+		public String productName;
+		@AuraEnabled
+		public List<Map<String, String>> productOptions = new List<Map<String, String>>();
 		public PCLLostProducts() {
 			this.lineNo2 = 0;
 			this.LostProductss=new PCLLostProduct__c();
@@ -647,7 +798,6 @@
 	// add tcm 20211119 end
 
 	// add tcm 20211118 start
-    @AuraEnabled
 	public static void search() {
 		if (LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c==null) {
 			LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=null;
@@ -668,5 +818,17 @@
 			}
 		}
 	}
+	@AuraEnabled
+	public static string searchProduct(String lostProduct){
+		Product2 prd = null;
+		try {
+			prd = [select Id,ProductClass__c, ProductCategory__c from Product2 where Id =:lostProduct];
+		} catch (Exception e) {
+			throw new AuraHandledException(e.getMessage());
+		}
+		return JSON.serialize(prd);
+	}
+
 	// add tcm 20211118 end
+
 }
\ No newline at end of file

--
Gitblit v1.9.1