| | |
| | | public with sharing class lexPCLLostReportLwcController { |
| | | public Product2 pro2 { get; set; } |
| | | public string oppId { get; set; } |
| | | public string lostReportId { get; set; } |
| | | @AuraEnabled |
| | | public static Product2 pro2 { get; set; } |
| | | @AuraEnabled |
| | | public static string oppId { get; set; } |
| | | @AuraEnabled |
| | | public static string lostReportId { get; set; } |
| | | // 当前页面状态 Create,View and Edit, MarketEdit |
| | | public string pageStatus { get; set; } |
| | | @AuraEnabled |
| | | 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;} |
| | | @AuraEnabled |
| | | public static string lostType {get; set;} |
| | | public static Set<ID> deleteBrandIDSet = new Set<ID>(); |
| | | @AuraEnabled |
| | | public static string submitFlag {get; set;} |
| | | @AuraEnabled |
| | | public static LostReport LostReport {get; set;} |
| | | @AuraEnabled |
| | | public static integer brandNo {get; set;} |
| | | @AuraEnabled |
| | | public static integer RemoveBrandNo {get; set;} |
| | | @AuraEnabled |
| | | public static integer setBrandNo {get; set;} |
| | | @AuraEnabled |
| | | public static integer brandCount {get; set;} |
| | | // add tcm 20211122 start |
| | | public integer topNum {get; set;} |
| | | public integer secondNum {get; set;} |
| | | @AuraEnabled |
| | | public static integer topNum {get; set;} |
| | | @AuraEnabled |
| | | public static integer secondNum {get; set;} |
| | | // add tcm 20211122 end |
| | | // 初始化 |
| | | public void initForApex(string oppId1,string lostReportId1,string pageStatus1,string lostType1,string submitFlag1){ |
| | | @AuraEnabled |
| | | public static 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(){ |
| | | @AuraEnabled |
| | | public static Map<string,object> init(){ |
| | | 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, |
| | |
| | | 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, |
| | |
| | | system.debug('edit1'); |
| | | if(string.isBlank(lostReportId)) { |
| | | pageStatus = null; |
| | | return '您没有查看这个失单/部分失单报告的权限!'; |
| | | maps.put('message', '您没有查看这个失单/部分失单报告的权限!'); |
| | | return maps; |
| | | } |
| | | system.debug('edit2'); |
| | | list<Lost_cancel_report__c> 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; |
| | |
| | | // 读取竞争对手品牌 |
| | | // BrandmapSet(); |
| | | if(string.isNotEmpty(submitFlag)) { |
| | | return '提交成功!'; |
| | | maps.put('message', '提交成功!'); |
| | | maps.put('LostReport', LostReport); |
| | | return maps; |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | // 编辑 只有系统管理员或者草案中可以编辑 |
| | | public String edit2(){ |
| | | @AuraEnabled |
| | | public static String edit2(){ |
| | | if( userinfo.getProfileId() == (ID) '00e10000000Y3o5AAC' || |
| | | '草案'.equals(LostReport.LostReport.Report_Status__c) |
| | | ) { |
| | |
| | | return null; |
| | | } |
| | | // 设置品牌 |
| | | public void setBrand(){ |
| | | @AuraEnabled |
| | | public static void setBrand(){ |
| | | list<LostBrand> LostBrandlist = LostReport.LostBrands; |
| | | LostBrand tempBrand = LostBrandlist.get(setBrandNo); |
| | | string brandName = tempBrand.lostBrand.Lost_By_Company__c; |
| | |
| | | } |
| | | } |
| | | // 设置品牌 |
| | | public void setbrandmannual(){ |
| | | @AuraEnabled |
| | | public static void setbrandmannual(){ |
| | | list<LostBrand> LostBrandlist = LostReport.LostBrands; |
| | | LostBrand tempBrand = LostBrandlist.get(setBrandNo); |
| | | string brandName = tempBrand.lostBrand.Lost_By_Company__c; |
| | |
| | | } |
| | | } |
| | | // 保存 |
| | | public String save(){ |
| | | @AuraEnabled |
| | | public static String save(){ |
| | | |
| | | if(!DataCheck()) { |
| | | return null; |
| | |
| | | |
| | | // } |
| | | // 数据检查 |
| | | public boolean DataCheck(){ |
| | | @AuraEnabled |
| | | public static boolean DataCheck(){ |
| | | boolean dataCheck = true; |
| | | if(string.isBlank(LostReport.LostReport.LostType__c)) |
| | | { |
| | |
| | | |
| | | return dataCheck; |
| | | } |
| | | public list<LostBrand> brandcopy(){ |
| | | @AuraEnabled |
| | | public static list<LostBrand> brandcopy(){ |
| | | list<LostBrand> tempbrands = new list<LostBrand>(); |
| | | for(LostBrand tempbrand: LostReport.LostBrands) { |
| | | LostBrand LostBrand = |
| | |
| | | return tempbrands; |
| | | } |
| | | // 数据录入 |
| | | public boolean dataEntry(){ |
| | | @AuraEnabled |
| | | public static boolean dataEntry(){ |
| | | system.debug('save---start:'); |
| | | Savepoint sp = Database.setSavepoint(); |
| | | Lost_cancel_report__c templostReport = LostReport.lostReport.clone(); |
| | |
| | | |
| | | |
| | | // 提交 |
| | | public Map<string,Object> submit(){ |
| | | @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', '只有在草案中才能提交申请!'); |
| | |
| | | } |
| | | } |
| | | // 添加品牌 |
| | | public String addBrand(){ |
| | | @AuraEnabled |
| | | public static String addBrand(){ |
| | | LostReport.LostBrands.add(new LostBrand(LostReport.LostBrands.size())); |
| | | brandCount = LostReport.LostBrands.size(); |
| | | return null; |
| | | } |
| | | // 删除品牌 这个有参数brandNo,才知道是删除那个品牌 |
| | | public String Remove(){ |
| | | @AuraEnabled |
| | | public static String Remove(){ |
| | | system.debug('RemoveBrandNo:'+RemoveBrandNo); |
| | | list<LostBrand> tempLostBrands = new List<lostBrand>(); |
| | | Integer i = 0; |
| | |
| | | } |
| | | // 添加型号, 这个有参数brandNo,才知道是添加到那个品牌 |
| | | // update tcm 20211125 添加型号时自动带出品牌 start |
| | | public String addProduct(){ |
| | | @AuraEnabled |
| | | public static 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)); |
| | |
| | | // 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(); |
| | |
| | | } |
| | | |
| | | public class LostBrand { |
| | | @AuraEnabled |
| | | public PCLLostBrand__c lostBrand { get; set; } |
| | | @AuraEnabled |
| | | public Integer lineNo { get; set; } |
| | | @AuraEnabled |
| | | public list<PCLLostProducts> LostProducts { get; set; } |
| | | @AuraEnabled |
| | | public Integer ProductSize {get; set;} |
| | | public LostBrand( integer lineNo ){ |
| | | lostBrand = new PCLLostBrand__c(); |
| | |
| | | } |
| | | // add tcm 20211119 start |
| | | public class PCLLostProducts { |
| | | @AuraEnabled |
| | | public Integer lineNo2 { get; set; } |
| | | @AuraEnabled |
| | | public PCLLostProduct__c LostProductss { get; set; } |
| | | @AuraEnabled |
| | | public Boolean bool { get; set; } |
| | | |
| | | public PCLLostProducts() { |
| | |
| | | // 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; |