From 25f056535350a0b80bad50d2cc45311998e5d1cd Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期一, 09 十月 2023 18:28:00 +0800
Subject: [PATCH] 近期修改
---
force-app/main/default/classes/lexPCLLostReportLwcController.cls | 835 +++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 523 insertions(+), 312 deletions(-)
diff --git a/force-app/main/default/classes/lexPCLLostReportLwcController.cls b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
index 9082354..9e33408 100644
--- a/force-app/main/default/classes/lexPCLLostReportLwcController.cls
+++ b/force-app/main/default/classes/lexPCLLostReportLwcController.cls
@@ -1,39 +1,125 @@
public with sharing class lexPCLLostReportLwcController {
- public Product2 pro2 { get; set; }
- public string oppId { get; set; }
- public string lostReportId { get; set; }
+
+ public static Product2 pro2 { get; set; }
+
+ public static string oppId { get; set; }
+
+ public static string lostReportId { get; set; }
// 褰撳墠椤甸潰鐘舵�� Create,View and Edit, MarketEdit
- public string pageStatus { get; set; }
+
+ public static string pageStatus { get; set; }
// 澶卞崟锛岄儴鍒嗗け鍗�
- 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;}
+
+ 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 integer topNum {get; set;}
- public integer secondNum {get; set;}
+
+ public static integer topNum {get; set;}
+
+ public static integer secondNum {get; set;}
// add tcm 20211122 end
- // 鍒濆鍖�
- public void initForApex(string oppId1,string lostReportId1,string pageStatus1,string lostType1,string submitFlag1){
- oppId = oppId1;
- lostReportId = lostReportId;
- pageStatus = pageStatus1;
- lostType = lostType1;
- submitFlag = submitFlag1;
+
+ @AuraEnabled(cacheable=true)
+ public static Id getUserProfileId() {
+ Id profileId = [SELECT ProfileId FROM User WHERE Id = :UserInfo.getUserId()].ProfileId;
+ return profileId;
+ }
+ @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>> xixiaoji = new List<Map<String, String>>();
+ List<Map<String, String>> guangyuan = 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 == 38) {
+ zhuji.add(lstPickvals[i]);
+ }
+ if ((i >= 7 && i <= 23) || i == 38) {
+ jingzi.add(lstPickvals[i]);
+ }
+ if ((i >= 24 && i <= 29) || i == 35|| i == 38) {
+ xiaojingzhong.add(lstPickvals[i]);
+ }
+ if ((i >= 30 && i <= 34) || i == 38) {
+ nengliang.add(lstPickvals[i]);
+ }
+ if (i == 36) {
+ guangyuan.add(lstPickvals[i]);
+ }
+ if (i == 37) {
+ xixiaoji.add(lstPickvals[i]);
+ }
+ if (i == 38) {
+ qita.add(lstPickvals[i]);
+ }
+ }
+ pickList.put('涓绘満', zhuji);
+ pickList.put('闀滃瓙', jingzi);
+ pickList.put('灏忛暅绉�', xiaojingzhong);
+ pickList.put('鑳介噺', nengliang);
+ pickList.put('娲楁秷鏈�', xixiaoji);
+ pickList.put('鍏夋簮', guangyuan);
+ pickList.put('鍏朵粬', qita);
+ return JSON.serialize(pickList);
+ }
+ @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());
+ }
}
- public 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,
@@ -44,11 +130,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,
@@ -65,7 +153,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 =
@@ -74,15 +163,19 @@
Lost_Reason_Sub__c,Lost_By_Company__c,
LostTotalAmount__c,LostType__c,
Report_Status__c,Sales_assistant__c,
+ TotalAmountLost__c,
+ InclusionUltrasound__c, //20230506 lt DB202304618804 鍖呭惈瓒呭0
+ ModifyAfterApproval__c,Approved_Day__c,//20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 add
Opportunity__c, Opportunity__r.Sales_assistant_ID__c,
Opportunity__r.Sales_manager_departmentID__c,
Manager_sales__c,recordtypeid,recordtype.DeveloperName
from Lost_cancel_report__c
where id =: lostReportId limit 1];
-
+ System.debug('chenjingwu' + lostReportList);
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;
@@ -95,7 +188,18 @@
lostReportList[0].LostType__c ='閮ㄥ垎澶卞崟';
}
// 鏉冮檺锛屽鏋滃綋鍓嶇姸鎬佷笉鏄崏妗堜腑锛岄偅涔堥渶瑕佽烦杞埌鍙椤甸潰
- if(!'鑽夋'.equals(lostReportList[0].Report_Status__c) && userinfo.getProfileId() != (ID) '00e10000000Y3o5AAC') {
+ //鍘燂細!'鑽夋'.equals(lostReportList[0].Report_Status__c) && userinfo.getProfileId() != (ID) '00e10000000Y3o5AAC'
+
+ // 20230814 lt DB202308068183 澶卞崟鎶ュ憡瀹℃壒鑺傜偣澧炲姞鍔╃悊瀹℃壒鑺傜偣 end 鏀筰f鏉′欢
+ if(
+ !('鑽夋'.equals(lostReportList[0].Report_Status__c)
+ || userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC'
+ ||('鎵瑰噯'.equals(lostReportList[0].Report_Status__c) &&
+ (userinfo.getProfileId() == (ID) '00e10000000xnp2AAA' ||
+ userinfo.getProfileId() == (ID) '00e10000000xnpRAAQ' ||
+ userinfo.getProfileId() == (ID) '00e10000000xnpHAAQ'))
+ )
+ ){
pageStatus = 'View';
}
oppId = lostReportList[0].Opportunity__c;
@@ -104,11 +208,12 @@
[
select id, LostPrice__c, Lost_By_Company__c,
Lost_reason_main__c,Lost_Reason_Sub__c,Name,Agency__c, AgencyMannual__c,
- // ProductCategory__c,ProductClass__c,
- Lost_cancel_report__c,Lost_By_Company_Mannual__c,
+ Lost_cancel_report__c,Lost_By_Company_Mannual__c,ChannelSpecificReasons__c,
( select id,PCLLostBrand__c,LostProduct__c,
+ LostProduct__r.Name,
LostProductMannual__c, //SWAG-C6P9PX lt 20210913 add
- ProductCategory__c,ProductClass__c, //add tcm 20211123
+ ProductCategory__c,
+ ProductClass__c, //add tcm 20211123
Quantity__c,Name, LostBrandName__c
from PCLLostBrand__c.PCLLostBrandProduct__r)
from PCLLostBrand__c
@@ -127,8 +232,11 @@
system.debug('check products:'+ (templostBrand.PCLLostBrandProduct__r != null) + '|' + (templostBrand.PCLLostBrandProduct__r.size() > 0));
if (templostBrand.PCLLostBrandProduct__r != null && templostBrand.PCLLostBrandProduct__r.size() > 0) {
for( PCLLostProduct__c tempProduct: templostBrand.PCLLostBrandProduct__r) {
-
- tempProductList.add(new PCLLostProducts(productCount,tempProduct));
+ PCLLostProducts pro = new PCLLostProducts(productCount,tempProduct);
+ if(tempProduct.LostProduct__r.Name != null){
+ pro.productName = tempProduct.LostProduct__r.Name;
+ }
+ tempProductList.add(pro);
productCount++;
}
} else {
@@ -141,10 +249,15 @@
newProduct.LostProductss.LostBrandName__c = templostBrand.Lost_By_Company__c;
}
system.debug('aaa4+++'+templostBrand.Lost_By_Company_Mannual__c);
+
tempProductList.add(newProduct);
productCount++;
}
- LostBrandList.add( new LostBrand(brandCount,tempProductList, templostBrand));
+ LostBrand br = new LostBrand(brandCount,tempProductList, templostBrand);
+ if(tempLostBrand.ChannelSpecificReasons__c != null){
+ br.reasonFlag = true;
+ }
+ LostBrandList.add(br);
brandCount++;
}
@@ -155,226 +268,176 @@
brandNo = 0;
// 璇诲彇绔炰簤瀵规墜鍝佺墝
// BrandmapSet();
+
+ if (lostReportId != null) {
+ // List<ProcessInstance> pros = [
+ // SELECT
+ // ProcessDefinition.Name,
+ // (
+ // SELECT
+ // Id,
+ // StepStatus,
+ // IsPending,
+ // Comments,
+ // CreatedDate,
+ // Actor.Name,
+ // OriginalActor.Name,
+ // ProcessNode.Name FROM StepsAndWorkitems order by IsPending DESC, CreatedDate DESC
+ // )
+ // FROM ProcessInstance where TargetObjectId =:LostReport.lostReport.id order by CreatedDate DESC
+ // ];
+ // List<ProcessInstanceHistory> items = new List<ProcessInstanceHistory>();
+ // for(ProcessInstance pro: pros){
+ // items.add(pro.StepsAndWorkitems);
+ // }
+ // LostReport.approvalHistorys = items;
+ List<ProcessInstance> pros = [
+ SELECT
+ ProcessDefinition.Name,
+ (
+ SELECT
+ Id,
+ StepStatus,
+ IsPending,
+ Comments,
+ CreatedDate,
+ Actor.Name,
+ OriginalActor.Name,
+ ProcessNode.Name FROM StepsAndWorkitems order by IsPending DESC, CreatedDate DESC
+ )
+ FROM ProcessInstance where TargetObjectId =:LostReport.lostReport.id order by CreatedDate DESC
+ ];
+ if(pros.size() > 0){
+
+ List<ProcessInstanceHistory> items = new List<ProcessInstanceHistory>();
+ maps.put('allowUserId',pros[0].StepsAndWorkitems[0].OriginalActor.Id);
+ maps.put('userProfileId',UserInfo.getProfileId());
+ for(ProcessInstance pro: pros){
+ items.addAll(pro.StepsAndWorkitems);
+ }
+ for(ProcessInstanceHistory pro: pros[0].StepsAndWorkitems){
+ if(pro.StepStatus == 'Started'){
+ maps.put('submitUserId',pro.OriginalActorId);
+ }
+ }
+ LostReport.approvalHistorys = items;
+ }else{
+ List<ProcessInstanceHistory> items = new List<ProcessInstanceHistory>();
+ LostReport.approvalHistorys = items;
+ }
+
+ }else{
+ List<ProcessInstanceHistory> items = new List<ProcessInstanceHistory>();
+ LostReport.approvalHistorys = items;
+ }
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);
+ maps.put('userId',UserInfo.getUserId());
+ return maps;
}
- // 缂栬緫 鍙湁绯荤粺绠$悊鍛樻垨鑰呰崏妗堜腑鍙互缂栬緫
- public String edit2(){
- if( userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC' ||
- '鑽夋'.equals(LostReport.LostReport.Report_Status__c)
- ) {
- pageStatus = 'Edit';
- init();
- }
- else{
- return '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘杩涜缂栬緫锛�';
- }
- return null;
+ @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 void setBrand(){
- list<LostBrand> LostBrandlist = LostReport.LostBrands;
- LostBrand tempBrand = LostBrandlist.get(setBrandNo);
- string brandName = tempBrand.lostBrand.Lost_By_Company__c;
- // fy SWAG-CCC6F6 start
- if(!'鍏朵粬'.equals(tempBrand.lostBrand.Lost_By_Company_Mannual__c)){
- tempBrand.lostBrand.Lost_By_Company_Mannual__c = null;
- }
- system.debug('aaa5+++'+tempBrand.lostBrand.Lost_By_Company_Mannual__c);
- // fy SWAG-CCC6F6 end
- // ID compID = CompetitionMap.get(brandName);
- for(PCLLostProducts tempLostProduct : tempBrand.LostProducts ) {
- // test
- // tempLostProduct.LostProductss.Competitor__c = compID;
- tempLostProduct.LostProductss.LostBrandName__c = brandName;
- tempLostProduct.LostProductss.LostProduct__c = null;
- tempLostProduct.LostProductss.LostProductMannual__c = null;
- tempLostProduct.LostProductss.Quantity__c = null;
- tempLostProduct.LostProductss.ProductClass__c = null;
- tempLostProduct.LostProductss.ProductCategory__c = null;
- tempLostProduct.bool=false;
- }
- }
- // 璁剧疆鍝佺墝
- public void setbrandmannual(){
- list<LostBrand> LostBrandlist = LostReport.LostBrands;
- LostBrand tempBrand = LostBrandlist.get(setBrandNo);
- string brandName = tempBrand.lostBrand.Lost_By_Company__c;
- String brandNameMannual = tempBrand.lostBrand.Lost_By_Company_Mannual__c;
- // ID compID = CompetitionMap.get(brandName);
- for(PCLLostProducts tempLostProduct : tempBrand.LostProducts ) {
- // test
- // tempLostProduct.LostProductss.Competitor__c = compID;
- system.debug('aaaa3++'+brandNameMannual);
- if ('鍏朵粬'.equals(brandName) && brandNameMannual != null && !''.equals(brandNameMannual)) {
- tempLostProduct.LostProductss.LostBrandName__c = brandNameMannual;
- // tempLostProduct.LostProductss.LostProduct__c = null;
- // tempLostProduct.LostProductss.LostProductMannual__c = null;
- // tempLostProduct.LostProductss.Quantity__c = null;
- // tempLostProduct.LostProductss.ProductClass__c = null;
- // tempLostProduct.LostProductss.ProductCategory__c = null;
- // tempLostProduct.bool=false;
+ @AuraEnabled
+ public static string searchBatchIfForProduct(String productName){
+ try {
+ List<BatchIF_Transfer__c> transfer = [select
+ Internal_value__c
+ from BatchIF_Transfer__c
+ where Dropped_Flag__c = false
+ and Table__c = 'PCLLostBrand__c' and Column__c = 'Lost_By_Company__c' and External_value__c =: productName];
+ if(transfer.size() > 0){
+ return transfer[0].Internal_value__c;
+ }else{
+ return null;
}
+
+ } catch (Exception e) {
+ throw new AuraHandledException(e.getMessage());
}
- }
- // 淇濆瓨
- public String save(){
-
- if(!DataCheck()) {
- return null;
- }
- if(!dataEntry()) {
- return null;
- }
-
- brandCount = LostReport.LostBrands.size();
- pageStatus = 'View';
- return '淇濆瓨鎴愬姛锛�';
- }
- //璇诲彇骞舵瀯寤虹珵浜夊鎵嬪搧鐗�
- // public void BrandmapSet(){
- // CompetitionMap = new map<string, id>();
- // list <Competition_Company__c> competitionList
- // = [select id,name from Competition_Company__c];
- // for(Competition_Company__c tempComp : competitionList ) {
- // CompetitionMap.put(tempComp.name, tempComp.id);
- // }
-
- // }
- // 鏁版嵁妫�鏌�
- public boolean DataCheck(){
- boolean dataCheck = true;
- if(string.isBlank(LostReport.LostReport.LostType__c))
- {
- LostReport.LostReport.LostType__c.addError('蹇呴』濉啓澶卞崟绫诲瀷锛�');
- dataCheck = false;
- }
- for(LostBrand tempLostBrand : LostReport.LostBrands ) {
- system.debug('aaaa1++'+tempLostBrand.lostBrand.Lost_By_Company_Mannual__c);
- if(string.isblank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
- tempLostBrand.lostBrand.Lost_By_Company__c.addError('璇峰~鍐欏け鍗曞搧鐗岋紒');
- dataCheck = false;
- }// fy SWAG-CCC6F6 start
- else if('鍏朵粬'.equals(tempLostBrand.lostBrand.Lost_By_Company__c)&&string.isblank(tempLostBrand.lostBrand.Lost_By_Company_Mannual__c)){
- tempLostBrand.lostBrand.Lost_By_Company_Mannual__c.addError('璇峰~鍐欏け鍗曞搧鐗岋紙鎵嬪姩锛夛紒');
- dataCheck = false;
- }// fy SWAG-CCC6F6 end
- system.debug('aaaa2++'+tempLostBrand.lostBrand.Lost_By_Company_Mannual__c);
- if(tempLostBrand.lostBrand.LostPrice__c == null) {
- tempLostBrand.lostBrand.LostPrice__c.addError('澶卞崟閲戦蹇呭~锛�');
- dataCheck = false;
- }
- if(string.isblank(tempLostBrand.lostBrand.Lost_reason_main__c )) {
- tempLostBrand.lostBrand.Lost_reason_main__c.addError('澶卞崟鐞嗙敱(涓�)蹇呭~锛�');
- dataCheck = false;
- }
- if(string.isblank(tempLostBrand.lostBrand.Agency__c )) {
- tempLostBrand.lostBrand.Agency__c.addError('涓爣缁忛攢鍟嗗繀濉紒');
- dataCheck = false;
- }
- // 妫�鏌ユ槸鍚︽湁瓒呰繃1涓湁鏁扮殑浜у搧
- integer productCount = 0;
- for( PCLLostProducts temlostProduct : tempLostBrand.LostProducts) {
- if (temlostProduct.LostProductss.LostProduct__c != null || temlostProduct.LostProductss.LostProductMannual__c != null) {
- System.debug('澶卞崟鍨嬪彿' + temlostProduct.LostProductss.LostProduct__c);
- System.debug('澶卞崟鍨嬪彿鎵嬪姩' + temlostProduct.LostProductss.LostProductMannual__c);
- productCount ++;
- }
- // update tcm 20211123 start
- if((temlostProduct.LostProductss.LostProduct__c!=null || temlostProduct.LostProductss.LostProductMannual__c!=null)&&(temlostProduct.LostProductss.Quantity__c==null || temlostProduct.LostProductss.Quantity__c ==0)) {
- temlostProduct.LostProductss.Quantity__c.addError('璇峰~鍐欏け鍗曟暟閲忥紒');
- dataCheck = false;
- }
- if((temlostProduct.LostProductss.LostProduct__c!=null || temlostProduct.LostProductss.LostProductMannual__c!=null)&&temlostProduct.LostProductss.ProductCategory__c==null) {
- if (temlostProduct.LostProductss.ProductClass__c==null) {
- temlostProduct.LostProductss.ProductClass__c.addError('澶卞崟浜у搧绫诲埆蹇呭~锛�');
- temlostProduct.LostProductss.ProductCategory__c.addError('澶卞崟浜у搧蹇呭~锛�');
- }else {
- temlostProduct.LostProductss.ProductCategory__c.addError('澶卞崟浜у搧蹇呭~锛�');
- }
- dataCheck = false;
- }
- // 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 start
- if ((temlostProduct.LostProductss.LostProduct__c==null && temlostProduct.LostProductss.LostProductMannual__c==null)&&(temlostProduct.LostProductss.ProductCategory__c!=null||temlostProduct.LostProductss.Quantity__c!=null)) {
- if(tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'){
- temlostProduct.LostProductss.LostProduct__c.addError('澶卞崟瀵规墜鍨嬪彿鎴栧け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛夊繀濉紒');
- } else{
- temlostProduct.LostProductss.LostProductMannual__c.addError('澶卞崟瀵规墜鍨嬪彿鎴栧け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛夊繀濉紒');
- }
- dataCheck = false;
- }
- // 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 end
- // update tcm 20211123 end
- }
- // 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 start
- if (productCount == 0 && tempLostBrand.LostProducts != null && tempLostBrand.LostProducts.size() > 0) {
- if(tempLostBrand.lostBrand.Lost_By_Company__c != '鍏朵粬'){
- tempLostBrand.LostProducts[0].LostProductss.LostProduct__c.addError('鑷冲皯褰曞叆1鏉″け鍗曞鎵嬪瀷鍙蜂俊鎭紒');
- }else{
- tempLostBrand.LostProducts[0].LostProductss.LostProductMannual__c.addError('鑷冲皯褰曞叆1鏉″け鍗曞鎵嬪瀷鍙蜂俊鎭紒');
- }
- dataCheck = false;
- }
- // 褰撳け鍗曞搧鐗屽悕涓哄叾浠栨椂,鎶ラ敊瀛楁涓哄け鍗曞鎵嬪瀷鍙凤紙鎵嬪姩锛� thh 2022-01-17 end
- }
-
- return dataCheck;
- }
- public list<LostBrand> brandcopy(){
- list<LostBrand> tempbrands = new list<LostBrand>();
- for(LostBrand tempbrand: LostReport.LostBrands) {
- LostBrand LostBrand =
- new LostBrand(tempbrand.lineNo,tempbrand.LostProducts );
- LostBrand.lostBrand = tempbrand.lostBrand.clone();
- LostBrand.lostBrand.id = tempbrand.lostBrand.id;
- tempbrands.add(LostBrand);
- }
- return tempbrands;
}
// 鏁版嵁褰曞叆
- public boolean dataEntry(){
+ @AuraEnabled
+ public static Map<String,String> dataEntry(String report1,List<Id> deleteBrandIdList,List<Id> deleteProductIdList){
+ // LostReport report = (LostReport)JSON.deserializeUntyped(report1, LostReport.class);
+ 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.TotalAmountLost__c = 0;
+ report.lostReport.Lost_reason_main__c = null;
+ report.lostReport.Lost_Reason_Sub__c = null;
+ report.lostReport.Lost_By_Company__c = null;
+ //鎵瑰噯鏃ヤ笉涓虹┖鏃剁粰淇敼鍚庡啀鎵瑰噯璧嬪��
+ if(report.lostReport.Approved_Day__c != null){
+ report.lostReport.ModifyAfterApproval__c = true;
+ }
+ 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;
+ Decimal med = tempLostBrand.lostBrand.LostPrice__c/1.13/1000;
+ Decimal med1 = med.setScale(2);
+ // System.debug('---lt123涓嶅惈绋庢暟鍊�(浜哄伐)Decimal---'+med);
+ // System.debug('---lt123涓嶅惈绋庢暟鍊�(浜哄伐)Decimal涓や綅灏忔暟---'+med1);
+ report.lostReport.TotalAmountLost__c += med1;
+ 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>();
// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
@@ -383,30 +446,32 @@
map<string,PCLLostProduct__c> upsertLostProductMap = new map<string,PCLLostProduct__c>();
// 闇�瑕佸垹鎺夌殑澶卞崟鍝佺墝
list<PCLLostProduct__c> deleteLostProductList = new list<PCLLostProduct__c>();
- for(LostBrand tempLostBrand : LostReport.LostBrands ) {
+ 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 = LostReport.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();
@@ -414,7 +479,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();
@@ -422,13 +487,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) {
@@ -438,11 +510,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;
}
@@ -455,113 +527,194 @@
}
}
}
- lostReportId = LostReport.lostReport.id;
+
+ List<ProcessInstance> pros = [
+ SELECT
+ ProcessDefinition.Name,
+ (
+ SELECT
+ Id,
+ StepStatus,
+ IsPending,
+ Comments,
+ CreatedDate,
+ Actor.Name,
+ OriginalActor.Name,
+ ProcessNode.Name FROM StepsAndWorkitems order by IsPending DESC, CreatedDate DESC
+ )
+ FROM ProcessInstance where TargetObjectId =:reportId order by CreatedDate DESC
+ ];
+ List<ProcessInstanceHistory> items = new List<ProcessInstanceHistory>();
+ for(ProcessInstance pro: pros){
+ items.addAll(pro.StepsAndWorkitems);
+ }
+ if(items.size() > 0){
+ report.approvalHistorys = items;
+ }else{
+ List<ProcessInstanceHistory> items1 = new List<ProcessInstanceHistory>();
+ report.approvalHistorys = items1;
+ }
+
+
+
+
+ // lostReportId = report.lostReport.id;
system.debug('save---end:');
- }catch (Exception ex) {
+ messageMap.put('LostReport',JSON.serialize(report));
+ }catch (Exception e) {
Database.rollback(sp);
- LostReport.lostReport = templostReport;
- LostReport.LostBrands = tempBrands;
// 杩欓噷闇�瑕佸啓涓�浜涙姤閿欎俊鎭�
- ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,ex.getMessage()));
- return false;
+ // if (e.getMessage().contains(',')) {
+ // System.debug(LoggingLevel.INFO, '*** e: ' + e);
+ // String exc = '' + e.getMessage();
+ // Integer left = exc.indexOf(':') + 1;
+ // Integer right = exc.lastIndexOf(':');
+ // String str = exc.substring(left,right);
+ // left = str.indexOf(',') + 1;
+ // String newStr = str.substring(left);
+ // messageMap.put('error', ''+ newStr);
+ // }else {
+ // messageMap.put('error', ''+ e.getMessage());
+ // }
+
+ messageMap.put('error', ''+ e.getMessage());
+ return messageMap;
}
- return true;
+ return messageMap;
}
// 鎻愪氦
- public Map<string,Object> submit(){
+ @AuraEnabled
+ public static Map<string,Object> submit(String reportStatus,Boolean modifyAfterApproval,String reportId){
+ // LostReport report = (LostReport)JSON.deserialize(report1, LostReport.class);
Map<string,string> messages = new Map<string,string>();
- if(!'鑽夋'.equals(LostReport.LostReport.Report_Status__c) ) {
+ if(!'鑽夋'.equals(reportStatus) && modifyAfterApproval == false) {
messages.put('error', '鍙湁鍦ㄨ崏妗堜腑鎵嶈兘鎻愪氦鐢宠锛�');
return messages;
}
Map<string,Object> objs = new Map<string,Object>();
+ Lost_cancel_report__c report = new Lost_cancel_report__c();
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);
+ report.Id = reportId;
+ report.Report_Status__c = '鎻愪氦';
+ update report;
+ // Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+ // psr.setObjectId(reportId);
+ // Approval.ProcessResult submitResult = Approval.process(psr);
objs.put('uri', '/apex/PCLLostReportPage');
- objs.put('Id', lostReportId);
+ 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;
- }
- }
- // 娣诲姞鍝佺墝
- public String addBrand(){
- LostReport.LostBrands.add(new LostBrand(LostReport.LostBrands.size()));
- brandCount = LostReport.LostBrands.size();
- return null;
- }
- // 鍒犻櫎鍝佺墝 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄垹闄ら偅涓搧鐗�
- public String Remove(){
- system.debug('RemoveBrandNo:'+RemoveBrandNo);
- list<LostBrand> tempLostBrands = new List<lostBrand>();
- Integer i = 0;
- for(integer j = 0; j< LostReport.LostBrands.size(); j++ ) {
- LostBrand templostBrand = LostReport.LostBrands.get(j);
- if(j != RemoveBrandNo) {
- templostBrand.lineNo = i;
- tempLostBrands.add(templostBrand);
- i++;
- }else if(!string.isBlank(templostBrand.lostBrand.id)) {
- deleteBrandIDSet.add(templostBrand.lostBrand.id);
+ List<ProcessInstance> pros = [
+ SELECT
+ ProcessDefinition.Name,
+ (
+ SELECT
+ Id,
+ StepStatus,
+ IsPending,
+ Comments,
+ CreatedDate,
+ Actor.Name,
+ OriginalActor.Name,
+ ProcessNode.Name FROM StepsAndWorkitems order by IsPending DESC, CreatedDate DESC
+ )
+ FROM ProcessInstance where TargetObjectId =:reportId order by CreatedDate DESC
+ ];
+
+ List<ProcessInstanceHistory> items = new List<ProcessInstanceHistory>();
+ for(ProcessInstance pro:pros){
+ items.addAll(pro.StepsAndWorkitems);
}
+
+ objs.put('approvalHistorys',items);
+ return objs;
+ }catch(exception e) {
+ Database.rollback(sp);
+ if (e.getMessage().contains(',')) {
+ System.debug(LoggingLevel.INFO, '*** e: ' + e);
+ String exc = '' + e.getMessage();
+ Integer left = exc.indexOf(':') + 1;
+ Integer right = exc.lastIndexOf(':');
+ String str = exc.substring(left,right);
+ left = str.indexOf(',') + 1;
+ String newStr = str.substring(left);
+ objs.put('error', ''+ newStr);
+ }else {
+ objs.put('error', ''+ e.getMessage());
+ }
+ return objs;
}
-
- LostReport.LostBrands = tempLostBrands;
-
- brandCount = LostReport.LostBrands.size();
- return null;
}
- // 娣诲姞鍨嬪彿锛� 杩欎釜鏈夊弬鏁癰randNo锛屾墠鐭ラ亾鏄坊鍔犲埌閭d釜鍝佺墝
- // update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� start
- 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));
- string brandName = tempLostBrand.lostBrand.Lost_By_Company__c;
- PCLLostProduct__c plp = new PCLLostProduct__c();
- plp.LostBrandName__c = brandName;
- tempLostBrand.LostProducts.add(new PCLLostProducts(tempLostBrand.LostProducts.size(),plp));
- tempLostBrand.ProductSize = tempLostBrand.LostProducts.size();
- return null;
+ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ @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;
}
+
+ @AuraEnabled
+ public static PCLLostProducts getNewLostProduct(Integer lineNo2){
+ PCLLostProducts pro = null;
+ try {
+ pro = new PCLLostProducts(lineNo2);
+ } catch (Exception e) {
+ System.debug(e.getMessage());
+ }
+ return pro;
+ }
+
// update tcm 20211125 娣诲姞鍨嬪彿鏃惰嚜鍔ㄥ甫鍑哄搧鐗� end
// 椤甸潰鐨勬暟鎹粨鏋�
public class LostReport {
+ @AuraEnabled
public Lost_cancel_report__c lostReport { get; set; }
+ @AuraEnabled
public list<LostBrand> LostBrands { get; set; }
+ @AuraEnabled
+ public list<ProcessInstanceHistory> approvalHistorys { get; set; }
public LostReport(){
lostReport = new Lost_cancel_report__c();
LostBrands = new list<LostBrand> {new LostBrand(0)};
+ approvalHistorys = new list<ProcessInstanceHistory>();
}
public LostReport(Lost_cancel_report__c lostReport){
this.lostReport = lostReport;
LostBrands = new list<LostBrand> {new LostBrand(0)};
+ approvalHistorys = new list<ProcessInstanceHistory>();
}
public LostReport(Lost_cancel_report__c lostReport, list<LostBrand> LostBrands){
this.lostReport = lostReport;
this.LostBrands = LostBrands;
+ approvalHistorys = new list<ProcessInstanceHistory>();
}
}
public class LostBrand {
- public PCLLostBrand__c lostBrand { get; set; }
- public Integer lineNo { get; set; }
- public list<PCLLostProducts> LostProducts { get; set; }
- public Integer ProductSize {get; set;}
+ @AuraEnabled
+ public PCLLostBrand__c lostBrand;
+ @AuraEnabled
+ public Integer lineNo;
+ @AuraEnabled
+ public list<PCLLostProducts> LostProducts;
+ @AuraEnabled
+ public Integer ProductSize;
+ @AuraEnabled
+ public Boolean reasonFlag = false;
+ @AuraEnabled
+ public String brandTitle;
public LostBrand( integer lineNo ){
lostBrand = new PCLLostBrand__c();
this.lineNo = lineNo;
+ this.brandTitle = '澶卞崟鍝佺墝' + (lineNo + 1);
LostProducts = new list<PCLLostProducts> {new PCLLostProducts()};
ProductSize = 1;
lostBrand = new PCLLostBrand__c();
@@ -569,22 +722,30 @@
public LostBrand( integer lineNo, list<PCLLostProducts> LostProducts ){
lostBrand = new PCLLostBrand__c();
this.lineNo = lineNo;
+ this.brandTitle = '澶卞崟鍝佺墝' + (lineNo + 1);
this.LostProducts = LostProducts;
ProductSize = LostProducts.size();
}
public LostBrand( integer lineNo, list<PCLLostProducts> LostProducts, PCLLostBrand__c lostBrand){
this.lostBrand = lostBrand;
this.lineNo = lineNo;
+ this.brandTitle = '澶卞崟鍝佺墝' + (lineNo + 1);
this.LostProducts = LostProducts;
ProductSize = LostProducts.size();
}
}
// add tcm 20211119 start
public class PCLLostProducts {
- public Integer lineNo2 { get; set; }
- public PCLLostProduct__c LostProductss { get; set; }
- public Boolean bool { get; set; }
-
+ @AuraEnabled
+ public Integer lineNo2;
+ @AuraEnabled
+ public PCLLostProduct__c LostProductss;
+ @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();
@@ -606,14 +767,15 @@
// add tcm 20211119 end
// add tcm 20211118 start
- public void search() {
+ public static 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;
LostReport.LostBrands[topNum].LostProducts[secondNum].bool=false;
}else {
- Product2 prd = [select Id,ProductClass__c, ProductCategory__c from Product2 where Id =:LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c];
+ Product2 prd = [select Id,ProductClass__c
+ , ProductCategory__c
+ from Product2 where Id =:LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.LostProduct__c];
if (prd.ProductCategory__c!=null) {
LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductClass__c=prd.ProductClass__c;
LostReport.LostBrands[topNum].LostProducts[secondNum].LostProductss.ProductCategory__c=prd.ProductCategory__c;
@@ -626,5 +788,54 @@
}
}
}
+ @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
+
+ @AuraEnabled
+ public static String submitForApproval(String recordId, String comments,String action){
+ try {
+ List<ProcessInstanceWorkitem> workItems = [
+ SELECT Id, ProcessInstanceId
+ FROM ProcessInstanceWorkitem
+ WHERE ProcessInstance.TargetObjectId = :recordId
+ ];
+ Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
+ req.setWorkitemId(workItems.get(0).Id);
+ req.setAction(action);
+ req.setComments(comments);
+
+
+ Approval.ProcessResult result = Approval.process(req);
+ return null;
+ } catch (Exception e) {
+ return e.getMessage();
+ }
+
+ }
+
+ @AuraEnabled
+ public static String reassignStep(String recordId, String newActorId ){
+ try {
+ List<ProcessInstanceWorkItem> workItemList = [SELECT ActorId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId = : recordId];
+ ApprovalHistoryUtil.reassignStep(workItemList, newActorId);
+ return null;
+ } catch (Exception e) {
+ return e.getMessage();
+ }
+
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.1