19626
2023-09-13 196df4d4bf1941546d349cadbf343655578ec280
force-app/main/default/classes/lexPCLLostReportLwcController.cls
@@ -150,6 +150,7 @@
          LostTotalAmount__c,LostType__c,
          Report_Status__c,Sales_assistant__c,
          InclusionUltrasound__c, //20230506 lt DB202304618804  包含超声
          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
@@ -172,7 +173,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 改if条件
      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;
@@ -232,6 +244,28 @@
      brandNo = 0;
      // 读取竞争对手品牌
      // BrandmapSet();
      if (LostReport.lostReport.Report_Status__c != '草案' && lostReportId != null) {
         ProcessInstance pro = [
         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>();
         items.addall(pro.StepsAndWorkitems);
         LostReport.approvalHistorys = items;
      }
      if(string.isNotEmpty(submitFlag)) {
         maps.put('message', '提交成功!');
         maps.put('LostReport', LostReport);
@@ -267,6 +301,19 @@
      String jsonStr = JSON.serialize(lstPickvals);
        return jsonStr;
   }
   @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];
         return transfer[0].Internal_value__c;
      } catch (Exception e) {
         throw new AuraHandledException(e.getMessage());
      }
   }
   // 数据录入
   @AuraEnabled
   public static Map<String,String> dataEntry(String report1,List<Id> deleteBrandIdList,List<Id> deleteProductIdList){
@@ -284,6 +331,10 @@
         report.lostReport.Lost_reason_main__c = null;
         report.lostReport.Lost_Reason_Sub__c  = null;
         report.lostReport.Lost_By_Company__c = null;
            //批准日不为空时给修改后再批准赋值
         if(LostReport.lostReport.Approved_Day__c != null){
            LostReport.lostReport.ModifyAfterApproval__c = true;
         }
         for(LostBrand tempLostBrand : report.LostBrands) {
            if(string.isNotBlank(tempLostBrand.lostBrand.Lost_By_Company__c)) {
               report.lostReport.LostTotalAmount__c += tempLostBrand.lostBrand.LostPrice__c;
@@ -438,7 +489,7 @@
   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) ) {
      if(!'草案'.equals(report.lostReport.Report_Status__c) && LostReport.LostReport.ModifyAfterApproval__c == false) {
         messages.put('error', '只有在草案中才能提交申请!');
         return messages;
      }
@@ -448,9 +499,9 @@
         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);
         // 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');