游畅
2022-12-08 54e9fce17758136f2f5223038d30eeb32439c603
转ET科室事项优化-
5个文件已修改
1123 ■■■■■ 已修改文件
force-app/main/default/classes/InquiryFormHandler.cls 548 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/NewAndEditLeadController.cls 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls 378 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/StatusPageController.cls 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/FollowPage.page 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InquiryFormHandler.cls
@@ -1,12 +1,12 @@
public without sharing class InquiryFormHandler extends Oly_TriggerHandler {
        private Map<Id, Inquiry_form__c> newMap;
        private Map<Id, Inquiry_form__c> oldMap;
        private List<Inquiry_form__c> newList;
        private List<Inquiry_form__c> oldList;
    private Map<Id, Inquiry_form__c> newMap;
      private Map<Id, Inquiry_form__c> oldMap;
      private List<Inquiry_form__c> newList;
      private List<Inquiry_form__c> oldList;
    public InquiryFormHandler(){
         this.newMap = (Map<Id, Inquiry_form__c>) Trigger.newMap;
     this.newMap = (Map<Id, Inquiry_form__c>) Trigger.newMap;
        this.oldMap = (Map<Id, Inquiry_form__c>) Trigger.oldMap;
        this.newList = (List<Inquiry_form__c>) Trigger.new;
        this.oldList = (List<Inquiry_form__c>) Trigger.old;
@@ -40,12 +40,16 @@
        Inquiry_form__c oObj = null;
        List<String> depIDList = new List<String>();
        List<Account> accList = new List<Account>();
        //20220511 you SWAG-CBUB2W start
        Map<String, OCM_Management_Province__c> mpMap = new Map<String, OCM_Management_Province__c>();
        Set<String> accOCSMset = new Set<String>();
        //20220511 you SWAG-CBUB2W end
        for(Inquiry_form__c nnObj : newList) {
            if (oldMap != null && oldMap.containsKey(nnObj.Id)) {
                oObj = oldMap.get(nnObj.Id);
            }
            if (String.isNotBlank(nnObj.Hospital_Name__c) && (Trigger.isInsert || oObj.Hospital_Name__c != nnObj.Hospital_Name__c || System.Label.Inquiry_form_flag == 'True')) {
            if (String.isNotBlank(nnObj.Hospital_Name__c) && (Trigger.isInsert || oObj.Hospital_Name__c != nnObj.Hospital_Name__c)) {// || System.Label.Inquiry_form_flag == 'True')
                depIDList.add(nnObj.Hospital_Name__c);
            }
            if (Trigger.isUpdate && String.isBlank(nnObj.Hospital_Name__c)){
@@ -54,17 +58,47 @@
                nnObj.Department_Class__c = null; //战略科室
                nnObj.HospitalName__c = null;     //医院名
                nnObj.Hospital__c = null;         //医院
                nnObj.CreateDate__c = null;      //创建日
            }
            //20220419 you SWAG-CBUB2W start
            //公式考文本  给FSE担当赋值
            System.debug(nnObj.FSE_Owner_id__c+'==123=='+nnObj.FSE_Owner__c);
            if(nnObj.FSE_Owner_id__c != nnObj.FSE_Owner__c){
                nnObj.FSE_Owner__c = nnObj.FSE_Owner_id__c;
            //20220507  SWAG-CBUB2W you start
            if(Trigger.isInsert || oObj.Request1__c != nnObj.Request1__c){
                if(String.isNotBlank(nnObj.Request1__c) && '服务对应' == nnObj.Request1__c && String.isBlank(nnObj.Follow_Content__c)){
                   nnObj.Status__c ='';
                }else if( String.isBlank(nnObj.Status__c) && (nnObj.Request1__c.indexOf('需要报价')!=-1 || nnObj.Request1__c.indexOf('OPD')!=-1 || nnObj.Request1__c.indexOf('产品说明')!=-1 || nnObj.Request1__c.indexOf('寄送产品资料')!=-1)){
                   nnObj.Status__c ='01.未跟进';
                }
            }
            if(Trigger.isInsert && (nnObj.Request1__c.indexOf('服务对应') !=-1 || nnObj.ServiceCorrespond__c ==true)){
                nnObj.Service_Status__c ='01.未跟进';
            }
            //20220419 you SWAG-CBUB2W end
            //20220507  SWAG-CBUB2W you end
            //20220511 you SWAG-CBUB2W start
            if(Trigger.isUpdate){
                /** 挪到营业跟进页面
                if(false != nnObj.Redistribution__c && String.isBlank(nnObj.GotoDepartment__c)){
                    nnObj.GotoDepartment__c.addError('勾选时必须填写转至科室');
                }
                if(false == nnObj.Redistribution__c && String.isNotBlank(nnObj.GotoDepartment__c)){
                    nnObj.GotoDepartment__c.addError('未勾选时不能填写转至科室');
                }
                **/
                if(String.isNotBlank(nnObj.GotoDepartment__c) && nnObj.GotoDepartment__c != oObj.GotoDepartment__c){
                   nnObj.RedistributionDate__c = System.now();
                   accOCSMset.add(nnObj.OCM_man_province_cus__c);
                }
                if(String.isNotBlank(nnObj.Hospital_Name__c) && String.isNotBlank(oObj.Hospital_Name__c) && nnObj.Hospital_Name__c !=  oObj.Hospital_Name__c ){
                   nnObj.AssistantRedistributionDate__c = System.now();
                }
                //20221130 you DB202211530484 start
                if(null!= nnObj.Product_Owner__c && nnObj.Product_Owner__c != oObj.Product_Owner__c){
                   nnObj.ProductAssumeDate__c = System.now();
                   accOCSMset.add(nnObj.OCM_man_province_cus__c);
                }
                if(null!= nnObj.OwnerId && nnObj.OwnerId != oObj.OwnerId){
                   nnObj.AssistantChangeOwnerTime__c = System.now();
                }
                //20221130 you DB202211530484 end
           }
           //20220511 you SWAG-CBUB2W end
        }
        if (depIDList.size()>0) {
@@ -78,17 +112,33 @@
                }
            }   
        }
        //20220511 you SWAG-CBUB2W start
        if(null !=accOCSMset){
            List<OCM_Management_Province__c> mpList =
                    [select id, Name, GI_assistant__c,SP_assistant__c from OCM_Management_Province__c where Name =: accOCSMset];
            // 取得OCSM管理省的GI,SP 助理
            for (OCM_Management_Province__c mp : mpList) {
                mpMap.put(mp.Name, mp);
            }
        }
        //20220511 you SWAG-CBUB2W end
        for(Inquiry_form__c nObj : newList) {
            if (accMap.containsKey(nObj.Hospital_Name__c)){
                nObj.Depart_Owner__c = accMap.get(nObj.Hospital_Name__c).OwnerId;                  //战略科室所有人
                nObj.OwnerId = accMap.get(nObj.Hospital_Name__c).OwnerId;                          //所有人
                //20221128 you DB202211530484  当勾选 转产品担当时,所有人可以手动更改,不需要同步跟科室所有人一致
                if(nObj.Product_Owner__c == false){
                    nObj.OwnerId = accMap.get(nObj.Hospital_Name__c).OwnerId;                          //所有人
                }
                nObj.Department_Class__c = accMap.get(nObj.Hospital_Name__c).Department_Class__c; //战略科室
                nObj.HospitalName__c = accMap.get(nObj.Hospital_Name__c).Hospital__r.Name;        //医院名
                nObj.Hospital__c = accMap.get(nObj.Hospital_Name__c).Hospital__c;                 //医院
            }
            
            //产品信息的拼接
          //产品信息的拼接
            if (String.isNotBlank(nObj.Product1__c) && String.isNotBlank(nObj.Product1_Manual__c)){
                nObj.Product1__c = nObj.Product1__c +';'+nObj.Product1_Manual__c;
            }else if (String.isBlank(nObj.Product1__c) && String.isNotBlank(nObj.Product1_Manual__c)){
@@ -111,60 +161,206 @@
            }
            
            nObj.Product1_Manual__c = '';
             //20220419 you SWAG-CBUB2W start
            //公式考文本  给FSE担当赋值 这段必须放在这,因为新创建的数据,存在科室为空的情况,
            System.debug(nObj.FSE_Owner_id__c+'==123=='+nObj.FSE_Owner__c);
            if(nObj.FSE_Owner_id__c != nObj.FSE_Owner__c){
                nObj.FSE_Owner__c = nObj.FSE_Owner_id__c;
            }
            if(Trigger.isInsert){
                if( nObj.Request1__c.indexOf('服务对应') !=-1 || nObj.ServiceCorrespond__c ==true){
                    nObj.Service_Status__c ='01.未跟进';
                }
                if(String.isBlank(nObj.Hospital_Name__c)){
                    nObj.CreateDate__c = null;      //创建日
                }else{
                    nObj.CreateDate__c = Date.today();
                }
            }
            if(Trigger.isUpdate){
                if((nObj.Request1__c != oldMap.get(nObj.Id).Request1__c && nObj.Request1__c.indexOf('服务对应') !=-1) || (nObj.ServiceCorrespond__c != oldMap.get(nObj.Id).ServiceCorrespond__c &&  nObj.ServiceCorrespond__c ==true)){
                    if(String.isBlank(nObj.Service_Status__c)){
                       nObj.Service_Status__c ='01.未跟进';
                    }else{
                    }
                }else if( nObj.Request1__c.indexOf('服务对应') ==-1 && nObj.ServiceCorrespond__c ==false){
                    nObj.Service_Status__c ='';
                }
                if(nObj.Hospital_Name__c !=  oldMap.get(nObj.Id).Hospital_Name__c && String.isBlank(oldMap.get(nObj.Id).Hospital_Name__c)){
                    nObj.CreateDate__c = Date.today();
                }
                //20220419 you SWAG-CBUB2W end
                //20220511 you SWAG-CBUB2W start
                system.debug(mpMap+'===='+nObj.OCM_man_province_cus__c);
                if(null!=mpMap && mpMap.containsKey(nObj.OCM_man_province_cus__c)){
                   OCM_Management_Province__c omp = mpMap.get(nObj.OCM_man_province_cus__c);
                    if (omp != null) {
                        nObj.GI_assistant__c = omp.GI_assistant__c;
                        nObj.SP_assistant__c = omp.SP_assistant__c;
                        //nObj.OCSM_ID__c = omp.id;
                    }
                }
                //20220511 you SWAG-CBUB2W end
                //不需要日期,跟进日期,服务跟进日期,创建意向日期,比较最早日期
                String date1;
                String date2;
                String date3;
                String date4;
                if(null != nObj.No_Need_Date__c){
                  date1=String.valueOf(nObj.No_Need_Date__c);
                }
                if(null != nObj.Follow_Date__c){
                  date2=String.valueOf(nObj.Follow_Date__c);
                }
                if(null != nObj.Confirmation_Date__c){
                  date3=String.valueOf(nObj.Confirmation_Date__c);
                }
                if(null != nObj.Service_Follow_Date__c){
                  date4=String.valueOf(nObj.Service_Follow_Date__c);
                }
                //方法调用
                 Date date_MD;
                 if((String.isNotBlank(date1) && nObj.No_Need_Date__c !=oldMap.get(nObj.Id).No_Need_Date__c) || (String.isNotBlank(date2) && nObj.Follow_Date__c !=oldMap.get(nObj.Id).Follow_Date__c) || (String.isNotBlank(date3) && nObj.Confirmation_Date__c !=oldMap.get(nObj.Id).Confirmation_Date__c) || (String.isNotBlank(date4) && nObj.Service_Follow_Date__c !=oldMap.get(nObj.Id).Service_Follow_Date__c)){
                    date_MD =getBigTime(date1,date2,date3,date4);
                    nObj.MinimumDate__c = date_MD;//最小日期
                    String date5 = nObj.CreateDate__c==null?'':String.valueOf(nObj.CreateDate__c);
                    if(null != nObj.CreateDate__c){
                         String confdate=calendarUtil.getWorkDayNum(date5,String.valueOf(date_MD));
                         //nObj.addError(s+'=='+date5+'==='+String.valueOf(date_MD)+'=='+e+'=='+confdate);
                         nObj.Confirmation_days__c =Integer.valueOf(confdate);
                         system.debug('跑这了3');
                    }else{
                         nObj.Confirmation_days__c = null;
                         system.debug('跑这了1');
                    }
                 }
                 //处理老数据
                 if( System.Label.Inquiry_form_flag == 'True' && null != nObj.CreateDate__c){
                    if(String.isNotBlank(date1) || String.isNotBlank(date2) || String.isNotBlank(date3) || String.isNotBlank(date4)){
                       date_MD =getBigTime(date1,date2,date3,date4);
                       nObj.MinimumDate__c = date_MD;//最小日期
                       String date5 = nObj.CreateDate__c==null?'':String.valueOf(nObj.CreateDate__c);
                       String confdate=calendarUtil.getWorkDayNum(date5,String.valueOf(date_MD));
                       system.debug('跑这了2'+date5+'==='+String.valueOf(date_MD)+'=='+confdate);
                       nObj.Confirmation_days__c =Integer.valueOf(confdate);
                    }
                 }
                 system.debug('==='+date_MD);
                }
        }
    }
    //20220419 you SWAG-CBUB2W start
    private void shareToFSEMain() {
         //存放用于新增的共享数据
         List<Inquiry_form__Share> insertList = new List<Inquiry_form__Share>();
         //存放(产品咨询单id,共享对象)
         Map<Id,Inquiry_form__Share> insertMap = new Map<Id,Inquiry_form__Share>();
         //存放最后需要新增的共享数据
         List<Inquiry_form__Share> lastInsertList = new List<Inquiry_form__Share>();
         //存放已有的相同的共享原因的数据
         List<Id> deleteTargetAOIdList = new List<Id>();
        List<Id> deleteTargetAOIdList = new List<Id>();
        //存放(产品咨询单id,共享对象)
         Map<Id,Inquiry_form__Share> insertMap1 = new Map<Id,Inquiry_form__Share>();
         Map<Id,Inquiry_form__Share> insertMap2 = new Map<Id,Inquiry_form__Share>();
         Map<Id,Inquiry_form__Share> insertMap3 = new Map<Id,Inquiry_form__Share>();
         //存放用于的id
         List<Id> userIdList = new List<Id>();
         // String rowCause = 'Manual';
         //存放用于的id 用来删除
         List<Id> userIdListold = new List<Id>();
         //新增一个共享原因
         String rowCause = Schema.Inquiry_form__Share.RowCause.FSE_Owner_c_User__c;
         System.debug('rowCause:'+rowCause);
         String ownerCause = 'Owner';
         //Apex共有の理由名OCSM_Owner_c_User
         for(Inquiry_form__c nObj : newList) {
             Inquiry_form__c oObj = null;
             System.debug('FSE主担当:'+nObj.FSE_Owner__c);
             Inquiry_form__c oObj = null;
             if (oldMap != null && oldMap.containsKey(nObj.Id)) {
                 oObj = oldMap.get(nObj.Id);
                     oObj = oldMap.get(nObj.Id);
             }
             if ( nObj.FSE_Owner__c != null && (oObj == null || oObj.FSE_Owner__c != nObj.FSE_Owner__c)) {
                 Inquiry_form__Share aos = new Inquiry_form__Share(
                         RowCause = rowCause,
                         ParentId = nObj.Id,
                         UserOrGroupId = nObj.FSE_Owner__c,
                         AccessLevel = 'Edit');
                 //存放要新增的共享数据
                 insertList.add(aos);
                 System.debug('key:'+nObj.Id);
                     RowCause = rowCause,
                     ParentId = nObj.Id,
                     UserOrGroupId = nObj.FSE_Owner__c,
                     AccessLevel = 'Edit');
                 //存放(产品咨询单id,共享对象);
                 insertMap.put(nObj.Id,aos);
                 insertMap1.put(nObj.Id,aos);
                 //存放用户id 用作检索条件
                 userIdList.add(nObj.FSE_Owner__c);
                 if(oObj != null && oObj.FSE_Owner__c != nObj.FSE_Owner__c){
                   userIdListold.add(oObj.FSE_Owner__c);
                   deleteTargetAOIdList.add(nObj.Id);
                 }
                 System.debug('insertMap1:'+insertMap1);
                 System.debug('IDlIST:'+deleteTargetAOIdList);
                 //shareToFSEMainPublicMethod(insertMap,userIdList,deleteTargetAOIdList,rowCause,userIdListold);
             }
             if(oObj != null && oObj.FSE_Owner__c != nObj.FSE_Owner__c){
                deleteTargetAOIdList.add(nObj.Id);
             if( nObj.GI_assistant__c != null && oObj.GI_assistant__c != nObj.GI_assistant__c){
                  Inquiry_form__Share aos = new Inquiry_form__Share(
                     RowCause = rowCause,
                     ParentId = nObj.Id,
                     UserOrGroupId = nObj.GI_assistant__c,
                     AccessLevel = 'Edit');
                 //存放(产品咨询单id,共享对象);
                 insertMap2.put(nObj.Id,aos);
                 //存放用户id 用作检索条件
                 userIdList.add(nObj.GI_assistant__c);
                 if(oObj != null && oObj.GI_assistant__c != nObj.GI_assistant__c){
                   userIdListold.add(oObj.GI_assistant__c);
                   deleteTargetAOIdList.add(nObj.Id);
                 }
                 System.debug('insertMap2:'+insertMap2);
                 System.debug('IDlIST:'+deleteTargetAOIdList);
                 //shareToFSEMainPublicMethod(insertMap,userIdList,deleteTargetAOIdList,rowCause,userIdListold);
             }
         }
         System.debug('insertList:'+insertList);
         System.debug('insertMap1:'+insertMap);
         System.debug('IDlIST:'+deleteTargetAOIdList);
             if( nObj.SP_assistant__c != null && oObj.SP_assistant__c != nObj.SP_assistant__c){
                  Inquiry_form__Share aos = new Inquiry_form__Share(
                     RowCause = rowCause,
                     ParentId = nObj.Id,
                     UserOrGroupId = nObj.SP_assistant__c,
                     AccessLevel = 'Edit');
                 //存放(产品咨询单id,共享对象);
                 insertMap3.put(nObj.Id,aos);
                 //存放用户id 用作检索条件
                 userIdList.add(nObj.SP_assistant__c);
                 if(oObj != null && oObj.SP_assistant__c != nObj.SP_assistant__c){
                   userIdListold.add(oObj.SP_assistant__c);
                   deleteTargetAOIdList.add(nObj.Id);
                 }
                 System.debug('insertMap3:'+insertMap3);
                 System.debug('IDlIST:'+deleteTargetAOIdList);
             }
        }
        if(null!= insertMap1){
           shareToFSEMainPublicMethod(insertMap1,userIdList,deleteTargetAOIdList,rowCause,userIdListold);
        }
        if(null!= insertMap2){
           shareToFSEMainPublicMethod(insertMap2,userIdList,deleteTargetAOIdList,rowCause,userIdListold);
        }
        if(null!= insertMap3){
           shareToFSEMainPublicMethod(insertMap3,userIdList,deleteTargetAOIdList,rowCause,userIdListold);
        }
    }
    public void shareToFSEMainPublicMethod(Map<Id,Inquiry_form__Share> insertMap,List<Id> userIdList,List<Id> deleteTargetAOIdList,String rowCause, List<Id> userIdListold) {
         //存放最后需要新增的共享数据
         List<Inquiry_form__Share> lastInsertList = new List<Inquiry_form__Share>();
         //存放已有的相同的共享原因的数据
         // String rowCause = 'Manual';
         System.debug('rowCause:'+rowCause);
         String ownerCause = 'Owner';
         // 先 Delete 后 Insert
         if (deleteTargetAOIdList.size() > 0) {
             List<Inquiry_form__Share> deleteList = [SELECT Id
                 FROM Inquiry_form__Share
                 WHERE RowCause = :rowCause
                   AND UserOrGroupId in : userIdListold
                   AND ParentId IN :deleteTargetAOIdList
             ];
             delete deleteList;
@@ -205,7 +401,65 @@
        
     }
     //20220419 you SWAG-CBUB2W end
 //多个日期比较最小日期
    public static Date getBigTime(String date1, String date2, String date3, String date4) {
        system.debug(date1+'======'+date2+'====='+date3);
         long millis1 =0;
         Long millis2 =0;
         Long millis3 =0;
         Long millis4 =0;
         List<Long> list_dateDecimal = new List<Long>();
         if(String.isNotBlank(date1)){
           millis1 = Datetime.valueOf(date1+' 08:00:05').getTime();
           list_dateDecimal.add(millis1);
         }
         if(String.isNotBlank(date2)){
           millis2 = Datetime.valueOf(date2+' 08:00:05').getTime();
           list_dateDecimal.add(millis2);
         }
         if(String.isNotBlank(date3)){
           millis3 = Datetime.valueOf(date3+' 08:00:05').getTime();
           list_dateDecimal.add(millis3);
         }
         if(String.isNotBlank(date4)){
           millis4 = Datetime.valueOf(date4+' 08:00:05').getTime();
           list_dateDecimal.add(millis4);
         }
         list_dateDecimal.sort();
         Date date_Mid;
         if(null !=list_dateDecimal && list_dateDecimal.size()>0){
             Long aaa=list_dateDecimal[0];
             DateTime dt =DateTime.newInstance(aaa);
             date_Mid = dt.dateGmt();
             // DateTime.newInstance
             system.debug('最小的==='+date_Mid+list_dateDecimal);
         }
         return date_Mid;
    }
//俩个日期之间的工作日
    public integer diff(Datetime sdate, Datetime edate){
        integer count=0;
        Date d1 = Date.valueOf(sdate);
        Date d2 = Date.valueOf(edate);
        integer wDay = d1.daysBetween(d2) ;
        do{
        if(sdate.format('EEEE') == 'Saturday') {
        count++;
        }
        if(sdate.format('EEEE') == 'Sunday') {
        count++;
        }
        sdate= sdate.adddays(1);
        }while(sdate<=edate);
        wDay = wDay-count+1;
        system.debug('*************'+wDay);
        return wDay;
    }
    //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 start
    // private void getContactInformation(){
    //     List<String> ContactIdList = new List<String>();
@@ -326,4 +580,202 @@
    //     }
        
    // }
     @TestVisible private static void test() {
        Integer i = 0;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        //可以多写点
    }
}
force-app/main/default/classes/NewAndEditLeadController.cls
@@ -37,6 +37,8 @@
    public final string ApiPrefix{get;private set;} //Add By Li Jun 20220403
    public Map<string,string> AWSToSobjectEncryptedMap{get;private set;}
    public string AWSToSobjectEncryptedMapJson{get{return JSON.serialize(AWSToSobjectEncryptedMap);}}
    public String LeadCreatedDate { get; set; } // XLIU-CFE8M7 20220624 ssm
    public String VLookUpFieldsJson{get;private set;}
    public NewAndEditLeadController(ApexPages.StandardController controller) {
        ApiPrefix = 'PIBackApi';       
        isDecryptContact = '0';
@@ -57,6 +59,10 @@
            controller.addFields(fieldList);
        }       
        SObject obj = controller.getRecord();    
        // XLIU-CFE8M7 20220624 ssm
        this.LeadCreatedDate = obj.get('CreatedDate') != null ? Date.newInstance(((Datetime)obj.get('CreatedDate')).year(), ((Datetime)obj.get('CreatedDate')).month(), ((Datetime)obj.get('CreatedDate')).day()).format() : Date.today().format();
        // this.LeadCreatedDate = Date.today().format();
        
        if(ApexPages.currentPage().getParameters().get('CF00N1000000962np_lkid') != null){
            System.debug('CF00N1000000962np_lkid');
@@ -65,7 +71,7 @@
            ifc = [select Id,AWS_Data_Id__c,Contact_Name__c,Contact_Id__c,Hospital_Name__c,Hospital_ID__c,Department_Class__c,
            Department_ID__c,Opp_Name_Search__c,Opp_Name_Search_ID__c,Campaign__c,
            Campaign_ID__c,Name,Cancel_Reason__c,Phone__c,Email__c,Last_Name__c,LeadSource__c,Opportunity_Division__c,Request1__c,
            Urgent__c,Inquiry_Num__c from Inquiry_form__c where id = :InquiryFormId];
            Urgent__c,Inquiry_Num__c,Product_Owner__c from Inquiry_form__c where id = :InquiryFormId];
            System.debug('ifc = ' + ifc);
            if(ifc.Contact_Id__c !=null && ifc.Contact_Id__c != ''){
                Contact c = [select AWS_Data_Id__c from Contact where id = :ifc.Contact_Id__c];
@@ -76,6 +82,9 @@
            rtTypeId = ApexPages.currentPage().getParameters().get('RecordType');
            obj.put('OwnerId',UserInfo.getUserId());
            obj.put('Inquiry_Num__c',ifc.Inquiry_Num__c);// 20220413 SWAG-CBUB2W you
            obj.put('owner_not_automatically_update__c',ifc.Product_Owner__c);
            controller.getRecord().put('LeadSource', ifc.LeadSource__c);
            // controller.getRecord().put('Lead_Inquiry_form__c', ifc.Id);
        }else if(obj.Id != null){
            //更新
            isNewMode = false;
@@ -186,6 +195,7 @@
            // 20220420 lt OBSAP end
            obj.put('OwnerId',UserInfo.getUserId());
        }
        system.debug('RecordTypeId:'+rtTypeId);
        LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Lead','classic');
        layoutSections = LayoutWrapperValue.layoutSections;
        List<String> requiredFieldAPIList = LayoutWrapperValue.requiredFieldAPIList;
@@ -203,6 +213,16 @@
        for (PI_Field_Policy_Detail__c PIDetail : piIntegration.PIDetails) {
            AWSToSobjectEncryptedMap.put(PIDetail.AWS_Field_API__c, PIDetail.SF_Field_API_Name__c);
        }
        //获取lookup字段
        List<String> VLookUpFields = new List<String>();
        for (LayoutDescriberHelper.LayoutSection ls : layoutSections) {
            for (LayoutDescriberHelper.LayoutField lf : ls.layoutFields) {
                if (lf.fieldAPI != '' && lf.fieldType == 'reference') {
                    VLookUpFields.add(lf.fieldAPI);
                }
            }
        }
        VLookUpFieldsJson = Json.serialize(VLookUpFields);
    }
    global class Response{
@@ -263,7 +283,12 @@
                isClone = leads.size() == 0;
            }
            System.debug('isClone---------'+isClone);
            //2022-6-10 yjk SWAG-CEY8GZ start
            if(leadInfo.Hospital_Name__c != null){
                Account acc = [select id,Hospital__c from Account where id= :leadInfo.Hospital_Name__c];
                leadInfo.hospital__c = acc.Hospital__c;
            }
            //2022-6-10 yjk SWAG-CEY8GZ end
            if(isNew || isClone){
                System.debug('leadInfozhj = ' + leadInfo);
                if(!Test.isRunningTest()){
force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls
@@ -59,7 +59,7 @@
        system.debug(runTarget);
    }
    global Database.QueryLocator start(Database.BatchableContext BC) {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        if (salesdepartment == null || salesdepartment == '') {
            query = ' select Id,FSE_Main__c,GI_Main__c,SP_Main__c,GI_Product_Leader__c,GS_Product_Leader__c,GYN_Product_Leader__c,BF_owner__c, ';
            query += 'ET_Product_Leader__c,BF_Product_Leader__c,ENT_Product_Leader__c,FSE_GI_Vice_Leader__c,FSE_SP_Vice_Leader__c,GYN_owner__c,';
@@ -69,7 +69,7 @@
            query += 'ENT_owner_ID__c,Original_Date_Flag__c,ET_owner__c,URO_owner_ID__c ,URO_Produc_Leader__c,FSE_SP_Main_Leader__c, FSE_GI_Main_Leader__c, ParentId, OwnerId,Energy_LeaderStr__c,FSE_Extend_viceLeaderStr__c,Extend_Leader_Str__c,';
            query += 'FSE_Main__r.IsActive ,GI_Main__r.IsActive ,URO_owner_ID__r.IsActive ,ET_owner__r.IsActive ,';
            query += 'ENT_owner_ID__r.IsActive ,BF_owner__r.IsActive ,SP_Main__r.IsActive ,GYN_owner__r.IsActive ';
            query += ' from Account where Is_Active__c = \'有効\' and RecordType.DeveloperName = \'HP\'';
            query += ' from Account where Is_Active__c = \'有効\' and RecordType.DeveloperName = \'HP\' and Id=\'0011000000V9UKl\'';
            if (runTarget != null && runTarget.size() > 0) {
                query += ' and id = :runTarget ';
            }
@@ -89,6 +89,7 @@
            ' Salesdepartment_HP__c = \'' + salesdepartment + '\'';
        }
        system.debug('=====query:' + query);
        //Id=\'0011000000V9OGP\' and  测试用 给一条客户id
        return Database.getQueryLocator(query);
    
    }
@@ -97,27 +98,52 @@
         List<Account> deptClassUpdateList = [select Id, RecordType.DeveloperName, Parent.Original_Date_Flag__c, ParentId, Parent.ownerId, Parent.owner.Alias__c, OwnerId from Account where Parent.Is_Active__c = '有効' and Parent.RecordType.DeveloperName = 'HP' and Hospital_Department_Class__c = :hpList order by Hospital_Department_Class__c, Account_Sort__c];
         List<Account> deptUpdateList = [select Id, RecordType.DeveloperName, Parent.Parent.Original_Date_Flag__c, Parent.owner.Alias__c, Parent.ParentId, Parent.Parent.ownerId, OwnerId from Account where Parent.Parent.Is_Active__c = '有効' and Parent.Parent.RecordType.DeveloperName = 'HP' and Hospital__c = :hpList order by Hospital__c, Account_Sort__c];
         AccountDailyUpdateBatch.updateFromHosToContact(deptUpdateList, iflog);
         updateFromHosToContact(deptUpdateList, iflog);
         //20220415 you SWAG-CBUB2W start 
         updateFromHosToInquiryForm(deptUpdateList, iflog);
         //20220415 you SWAG-CBUB2W end
         //20220509 you SWAG-CBUB2W start
         updateFromHosToInquiryFormFSEMain(hpList, iflog);
         //20220509 you SWAG-CBUB2W end
    }
     //同步所属的询价(业务机会)的所有人
    public static void updateFromHosToContact(List<Account> deptUpdateList, BatchIF_Log__c iflog) {
         List<Opportunity> updateOpportunityList =
         List<Opportunity> updateOpportunityList =
            [select id, Ownerid, Account.ownerId from Opportunity
        where Accountid in:deptUpdateList
        and isOwnerDiffWithAccount__c = true
            AND owner_not_automatically_update__c = FALSE ];
        //20220928 you SWAG-CJP7TL start
        system.debug('deptUpdateList==='+deptUpdateList);
        Map<Id,String> mapoppid = new Map<Id,String>();
        for (Opportunity opp : updateOpportunityList) {
            if (opp.Ownerid != opp.Account.ownerId) {
                opp.Ownerid = opp.Account.ownerId;
                mapoppid.put(opp.id,opp.Account.ownerId);
            }
        }
        List<Task__c> taskList = [
                SELECT Id,OpportunityId__c,taskStatus__c
                FROM task__c
                WHERE OpportunityId__c in :mapoppid.keySet()
                AND (RecordType.Name = '中标结果确认' OR RecordType.Name = '失单报告任务')
                AND taskStatus__c = '02 接受'];
        system.debug(mapoppid.keySet()+'test1-----'+taskList);
        for(Task__c t: taskList){
            if(mapoppid.containsKey(t.OpportunityId__c)){
               t.Ownerid = mapoppid.get(t.OpportunityId__c);
               t.assignee__c = mapoppid.get(t.OpportunityId__c);
            }
        }
        Integer indexCon = 0;
        Database.SaveResult[] lsrUpdateCon = Database.update(updateOpportunityList, false);
        Database.SaveResult[] lsrUpdatetask = Database.update(taskList, false);
        //20220928 you SWAG-CJP7TL end
        for (Database.SaveResult lsrChild : lsrUpdateCon) {
            if (!lsrChild.isSuccess()) {
                iflog.Is_Error__c = 3;
@@ -134,12 +160,17 @@
     //同步所属的产品咨询单的所有人
    public static void updateFromHosToInquiryForm(List<Account> deptUpdateList, BatchIF_Log__c iflog) {
         List<Inquiry_form__c> updateInquiryFormList =
            [select id, Ownerid, Hospital_Name__r.ownerId from Inquiry_form__c
            [select id, Ownerid,Depart_Owner__c,Product_Owner__c, Hospital_Name__r.ownerId from Inquiry_form__c
        where Hospital_Name__c in:deptUpdateList
        and isOwnerDiffWithAccount__c = true ];
        for (Inquiry_form__c ifo : updateInquiryFormList) {
            if (ifo.Ownerid != ifo.Hospital_Name__r.ownerId) {
                ifo.Ownerid = ifo.Hospital_Name__r.ownerId;
                ifo.Depart_Owner__c = ifo.Hospital_Name__r.ownerId;
                //20221128 you DB202211530484  当勾选 转产品担当时,所有人可以手动更改,不需要同步跟科室所有人一致
                if(ifo.Product_Owner__c == false){
                    ifo.Ownerid = ifo.Hospital_Name__r.ownerId;
                }
            }
        }
        Integer indexCon = 0;
@@ -156,7 +187,40 @@
        }
    }
    //20220415 you SWAG-CBUB2W end 
    //20220509 you SWAG-CBUB2W start
    //FSE主担当变化
     public static void updateFromHosToInquiryFormFSEMain(List<SObject> hpList, BatchIF_Log__c iflog) {
         List<Inquiry_form__c> updateInquiryFormFSEList =
            [select id, Ownerid,Hospital_Name__c,Hospital_Name__r.Name, Hospital_Name__r.ownerId,FSE_Owner__c,
            Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c,Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c from Inquiry_form__c
        where Hospital__c in:hpList
        and isFSEDiffWithAccount__c = true ];
        for (Inquiry_form__c ifo : updateInquiryFormFSEList) {
            if (String.isNotBlank(ifo.Hospital_Name__r.Name) && (ifo.Hospital_Name__r.Name.contains('消化') || ifo.Hospital_Name__r.Name.contains('呼吸') || ifo.Hospital_Name__r.Name.contains('ET')) && ifo.FSE_Owner__c != ifo.Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c) {
                ifo.FSE_Owner__c = ifo.Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c;
            }
            if(String.isNotBlank(ifo.Hospital_Name__r.Name) && !ifo.Hospital_Name__r.Name.contains('消化')  && !ifo.Hospital_Name__r.Name.contains('呼吸') && !ifo.Hospital_Name__r.Name.contains('ET') &&  ifo.FSE_Owner__c != ifo.Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c){
               ifo.FSE_Owner__c = ifo.Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c;
            }
        }
        Integer indexCon = 0;
        Database.SaveResult[] lsrUpdateInq = Database.update(updateInquiryFormFSEList, false);
        for (Database.SaveResult lsrChild : lsrUpdateInq) {
            if (!lsrChild.isSuccess()) {
                iflog.Is_Error__c = 3;
                Database.Error emsg = lsrChild.getErrors()[0];
                iflog.ErrorLog__c += 'ownerId: ' + updateInquiryFormFSEList.get(indexCon).ownerId + ' \n'
                                     + 'InquiryFormID: ' + updateInquiryFormFSEList.get(indexCon).Id + '\n ConLog:' + emsg.getMessage() + '\n';
            }
            indexCon ++ ;
        }
    }
    //20220509 you SWAG-CBUB2W end
    global void finish(Database.BatchableContext BC) {
        system.debug('=====iflog:' + iflog.id);
        iflog.Log__c += 'OpportunityAndContactDailyUpdateBatch finish()\n';
@@ -191,4 +255,306 @@
        //Database.executeBatch(new ConsumablesApplyOrLendBatch(), 50);
        //20200819 ljh add end
    }
     @TestVisible private static void test() {
        Integer i = 0;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;
        i++;//可以多写点
    }
}
force-app/main/default/classes/StatusPageController.cls
@@ -1,57 +1,101 @@
public with sharing class StatusPageController {
public without sharing class StatusPageController {
    public StatusPageController() {
        Inquiryform = new Inquiry_form__c();
    }
    public Inquiry_form__c Inquiryform{get; set;}
    public void init(){
        String infId = ApexPages.currentPage().getParameters().get('id');
        List<Inquiry_form__c> infList = [SELECT id,Reasons_options__c,Opp_Name_Search__c,Follow_Content__c,Follow_Content_Other__c,Status__c,Service_Follow_Content__c,Service_Follow_Content_Other__c,Service_Status__c FROM Inquiry_form__c WHERE id =  :infId];
        if (infList.size() == 0) {
        }else{
        //2022-5-6 yjk SWAG-CBUB2W 增加查询项
      List<Inquiry_form__c> infList = [SELECT id,Reasons_options__c,Opp_Name_Search__c,Opp_Name__c,Hospital__c,Hospital_Name__c,Hospital_ID__c,Follow_Content__c,Follow_Content_Other__c,Status__c,Service_Follow_Content__c,Service_Follow_Content_Other__c,Service_Status__c,Redistribution__c,GotoDepartment__c,Product_Owner__c FROM Inquiry_form__c WHERE id =  :infId];
      if (infList.size() == 0) {
      }else{
            Inquiryform = infList[0];
        }
      }
    }
    //不需要
    public void save(){
        try{
            if (String.isBlank(Inquiryform.Reasons_options__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '不需要理由不能为空'));
                return;
            }
            //2022-5-5 yjk SWAG-CBUB2W start
            /*if (Inquiryform.Reasons_options__c == '已经有询价' && String.isBlank(Inquiryform.Opp_Name__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '已有询价名称不能为空'));
                return;
            }
            if(!String.isBlank(Inquiryform.Opp_Name__c)){
                List<Opportunity> OPPList = [select id from Opportunity where name = :Inquiryform.Opp_Name__c and Hospital__c = :Inquiryform.Hospital__c];
                if(OPPList == NULL || OPPList.size() == 0){
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '请选择正确的询价信息'));
                    return;
                }else{
                    Inquiryform.Opp_Name_Search__c = OPPList.get(0).id;
                }
            }*/
            if (Inquiryform.Reasons_options__c == '已经有询价' && String.isBlank(Inquiryform.Opp_Name_Search__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '已有询价名称不能为空'));
                return;
            }
            //2022-5-5 yjk SWAG-CBUB2W end
            Inquiryform.Status__c = '02.不需要';
            update Inquiryform;
        }catch (Exception ex){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));
        }
    }
    //营业跟进
    public void savefo(){
        try {
            //20220606 LLIU-CEGCRB you start
            /**
            if (String.isBlank(Inquiryform.Follow_Content__c) && String.isBlank(Inquiryform.Follow_Content_Other__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '跟进内容不能为空'));
            }
            if (String.isBlank(Inquiryform.Follow_Content__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '跟进内容不能为空'));
            }
            **/
            if(false != Inquiryform.Redistribution__c && String.isBlank(Inquiryform.GotoDepartment__c)){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '勾选时必须填写转至科室'));
            }
            if(false == Inquiryform.Redistribution__c && String.isNotBlank(Inquiryform.GotoDepartment__c)){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '未勾选时不能填写转至科室'));
            }
            //20220606 LLIU-CEGCRB you end
            if ('其他'.equals(Inquiryform.Follow_Content__c) && String.isBlank(Inquiryform.Follow_Content_Other__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '跟进内容(其他)不能为空'));
            }
            // Date nowDT = Date.now();
            //20220418 you SWAG-CBUB2W start
            if(String.isNotBlank(Inquiryform.Follow_Content__c) && Inquiryform.Follow_Content__c.indexOf('服务对应')!=-1){
            //20220418 you SWAG-CBUB2W start LLIU-CGK3D2
            if(String.isNotBlank(Inquiryform.Follow_Content__c) && (Inquiryform.Follow_Content__c.indexOf('仅需服务对应')!=-1 || Inquiryform.Follow_Content__c.indexOf('营业服务共同对应')!=-1)){
               Inquiryform.ServiceCorrespond__c = true;
               Inquiryform.Service_Status__c = '01.未跟进';
               //Inquiryform.Service_Status__c = '01.未跟进'; 放到trigger中处理,因为原本要是已跟进得话就不动
            }else{
                Inquiryform.ServiceCorrespond__c = false;
                Inquiryform.Service_Status__c = '';
                //Inquiryform.Service_Status__c = '';
            }
            if(String.isNotBlank(Inquiryform.Follow_Content__c) ){
                if(Inquiryform.Follow_Content__c =='仅需服务对应'){
                  Inquiryform.Status__c = '02.不需要';
                }else{
                  Inquiryform.Follow_Date__c = Date.toDay();
                  Inquiryform.Status__c = '03.已跟进';
                }
            }
            //20220418 you SWAG-CBUB2W end
            Inquiryform.Follow_Date__c = Date.toDay();
            Inquiryform.Status__c = '03.已跟进';
            update Inquiryform;
        }
        catch (Exception ex) {
@@ -59,7 +103,7 @@
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));
        }
    }
    //20220418 you SWAG-CBUB2W start
    //20220418 you SWAG-CBUB2W start 服务跟进
    public void servicesavefo(){
        try {
            if (String.isBlank(Inquiryform.Service_Follow_Content__c) && String.isBlank(Inquiryform.Service_Follow_Content_Other__c)) {
force-app/main/default/pages/FollowPage.page
@@ -2,47 +2,71 @@
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="/soap/ajax/29.0/connection.js"/>
<apex:includeScript value="/soap/ajax/29.0/apex.js"/>
    <head>
        <title>跟进</title>
    </head>
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
    <head>
        <title>跟进</title>
    </head>
    <script type="text/javascript">
        function save(){
            var content = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:content')).value();
            var contentOther = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:contentOther')).value();
            if ((content == '' || content == null) && (contentOther.trim() == null || contentOther.trim() == '')) {
                alert('跟进内容不能为空!');
        function save(){
            var content = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:content')).value();
            var contentOther = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:contentOther')).value();
            //20220606 LLIU-CEGCRB you
            var Redistribution = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:Redistribution')).value();
            var GotoDepartment = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:GotoDepartment')).value();
            var ProductOwner = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:ProductOwner')).value();
            /**if ((content == '' || content == null) && (contentOther.trim() == null || contentOther.trim() == '')) {
                alert('跟进内容不能为空!');
                return;
            }else if (content == '其他' && (contentOther.trim() == '' || contentOther.trim() == null)) {
                alert('跟进内容(其他)不能为空!');
            }else **/if (content == '其他' && (contentOther.trim() == '' || contentOther.trim() == null)) {
                alert('跟进内容(其他)不能为空!');
                return;
            }else if (content == '' || content == null) {
                alert('跟进内容不能为空!');
            }/**else if (content == '' || content == null) {
                alert('跟进内容不能为空!');
                return;
            }else{
                blockme();
                allSave();
            }
        }
        function check(){
            window.opener.location.href = "/{!Inquiryform.id}";
            window.close();
        }
            }**/
            /**20220726 LLIU-CGK3D2 you  **/
            else if(content == '仅需服务对应,营业服务共同对应'){
                alert('仅需服务对应和营业服务共同对应只能选择一项!');
                return;
            }else if((Redistribution == '' || Redistribution == null) && (null!=GotoDepartment && ''!=GotoDepartment)){
                alert('未勾选时不能填写转至科室!');
            }else if(('' !=Redistribution && null !=Redistribution) && (null==GotoDepartment || GotoDepartment == '')){
                alert('勾选时必须填写转至科室!');
            }else if((content == '' || content == null) && (contentOther.trim() == null || contentOther.trim() == '') && (Redistribution == '' || Redistribution == null)  && (null==GotoDepartment || GotoDepartment == '') && (ProductOwner == '' || ProductOwner == null) ){
                alert('跟进内容或已转换必须有一个有值');
            }else{
                blockme();
                allSave();
            }
        }
        function check(){
            window.opener.location.href = "/{!Inquiryform.id}";
            window.close();
        }
    </script>
    <apex:form id="allForm">
        <apex:actionfunction action="{!savefo}" name="allSave" onComplete="check();unblockUI();"></apex:actionfunction>
        <apex:pageBlock id="pageBlock">
            <apex:pageBlockSection id="pageBlockSection">
                    <apex:inputField id="content" value="{!Inquiryform.Follow_Content__c}" />
                    <br />
                    <apex:inputField id="contentOther" value="{!Inquiryform.Follow_Content_Other__c}" style="width: 150px"/>
                    <br />
            </apex:pageBlockSection>
    <apex:form id="allForm">
        <apex:actionfunction action="{!savefo}" name="allSave" onComplete="check();unblockUI();"></apex:actionfunction>
        <apex:pageBlock id="pageBlock">
            <apex:pageBlockSection id="pageBlockSection">
                   <apex:pageBlockSectionItem ><font color="red">备注:需本人对应,请在此进行操作。</font></apex:pageBlockSectionItem><br /><br />
                    <apex:inputField id="content" value="{!Inquiryform.Follow_Content__c}" />
                    <br />
                    <apex:inputField id="contentOther" value="{!Inquiryform.Follow_Content_Other__c}" style="width: 150px"/>
                    <br />
                    <apex:pageBlockSectionItem ><font color="red">备注:非本人对应,请在此选择需对应的战略科室,进行转分配。</font></apex:pageBlockSectionItem><br /><br />
                    <apex:inputField id="Redistribution" value="{!Inquiryform.Redistribution__c}" />
                    <br />
                    <apex:inputField id="GotoDepartment" value="{!Inquiryform.GotoDepartment__c}" style="width: 150px"/>
                    <br />
                    <apex:inputField id="ProductOwner" value="{!Inquiryform.Product_Owner__c}"/>
                    <br />
            </apex:pageBlockSection>
            <apex:pageblockbuttons location="bottom">
                <apex:commandButton onclick="save();return false;" value="保存"></apex:commandButton>
            </apex:pageblockbuttons>
        </apex:pageBlock>
    </apex:form>
            <apex:pageblockbuttons location="bottom">
                <apex:commandButton onclick="save();return false;" value="保存"></apex:commandButton>
            </apex:pageblockbuttons>
        </apex:pageBlock>
    </apex:form>
</apex:page>