| | |
| | | component.set('v.allselectlist',res.allselectlist); |
| | | component.set('v.doclist',res.doclist); |
| | | // PIPL update Yin Mingjie 21/02/2022 start |
| | | // component.find('select_agency_person').set('v.options', this.conv_selected(res.allselectlist.AgencyPerson__c)); |
| | | this.search_contact(component, event, helper,res.allselectlist.AgencyPerson__c); |
| | | component.find('select_agency_person').set('v.options', this.conv_selected(res.allselectlist.AgencyPerson__c)); |
| | | // this.search_contact(component, event, helper,res.allselectlist.AgencyPerson__c); |
| | | // PIPL update Yin Mingjie 21/02/2022 end |
| | | component.find('select_department').set('v.options', this.conv_selected(res.allselectlist.Department_Cateogy__c)); |
| | | component.find('select_purpose_type').set('v.options', this.conv_selected(res.allselectlist.Purpose_Type__c)); |
| | |
| | | var searchUrl = result.searchUrl; |
| | | this.search_core(token,searchUrl,payload,(result)=>{ |
| | | if(result.status == '0'){ |
| | | this.to_contact_list(result,contactData,component); |
| | | if(result.object != null){ |
| | | this.to_contact_list(result,contactData,component); |
| | | }else{ |
| | | component.set('v.login',false); |
| | | } |
| | | }else{ |
| | | this.error('AWS search status : ' + result.status); |
| | | component.set('v.login',false); |
| | |
| | | |
| | | get_agency_person_name : function(component, agency_person_value) { |
| | | // PIPL update Yin Mingjie 21/02/2022 start |
| | | // var allselectlist = component.get('v.allselectlist.AgencyPerson__c'); |
| | | var allselectlist = component.get('v.allselectlistAgencyPerson'); |
| | | var allselectlist = component.get('v.allselectlist.AgencyPerson__c'); |
| | | // var allselectlist = component.get('v.allselectlistAgencyPerson'); |
| | | // PIPL update Yin Mingjie 21/02/2022 end |
| | | var new_label = ''; |
| | | for (var i = 0; i < allselectlist.length; i++) { |
| | |
| | | String firstNameStr = String.isNotBlank(contact.FirstName) ? contact.FirstName:''; |
| | | String contactFullName = lastNameStr + firstNameStr; |
| | | contactFullName = contact.LastName_Encrypted__c;// 20220314 PI改造 by Bright |
| | | if(string.isBlank(contactFullName)){ |
| | | continue; |
| | | } |
| | | String accountId = String.valueOf(contact.AccountId).SubString(0,15); |
| | | Map<String,Contact> contactFullNameMap = new Map<String,Contact>(); |
| | | if (accountContactMap.containsKey(accountId)) { |
| | |
| | | layoutSections.get(layoutSections.size() - 2).layoutFields.add(lf); |
| | | } |
| | | if(lf.isRequired){ |
| | | system.debug(lf.fieldAPI+' is required'); |
| | | requiredFieldAPIList.add(lf.fieldAPI); |
| | | } |
| | | if(string.isBlank(lf.fieldAPI)){ |
| | |
| | | for(String nameField:nameDetail){ |
| | | LayoutField lf = new LayoutField(); |
| | | lf.isRequired = (Boolean)fields.get('required'); |
| | | if(nameField == 'Salutation'){ |
| | | lf.isRequired = false; |
| | | } |
| | | lf.isPlaceHolder = placeholderF; |
| | | lf.editableField = isEditable; |
| | | lf.fieldAPI = nameField; |
| | |
| | | layoutSections.get(layoutSections.size() - 2).layoutFields.add(lf); |
| | | } |
| | | if(lf.isRequired){ |
| | | system.debug(lf.fieldAPI+' is required'); |
| | | requiredFieldAPIList.add(lf.fieldAPI); |
| | | } |
| | | if(string.isBlank(lf.fieldAPI)){ |
| | |
| | | layoutSections.get(layoutSections.size() - 2).layoutFields.add(lf); |
| | | } |
| | | if(lf.isRequired){ |
| | | system.debug(lf.fieldAPI+' is required'); |
| | | requiredFieldAPIList.add(lf.fieldAPI); |
| | | } |
| | | if(string.isBlank(lf.fieldAPI)){ |
| | |
| | | public String DepartmentName; //所属科室 |
| | | public String RelatedDepartment; //关联SFDC科室 客户管理编码(手写) AgentCode_Ext__c |
| | | public String Type; //职种 |
| | | public String TypeEncrypted;//职种Hash add for pipl 20220316 sushanhu |
| | | public String ContactAddress; //联系地址 |
| | | public String ContactAddressEncrypted;//联系地址密文 |
| | | public Boolean ForbiddenStatus; //平台用户禁用标识 |
| | |
| | | ct.LastName = gedata.Name; |
| | | ct.FirstName = ''; |
| | | ct.Type__c = gedata.Type; |
| | | ct.Type_Encrypted__c = gedata.TypeEncrypted;//add for pipl sushanhu 20220316 |
| | | ct.MobilePhone = gedata.Mobile; |
| | | ct.RegSource__c = comefrom; |
| | | ct.UnifiedI_Contact_ID__c = gedata.ContactId; //统一平台Id |
| | |
| | | public String sobjectPrefix{set;get;} |
| | | public String sobjecttypeForFrontEnd{set;get;} |
| | | public String contactsInfo {set;get;}//key sfid;value awsid |
| | | public String layoutSectionsStr {get; set;} |
| | | // public String CurrentUserId{private set; get;} |
| | | // public String CurrentUserName{private set; get;} |
| | | public NewAndEditAddressController(ApexPages.StandardController controller) { |
| | | isNewMode = true; |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | |
| | | staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); |
| | | encryptedAPIList = piIntegration.PIFields; |
| | | sobjectPrefix = piIntegration.sobjectPrefix; |
| | | layoutSectionsStr = JSON.serialize(layoutSections); |
| | | // CurrentUserName = UserInfo.getName(); |
| | | // CurrentUserId = UserInfo.getUserId(); |
| | | } |
| | | |
| | | global class Response{ |
| | |
| | | global abstract class NewAndEditBaseController { |
| | | |
| | | public List <LayoutDescriberHelper.LayoutSection > layoutSections{set;get;} |
| | | public String layoutSectionsStr {get; set;}//for dynamic add readonly attribute 20220316 by Mingjie |
| | | public String awsToken{set;get;} |
| | | public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); |
| | | public String sobjectTypeValue {private set; get;} |
| | | public Boolean isNewMode{set;get;} |
| | | public String rtTypeId {get; set;} |
| | | public String AWSDataId{set;get;} |
| | | public String CurrentUserId{private set;get;} |
| | | public String CurrentUserName{private set;get;} |
| | | |
| | | // 当前对象所有的加密字段集合 |
| | | public List<String> encryptedAPIList{private set;get;} |
| | |
| | | public List<String> VLookUpFields{get;private set;} |
| | | public String VLookUpFieldsJson{get{return Json.serialize(VLookUpFields);}} |
| | | public List<String> LookUpOverrideFields{get;private set;} |
| | | public string LookUpOverrideFieldsMapJson{get;private set;} |
| | | public string LookUpOverrideFieldsMapJson{get; set;} |
| | | |
| | | |
| | | public NewAndEditBaseController(){ |
| | |
| | | VLookUpFields = new List<String>(); |
| | | layoutEncryptedAPIList = new List<String>(); |
| | | LookUpOverrideFields = new List<String>(); |
| | | CurrentUserName = UserInfo.getName(); |
| | | CurrentUserId = UserInfo.getUserId(); |
| | | } |
| | | |
| | | protected virtual void Init(SObject obj){ |
| | |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | } |
| | | PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobjectTypeValue); |
| | | layoutEncryptedAPIList = piIntegration.PIFields; |
| | | //layoutEncryptedAPIList = piIntegration.PIFields; |
| | | encryptedAPIList = piIntegration.PIFields; |
| | | staticResource = JSON.serialize(piIntegration); |
| | | sobjectPrefix = piIntegration.sobjectPrefix; |
| | |
| | | system.debug(AWSToSobjectNonEncryptedMapJson); |
| | | try{ |
| | | LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, sobjectTypeValue,'classic'); |
| | | layoutSections = LayoutWrapperValue.layoutSections; |
| | | layoutSections = LayoutWrapperValue.layoutSections; |
| | | List<String> requiredFieldAPIList = LayoutWrapperValue.requiredFieldAPIList; |
| | | Map<String,String> fieldAPIToLabelMap = LayoutWrapperValue.fieldAPIToLabelMap; |
| | | List<String> fieldApiList = new List<String>(); |
| | |
| | | } |
| | | |
| | | //在view解密section中只需显示当前layout中的加密字段 |
| | | // if (encryptedAPIList.contains(lf.fieldAPI)) { |
| | | // layoutEncryptedAPIList.add(lf.fieldAPI); |
| | | // } |
| | | if (encryptedAPIList.contains(lf.fieldAPI)) { |
| | | layoutEncryptedAPIList.add(lf.fieldAPI); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | layoutSectionsStr = JSON.serialize(layoutSections); //for dynamic add readonly attribute 20220316 by Mingjie |
| | | fieldApiListStr = JSON.serialize(fieldApiList); |
| | | fieldAPIToLabelMapStr = JSON.serialize(fieldAPIToLabelMap); |
| | | requiredFieldAPIListStr = JSON.serialize(requiredFieldAPIList); |
| | | //awsToken = AWSServiceTool.getAWSToken(); |
| | | }catch(Exception e){ |
| | | layoutEncryptedAPIList = piIntegration.PIFields; |
| | | system.debug('Exception from get layout service:'+e.getmessage()); |
| | | } |
| | | } |
| | |
| | | public String sobjectPrefix{set;get;} |
| | | public String sobjecttypeForFrontEnd{set;get;} |
| | | public String contactsInfo {set;get;}//key sfid;value awsid |
| | | public String layoutSectionsStr {get; set;} |
| | | public NewAndEditCaseController(ApexPages.StandardController controller) { |
| | | isNewMode = true; |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | |
| | | staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); |
| | | encryptedAPIList = piIntegration.PIFields; |
| | | sobjectPrefix = piIntegration.sobjectPrefix; |
| | | layoutSectionsStr = JSON.serialize(layoutSections); |
| | | } |
| | | global class Response{ |
| | | public String recordId{set;get;} |
| | |
| | | unifiedIContactID = c.UnifiedI_Contact_ID__c; |
| | | } |
| | | |
| | | // AWSToSobjectNonEncryptedMap.put('lastName', 'LastName'); |
| | | // AWSToSobjectNonEncryptedMap.put('phone', 'Phone'); |
| | | // AWSToSobjectNonEncryptedMap.put('email', 'Email'); |
| | | // AWSToSobjectNonEncryptedMap.put('medicalStaffFullName', 'MedicalStaff_Full_name__c'); |
| | | // AWSToSobjectNonEncryptedMap.put('mobilePhone', 'MobilePhone'); |
| | | // AWSToSobjectNonEncryptedMap.put('title', 'Title'); |
| | | // AWSToSobjectNonEncryptedMap.put('olyAssistantType', 'OLY_Assistant_Type__c'); |
| | | // AWSToSobjectNonEncryptedMap.put('jobCategoryPicklist', 'Job_Category_picklist__c'); |
| | | // AWSToSobjectNonEncryptedMap.put('type', 'Type__c'); |
| | | // AWSToSobjectNonEncryptedMap.put('contactAddress', 'Contact_address__c'); |
| | | // AWSToSobjectNonEncryptedMap.put('contactType', 'ContactType__c'); |
| | | // AWSToSobjectNonEncryptedMap.put('doctorDivision1', 'Doctor_Division1__c'); |
| | | // AWSToSobjectNonEncryptedMap.put('uniqueNumber', 'UniqueNumber__c'); |
| | | |
| | | // AWSToSobjectEncryptedMap.put('lastNameEncrypt', 'LastName_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('phoneEncrypt', 'Phone_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('emailEncrypt', 'Email_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('medicalStaffFullNameEncrypt', 'MedicalStaff_Full_name_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('mobilePhoneEncrypt', 'MobilePhone_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('titleEncrypt', 'Title_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('olyAssistantTypeEncrypt', 'OLY_Assistant_Type_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('jobCategoryPicklistEncrypt', 'Job_Category_picklist_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('typeEncrypt', 'Type_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('contactAddressEncrypt', 'Contact_address_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('contactTypeEncrypt', 'ContactType_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('doctorDivision1Encrypt', 'Doctor_Division1_Encrypted__c'); |
| | | // AWSToSobjectEncryptedMap.put('uniqueNumberEncrypt', 'UniqueNumber_Encrypted__c'); |
| | | } |
| | | |
| | | PageReference RedirectStandardPage(){ |
| | | Map<string,string> mso = ApexPages.currentPage().getParameters(); |
| | | system.debug(mso); |
| | | mso.remove('sfdc.override'); |
| | | PageReference pg = new PageReference('/003/e'); |
| | | mso.putAll(mso); |
| | | pg.getParameters().put('nooverride','1'); |
| | | pg.setRedirect(true); |
| | | return pg; |
| | | } |
| | | |
| | | public PageReference PageLoad(){ |
| | | system.debug('rtTypeId='+rtTypeId); |
| | | string s = null; |
| | | |
| | | if(!string.isBlank(rtTypeId)){ |
| | | s = Schema.SObjectType.Contact.getRecordTypeInfosById().get(rtTypeId).getDeveloperName(); |
| | | if(s == 'Agency' || s == 'Internal_staff'){ |
| | | return RedirectStandardPage(); |
| | | } |
| | | } |
| | | string accid = ApexPages.currentPage().getParameters().get('accid'); |
| | | if(!string.isBlank(accid)){ |
| | | List<Account> accs = [select RecordType.DeveloperName from account where id = :accid]; |
| | | if(accs.size()>0){ |
| | | s = accs[0].RecordType.DeveloperName; |
| | | if(s == 'Office' || s == 'AgencyContact' || s == 'Agency'){ |
| | | return RedirectStandardPage(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @RemoteAction |
| | | global static Response saveContact(String leadJson,String transId,Boolean isNew) { |
| | |
| | | public String leadId{set;get;}//For Lead Lookup |
| | | public String staticResourceContact {get; set;} |
| | | public String staticResourceLead {get; set;} |
| | | public String urlCheckContactAWSid {get; set;} |
| | | public NewAndEditInquiryFormController(ApexPages.StandardController controller) { |
| | | List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Inquiry_form__c').getDescribe().fields.getMap().keyset()); |
| | | // Add fields to controller. This is to avoid the SOQL error in visualforce page |
| | |
| | | staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); |
| | | //Lead信息(搜索查询query url用) |
| | | staticResourceLead = JSON.serialize(PIHelper.getPIIntegrationInfo('Lead')); |
| | | |
| | | checkUrl('CF00N1000000962n8_lkid','Contact'); |
| | | } |
| | | |
| | | |
| | | @RemoteAction |
| | | global static Response saveInquiryForm(String leadJson,String transId,Boolean isNew) { |
| | | return save(new Inquiry_form__c(),leadJson,transId,isNew); |
| | | } |
| | | |
| | | private void checkUrl(String urlStr, String sobjType){ |
| | | Map<String, String> urlFieldMap = new Map<String, String>(); |
| | | urlFieldMap = ApexPages.currentPage().getParameters(); |
| | | if (urlFieldMap.containsKey(urlStr)) { |
| | | String sobjId = urlFieldMap.get(urlStr); |
| | | String soql = 'select id,AWS_Data_Id__c from ' + sobjType; |
| | | soql += ' where id=\'' + sobjId + '\''; |
| | | Sobject sobj = Database.query(soql); |
| | | |
| | | Map<String, String> m = new Map<String, String>(); |
| | | m.put((String)sobjId, (String)sobj.get('AWS_Data_Id__c')); |
| | | |
| | | LookUpOverrideFieldsMapJson = JSON.serialize(m); |
| | | } |
| | | } |
| | | } |
| | |
| | | public Boolean isNewMode{set;get;} |
| | | public String rtTypeId {get; set;} |
| | | public String AWSDataId{set;get;} |
| | | public String AWSDataIdInquiryForm{set;get;} |
| | | public String contactId{set;get;}//For Lookup field |
| | | public List<String> encryptedAPIList{set;get;} |
| | | public String staticResource {get; set;} |
| | | public String staticResourceContact {get; set;} |
| | | public String staticResourceInquiryForm{get; set;} |
| | | public String requiredFieldAPIListStr {get; set;} |
| | | public String fieldAPIToLabelMapStr {get; set;} |
| | | public String Input_Required_Field_Msg{set;get;} |
| | |
| | | public String sobjectPrefix{set;get;} |
| | | public String sobjecttypeForFrontEnd{set;get;} |
| | | public String contactsInfo {set;get;}//key sfid;value awsid |
| | | public Inquiry_form__c ifc{get; private set;} |
| | | public String contactDataId{get; set;} |
| | | public String layoutSectionsStr {get; set;} |
| | | public String isQueryContact{get; set;} |
| | | public NewAndEditLeadController(ApexPages.StandardController controller) { |
| | | isQueryContact = '0'; |
| | | isNewMode = true; |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | | PIPL_Name_Label = Label.PIPL_Name_Label; |
| | |
| | | List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Lead').getDescribe().fields.getMap().keyset()); |
| | | // Add fields to controller. This is to avoid the SOQL error in visualforce page |
| | | controller.addFields(fieldList); |
| | | SObject obj = controller.getRecord(); |
| | | if(obj.Id != null){ |
| | | SObject obj = controller.getRecord(); |
| | | |
| | | if(ApexPages.currentPage().getParameters().get('CF00N1000000962np_lkid') != null){ |
| | | System.debug('CF00N1000000962np_lkid'); |
| | | //产品咨询单过来的 |
| | | String InquiryFormId = ApexPages.currentPage().getParameters().get('CF00N1000000962np_lkid'); |
| | | 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 from Inquiry_form__c where id = :InquiryFormId]; |
| | | Contact c = [select AWS_Data_Id__c from Contact where id = :ifc.Contact_Id__c]; |
| | | contactDataId = c.AWS_Data_Id__c; |
| | | AWSDataIdInquiryForm = ifc.AWS_Data_Id__c; |
| | | System.debug('ifc = ' + ifc); |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | obj.put('OwnerId',UserInfo.getUserId()); |
| | | }else if(obj.Id != null){ |
| | | //更新 |
| | | isNewMode = false; |
| | | Lead leadData = [select Id,RecordTypeId,AWS_Data_Id__c,Contact_Name__r.Id,Contact_Name__r.AWS_Data_Id__c from Lead where id =: obj.Id]; |
| | |
| | | sfIdToAWSIdMap.put(String.valueof(leadData.Contact_Name__r.Id).subString(0,15),leadData.Contact_Name__r.AWS_Data_Id__c); |
| | | } |
| | | contactsInfo = JSON.serialize(sfIdToAWSIdMap); |
| | | }else if(ApexPages.currentPage().getParameters().get('CF00N10000006ps6f_lkid') != null){ |
| | | //联系人过来的点击新建意向 |
| | | isQueryContact = '1'; |
| | | String contactId = ApexPages.currentPage().getParameters().get('CF00N10000006ps6f_lkid'); |
| | | Lead leadData = [select Id,RecordTypeId,AWS_Data_Id__c,Contact_Name__r.Id,Contact_Name__r.AWS_Data_Id__c from Lead where id =:contactId]; |
| | | Map<String,String> sfIdToAWSIdMap = new Map<String,String>(); |
| | | if(leadData.Contact_Name__r.Id != null){ |
| | | sfIdToAWSIdMap.put(String.valueof(leadData.Contact_Name__r.Id).subString(0,15),leadData.Contact_Name__r.AWS_Data_Id__c); |
| | | } |
| | | contactsInfo = JSON.serialize(sfIdToAWSIdMap); |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | obj.put('OwnerId',UserInfo.getUserId()); |
| | | }else{ |
| | | //新建 |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | |
| | | PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo('Lead'); |
| | | staticResource = JSON.serialize(piIntegration); |
| | | staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); |
| | | staticResourceInquiryForm = JSON.serialize(PIHelper.getPIIntegrationInfo('Inquiry_form__c')); |
| | | encryptedAPIList = piIntegration.PIFields; |
| | | sobjectPrefix = piIntegration.sobjectPrefix; |
| | | layoutSectionsStr = JSON.serialize(layoutSections); |
| | | } |
| | | |
| | | global class Response{ |
| | |
| | | global with sharing class NewAndEditQISController extends NewAndEditBaseController{ |
| | | public String Input_Required_Field_Msg{set;get;} |
| | | public NewAndEditQISController(ApexPages.StandardController controller) { |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | | List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('QIS_Report__c').getDescribe().fields.getMap().keyset()); |
| | | controller.addFields(fieldList); |
| | | Init(controller.getRecord()); |
| | |
| | | public String staticResourceContact {get; set;} |
| | | public String requiredFieldAPIListStr {get; set;} |
| | | public String fieldAPIToLabelMapStr {get; set;} |
| | | public String requiredErrorMsg{set;get;} |
| | | public String Input_Required_Field_Msg{set;get;} |
| | | public String contactsInfo {set;get;} |
| | | public String PIPL_Input_Account_Error_Msg{set;get;} |
| | | public String SaveAndNewButtonUrl{get;private set;} |
| | | public String sobjectPrefix{get;private set;} |
| | | public String sobjecttypeForFrontEnd{set;get;} |
| | | public String sobjectId{set;get;} |
| | | public String layoutSectionsStr {get; set;} |
| | | public NewAndEditReportController(ApexPages.StandardController controller) { |
| | | sobjectId = [SELECT CustomObjectId,CustomObjectName FROM CustomObjectUserLicenseMetrics where CustomObjectName ='Report' limit 1].CustomObjectId; |
| | | isNewMode = true; |
| | | requiredErrorMsg = Label.Input_Required_Field_Msg; |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | | PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg; |
| | | sobjecttypeForFrontEnd = sobjectTypeValue; |
| | | //获取所有字段 |
| | |
| | | encryptedAPIList = piIntegration.PIFields; |
| | | staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); |
| | | sobjectPrefix = piIntegration.sobjectPrefix; |
| | | layoutSectionsStr = JSON.serialize(layoutSections); |
| | | } |
| | | |
| | | global class Response{ |
| | |
| | | System.debug('自定义格式转换开始'); |
| | | //自定义格式转换 |
| | | for (String fieldAPI: fieldValueMap.keySet()) { |
| | | System.debug('field API'+fieldAPI); |
| | | Schema.DisplayType fielddataType = fieldAPIToTypeMap.get(fieldAPI).getDescribe().getType(); |
| | | String fieldValue = String.valueOf(fieldValueMap.get(fieldAPI)); |
| | | if(String.isBlank(fieldValue)){ |
| | | continue; |
| | | } |
| | | if(String.valueOf(fielddataType)=='DATE'){ |
| | | System.debug('DATE fieldAPI = '+fieldAPI+' filedData = '+String.valueOf(fieldValueMap.get(fieldAPI))); |
| | | reportInfo.put(fieldAPI, Date.valueOf(String.valueOf(fieldValueMap.get(fieldAPI)).replace('/', '-'))); |
| | | }else if(String.valueOf(fielddataType)=='DATETIME'){ |
| | | String dt = String.valueOf(fieldValueMap.get(fieldAPI)); |
| | | if(String.isNotBlank(dt)&&dt.contains('T')){ |
| | | dt = dt.replace('T',' '); |
| | | reportInfo.put(fieldAPI, Datetime.valueOfGmt(dt)); |
| | | } |
| | | }else if(String.isNotBlank(dt)) { |
| | | reportInfo.put(fieldAPI, Datetime.valueOf(dt)); |
| | | } |
| | | }else if(String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){ |
| | | reportInfo.put(fieldAPI, Decimal.valueOf(String.valueOf(fieldValueMap.get(fieldAPI)))); |
| | | } else if(String.valueof(fielddataType)=='BOOLEAN'){ |
| | |
| | | } |
| | | List<String> awsDataIds = (List<String>) JSON.deserialize(awsContactIds, List<String>.class); |
| | | Map<String,Contact> awsIdToContactMapTemp = new Map<String,Contact>(); |
| | | List<Contact> conListTemp = new List<Contact>([select Id,AWS_Data_Id__c from Contact where AWS_Data_Id__c in:awsDataIds]); |
| | | List<Contact> conListTemp = new List<Contact>([select Id,AWS_Data_Id__c,Account.Name from Contact where AWS_Data_Id__c in:awsDataIds]); |
| | | for(Contact con:conListTemp){ |
| | | awsIdToContactMapTemp.put(con.AWS_Data_Id__c,con); |
| | | } |
| | |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> |
| | | <style> |
| | | .decrypt{ |
| | | position: relative; |
| | | text-align: left; |
| | | display: block; |
| | | margin-left: 5px; |
| | | margin-top: -5px; |
| | | .decrypt{position: absolute; |
| | | top: 0; |
| | | left: 100%; |
| | | display: none; |
| | | text-align: left; |
| | | padding-left: 5px; |
| | | } |
| | | a:hover .decrypt{display: block;width: 150px} |
| | | </style> |
| | | <script type="text/javascript"> |
| | | |
| | |
| | | var now_edit_id = ''; |
| | | var aws_result = {}; |
| | | searchContactAll(); |
| | | function Foo(){ |
| | | j$('[aws-id]').each(function(i,e){ |
| | | let awsDataId = j$(e).attr('aws-id'); |
| | | let piInformation = 'Name:'+contact[awsDataId].lastName +'<br/>' +'Phone:'+ (contact[awsDataId].phone ? contact[awsDataId].phone :''); |
| | | j$(e).find('.decrypt').html(piInformation); |
| | | }); |
| | | } |
| | | |
| | | function preparePayloadForSearchContact(){ |
| | | let searchPayload = new Object(); |
| | |
| | | contact[contacts[i].dataId] = temp; |
| | | } |
| | | console.log(JSON.stringify(contact)); |
| | | Foo(); |
| | | }; |
| | | AWSService.search(staticResources.searchUrl,data,searchCallBack,staticResources.token); |
| | | } |
| | |
| | | // createDiv.style.position = "absolute"; |
| | | // parentNode.appendChild(createDiv); |
| | | console.log('dataId:'+dataId+'awsDataId Value:'+awsDataId); |
| | | let piInformation = 'Name:'+contact[awsDataId].lastName +'\n' +'Phone:'+contact[awsDataId].phone |
| | | let piInformation = 'Name:'+contact[awsDataId].lastName +'\n' +'Phone:'+ (contact[awsDataId].phone ? contact[awsDataId].phone :''); |
| | | document.getElementById(dataId+'_'+awsDataId).innerText = piInformation; |
| | | } |
| | | |
| | |
| | | <table class="edittable" border="0" style="border-collapse: collapse;width:580px;table-layout:fixed;"> |
| | | <colgroup> |
| | | <col width="50px" /> |
| | | <col width="100px" /> |
| | | <col width="200px" /> |
| | | <col width="380px" /> |
| | | <col width="50px" /> |
| | | </colgroup> |
| | |
| | | <!-- <td><a href="#" onclick="setContact('{!lineinfo.lineNo}');" id="943114607025717249" onmouseover="showPIDiv('943114607025717249')" onmouseout="hidePIDiv('943114607025717249')">{!lineinfo.con.Name}</a></td> --> |
| | | <!-- 2022/02/15 张华建 解密信息 start --> |
| | | <td> |
| | | <a href="#" onclick="setContact('{!lineinfo.lineNo}','{!lineinfo.con.AWS_Data_Id__c}');" id="{!lineinfo.con.AWS_Data_Id__c}" onmouseover="showPIDiv('{!lineinfo.con.id}','{!lineinfo.con.AWS_Data_Id__c}')" onmouseout="hidePIDiv('{!lineinfo.con.id}','{!lineinfo.con.AWS_Data_Id__c}')"> |
| | | {!lineinfo.con.Name} |
| | | <a href="/{!lineinfo.con.Id}" onclick="setContact('{!lineinfo.lineNo}','{!lineinfo.con.AWS_Data_Id__c}');" aws-id="{!lineinfo.con.AWS_Data_Id__c}" style="position:relative"> |
| | | <span class="encrypt">{!lineinfo.con.Name}</span> |
| | | <span class="decrypt"></span> |
| | | </a> |
| | | <span id="{!lineinfo.con.id}_{!lineinfo.con.AWS_Data_Id__c}" class="decrypt"></span> |
| | | |
| | | </td> |
| | | <!-- 2022/02/15 张华建 解密信息 end --> |
| | | <td>{!lineinfo.con.AccountName__c}</td> |
| | |
| | | document.getElementById("allPage:Shippmentadress").innerHTML = data.object.directShippmentAddress; |
| | | //document.getElementById("Caller_phone__c").innerHTML = data.object.callerPhone; |
| | | |
| | | setTimeout(() => { |
| | | setTimeout(function() { |
| | | jsPdfDownload(); |
| | | }, 1500); |
| | | }, staticResources.token); |
| | |
| | | <!-- |
| | | @description : |
| | | @author : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | @group : |
| | | @last modified on : 03-17-2022 |
| | | @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | --> |
| | | <apex:page standardController="Address__c" extensions="NewAndEditAddressController" id="page"> |
| | | <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | |
| | | // error_msg += ';邮件格式错误'; |
| | | // } |
| | | let phone = document.querySelector(textPhone); |
| | | |
| | | if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){ |
| | | error_msg += ';电话号码错误'; |
| | | if(phone ){ |
| | | if(phone.value){ |
| | | if(!/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){ |
| | | error_msg += ';电话号码错误'; |
| | | } |
| | | }else{ |
| | | if(phone.previousSibling && phone.previousSibling.className.indexOf('requiredBlock')>-1){ |
| | | error_msg += ';电话号码错误'; |
| | | } |
| | | } |
| | | } |
| | | |
| | | for(let e of document.getElementsByTagName('select')){ |
| | | for(let op of e.options){ |
| | | let es = document.getElementsByTagName('select') |
| | | for(let ei in es){ |
| | | let e = es[ei]; |
| | | for(let opi in e.options){ |
| | | let op = e.options[opi]; |
| | | if(!op)continue; |
| | | if(op.value == "*****" && op.selected){ |
| | | error_msg += ';下拉框不能主动选择密文选项'; |
| | | } |
| | |
| | | function replaceSearchContactLookup() { |
| | | let lookUpNode = htmlToElement(contactHtmlString); |
| | | console.log(lookUpNode); |
| | | if (!{!isNewMode}) { |
| | | let eleContactValue = document.querySelector("[data-id='Contacts__c']").parentNode.parentNode.children[1].value; |
| | | if (!{!isNewMode} || (eleContactValue != '000000000000000')) { |
| | | //1. Query Contact from AWS by AWSDataId |
| | | queryContactName() |
| | | // document.querySelector("[data-id='Contacts__c']").value = '王奎'; |
| | |
| | | </apex:repeat> |
| | | <script> |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField); |
| | | } |
| | | } |
| | | } |
| | | //1. Set Last Name label |
| | | //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '姓名'; |
| | | //2. Query AWS Data by dataId |
| | |
| | | replaceSearchContactLookup(); |
| | | //3. Set Readonly Attribute |
| | | // document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton"); |
| | | jQuery(".lookupInput").each(function(i,e){ |
| | | let je =jQuery(e).find('input'); |
| | | je.attr("readonly",""); |
| | | je.css("background","unset"); |
| | | |
| | | let dataid = je.attr('data-id'); |
| | | if(['OwnerId'].indexOf(dataid) > -1) return; |
| | | jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); |
| | | }) |
| | | |
| | | jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){ |
| | | this.className = "closeIconOn"; |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){ |
| | | this.className = "closeIcon" |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("click","img[generate]",function(e){ |
| | | let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id"); |
| | | let input = document.getElementById(id); |
| | | if(input){ |
| | | input.value = ''; |
| | | let hidden = document.getElementById(id+'_lkid'); |
| | | if(hidden){ |
| | | hidden.value = ''; |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | </script> |
| | | <div class="pbBottomButtons"> |
| | |
| | | let arr = data.object[f].split(';'); |
| | | |
| | | // 给隐藏的select赋值 |
| | | for(let op of ele.options){ |
| | | for(let opi in ele.options){ |
| | | let op = ele.options[opi] |
| | | op.selected = arr.indexOf(op.value)>-1; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | var GetEleApiName = function(ele){ |
| | | for(let c of ele.classList){ |
| | | for(let ci in ele.classList){ |
| | | let c = ele.classList[ci] |
| | | if(c.indexOf(config.ApiPrefix+'_')>-1){ |
| | | return c.replace(config.ApiPrefix+'_',''); |
| | | } |
| | |
| | | error_msg += ';电话号码错误'; |
| | | } |
| | | |
| | | for(let e of document.getElementsByTagName('select')){ |
| | | for(let op of e.options){ |
| | | for(let ei in document.getElementsByTagName('select')){ |
| | | let e = e.options[ei]; |
| | | for(let opi in e.options){ |
| | | let op = e.options[opi]; |
| | | if(op.value == "*****" && op.selected){ |
| | | error_msg += ';下拉框不能主动选择密文选项'; |
| | | } |
| | |
| | | v = ele.value; |
| | | } |
| | | |
| | | if(v && v != "000000000000000"){ |
| | | // if(v && v != "000000000000000"){ |
| | | result[field_api_name] = v; |
| | | } |
| | | // } |
| | | |
| | | } |
| | | } else if (ele.type == 'checkbox') { |
| | |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Contact__c']").id + '_lkid').value; |
| | | let contactsInfo = JSON.parse('{!LookUpOverrideFieldsMapJson}'); |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | fetch(url, { |
| | | method: 'GET', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | |
| | | AWSService.query(staticResourcesContact.queryUrl,dataId,function(result){ |
| | | if(result.object){ |
| | | document.querySelector("[data-id='Contact__c']").value = result.object.lastName; |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | document.querySelector("[data-id='Contact__c']").value = result.object.lastName; |
| | | }) |
| | | |
| | | },staticResources.token); |
| | | } |
| | | |
| | | </script> |
| | |
| | | </apex:repeat> |
| | | <script> |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | |
| | | //Replace Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | |
| | | //1. Set Last Name label |
| | | //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '姓名'; |
| | | //2. Query AWS Data by dataId |
| | |
| | | if (!{!isNewMode}) { |
| | | blockme(); |
| | | QuerySobjectFromAWS(); |
| | | }else{ |
| | | let ot = jQuery('input[data-id="OwnerId"]'); |
| | | let oi = document.getElementById(ot.attr("id")+'_lkid'); |
| | | ot.val('{!CurrentUserName}'); |
| | | ot.attr("readonly",""); |
| | | ot.css("background","unset"); |
| | | ot.css("border","0"); |
| | | ot.css("outline","0"); |
| | | |
| | | if(oi){ |
| | | oi.value = '{!CurrentUserId}' |
| | | } |
| | | } |
| | | jQuery('a[data-id="OwnerId"]').remove(); |
| | | |
| | | jQuery(".lookupInput").each(function(i,e){ |
| | | let je =jQuery(e).find('input'); |
| | | je.attr("readonly",""); |
| | | je.css("background","unset"); |
| | | |
| | | let dataid = je.attr('data-id'); |
| | | if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return; |
| | | jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); |
| | | }) |
| | | |
| | | jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){ |
| | | this.className = "closeIconOn"; |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){ |
| | | this.className = "closeIcon" |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("click","img[generate]",function(e){ |
| | | let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id"); |
| | | let input = document.getElementById(id); |
| | | if(input){ |
| | | input.value = ''; |
| | | let hidden = document.getElementById(id+'_lkid'); |
| | | if(hidden){ |
| | | hidden.value = ''; |
| | | } |
| | | } |
| | | }); |
| | | |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //Replace Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | |
| | | }); |
| | | </script> |
| | | <div class="pbBottomButtons"> |
| | |
| | | let arr = data.object[f].split(';'); |
| | | |
| | | // 给隐藏的select赋值 |
| | | for(let op of ele.options){ |
| | | for(let opi in ele.options){ |
| | | let op = ele.options[opi]; |
| | | op.selected = arr.indexOf(op.value)>-1; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | var GetEleApiName = function(ele){ |
| | | for(let c of ele.classList){ |
| | | for(let ci in ele.classList){ |
| | | let c = ele.classList[ci]; |
| | | if(c.indexOf(config.ApiPrefix+'_')>-1){ |
| | | return c.replace(config.ApiPrefix+'_',''); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | for(let e of document.getElementsByTagName('select')){ |
| | | for(let op of e.options){ |
| | | for(let ei in document.getElementsByTagName('select')){ |
| | | let e = document.getElementsByTagName('select')[ei]; |
| | | for(let opi in e.options){ |
| | | let op = e.options[opi]; |
| | | if(op.value == "*****" && op.selected){ |
| | | error_msg += ';下拉框不能主动选择密文选项'; |
| | | } |
| | |
| | | v = ele.value; |
| | | } |
| | | |
| | | if(v && v != "000000000000000"){ |
| | | //if(v && v != "000000000000000"){ |
| | | result[field_api_name] = v; |
| | | } |
| | | //} |
| | | |
| | | } |
| | | } else if (ele.type == 'checkbox') { |
| | |
| | | // Check Required Field |
| | | let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson); |
| | | if (checkRequiredFieldMsgResult) { |
| | | alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult); |
| | | alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult); |
| | | return |
| | | } |
| | | // //3. Prepare the payload for New PI API To AWS - To Do |
| | |
| | | errorMsgNode.className = ''; |
| | | } |
| | | |
| | | var newSearchContactWindow = null; |
| | | var newSearchContactWindow = null; |
| | | var contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'page:form:contactId\')" alt="Reference Document Number Lookup" class="lookupIcon" title="Reference Document Number Lookup (New Window)"/>'; |
| | | function htmlToElement(html) { |
| | | var template = document.createElement('template'); |
| | |
| | | function replaceSearchContactLookup() { |
| | | let lookUpNode = htmlToElement(contactHtmlString); |
| | | console.log(lookUpNode); |
| | | if (!{!isNewMode}) { |
| | | let eleContactValue = document.querySelector("[data-id='Contact_Name__c']").parentNode.parentNode.children[0].value; |
| | | if (!{!isNewMode} || (eleContactValue != '000000000000000')) { |
| | | //1. Query Contact from AWS by AWSDataId |
| | | queryContactName() |
| | | } |
| | |
| | | function queryContactName() { |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Contact_Name__c']").id + '_lkid').value; |
| | | let contactsInfo = JSON.parse('{!LookUpOverrideFieldsMapJson}'); |
| | | let dataId = contactsInfo[sfId]; |
| | | // let queryContactBack = function(data){ |
| | | // //To Do later |
| | | // console.log('ContactData = ' + data.object); |
| | | |
| | | // document.querySelector("[data-id='Contact_Name__c']").value = data.object.lastName; |
| | | // if (contactsInfo == null){ |
| | | // contactsInfo = JSON.parse('{!urlCheckContactAWSid}'); |
| | | // } |
| | | // AWSService.query(staticResourcesContact.queryUrl, dataId, queryContactBack, staticResources.token); |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | fetch(url, { |
| | | method: 'GET', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | document.querySelector("[data-id='Contact_Name__c']").value = result.object.lastName; |
| | | }) |
| | | let dataId = contactsInfo[sfId]; |
| | | // let dataId = JSON.parse('{!urlCheckContactAWSid}') |
| | | // if (dataId == '') { |
| | | // let contactsInfo = JSON.parse('{!LookUpOverrideFieldsMapJson}'); |
| | | // dataId = contactsInfo[sfId]; |
| | | // } |
| | | let queryContactBack = function(data){ |
| | | //To Do later |
| | | console.log('ContactData = ' + data.object); |
| | | |
| | | document.querySelector("[data-id='Contact_Name__c']").value = data.object.lastName; |
| | | } |
| | | AWSService.query(staticResourcesContact.queryUrl, dataId, queryContactBack, staticResources.token); |
| | | // let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | // fetch(url, { |
| | | // method: 'GET', |
| | | // headers: { |
| | | // 'Content-Type': 'application/json', |
| | | // 'pi-token': staticResources.token |
| | | // } |
| | | // }).then((data) => { |
| | | // return data.json(); |
| | | // }).then((result) => { |
| | | // document.querySelector("[data-id='Contact_Name__c']").value = result.object.lastName; |
| | | // }) |
| | | } |
| | | |
| | | //For Lead Search |
| | |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Lead_link__c']").id + '_lkid').value; |
| | | let leadsInfo = JSON.parse('{!LookUpOverrideFieldsMapJson}'); |
| | | let dataId = leadsInfo[sfId]; |
| | | // let queryLeadBack = function(data){ |
| | | // //To Do later |
| | | // console.log('ContactData = ' + data.object); |
| | | let queryLeadBack = function(data){ |
| | | //To Do later |
| | | console.log('ContactData = ' + data.object); |
| | | |
| | | // document.querySelector("[data-id='Lead_link__c']").value = data.object.lastName; |
| | | // } |
| | | // AWSService.query(staticResourcesLead.queryUrl, dataId, queryLeadBack, staticResources.token); |
| | | let url = staticResourcesLead.queryUrl + '?dataId=' + dataId; |
| | | fetch(url, { |
| | | method: 'GET', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | document.querySelector("[data-id='Lead_link__c']").value = result.object.lastName; |
| | | }) |
| | | document.querySelector("[data-id='Lead_link__c']").value = data.object.lastName; |
| | | } |
| | | AWSService.query(staticResourcesLead.queryUrl, dataId, queryLeadBack, staticResources.token); |
| | | // let url = staticResourcesLead.queryUrl + '?dataId=' + dataId; |
| | | // fetch(url, { |
| | | // method: 'GET', |
| | | // headers: { |
| | | // 'Content-Type': 'application/json', |
| | | // 'pi-token': staticResources.token |
| | | // } |
| | | // }).then((data) => { |
| | | // return data.json(); |
| | | // }).then((result) => { |
| | | // document.querySelector("[data-id='Lead_link__c']").value = result.object.lastName; |
| | | // }) |
| | | } |
| | | |
| | | </script> |
| | |
| | | </apex:repeat> |
| | | <script> |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField); |
| | | } |
| | | } |
| | | } |
| | | //1. Set Last Name label |
| | | //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '姓名'; |
| | | //2. Query AWS Data by dataId |
| | |
| | | blockme(); |
| | | QuerySobjectFromAWS(); |
| | | unblockUI(); |
| | | } |
| | | }else{ |
| | | let ot = jQuery('input[data-id="OwnerId"]'); |
| | | let oi = document.getElementById(ot.attr("id")+'_lkid'); |
| | | ot.val('{!CurrentUserName}'); |
| | | ot.attr("readonly",""); |
| | | ot.css("background","unset"); |
| | | ot.css("border","0"); |
| | | ot.css( "outline","0"); |
| | | jQuery('a[data-id="OwnerId"]').remove(); |
| | | if(oi){ |
| | | oi.value = '{!CurrentUserId}' |
| | | } |
| | | } |
| | | //Replace Contact Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | //Replace Lead Vlookup Field |
| | | replaceSearchLeadLookup(); |
| | | document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton"); |
| | | document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton"); |
| | | // document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton"); |
| | | |
| | | jQuery('a[data-id="OwnerId"]').remove(); |
| | | |
| | | jQuery(".lookupInput").each(function(i,e){ |
| | | let je =jQuery(e).find('input'); |
| | | je.attr("readonly",""); |
| | | je.css("background","unset"); |
| | | |
| | | let dataid = je.attr('data-id'); |
| | | if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return; |
| | | jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); |
| | | }) |
| | | |
| | | jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){ |
| | | this.className = "closeIconOn"; |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){ |
| | | this.className = "closeIcon" |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("click","img[generate]",function(e){ |
| | | let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id"); |
| | | let input = document.getElementById(id); |
| | | if(input){ |
| | | input.value = ''; |
| | | let hidden = document.getElementById(id+'_lkid'); |
| | | if(hidden){ |
| | | hidden.value = ''; |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | </script> |
| | | <div class="pbBottomButtons"> |
| | |
| | | AWSService.sfSessionId = '{!GETSESSIONID()}'; |
| | | var staticResources = JSON.parse('{!staticResource}'); |
| | | var staticResourcesContact = JSON.parse('{!staticResourceContact}'); |
| | | var staticResourceInquiryForm = JSON.parse('{!staticResourceInquiryForm}'); |
| | | var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}'); |
| | | var fieldAPIToLabelMap = JSON.parse('{!fieldAPIToLabelMapStr}'); |
| | | var redirectMode = 'Save';//1. Save 2. SaveAndNew |
| | | var requiredAPIToChangedLabelMap = new Map(); |
| | | requiredAPIToChangedLabelMap.set('LastName', '{!PIPL_Name_Label}'); |
| | | console.log('{!contactsInfo}'); |
| | | var VLookUpFields = new Set(['Hospital_Name__c', 'Department_Class__c', 'Contact_Name__c', 'Campaign__c']); |
| | | var VLookUpFields = new Set(['Hospital_Name__c', 'Department_Class__c', 'Contact_Name__c', 'Campaign__c', 'Lead_Inquiry_form__c', 'Opp_Name_Search__c']); |
| | | function ProcessPI(leadJson, payloadForNewPI) { |
| | | blockme(); |
| | | if ({!isNewMode}) { |
| | |
| | | function QueryLeadFromAWS() { |
| | | AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token); |
| | | } |
| | | function QueryLeadFromAWSIFS() { |
| | | //staticResourceInquiryForm |
| | | AWSService.query(staticResourceInquiryForm.queryUrl, '{!AWSDataIdInquiryForm}', queryBack, staticResourceInquiryForm.token); |
| | | } |
| | | var queryBack = function queryBack(data) { |
| | | console.log('data = ' + data); |
| | | document.querySelector("[data-id='LastName']").value = data.object.lastName.replace(/"/g,""); |
| | | document.querySelector("[data-id='Phone']").value = data.object.phone.replace(/"/g,""); |
| | | document.querySelector("[data-id='Email']").value = data.object.email.replace(/"/g,""); |
| | | document.querySelector("[data-id='LastName']").value = data.object.lastName == null ? '' : data.object.lastName; |
| | | document.querySelector("[data-id='Phone']").value = data.object.phone == null ? '' : data.object.phone; |
| | | document.querySelector("[data-id='Email']").value = data.object.email == null ? '' : data.object.email; |
| | | unblockUI(); |
| | | }; |
| | | |
| | |
| | | return blankRequiredFields; |
| | | } |
| | | function saveLeadProcess(saveMode) { |
| | | |
| | | |
| | | disableButtonStatus(); |
| | | redirectMode = saveMode; |
| | | console.log('redirectMode' + redirectMode); |
| | |
| | | queryContactName() |
| | | //document.querySelector("[data-id='Contact_Name__c']").value = '王奎'; |
| | | } |
| | | let parentNode = document.querySelector("[data-id='Contact_Name__c']").parentNode; |
| | | document.querySelector("[data-id='Contact_Name__c']").removeAttribute("onchange"); |
| | | parentNode.replaceChild(lookUpNode, document.querySelector("[data-id='Contact_Name__c']").parentNode.children[2]); |
| | | let parentNode = document.querySelector("[data-id='Contact_Name__c']").parentNode; |
| | | document.querySelector("[data-id='Contact_Name__c']").removeAttribute("onchange"); |
| | | parentNode.replaceChild(lookUpNode, document.querySelector("[data-id='Contact_Name__c']").parentNode.children[2]); |
| | | } |
| | | |
| | | function queryContactName() { |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Contact_Name__c']").id + '_lkid').value; |
| | | let contactsInfo = JSON.parse('{!contactsInfo}'); |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | fetch(url, { |
| | | method: 'GET', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | let dataId = ''; |
| | | if ('{!contactsInfo}' != '') { |
| | | let contactsInfo = JSON.parse('{!contactsInfo}'); |
| | | dataId = contactsInfo[sfId]; |
| | | } else if ('{!contactDataId}' != '') { |
| | | dataId = '{!contactDataId}'; |
| | | } |
| | | let queryBackContactName = function queryBackContactName(result){ |
| | | document.querySelector("[data-id='Contact_Name__c']").value = result.object.lastName; |
| | | }) |
| | | }; |
| | | AWSService.query(staticResourcesContact.queryUrl, dataId, queryBackContactName, staticResourcesContact.token); |
| | | |
| | | // let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | // fetch(url, { |
| | | // method: 'GET', |
| | | // headers: { |
| | | // 'Content-Type': 'application/json', |
| | | // 'pi-token': staticResources.token |
| | | // } |
| | | // }).then((data) => { |
| | | // return data.json(); |
| | | // }).then((result) => { |
| | | // document.querySelector("[data-id='Contact_Name__c']").value = result.object.lastName; |
| | | // }) |
| | | } |
| | | </script> |
| | | <div class="bPageTitle"> |
| | |
| | | </apex:repeat> |
| | | <script> |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | |
| | | //判断是否为只读选项 |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='" + layoutField.fieldAPI + "']") != null) { |
| | | document.querySelector("[data-id='" + layoutField.fieldAPI + "']").disabled = !(layoutField.editableField); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //1. Set Last Name label |
| | | console.log('NameLabel = ' + '{!PIPL_Name_Label}') |
| | | document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[0].children[0].innerText = '{!PIPL_Name_Label}'; |
| | | //2. Query AWS Data by dataId |
| | | console.log('Mode for Lead Page:' + {!isNewMode}); |
| | | if (!{!isNewMode}) { |
| | | blockme();//for loading search by Li Jun 20220218 |
| | | QueryLeadFromAWS(); |
| | | if (!{!isNewMode}) { |
| | | blockme();//for loading search by Li Jun 20220218 |
| | | QueryLeadFromAWS(); |
| | | } |
| | | //Replace Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | //3. Set Readonly Attribute |
| | | document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton"); |
| | | |
| | | //如果是联系人过来的点击新建意向 |
| | | if('{!isQueryContact}' == '1'){ |
| | | //查找客户姓名 |
| | | queryContactName(); |
| | | } |
| | | |
| | | |
| | | //如果是产品咨询单过来的 |
| | | if ('{!ifc}' != '') { |
| | | blockme(); |
| | | //状态 |
| | | document.querySelector("[data-id='Status']").value = '跟进中' |
| | | //会议询问单 |
| | | if ('{!ifc.Id}') |
| | | document.getElementById('page:form:block:j_id34:0:j_id35:j_id36:15:j_id37_lkid').value = '{!ifc.Id}' |
| | | if ('{!ifc.Name}') |
| | | document.querySelector("[data-id='Lead_Inquiry_form__c']").value = '{!ifc.Name}' |
| | | //客户姓名 |
| | | // if('{!ifc.Contact_Name__c}') |
| | | // document.querySelector("[data-id='Contact_Name__c']").value = '{!ifc.Contact_Name__c}' |
| | | if ('{!ifc.Contact_Id__c}') |
| | | document.getElementById(document.querySelector("[data-id='Contact_Name__c']").id + '_lkid').value = '{!ifc.Contact_Id__c}' |
| | | //医院 |
| | | if ('{!ifc.Hospital_Name__c}') |
| | | document.getElementById('page:form:block:j_id34:0:j_id35:j_id36:2:j_id37_lkold').value = '{!ifc.Hospital_Name__c}' |
| | | if ('{!ifc.Hospital_ID__c}') |
| | | document.getElementById('page:form:block:j_id34:0:j_id35:j_id36:2:j_id37_lkid').value = '{!ifc.Hospital_ID__c}' |
| | | //战略科室分类 |
| | | if ('{!ifc.Department_Class__c}') |
| | | document.getElementById('page:form:block:j_id34:0:j_id35:j_id36:4:j_id37_lkold').value = '{!ifc.Department_Class__c}' |
| | | if ('{!ifc.Department_ID__c}') |
| | | document.getElementById('page:form:block:j_id34:0:j_id35:j_id36:4:j_id37_lkid').value = '{!ifc.Department_ID__c}' |
| | | //已有询价名称 |
| | | if ('{!ifc.Opp_Name_Search__c}') |
| | | document.getElementById('page:form:block:j_id34:0:j_id35:j_id36:12:j_id37_lkold').value = '{!ifc.Opp_Name_Search__c}' |
| | | if ('{!ifc.Opp_Name_Search_ID__c}') |
| | | document.getElementById('page:form:block:j_id34:0:j_id35:j_id36:12:j_id37_lkid').value = '{!ifc.Opp_Name_Search_ID__c}' |
| | | //主要学会 |
| | | if ('{!ifc.Campaign__c}') |
| | | document.getElementById('page:form:block:j_id34:1:j_id35:j_id36:3:j_id37_lkold').value = '{!ifc.Campaign__c}' |
| | | if ('{!ifc.Campaign_ID__c}') |
| | | document.getElementById('page:form:block:j_id34:1:j_id35:j_id36:3:j_id37_lkid').value = '{!ifc.Campaign_ID__c}' |
| | | //取消原因 |
| | | if ('{!ifc.Cancel_Reason__c}') |
| | | document.querySelector("[data-id='Cancel_Reason__c']").value = '{!ifc.Cancel_Reason__c}' |
| | | //电话 |
| | | if ('{!ifc.Phone__c}') |
| | | document.querySelector("[data-id='Phone']").value = '{!ifc.Phone__c}' |
| | | //邮件 |
| | | if ('{!ifc.Email__c}') |
| | | document.querySelector("[data-id='Email']").value = '{!ifc.Email__c}' |
| | | //姓名 |
| | | if ('{!ifc.Last_Name__c}') |
| | | document.querySelector("[data-id='LastName']").value = '{!ifc.Last_Name__c}' |
| | | //咨询单来源 |
| | | if ('{!ifc.LeadSource__c}' && document.querySelector("[data-id='LeadSource__c']")) |
| | | document.querySelector("[data-id='LeadSource__c']").value = '{!ifc.LeadSource__c}' |
| | | //意向区分 |
| | | if ('{!ifc.Opportunity_Division__c}') |
| | | document.querySelector("[data-id='Opportunity_Division__c']").value = '{!ifc.Opportunity_Division__c}' |
| | | //委托事项 |
| | | if ('{!ifc.Request1__c}') { |
| | | var Request1__c = '{!ifc.Request1__c}'; |
| | | //赋值给第二个多选框 |
| | | var array = Request1__c.split(';'); |
| | | //赋值给第二个多选框 |
| | | for (var i = 0; i < array.length; i++) { |
| | | for (var j = document.querySelector("[data-id='Request__c']").parentNode.children[1].children[0].children[1].children[0].children[0].options.length - 1; j >= 0; j--) { |
| | | if (array[i] == document.querySelector("[data-id='Request__c']").parentNode.children[1].children[0].children[1].children[0].children[0].options[j].innerHTML) { |
| | | var option = new Option(); |
| | | option.text = array[i]; |
| | | option.value = j; |
| | | document.querySelector("[data-id='Request__c']").parentNode.children[1].children[0].children[1].children[2].children[0].add(option); |
| | | } |
| | | } |
| | | } |
| | | //删除第一个多选框的重复值 |
| | | for (var i = 0; i < array.length; i++) { |
| | | for (var j = document.querySelector("[data-id='Request__c']").parentNode.children[1].children[0].children[1].children[0].children[0].options.length - 1; j >= 0; j--) { |
| | | if (array[i] == document.querySelector("[data-id='Request__c']").parentNode.children[1].children[0].children[1].children[0].children[0].options[j].innerHTML) { |
| | | document.querySelector("[data-id='Request__c']").parentNode.children[1].children[0].children[1].children[0].children[0].options[j] = null; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //Replace Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | //3. Set Readonly Attribute |
| | | document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton"); |
| | | //紧急 |
| | | if ('{!ifc.Urgent__c}') |
| | | document.querySelector("[data-id='urgent__c']").checked = '{!ifc.Urgent__c}' == 'false' ? false : true; |
| | | //查找客户姓名 |
| | | queryContactName(); |
| | | //解密 |
| | | QueryLeadFromAWSIFS(); |
| | | unblockUI(); |
| | | } |
| | | jQuery(".lookupInput").each(function (i, e) { |
| | | let je = jQuery(e).find('input'); |
| | | je.attr("readonly", ""); |
| | | je.css("background", "unset"); |
| | | |
| | | let dataid = je.attr('data-id'); |
| | | if (['Contact_Name__c'].indexOf(dataid) > -1) |
| | | jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="' + dataid + '" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); |
| | | }) |
| | | |
| | | jQuery(".lookupInput").on("mouseenter", "img[generate]", function (e) { |
| | | this.className = "closeIconOn"; |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("mouseleave", "img[generate]", function (e) { |
| | | this.className = "closeIcon" |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("click", "img[generate]", function (e) { |
| | | let id = jQuery("input[data-id='" + jQuery(this).attr("data-id") + "']").attr("id"); |
| | | let input = document.getElementById(id); |
| | | if (input) { |
| | | input.value = ''; |
| | | let hidden = document.getElementById(id + '_lkid'); |
| | | if (hidden) { |
| | | hidden.value = ''; |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | </script> |
| | | <div class="pbBottomButtons"> |
| | |
| | | let phone = document.querySelector(textPhone); |
| | | |
| | | if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){ |
| | | error_msg += ';电话号码错误'; |
| | | error_msg += ';联系电话格式错误'; |
| | | } |
| | | |
| | | for(let e of document.getElementsByTagName('select')){ |
| | |
| | | // Check Required Field |
| | | let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson); |
| | | if (checkRequiredFieldMsgResult) { |
| | | alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult); |
| | | alertErrorMessage('{!Input_Required_Field_Msg}' + checkRequiredFieldMsgResult); |
| | | return |
| | | } |
| | | // //3. Prepare the payload for New PI API To AWS - To Do |
| | |
| | | } |
| | | console.log(api_id_map); |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | //判断是否为只读选项 |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField); |
| | | } |
| | | } |
| | | } |
| | | //1. Set Last Name label |
| | | //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '姓名'; |
| | | //2. Query AWS Data by dataId |
| | |
| | | <!-- |
| | | @description : |
| | | @author : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | @group : |
| | | @last modified on : 03-17-2022 |
| | | @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | --> |
| | | <apex:page standardController="RepairSubOrder__c" extensions="NewAndEditRepairSubOrderController" id="page"> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | | <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script> |
| | |
| | | queryBack:function (data) { |
| | | console.log('data = ' + data); |
| | | if(data.object){ |
| | | for(let f in config.AWSToSobjectNonEncryptedMap){ |
| | | let ele = GetEleByClass(config.ApiPrefix + "_"+ config.AWSToSobjectNonEncryptedMap[f]); |
| | | for(let fi in config.AWSToSobjectNonEncryptedMapKeySet){ |
| | | let f = config.AWSToSobjectNonEncryptedMapKeySet[fi]; |
| | | let ele = document.getElementById(api_id_map[config.AWSToSobjectNonEncryptedMap[f]]) |
| | | if(data.object.hasOwnProperty(f) && ele){ |
| | | |
| | | // 多选特殊处理 |
| | | if(ele.type == 'select-multiple'){ |
| | | //let me = GetEleByClass(config.ApiPrefix+'_'+field_api_name); |
| | | if(ele && data.object[f]){ |
| | | let arr = data.object[f].split(';'); |
| | | |
| | | // 给隐藏的select赋值 |
| | | for(let op of ele.options){ |
| | | op.selected = arr.indexOf(op.value)>-1; |
| | | if(ele ){ |
| | | //_unselected |
| | | let v = ''; |
| | | if(data.object[f]){ |
| | | v = data.object[f]; |
| | | } |
| | | |
| | | // 利用按钮给显示的select赋值 |
| | | let arr = v.split(';'); |
| | | |
| | | for(let opi in ele.options){ |
| | | let op = ele.options[opi]; |
| | | if(!op)continue; |
| | | op.selected = arr.indexOf(op.value)>-1; |
| | | } |
| | | let ra = document.getElementById(ele.id + '_right_arrow'); |
| | | if(ra){ |
| | | ra.click(); |
| | |
| | | } |
| | | }else{ |
| | | ele.value = data.object[f]; |
| | | } |
| | | |
| | | if(ele.type.indexOf("select")>-1 && ele.value){ |
| | | jQuery(ele).change() |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | var GetEleApiName = function(ele){ |
| | | for(let c of ele.classList){ |
| | | for(let ci in ele.classList){ |
| | | let c = ele.classList[ci]; |
| | | if(c.indexOf(config.ApiPrefix+'_')>-1){ |
| | | return c.replace(config.ApiPrefix+'_',''); |
| | | } |
| | |
| | | // } |
| | | let phone = document.querySelector(textPhone); |
| | | |
| | | if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){ |
| | | error_msg += ';电话号码错误'; |
| | | if(phone ){ |
| | | if(phone.value){ |
| | | if(!/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){ |
| | | error_msg += ';电话号码错误'; |
| | | } |
| | | }else{ |
| | | if(phone.previousSibling && phone.previousSibling.className.indexOf('requiredBlock')>-1){ |
| | | error_msg += ';电话号码错误'; |
| | | } |
| | | } |
| | | } |
| | | |
| | | for(let e of document.getElementsByTagName('select')){ |
| | | for(let op of e.options){ |
| | | let es = document.getElementsByTagName('select') |
| | | for(let ei in es){ |
| | | let e = es[ei]; |
| | | for(let opi in e.options){ |
| | | let op = e.options[opi]; |
| | | if(!op)continue; |
| | | if(op.value == "*****" && op.selected){ |
| | | error_msg += ';下拉框不能主动选择密文选项'; |
| | | } |
| | |
| | | v = ele.value; |
| | | } |
| | | |
| | | if(v && v != "000000000000000"){ |
| | | // if(v && v != "000000000000000"){ |
| | | result[field_api_name] = v; |
| | | } |
| | | // } |
| | | |
| | | } |
| | | } else if (ele.type == 'checkbox') { |
| | |
| | | // Check Required Field |
| | | let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson); |
| | | if (checkRequiredFieldMsgResult) { |
| | | alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult); |
| | | alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult); |
| | | return |
| | | } |
| | | // //3. Prepare the payload for New PI API To AWS - To Do |
| | |
| | | var closeField = ''; |
| | | |
| | | function replaceSearchContactLookup() { |
| | | if (!{!isNewMode}) { |
| | | let eleContactValue = document.querySelector("[data-id='Receiver__c']").parentNode.parentNode.children[0].value; |
| | | let eleContactsValue = document.querySelector("[data-id='Applicanter__c']").parentNode.parentNode.children[0].value; |
| | | if (!{!isNewMode} || (eleContactValue != '000000000000000') || (eleContactsValue != '000000000000000')) { |
| | | //1. Query Contact from AWS by AWSDataId |
| | | queryContactName() |
| | | } |
| | |
| | | <script> |
| | | var init_nodes = document.getElementsByClassName("PIBackApi"); |
| | | var api_id_map={}; |
| | | for(let e of init_nodes){ |
| | | for(let e in init_nodes){ |
| | | if(IsFormElement(e)){ |
| | | api_id_map[GetEleApiName(e)] = e.id; |
| | | } |
| | |
| | | console.log(api_id_map); |
| | | |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField); |
| | | } |
| | | } |
| | | } |
| | | //1. Set Last Name label |
| | | //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '姓名'; |
| | | //2. Query AWS Data by dataId |
| | |
| | | replaceSearchContactLookup(); |
| | | //3. Set Readonly Attribute |
| | | document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton"); |
| | | document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton"); |
| | | |
| | | jQuery('a[data-id="OwnerId"]').remove(); |
| | | jQuery(".lookupInput").each(function(i,e){ |
| | | let je =jQuery(e).find('input'); |
| | | je.attr("readonly",""); |
| | | je.css("background","unset"); |
| | | |
| | | let dataid = je.attr('data-id'); |
| | | if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return; |
| | | jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); |
| | | }) |
| | | |
| | | jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){ |
| | | this.className = "closeIconOn"; |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){ |
| | | this.className = "closeIcon" |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("click","img[generate]",function(e){ |
| | | let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id"); |
| | | let input = document.getElementById(id); |
| | | if(input){ |
| | | input.value = ''; |
| | | let hidden = document.getElementById(id+'_lkid'); |
| | | if(hidden){ |
| | | hidden.value = ''; |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | </script> |
| | | <div class="pbBottomButtons"> |
| | |
| | | } |
| | | } |
| | | //手术分类1 |
| | | result.Technical_Category1__c = document.getElementById('page:form:j_id30:j_id60:4:j_id61:j_id62:2:j_id63')!=null?document.getElementById('page:form:j_id30:j_id60:4:j_id61:j_id62:2:j_id63').value:''; |
| | | result.Technical_Category1__c = document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:2:j_id38')!=null?document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:2:j_id38').value:''; |
| | | //手术分类2 |
| | | result.Technical_Category2__c = document.getElementById('page:form:j_id30:j_id60:4:j_id61:j_id62:4:j_id63')!=null?document.getElementById('page:form:j_id30:j_id60:4:j_id61:j_id62:4:j_id63').value:''; |
| | | result.Technical_Category2__c = document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:4:j_id38')!=null?document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:4:j_id38').value:''; |
| | | //目的2 |
| | | if(document.getElementById('page:form:j_id30:j_id60:3:j_id61:j_id62:1:j_id63')){ |
| | | result.Purpose2__c = document.getElementById('page:form:j_id30:j_id60:3:j_id61:j_id62:1:j_id63').value; |
| | | } |
| | | if(document.getElementById('page:form:j_id30:j_id60:2:j_id61:j_id62:1:j_id63')){ |
| | | result.Purpose2__c = document.getElementById('page:form:j_id30:j_id60:2:j_id61:j_id62:1:j_id63').value; |
| | | if(document.getElementById('page:form:j_id5:j_id35:2:j_id36:j_id37:1:j_id38')){ |
| | | result.Purpose2__c = document.getElementById('page:form:j_id5:j_id35:2:j_id36:j_id37:1:j_id38').value; |
| | | } |
| | | //富文本框赋值 |
| | | //用户签字的照片 |
| | |
| | | //对应结果第一次 VOC_follow_up_result1__c cke_71 |
| | | if(document.querySelector("[aria-describedby = 'cke_71']")){ |
| | | result.VOC_follow_up_result1__c = document.querySelector("[aria-describedby = 'cke_71']").contentWindow.document.getElementsByTagName('body')[0].innerHTML |
| | | } |
| | | if(result.From__c){ |
| | | result.From__c = result.From__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.To__c){ |
| | | result.To__c = result.To__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | return result; |
| | | } |
| | |
| | | if(document.querySelector("[data-id='Practitioner1__c']") != null){ |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Practitioner1__c']").id + '_lkid').value; |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | queryContactNameFetch(url,'Practitioner1__c'); |
| | | let url = staticResourcesContact.queryUrl; |
| | | queryContactNameFetch(url,dataId,'Practitioner1__c'); |
| | | } |
| | | if(document.querySelector("[data-id='Practitioner2__c']") != null){ |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Practitioner2__c']").id + '_lkid').value; |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | queryContactNameFetch(url,'Practitioner2__c'); |
| | | let url = staticResourcesContact.queryUrl; |
| | | queryContactNameFetch(url,dataId,'Practitioner2__c'); |
| | | } |
| | | if(document.querySelector("[data-id='Practitioner3__c']") != null){ |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Practitioner3__c']").id + '_lkid').value; |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | queryContactNameFetch(url,'Practitioner3__c'); |
| | | let url = staticResourcesContact.queryUrl; |
| | | queryContactNameFetch(url,dataId,'Practitioner3__c'); |
| | | } |
| | | if(document.querySelector("[data-id='Practitioner4__c']") != null){ |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Practitioner4__c']").id + '_lkid').value; |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | queryContactNameFetch(url,'Practitioner4__c'); |
| | | let url = staticResourcesContact.queryUrl; |
| | | queryContactNameFetch(url,dataId,'Practitioner4__c'); |
| | | } |
| | | if(document.querySelector("[data-id='Practitioner5__c']") != null){ |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Practitioner5__c']").id + '_lkid').value; |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | queryContactNameFetch(url,'Practitioner5__c'); |
| | | let url = staticResourcesContact.queryUrl; |
| | | queryContactNameFetch(url,dataId,'Practitioner5__c'); |
| | | } |
| | | if(document.querySelector("[data-id='Person_In_Charge__c']") != null){ |
| | | let sfId = document.getElementById(document.querySelector("[data-id='Person_In_Charge__c']").id + '_lkid').value; |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | queryContactNameFetch(url,'Person_In_Charge__c'); |
| | | let url = staticResourcesContact.queryUrl; |
| | | queryContactNameFetch(url,dataId,'Person_In_Charge__c'); |
| | | } |
| | | } |
| | | |
| | | function queryContactNameFetch(url,filedId){ |
| | | fetch(url, { |
| | | method: 'GET', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | if(result.object){ |
| | | document.querySelector("[data-id="+filedId+"]").value = result.object.lastName; |
| | | } |
| | | }) |
| | | function queryContactNameFetch(url,dataId,filedId){ |
| | | let queryBackContactNameFetch = function queryBackContactNameFetch(result){ |
| | | document.querySelector("[data-id="+filedId+"]").value = result.object.lastName; |
| | | }; |
| | | AWSService.query(url, dataId, queryBackContactNameFetch, staticResources.token); |
| | | } |
| | | |
| | | //自定义lookup查询 |
| | |
| | | //新建编辑回调函数 |
| | | var insertOrUpdateBack = function insertOrUpdateBack(payloadJson, result, isNewMode) { |
| | | console.log(result); |
| | | if(result.status != '0'){ |
| | | unblockUI(); |
| | | console.log('回调函数出错拉') |
| | | return |
| | | } |
| | | console.log('Result from AWS' + result); |
| | | console.log('payloadJson=' + payloadJson); |
| | | payloadJson.VOC_Informer_Name__c = result.object[0].vocInformerName; |
| | |
| | | // 3. Check Required Field |
| | | let checkRequiredFieldMsgResult = checkRequiredFieldMsg(reportJson); |
| | | if (checkRequiredFieldMsgResult) { |
| | | alertErrorMessage('{!requiredErrorMsg}'+checkRequiredFieldMsgResult); |
| | | alertErrorMessage('{!Input_Required_Field_Msg}'+checkRequiredFieldMsgResult); |
| | | return |
| | | } |
| | | //4. Prepare the payload for New PI API To AWS - To Do |
| | |
| | | </apex:repeat> |
| | | <script> |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | //判断是否为只读选项 |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //1. Set Last Name label |
| | | //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '姓名'; |
| | | //2. Query AWS Data by dataId |
| | |
| | | replaceSearchContactLookup(); |
| | | //3. Set Readonly Attribute |
| | | document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton"); |
| | | jQuery(".lookupInput").each(function (i, e) { |
| | | let je = jQuery(e).find('input'); |
| | | je.attr("readonly", ""); |
| | | je.css("background", "unset"); |
| | | |
| | | let dataid = je.attr('data-id'); |
| | | if (['Practitioner1__c','Practitioner2__c','Practitioner3__c','Practitioner4__c','Practitioner5__c','Person_In_Charge__c'].indexOf(dataid) > -1) |
| | | jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="' + dataid + '" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); |
| | | }) |
| | | |
| | | jQuery(".lookupInput").on("mouseenter", "img[generate]", function (e) { |
| | | this.className = "closeIconOn"; |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("mouseleave", "img[generate]", function (e) { |
| | | this.className = "closeIcon" |
| | | }); |
| | | |
| | | jQuery(".lookupInput").on("click", "img[generate]", function (e) { |
| | | let id = jQuery("input[data-id='" + jQuery(this).attr("data-id") + "']").attr("id"); |
| | | let input = document.getElementById(id); |
| | | if (input) { |
| | | input.value = ''; |
| | | let hidden = document.getElementById(id + '_lkid'); |
| | | if (hidden) { |
| | | hidden.value = ''; |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | </script> |
| | | <div class="pbBottomButtons"> |
New file |
| | |
| | | <apex:page controller="SearchContactController" id="page"> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | | |
| | | <head> |
| | | </head> |
| | | <style> |
| | | /* 1. 定义表单样式 To Do Later*/ |
| | | |
| | | table { |
| | | border-collapse: collapse; |
| | | border-spacing: 0; |
| | | width: 98%; |
| | | margin-left: 5px; |
| | | } |
| | | </style> |
| | | |
| | | <body id="body" class="lookupTab"> |
| | | <script type="text/javascript"> |
| | | var staticResources = JSON.parse('{!staticResource}'); |
| | | var contactAWSIds = JSON.parse('{!contactAWSIds}'); |
| | | var contactsInfo = JSON.parse('{!contactsInfo}'); |
| | | var searchContactName = ''; |
| | | function searchAWSContact(){ |
| | | console.log('Search process!'); |
| | | //1. reset table; |
| | | resetTable(); |
| | | //2. get contact name value |
| | | searchContactName = document.getElementById('page:form:lksrch').value; |
| | | //3. check searchContactName.length>=2 |
| | | if(searchContactName.length>=2){ |
| | | queryLeadFromAWS(); |
| | | }else{ |
| | | alert("请输入至少2个关键字"); |
| | | } |
| | | |
| | | } |
| | | function resetTable(){ |
| | | let queryResult = document.getElementById('QueryResult'); |
| | | let table = document.getElementById('table'); |
| | | if(table){ |
| | | queryResult.removeChild(table); |
| | | } |
| | | } |
| | | function preparePayloadForSearchContact(){ |
| | | let searchPayload = new Object(); |
| | | searchPayload.dataIds = []; |
| | | searchPayload.contactName = searchContactName; |
| | | return JSON.stringify(searchPayload); |
| | | } |
| | | function queryLeadFromAWS() { |
| | | //1. Prepare the payload for contact search |
| | | let requestSearchPayload = preparePayloadForSearchContact(); |
| | | console.log('request payload body:'+requestSearchPayload); |
| | | //2. Invoke AWS Service |
| | | fetch(staticResources.searchUrl, { |
| | | method: 'POST', |
| | | body: requestSearchPayload, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | console.log('JSON Result from aws:'+JSON.stringify(result)); |
| | | if(result.object&&result.object.length>0){ |
| | | initContactTable(result); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function redirectToParentPage(obj) { |
| | | var winMain = window.opener; |
| | | if (null == winMain) { |
| | | winMain = window.parent.opener; |
| | | } |
| | | let value = obj.currentTarget.innerText; |
| | | let contactInfo = new Object(); |
| | | contactInfo.Name = obj.currentTarget.innerText; |
| | | contactInfo.ContactId = obj.currentTarget.id; |
| | | window.open('\\'+obj.currentTarget.id,'_blank'); |
| | | console.log('Contact Infor:'+JSON.stringify(contactInfo)); |
| | | } |
| | | |
| | | function refreshTable(cols,contactInfoList){ |
| | | let myTableDiv = document.getElementById("QueryResult"); |
| | | let table = document.createElement('TABLE'); |
| | | table.border = '1'; |
| | | table.id = 'table' |
| | | let tableBody = document.createElement('TBODY'); |
| | | table.appendChild(tableBody); |
| | | let headerTR = document.createElement('TR'); |
| | | let colsHeader = ['姓名','客户名称','邮箱', '电话']; |
| | | tableBody.appendChild(headerTR); |
| | | for (let i = 0; i < colsHeader.length; i++) { |
| | | let td = document.createElement('TH'); |
| | | td.width = '75'; |
| | | td.appendChild(document.createTextNode(colsHeader[i])); |
| | | headerTR.appendChild(td); |
| | | } |
| | | //3. Init the AWS data |
| | | for (let i = 0; i < contactInfoList.length; i++) { |
| | | let contactInfoTemp = contactInfoList[i] |
| | | if(contactsInfo[contactInfoTemp.AWSDataId] != null){ |
| | | let tr = document.createElement('TR'); |
| | | tableBody.appendChild(tr); |
| | | for (let j = 0; j < cols.length; j++) { |
| | | let td = document.createElement('TD'); |
| | | td.width = '75'; |
| | | if(j == 0){ |
| | | td.id = contactsInfo[contactInfoTemp.AWSDataId].Id; |
| | | } |
| | | td.appendChild(document.createTextNode(contactInfoTemp[cols[j]]!=null?contactInfoTemp[cols[j]]:'')); |
| | | if (cols[j] == 'Name') { |
| | | td.addEventListener("click", function (obj) { |
| | | redirectToParentPage(obj); |
| | | }); |
| | | } |
| | | tr.appendChild(td); |
| | | } |
| | | } |
| | | } |
| | | myTableDiv.appendChild(table); |
| | | } |
| | | function initContactTable(data) { |
| | | let cols = ['Name','AccountName','Email', 'Phone']; |
| | | let contactInfoList = []; |
| | | let awsDataIds = []; |
| | | for(var i=0;i<data.object.length;i++){ |
| | | if(data.object[i].dataId){ |
| | | let contactInfo = new Object(); |
| | | contactInfo.Name = data.object[i].lastName; |
| | | contactInfo.Email = data.object[i].email; |
| | | contactInfo.Phone = data.object[i].phone; |
| | | contactInfo.AWSDataId = data.object[i].dataId; |
| | | awsDataIds.push(contactInfo.AWSDataId); |
| | | contactInfo.sfRecordId = ''; |
| | | contactInfoList.push(contactInfo); |
| | | } |
| | | } |
| | | let AWSIdToSFIdMapValue = {}; |
| | | console.log('Contact Info from AWS:'+JSON.stringify(contactInfoList)); |
| | | //Invoke SF BackEnd |
| | | Visualforce.remoting.Manager.invokeAction( |
| | | '{!$RemoteAction.SearchContactController.searchContacts}', |
| | | JSON.stringify(awsDataIds), |
| | | function (result, event) { |
| | | if(event.status){ |
| | | if(result.status == 'success'){ |
| | | contactsInfo = JSON.parse(result.message.replace(/("\;)/g,"\"")); |
| | | console.log('Contact Info from SF:'+JSON.stringify(contactsInfo)); |
| | | if(Object.keys(contactsInfo).length>0){ |
| | | for(let i=0;i<contactInfoList.length;i++){ |
| | | let contactFromSF = contactsInfo[contactInfoList[i]['AWSDataId']]; |
| | | if(contactFromSF){ |
| | | contactInfoList[i].sfRecordId = contactFromSF['Id']; |
| | | contactInfoList[i].AccountName = contactFromSF['Account']['Name']; |
| | | } |
| | | } |
| | | } |
| | | |
| | | refreshTable(cols,contactInfoList); |
| | | }else{ |
| | | alert('没查询到该联系人'); |
| | | console.log('No result'); |
| | | refreshTable(cols,[]); |
| | | } |
| | | } |
| | | }, |
| | | { escape: true } |
| | | ); |
| | | } |
| | | </script> |
| | | <apex:form id="form"> |
| | | <!-- Search Filter--> |
| | | <div class="lookup"> |
| | | <div class="bPageTitle"> |
| | | <div class="ptBody secondaryPalette"> |
| | | <div class="content"> |
| | | <img src="/img/s.gif" alt="" class="pageTitleIcon" title="" /> |
| | | <h1>联系人搜索</h1> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="pBody"> |
| | | <label class="assistiveText" for="lksrch">Search</label> |
| | | <apex:inputText id="lksrch" html-placeholder="{!PIPL_Search_Contact_Label}" value="{!searchKeyWord}" /> |
| | | <input value=" Go! " type="Button" onclick="searchAWSContact()" styleClass="btn" /> |
| | | <div class="bDescription">请输入联系人的姓名进行搜索。 |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div id="QueryResult"> |
| | | </div> |
| | | </apex:form> |
| | | </body> |
| | | </apex:page> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexPage xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>52.0</apiVersion> |
| | | <availableInTouch>false</availableInTouch> |
| | | <confirmationTokenRequired>false</confirmationTokenRequired> |
| | | <label>SearchAWSContactByNamePage</label> |
| | | </ApexPage> |
| | |
| | | for (let j = 0; j < cols.length; j++) { |
| | | let td = document.createElement('TD'); |
| | | td.width = '75'; |
| | | if (!contactsInfo.hasOwnProperty(contactInfoTemp.AWSDataId)) { |
| | | continue; |
| | | } |
| | | if(j == 0){ |
| | | td.id = contactsInfo[contactInfoTemp.AWSDataId].Id; |
| | | } |
| | |
| | | function Trans(){ |
| | | AWSService.postAWS(staticResources.transactionUrl,AWSService.confirmTrans, JSON.stringify({ |
| | | "txId":aws_result.txId, |
| | | "sfRecordId":"", |
| | | "isSuccess":1 |
| | | }), function(result){ |
| | | window.location.reload(); |
| | |
| | | let queryBack = function queryBack(result) { |
| | | let contacts = result.object; |
| | | if(contacts == null){ |
| | | console.log('查询联系人的数据 == null') |
| | | return; |
| | | } |
| | | for(var i=0;i<result.object.length;i++){ |
| | |
| | | '\n邮编: '+PIData[awsDataId].zipCode+ |
| | | '\n详细地址: '+PIData[awsDataId].detailedAddress |
| | | }else{ |
| | | piInformation = '联系人: null'+ |
| | | piInformation = '联系人: '+ |
| | | '\n电话: '+PIData[awsDataId].telephone+ |
| | | '\n邮编: '+PIData[awsDataId].zipCode+ |
| | | '\n详细地址: '+PIData[awsDataId].detailedAddress |
| | |
| | | let y=window.event.y; |
| | | createDiv.style.left=x; |
| | | createDiv.style.top=y; |
| | | createDiv.style.width = '100px'; |
| | | createDiv.style.height = '100px'; |
| | | createDiv.style.background="#dddddd"; |
| | | createDiv.style.position = "absolute"; |
| | | parentNode.appendChild(createDiv); |
| | | parentNode.style.position = "relative"; |
| | | } |
| | | |
| | | function hidePIDiv(awsDataId){ |
| | |
| | | <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;"> |
| | | <apex:outputfield value="{!or.address.Customer__c}" /> |
| | | </td> |
| | | <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;" aws-data-id="{!or.address.AWS_Data_Id__c}"> |
| | | <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;" aws-data-id="{!or.address.AWS_Data_Id__c}" > |
| | | <!-- <apex:outputfield value="{!or.address.Contacts__c}" id="{!or.address.Contacts__c}_{!or.address.Id}"/> --> |
| | | <a href="#" id="{!or.address.Id}" onmouseover="showPIDiv('{!or.address.Id}')" onmouseout="hidePIDiv('{!or.address.Id}')" aws-data-id="{!or.address.Contacts__r.AWS_Data_Id__c}">{!or.address.Contacts__r.Name}</a> |
| | | <a href="#" id="{!or.address.Id}" aws-data-id="{!or.address.Contacts__r.AWS_Data_Id__c}" onmouseover="showPIDiv('{!or.address.Id}')" onmouseout="hidePIDiv('{!or.address.Id}')">{!or.address.Contacts__r.Name}</a> |
| | | </td> |
| | | <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;"> |
| | | <apex:outputText value="{!or.address.Telephone__c}" /> |
| | |
| | | <!-- 该页面用于Lead对象上传PDF,未来如果要添加其他对象的上传PDF功能,复制该页面,将**standardController**修改为其他对象API名称即可 --> |
| | | <apex:page standardController="Lead" extensions="FileUploadController" id="page" lightningStyleSheets="true"> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <script> |
| | | var staticResources = JSON.parse('{!staticResource}'); |
| | | var parentId = '{!parentId}'; |
| | |
| | | return new Promise((resolve, reject) => { |
| | | const reader = new FileReader(); |
| | | reader.readAsDataURL(file); |
| | | reader.onload = () => resolve(reader.result); |
| | | reader.onerror = error => reject(error); |
| | | reader.onload = function(){resolve(reader.result)} ; |
| | | reader.onerror =function(error){reject(error)}; |
| | | }); |
| | | } |
| | | function disableButtonStatus() { |
| | |
| | | disableButtonStatus(); |
| | | var fileObject = document.getElementById("file").files[0]; |
| | | getBase64(fileObject).then( |
| | | data => { |
| | | function(data) { |
| | | console.log(data); |
| | | uploadFileToAWS(data, (fileObject.size).toString(), fileObject.name); |
| | | |
| | |
| | | } |
| | | function confirmTrans(transId, isSuccess) { |
| | | |
| | | fetch(staticResources.updateUrl, { |
| | | method: 'POST', |
| | | body: JSON.stringify({ 'txId': transId, "isSuccess": isSuccess }), |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then(data => { |
| | | console.log("confirmTrans-" + JSON.stringify(data)); |
| | | document.getElementById("file").files[0].name = ''; |
| | | enableButtonStatus(); |
| | | refreshFiles(); |
| | | return data.status; |
| | | }) |
| | | |
| | | // fetch(staticResources.updateUrl, { |
| | | // method: 'POST', |
| | | // body: JSON.stringify({ 'txId': transId, "isSuccess": isSuccess }), |
| | | // headers: { |
| | | // 'Content-Type': 'application/json', |
| | | // 'pi-token': staticResources.token |
| | | // } |
| | | // }).then(function(data) { |
| | | // return data.json(); |
| | | // }).then(function(data) { |
| | | // console.log("confirmTrans-" + JSON.stringify(data)); |
| | | // document.getElementById("file").files[0].name = ''; |
| | | // enableButtonStatus(); |
| | | // refreshFiles(); |
| | | // return data.status; |
| | | // }) |
| | | |
| | | AWSService.post(staticResources.updateUrl, JSON.stringify({ |
| | | "txId":transId, |
| | | "sfRecordId":"", |
| | | "isSuccess":isSuccess |
| | | }), function(result){ |
| | | window.location.reload(); |
| | | }, staticResources.token); |
| | | |
| | | } |
| | | function calculateFileSize(fileObject) { |
| | | if (fileObject.size > 20971520) { |
| | |
| | | } |
| | | function uploadFileToAWS(data, size, fileName) { |
| | | console.log("body=" + JSON.stringify({ 'file': data, "size": size, 'fileName': fileName })); |
| | | |
| | | fetch(uploadUrl, { |
| | | method: 'POST', |
| | | body: JSON.stringify({ 'file': data, "size": size, 'fileName': fileName }), |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then(result => { |
| | | AWSService.post(uploadUrl, JSON.stringify({ |
| | | 'file': data, |
| | | "size": size, |
| | | 'fileName': fileName }) |
| | | , function(result){ |
| | | console.log("result" + JSON.stringify(result)); |
| | | |
| | | console.log("result" + JSON.stringify(result)); |
| | | |
| | | if (result.success == true) { |
| | | if (result.success == true) { |
| | | key = result.object; |
| | | |
| | | Visualforce.remoting.Manager.invokeAction( |
| | |
| | | } else { |
| | | alertErrorMessage('上传失败请稍后再试!'); |
| | | } |
| | | }).catch((error) => { |
| | | console.error('Error:', error); |
| | | }) |
| | | debugger |
| | | }, staticResources.token); |
| | | |
| | | } |
| | | // fetch(uploadUrl, { |
| | | // method: 'POST', |
| | | // body: JSON.stringify({ 'file': data, "size": size, 'fileName': fileName }), |
| | | // headers: { |
| | | // 'Content-Type': 'application/json', |
| | | // 'pi-token': staticResources.token |
| | | // } |
| | | // }).then(function(data) { |
| | | // return data.json(); |
| | | // }).then(function(result) { |
| | | |
| | | // console.log("result" + JSON.stringify(result)); |
| | | |
| | | // if (result.success == true) { |
| | | // key = result.object; |
| | | |
| | | // Visualforce.remoting.Manager.invokeAction( |
| | | // '{!$RemoteAction.FileUploadController.saveFile}', |
| | | // fileName, key, result.txId, parentId, |
| | | // function (resultvalue, event) { |
| | | |
| | | |
| | | |
| | | // //2. show file list |
| | | // if (resultvalue.status == 'fail') { |
| | | // alertErrorMessage(resultvalue.message); |
| | | // //1. Confirm trans |
| | | // confirmTrans(result.txId, 0); |
| | | // } else { |
| | | // alertErrorMessage('上传成功'); |
| | | // confirmTrans(result.txId, 1); |
| | | // } |
| | | |
| | | // // window.location.reload(); |
| | | // }, |
| | | // { escape: true } |
| | | // ); |
| | | |
| | | // console.log('key' + key); |
| | | // } else { |
| | | // alertErrorMessage('上传失败请稍后再试!'); |
| | | // } |
| | | // }).catch(function(error) { |
| | | // console.error('Error:', error); |
| | | // }) |
| | | // debugger |
| | | // } |
| | | function downPdf(fileUrl) { |
| | | window.open(fileUrl,'_blank'); |
| | | } |
| | |
| | | <apex:page standardController="Agency_Contact__c" extensions="NewAndEditAgencyContactController" id="page"> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/> |
| | | <apex:form id="form"> |
| | | <apex:pageblock id="pageBlock"> |
| | |
| | | <apex:page standardController="Contact" extensions="NewAndEditContactController" id="page"> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | | <apex:form id="form"> |
| | | <apex:pageblock id="pageBlock"> |
| | | <apex:pageBlockSection showHeader="false" title="" collapsible="true" columns="2" id="pageBlockSection"> |
| | |
| | | <apex:page standardController="Lead" extensions="NewAndEditLeadController" id="page"> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/> |
| | | <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script> |
| | | <apex:form id="form"> |
| | |
| | | } |
| | | var queryBack = function queryBack(data) { |
| | | document.querySelector("[data-id='LastName']").innerHTML = data.object.lastName; |
| | | document.querySelector("[id='page:form:pageBlock:pageBlockSection:j_id2:0:j_id3']").innerHTML = data.object.phone; |
| | | document.querySelector("[id='page:form:pageBlock:pageBlockSection:j_id3:0:j_id4']").innerHTML = data.object.phone; |
| | | document.querySelector("[data-id='Email']").innerHTML = data.object.email; |
| | | |
| | | }; |
| | |
| | | <apex:page standardController="QIS_Report__c" extensions="NewAndEditQISController" id="page"> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/> |
| | | <apex:form id="form"> |
| | | <apex:pageblock id="pageBlock"> |
| | |
| | | <apex:page standardController="Report__c" extensions="NewAndEditReportController" id="page"> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/> |
| | | <apex:form id="form"> |
| | | <apex:pageblock id="pageBlock"> |
| | |
| | | } |
| | | var queryBack = function queryBack(data) { |
| | | document.querySelector("[data-id='VOC_Informer_Name__c']").innerHTML=data.object.vocInformerName!=null?data.object.vocInformerName.replace(/"/g,""):''; |
| | | document.querySelector("[id='page:form:pageBlock:pageBlockSection:j_id1:1:j_id2']").innerHTML=data.object.callerPhone!=null?data.object.callerPhone.replace(/"/g,""):''; |
| | | document.querySelector("[id='page:form:pageBlock:pageBlockSection:j_id2:1:j_id3']").innerHTML=data.object.callerPhone!=null?data.object.callerPhone.replace(/"/g,""):''; |
| | | document.querySelector("[data-id='VOC_Informer_Contact__c']").innerHTML=data.object.vocInformerContact!=null?data.object.vocInformerContact.replace(/"/g,""):''; |
| | | document.querySelector("[data-id='Person_In_Charge_Text__c']").innerHTML=data.object.personInChargeText!=null?data.object.personInChargeText.replace(/"/g,""):''; |
| | | document.querySelector("[data-id='Professor_sigh_text__c']").innerHTML=data.object.professorSighText!=null?data.object.professorSighText.replace(/"/g,""):''; |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <StaticResource xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <cacheControl>Public</cacheControl> |
| | | <contentType>application/zip</contentType> |
| | | </StaticResource> |
New file |
| | |
| | | var AWSService = {}; |
| | | AWSService = { |
| | | sfSessionId : '', |
| | | insertModule : 'Insert AWS ', |
| | | updateModule : 'Update AWS ', |
| | | queryModule : 'Query AWS ', |
| | | searchModule : 'Search AWS ', |
| | | confirmTrans : 'Confirm Transaction To AWS', |
| | | successStatus : 'success', |
| | | failStatus : 'fail', |
| | | insertCalloutLog:function(module,url,request,response,status){ |
| | | if(AWSService.sfSessionId){ |
| | | sforce.connection.sessionId = AWSService.sfSessionId; |
| | | let transLog = new sforce.SObject('Transaction_Log__c'); |
| | | transLog.AWS_Data_Id__c = ''; |
| | | transLog.Module__c = module; |
| | | transLog.Interface_URL__c = url; |
| | | transLog.Request__c = request; |
| | | transLog.Response__c = response; |
| | | transLog.Status__c = status; |
| | | let insertLogResult = sforce.connection.create([transLog]); |
| | | if(insertLogResult[0].getBoolean(AWSService.successStatus)) { |
| | | console.log('Insert Log Id: ' + insertLogResult[0].id); |
| | | return insertLogResult[0].id; |
| | | }else { |
| | | console.log('Faield to insert log'); |
| | | return ''; |
| | | } |
| | | } |
| | | }, |
| | | //Search Contact |
| | | search:function(searchUrl,requestSearchPayload,searchBack,token) { |
| | | let payloadstr= null; |
| | | if (requestSearchPayload) { |
| | | if (typeof requestSearchPayload == 'string') { |
| | | payloadstr = requestSearchPayload; |
| | | }else{ |
| | | payloadstr = JSON.stringify(requestSearchPayload); |
| | | } |
| | | } |
| | | let para = { |
| | | url:searchUrl, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "post", |
| | | success: function (result) { |
| | | AWSService.insertCalloutLog(AWSService.searchModule,searchUrl,JSON.stringify(requestSearchPayload),JSON.stringify(result),AWSService.successStatus); |
| | | searchBack(result); |
| | | }, |
| | | error: function (error){ |
| | | //错误相关处理 404属于该处理(经测试) |
| | | //还可能是"timeout", "error", "notmodified" 和 "parsererror"。 |
| | | AWSService.insertCalloutLog(AWSService.searchModule,searchUrl,JSON.stringify(requestSearchPayload),JSON.stringify(error),AWSService.failStatus); |
| | | console.log('错误处理',error); |
| | | } |
| | | }; |
| | | if (payloadstr) { |
| | | para.data = payloadstr; |
| | | } |
| | | jQuery.ajax(para); |
| | | |
| | | }, |
| | | |
| | | //query |
| | | query:function(queryURL, awsDataId, queryback, token) { |
| | | if(awsDataId){ |
| | | let para = { |
| | | url:queryURL + '?dataId=' + awsDataId, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "get", |
| | | success: function (data) { |
| | | AWSService.insertCalloutLog(AWSService.queryModule,queryURL,queryURL + '?dataId=' + awsDataId,JSON.stringify(data),AWSService.successStatus); |
| | | queryback(data); |
| | | }, |
| | | error: function (error){ |
| | | //错误相关处理 404属于该处理(经测试) |
| | | //还可能是"timeout", "error", "notmodified" 和 "parsererror"。 |
| | | AWSService.insertCalloutLog(AWSService.queryModule,queryURL,queryURL + '?dataId=' + awsDataId,JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | jQuery.ajax(para);}else{ |
| | | unblockUI(); |
| | | } |
| | | }, |
| | | |
| | | //queryRepair |
| | | queryRepair:function(queryURL, awsDataId,Id,ContactId,queryback, token) { |
| | | if(awsDataId){ |
| | | let para = { |
| | | url:queryURL + '?dataId=' + awsDataId, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "get", |
| | | success: function (data) { |
| | | AWSService.insertCalloutLog(AWSService.queryModule,queryURL,queryURL + '?dataId=' + awsDataId,JSON.stringify(data),AWSService.successStatus); |
| | | queryback(data,Id,ContactId); |
| | | }, |
| | | error: function (error){ |
| | | //错误相关处理 404属于该处理(经测试) |
| | | //还可能是"timeout", "error", "notmodified" 和 "parsererror"。 |
| | | AWSService.insertCalloutLog(AWSService.queryModule,queryURL,queryURL + '?dataId=' + awsDataId,JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | jQuery.ajax(para);}else{ |
| | | unblockUI(); |
| | | } |
| | | |
| | | }, |
| | | |
| | | //queryAddress |
| | | queryAddress:function(queryURL, addressName, queryback, token) { |
| | | if(addressName){ |
| | | let para = { |
| | | url:queryURL + '?detailedAddress=' + addressName, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "get", |
| | | success: function (data) { |
| | | AWSService.insertCalloutLog(AWSService.queryModule,queryURL,queryURL + '?detailedAddress=' + awsDataId,JSON.stringify(data),AWSService.successStatus); |
| | | queryback(data); |
| | | }, |
| | | error: function (error){ |
| | | //错误相关处理 404属于该处理(经测试) |
| | | //还可能是"timeout", "error", "notmodified" 和 "parsererror"。 |
| | | AWSService.insertCalloutLog(AWSService.queryModule,queryURL,queryURL + '?detailedAddress=' + awsDataId,JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | jQuery.ajax(para);}else{ |
| | | unblockUI(); |
| | | } |
| | | |
| | | }, |
| | | |
| | | //insert |
| | | insert:function(newURL, payloadJson, payloadForNewPI, controllerSaveMethod, token, transactionURL,isNewMode,insertOrUpdateBack,redirectCallBack) { |
| | | console.log('Process New PI Data'); |
| | | console.log(JSON.stringify(payloadForNewPI)); |
| | | |
| | | |
| | | let payloadstr= null; |
| | | if (payloadForNewPI) { |
| | | if (typeof payloadForNewPI == 'string') { |
| | | payloadstr = payloadForNewPI; |
| | | }else{ |
| | | payloadstr = JSON.stringify(payloadForNewPI); |
| | | } |
| | | } |
| | | let para = { |
| | | url:newURL, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "post", |
| | | success: function (result) { |
| | | AWSService.insertCalloutLog(AWSService.insertModule,newURL,JSON.stringify(payloadForNewPI),JSON.stringify(result),AWSService.successStatus); |
| | | AWSService.back(result, payloadJson, transactionURL, token, controllerSaveMethod,isNewMode,insertOrUpdateBack,redirectCallBack); |
| | | }, |
| | | error: function (error){ |
| | | //错误相关处理 404属于该处理(经测试) |
| | | //还可能是"timeout", "error", "notmodified" 和 "parsererror"。 |
| | | AWSService.insertCalloutLog(AWSService.insertModule,newURL,JSON.stringify(payloadForNewPI),JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | if (payloadstr) { |
| | | para.data = payloadstr; |
| | | } |
| | | jQuery.ajax(para); |
| | | |
| | | |
| | | }, |
| | | |
| | | //update |
| | | update:function(updateURL, payloadJson, payloadForNewPI, controllerSaveMethod, token, transactionURL,isNewMode,insertOrUpdateBack,redirectCallBack) { |
| | | console.log('Process New PI Data'); |
| | | console.log(JSON.stringify(payloadForNewPI)); |
| | | if(payloadForNewPI && JSON.parse(payloadForNewPI)[0] && JSON.parse(payloadForNewPI)[0]['dataId']){ |
| | | let payloadstr= null; |
| | | if (payloadForNewPI) { |
| | | if (typeof payloadForNewPI == 'string') { |
| | | payloadstr = payloadForNewPI; |
| | | }else{ |
| | | payloadstr = JSON.stringify(payloadForNewPI); |
| | | } |
| | | } |
| | | let para = { |
| | | url:updateURL, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "post", |
| | | success: function (result) { |
| | | AWSService.insertCalloutLog(AWSService.updateModule,updateURL,JSON.stringify(payloadForNewPI),JSON.stringify(result),AWSService.successStatus); |
| | | AWSService.back(result, payloadJson, transactionURL, token, controllerSaveMethod,isNewMode,insertOrUpdateBack,redirectCallBack); |
| | | }, |
| | | error: function (error){ |
| | | //错误相关处理 404属于该处理(经测试) |
| | | //还可能是"timeout", "error", "notmodified" 和 "parsererror"。 |
| | | AWSService.insertCalloutLog(AWSService.updateModule,updateURL,JSON.stringify(payloadForNewPI),JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | if (payloadstr) { |
| | | para.data = payloadstr; |
| | | } |
| | | jQuery.ajax(para); |
| | | }else{ |
| | | unblockUI(); |
| | | } |
| | | |
| | | }, |
| | | |
| | | //update |
| | | post:function(postURL, payloadForNewPI, callback, token) { |
| | | console.log('Process New PI Data'); |
| | | console.log(JSON.stringify(payloadForNewPI)); |
| | | |
| | | let payloadstr= null; |
| | | if (payloadForNewPI) { |
| | | if (typeof payloadForNewPI == 'string') { |
| | | payloadstr = payloadForNewPI; |
| | | }else{ |
| | | payloadstr = JSON.stringify(payloadForNewPI); |
| | | } |
| | | } |
| | | let para = { |
| | | url:postURL, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "post", |
| | | success: function (result) { |
| | | AWSService.insertCalloutLog(AWSService.insertModule,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(result),AWSService.successStatus); |
| | | if(callback) callback(result); |
| | | }, |
| | | error: function (error){ |
| | | AWSService.insertCalloutLog(AWSService.insertModule,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | if (payloadstr) { |
| | | para.data = payloadstr; |
| | | } |
| | | jQuery.ajax(para); |
| | | |
| | | }, |
| | | |
| | | //update |
| | | postAWS:function(postURL,moduleName,payloadForNewPI, callback, token) { |
| | | console.log('Process New PI Data'); |
| | | console.log(JSON.stringify(payloadForNewPI)); |
| | | |
| | | let payloadstr= null; |
| | | if (payloadForNewPI) { |
| | | if (typeof payloadForNewPI == 'string') { |
| | | payloadstr = payloadForNewPI; |
| | | }else{ |
| | | payloadstr = JSON.stringify(payloadForNewPI); |
| | | } |
| | | } |
| | | let para = { |
| | | url:postURL, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "post", |
| | | success: function (result) { |
| | | AWSService.insertCalloutLog(moduleName,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(result),AWSService.successStatus); |
| | | if(callback)callback(result); |
| | | }, |
| | | error: function (error){ |
| | | AWSService.insertCalloutLog(moduleName,postURL,JSON.stringify(payloadForNewPI),JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | if (payloadstr) { |
| | | para.data = payloadstr; |
| | | } |
| | | jQuery.ajax(para); |
| | | |
| | | }, |
| | | |
| | | confirmTrans:function(transactionURL,transParameters,callback,token){ |
| | | |
| | | let payloadstr= null; |
| | | if (transParameters) { |
| | | if (typeof transParameters == 'string') { |
| | | payloadstr = transParameters; |
| | | }else{ |
| | | payloadstr = JSON.stringify(transParameters); |
| | | } |
| | | } |
| | | let para = { |
| | | url:transactionURL, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | type: "post", |
| | | success: function (result) { |
| | | AWSService.insertCalloutLog(AWSService.confirmTrans,transactionURL,JSON.stringify(transParameters),JSON.stringify(result),AWSService.successStatus); |
| | | if(callback)callback(result); |
| | | }, |
| | | error: function (error){ |
| | | AWSService.insertCalloutLog(AWSService.confirmTrans,transactionURL,JSON.stringify(transParameters),JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | |
| | | if (payloadstr) { |
| | | para.data = payloadstr; |
| | | } |
| | | jQuery.ajax(para); |
| | | |
| | | }, |
| | | |
| | | sfdcBack : function(event, result, transId, token, transactionURL,redirectCallBack) { |
| | | let sfId = ''; |
| | | let errorMsg = ''; |
| | | if (event.status) { |
| | | console.log('sf Id from SF Backend:' + JSON.stringify(result)); |
| | | let transParameters = { |
| | | txId: transId |
| | | }; |
| | | if (result.status == 'success') { |
| | | transParameters.isSuccess = 1; |
| | | transParameters.sfRecordId = sfId = result.recordId;; |
| | | }else{ |
| | | transParameters.isSuccess = 0; |
| | | errorMsg = result.message; |
| | | } |
| | | |
| | | let para = { |
| | | url:transactionURL, |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': token |
| | | }, |
| | | data:JSON.stringify(transParameters), |
| | | type: "post", |
| | | success: function (result) { |
| | | AWSService.insertCalloutLog(AWSService.confirmTrans,transactionURL,JSON.stringify(transParameters),JSON.stringify(result),AWSService.successStatus); |
| | | redirectCallBack(sfId,errorMsg); |
| | | }, |
| | | error: function (error){ |
| | | AWSService.insertCalloutLog(AWSService.confirmTrans,transactionURL,JSON.stringify(transParameters),JSON.stringify(error),AWSService.failStatus); |
| | | console.log(error); |
| | | } |
| | | }; |
| | | |
| | | jQuery.ajax(para); |
| | | } |
| | | }, |
| | | |
| | | // AWSService.back(result, payloadJson, transactionURL, token, controllerSaveMethod); |
| | | back : function(result, payloadJson, transactionURL, token, controllerSaveMethod,isNewMode,insertOrUpdateBack,redirectCallBack) { |
| | | let payloadJsonStr = JSON.stringify(insertOrUpdateBack(payloadJson, result,isNewMode)); |
| | | let transId = result.txId + ''; |
| | | Visualforce.remoting.Manager.invokeAction( |
| | | controllerSaveMethod, // example '{!$RemoteAction.NewAndEditLeadController.saveLead}' |
| | | payloadJsonStr, transId, isNewMode, |
| | | function (result, event) { |
| | | AWSService.sfdcBack(event, result, transId, token, transactionURL,redirectCallBack); |
| | | }, |
| | | { escape: true } |
| | | ); |
| | | } |
| | | }; |