@isTest
|
private class lexPCLLostReportLwcControllerTest {
|
|
@TestSetup
|
static void makeData(){
|
PCLLostProduct2AssetHandlerTest.setUp();
|
}
|
static testMethod void testInitCreate(){
|
Opportunity opp = [select Id from Opportunity limit 1];
|
Test.startTest();
|
lexPCLLostReportLwcController.init('' + opp.Id,'','Create','失单','');
|
Test.stopTest();
|
}
|
static testMethod void testInitView(){
|
Lost_cancel_report__c report = [select Id from Lost_cancel_report__c where LostType__c = '失单'];
|
Test.startTest();
|
lexPCLLostReportLwcController.init('','' + report.Id,'View','','');
|
Test.stopTest();
|
}
|
static testMethod void testOther(){
|
Lost_cancel_report__c report = [select Id from Lost_cancel_report__c where LostType__c = '失单'];
|
Test.startTest();
|
lexPCLLostReportLwcController.getUserProfileId();
|
lexPCLLostReportLwcController.getPickList('PCLLostProduct__c','ProductCategory__c');
|
lexPCLLostReportLwcController.searchBrands();
|
lexPCLLostReportLwcController.searchBatchIfForProduct('');
|
lexPCLLostReportLwcController.getNewLostBrand(0);
|
lexPCLLostReportLwcController.getNewLostProduct(0);
|
|
Test.stopTest();
|
}
|
static testMethod void testSave(){
|
// Lost_cancel_report__c report = [select Id from Lost_cancel_report__c where LostType__c = '失单'];
|
Account depart1 = [select Id from Account where RecordTypeId = '01210000000QemG' limit 1];
|
LostReport conTest2 = new LostReport();
|
conTest2.lostReport.LostType__c = '失单';
|
conTest2.LostBrands[0].lostBrand.LostPrice__c = 12;
|
conTest2.LostBrands[0].lostBrand.Lost_reason_main__c = '价格';
|
conTest2.LostBrands[0].LostProducts[0].LostProductss.Quantity__c =3;
|
conTest2.LostBrands[0].lostBrand.Agency__c = depart1.Id;
|
conTest2.LostBrands[0].lostBrand.Lost_By_Company__c = '其他';
|
conTest2.LostBrands[0].lostBrand.Lost_By_Company_Mannual__c = 'dddddd';
|
conTest2.LostBrands[0].LostProducts[0].lineNo2 = 0;
|
conTest2.LostBrands[0].LostProducts[0].LostProductss = new PCLLostProduct__c(Quantity__c = 3);
|
|
Test.startTest();
|
lexPCLLostReportLwcController.dataEntry(JSON.serialize(conTest2),new List<Id>(),new List<Id>());
|
Test.stopTest();
|
}
|
|
// 页面的数据结构
|
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 {
|
@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();
|
}
|
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 {
|
@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();
|
}
|
|
public PCLLostProducts(Integer lineNo2) {
|
this.lineNo2 = lineNo2;
|
this.LostProductss=new PCLLostProduct__c();
|
}
|
|
public PCLLostProducts(Integer lineNo2,PCLLostProduct__c LostProductss) {
|
this.lineNo2 = lineNo2;
|
this.LostProductss=LostProductss;
|
if (LostProductss.LostProduct__c != null) {
|
this.bool = true;
|
}
|
}
|
}
|
|
}
|