From 71b93327e8f3fb3bffffc7c033c1f782e7b6ab32 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 22 五月 2023 17:37:16 +0800
Subject: [PATCH] test
---
force-app/main/default/classes/lexPCLLostReportLwcController.cls | 293 +++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 188 insertions(+), 105 deletions(-)
diff --git a/force-app/main/default/classes/lexPCLLostReportLwcController.cls b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
index 6b5484f..83c5603 100644
--- a/force-app/main/default/classes/lexPCLLostReportLwcController.cls
+++ b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
@@ -1,59 +1,102 @@
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 List<String> getPickList(String objectName, String fieldName) {
+ List<String> values = new List<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()) {
+ values.add(entry.getValue());
+ }
+ }
+ }
+ return values;
+ }
+
+
+ @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 +107,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 +130,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 =
@@ -102,7 +148,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 +223,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 +275,7 @@
}
}
// 璁剧疆鍝佺墝
- @AuraEnabled
+ @AuraEnabled
public static void setbrandmannual(){
list<LostBrand> LostBrandlist = LostReport.LostBrands;
LostBrand tempBrand = LostBrandlist.get(setBrandNo);
@@ -243,7 +298,7 @@
}
}
// 淇濆瓨
- @AuraEnabled
+ @AuraEnabled
public static String save(){
if(!DataCheck()) {
@@ -268,7 +323,7 @@
// }
// 鏁版嵁妫�鏌�
- @AuraEnabled
+ @AuraEnabled
public static boolean DataCheck(){
boolean dataCheck = true;
if(string.isBlank(LostReport.LostReport.LostType__c))
@@ -347,7 +402,30 @@
return dataCheck;
}
- @AuraEnabled
+ @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;
+ }
+ @AuraEnabled
public static list<LostBrand> brandcopy(){
list<LostBrand> tempbrands = new list<LostBrand>();
for(LostBrand tempbrand: LostReport.LostBrands) {
@@ -360,7 +438,7 @@
return tempbrands;
}
// 鏁版嵁褰曞叆
- @AuraEnabled
+ @AuraEnabled
public static boolean dataEntry(){
system.debug('save---start:');
Savepoint sp = Database.setSavepoint();
@@ -488,51 +566,55 @@
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();
- // }
- // }
- // 娣诲姞鍝佺墝
- @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(){
+ 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 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 +637,7 @@
}
// 娣诲姞鍨嬪彿锛� 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄坊鍔犲埌閭d釜鍝佺墝
// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� start
- @AuraEnabled
+ @AuraEnabled
public static String addProduct(){
system.debug('brandNo:'+brandNo);
LostBrand tempLostBrand = LostReport.LostBrands.get(brandNo);
@@ -570,9 +652,9 @@
// 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,14 +671,16 @@
}
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;
+ @AuraEnabled
+ public List<Map<String,String>> columns;
public LostBrand( integer lineNo ){
lostBrand = new PCLLostBrand__c();
this.lineNo = lineNo;
@@ -619,11 +703,11 @@
}
// add tcm 20211119 start
public class PCLLostProducts {
- @AuraEnabled
+ @AuraEnabled
public Integer lineNo2;
- @AuraEnabled
+ @AuraEnabled
public PCLLostProduct__c LostProductss;
- @AuraEnabled
+ @AuraEnabled
public Boolean bool;
public PCLLostProducts() {
@@ -647,7 +731,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;
--
Gitblit v1.9.1