public without sharing class B_Test { public Contact newCon { get; set; } public Contact searchCon { get; set; } public List lineInfoList { get; set; } public String conId { get; set; } public String openLine { get; set; } private String accountId; // SWAG-BB44G7 所在医院id start private String HPId; private Integer i = 0; // SWAG-BB44G7 所在医院id end private String nowValue; public final string ApiPrefix{get;private set;} public String staticResource {get; set;} public B_Test() { openLine = Apexpages.currentPage().getParameters().get('line'); accountId = Apexpages.currentPage().getParameters().get('acc'); // SWAG-BB44G7 检索所在医院id start Account temAccount = [select id, Parent.parentid from account where id = : accountId]; if (temAccount.Parent.parentid != null) { HPId = temAccount.Parent.parentid; i = 1; }else{ HPId = accountId; i = 2; } // SWAG-BB44G7 检索所在医院id end nowValue = Apexpages.currentPage().getParameters().get('now'); lineInfoList = new List(); ApiPrefix = 'PIBackApi'; PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo('Contact'); staticResource = JSON.serialize(piIntegration); System.debug('B_Test'); } public void init() { searchCon = new Contact(); if (nowValue != null && nowValue != '') { searchCon = [select Id, Name, Department__c, Type__c, Search_LastName__c, Search_FirstName__c, Phone, Supplement__c, FirstName, LastName from Contact where Id = :nowValue]; searchCon.Search_LastName__c = searchCon.LastName; searchCon.Search_FirstName__c = searchCon.FirstName; } searchContact(); newCon = new Contact(); newCon.AccountId = accountId; return; } public PageReference searchContact() { String searchStr = 'select Id, Name, Department__c, Type__c, AccountName__c, Supplement__c, Phone,accountid '; searchStr += ' from Contact '; searchStr += ' where Isactive__c = \'有效\' '; // SWAG-BB44G7 检索所在医院的客户人员 start if(i == 1 ){ searchStr += ' and Account.parent.parentid = :HPId '; } if(i == 2){ searchStr += ' and AccountId = :HPId '; } // searchStr += ' and Account.parent.parentid = :HPId '; // SWAG-BB44G7 检索所在医院的客户人员 end if (searchCon.Search_LastName__c != null && searchCon.Search_LastName__c != '') { searchStr += ' and LastName like \'%' + searchCon.Search_LastName__c + '%\''; } if (searchCon.Search_FirstName__c != null && searchCon.Search_FirstName__c != '') { searchStr += ' and FirstName like \'%' + searchCon.Search_FirstName__c + '%\''; } system.debug('=====searchStr:' + searchStr); List searchResult = Database.query(searchStr); lineInfoList = new List(); Integer line = 0; for (Contact con : searchResult) { line += 1; LineInfo li = new LineInfo(line, con); lineInfoList.add(li); } editClear(); return null; } public PageReference editContact() { if (conId != null && conId != '') { newCon = [select Id, Name, Department__c, Type__c, Search_LastName__c, Search_FirstName__c, Phone, Supplement__c,LastName_Encrypted__c,Phone_Encrypted__c, FirstName, LastName,AWS_Data_Id__c from Contact where Id = :conId]; } System.debug(newCon); System.debug('editContact'); return null; } public PageReference saveNew() { if (newCon.Search_LastName__c == null || newCon.Search_LastName__c == '') { newCon.Search_LastName__c.addError('必须填写。'); return null; } newCon.LastName = newCon.Search_LastName__c; newCon.FirstName = newCon.Search_FirstName__c; upsert newCon; searchCon.Search_LastName__c = newCon.LastName; searchCon.Search_FirstName__c = newCon.FirstName; searchContact(); return null; } public PageReference editClear() { newCon = new Contact(); newCon.AccountId = accountId; return null; } class LineInfo { public Integer lineNo { get; set; } public Contact con { get; set; } public LineInfo(Integer in_line) { lineNo = in_line; con = new Contact(); } public LineInfo(Integer in_line, Contact in_con) { lineNo = in_line; con = in_con; } } // @RemoteAction // global static Response saveContact(String leadJson,String transId) { // return NewAndEditBaseController.save(new Contact(),leadJson,transId,isNew); // } }