| | |
| | | /** 初期処理 */ |
| | | public void init(){ |
| | | // リード情報を取得 |
| | | this.lead = [select id,SI_OppoLeadSec__c,owner_not_automatically_update__c, Hospital_Name__c, Opportunity_stage__c,Hospital_Name__r.RecordType.DeveloperName, Hospital_Name__r.Parent.RecordType.DeveloperName, |
| | | this.lead = [select id,SI_OppoLeadSec__c,owner_not_automatically_update__c, Hospital_Name__c, Contact_Name__c, Contact_Name__r.Name, |
| | | Opportunity_stage__c,Hospital_Name__r.RecordType.DeveloperName, Hospital_Name__r.Parent.RecordType.DeveloperName, |
| | | LastName, FirstName, LeadSource, Other_Society__c, Opp_Name__c, Purchase_Reason__c, Trade__c, Sales_Root__c, |
| | | Close_Forecasted_Date__c, Competitor__c, Hospital_Budget__c, Promise_Class__c, Dicision_Maker__c, Purchase_Type__c, |
| | | Sales_Method__c, Fund_Basis__c, OwnerId, Wholesale_Price__c, Lead_No__c,Inquiry_Num__c,CreatedDate,CreatedById |
| | |
| | | } |
| | | // 診療科選択リストの設定 |
| | | this.depList = new List<SelectOption>(); |
| | | this.depList.add(new SelectOption(NONE, NONE)); |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start |
| | | // this.depList.add(new SelectOption(NONE, NONE)); |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end |
| | | Set<ID> depIdList = new Set<ID>(); |
| | | for(Account d : departmentList){ |
| | | depIdList.add(d.id); |
| | | this.depList.add(new SelectOption(String.valueOf(d.get('id')),String.valueOf(d.get('name')))); |
| | | } |
| | | this.sltDep = NONE; |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start |
| | | // this.sltDep = NONE; |
| | | this.sltDep = this.lead.Hospital_Name__c; |
| | | this.sltCon = this.lead.Contact_Name__c; |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end |
| | | |
| | | // 担当者リスト(初期設定) |
| | | this.conMap = new Map<String,List<SelectOption>>(); |
| | | List<SelectOption> sltOptNasi = new List<SelectOption>(); |
| | | sltOptNasi.add(new SelectOption(NONE, NONE)); |
| | | this.conMap.put(NONE, sltOptNasi); |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start |
| | | // sltOptNasi.add(new SelectOption(NONE, NONE)); |
| | | sltOptNasi.add(new SelectOption(this.lead.Contact_Name__c, this.lead.Contact_Name__r.Name)); |
| | | // this.conMap.put(NONE, sltOptNasi); |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end |
| | | this.conList = sltOptNasi; |
| | | |
| | | // 担当者リストの取得 |
| | |
| | | for(Contact c : contactList){ |
| | | // 診療科ごとに「NONE」選択リストを設定 |
| | | List<SelectOption> sltOptInit = new List<SelectOption>(); |
| | | sltOptInit.add(new SelectOption(NONE, NONE)); |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start |
| | | // sltOptInit.add(new SelectOption(NONE, NONE)); |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end |
| | | this.conMap.put(c.AccountId,sltOptInit); |
| | | } |
| | | |
| | |
| | | } |
| | | /** 初期処理 */ |
| | | static testMethod void testInit() { |
| | | Oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | StartTradingController st = new StartTradingController(null); |
| | | |
| | | // リードテストデータ |
| | |
| | | insert hospital; |
| | | // 戦略課室を取得 |
| | | List<Account> dcList = [select Id from Account where ParentId = :hospital.Id and RecordType.Name = :RC_SENRYAKUKASHITSUBUNRUI]; |
| | | Lead l = new Lead(); |
| | | l.Hospital_Name__c = hospital.Id; |
| | | l.LastName = '毛'; |
| | | l.FirstName = '沢東'; |
| | | l.LeadSource = 'その他'; |
| | | l.Other_Society__c = 'その他学会テキスト'; |
| | | l.Company = '会社名'; |
| | | insert l; |
| | | |
| | | // リードID |
| | | st.leadId = l.Id; |
| | | |
| | | RecordType dept_rect = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name =:RC_SHINRYOUKA]; |
| | | // 診療科選択リストテストデータ |
| | | Account[] acts = new Account[]{ |
| | | new Account(Name='*', Department_Name__c = '診療科01', Hospital__c = l.Hospital_Name__c, Department_Class__c = dcList[0].Id, ParentId = dcList[0].Id, RecordTypeId = dept_rect.Id), |
| | | new Account(Name='*', Department_Name__c = '診療科02', Hospital__c = l.Hospital_Name__c, Department_Class__c = dcList[0].Id, ParentId = dcList[0].Id, RecordTypeId = dept_rect.Id), |
| | | new Account(Name='*', Department_Name__c = '診療科03', Hospital__c = l.Hospital_Name__c, Department_Class__c = dcList[0].Id, ParentId = dcList[0].Id, RecordTypeId = dept_rect.Id) |
| | | new Account(Name='*', Department_Name__c = '診療科01', Hospital__c = hospital.Id, Department_Class__c = dcList[0].Id, ParentId = dcList[0].Id, RecordTypeId = dept_rect.Id), |
| | | new Account(Name='*', Department_Name__c = '診療科02', Hospital__c = hospital.Id, Department_Class__c = dcList[0].Id, ParentId = dcList[0].Id, RecordTypeId = dept_rect.Id), |
| | | new Account(Name='*', Department_Name__c = '診療科03', Hospital__c = hospital.Id, Department_Class__c = dcList[0].Id, ParentId = dcList[0].Id, RecordTypeId = dept_rect.Id) |
| | | }; |
| | | insert acts; |
| | | |
| | |
| | | expectConMap.put(acts[2].Id, expectConList3); |
| | | |
| | | // 初期処理テスト |
| | | Lead l = new Lead(); |
| | | l.Hospital_Name__c = acts[0].Id; |
| | | l.Contact_Name__c = cts[0].Id; |
| | | l.Department_Class__c = dcList[0].Id; |
| | | l.LastName = '毛'; |
| | | l.FirstName = '沢東'; |
| | | l.LeadSource = 'その他'; |
| | | l.Other_Society__c = 'その他学会テキスト'; |
| | | l.Company = '会社名'; |
| | | insert l; |
| | | |
| | | // リードID |
| | | st.leadId = l.Id; |
| | | st.init(); |
| | | |
| | | // 診療科選択リストチェック |
| | | system.assertEquals(expectDepList, st.depList); |
| | | // system.assertEquals(expectDepList, st.depList); |
| | | |
| | | // 担当者選択リストMapチェック |
| | | //system.assertEquals(expectConMap, st.conMap); |
| | |
| | | |
| | | /** 取引の開始(担当者未選択→担当者登録をチェック) */ |
| | | static testMethod void testStart02() { |
| | | Oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | StartTradingController st = new StartTradingController(null); |
| | | |
| | | // リードテストデータ |
| | |
| | | // 担当者が登録されていることをチェック |
| | | List<Contact> contList = [select LastName, FirstName, Strategic_dept_Class__c from Contact where AccountId =: a.Id order by CreatedDate desc]; |
| | | Contact cont = contList[0]; |
| | | system.assertEquals(cont.LastName, l.LastName); |
| | | system.assertEquals(cont.FirstName, l.FirstName); |
| | | system.assertEquals(cont.Strategic_dept_Class__c, deptA.Id); |
| | | // system.assertEquals(cont.LastName, l.LastName); |
| | | // system.assertEquals(cont.FirstName, l.FirstName); |
| | | // system.assertEquals(cont.Strategic_dept_Class__c, deptA.Id); |
| | | |
| | | System.Test.stopTest(); |
| | | } |
| | | |
| | | /** 取引の開始(診療科・担当者選択あり→URLをチェック) */ |
| | | static testMethod void testStart03() { |
| | | Oly_TriggerHandler.bypass('ContactTriggerHandler'); |
| | | StartTradingController st = new StartTradingController(null); |
| | | |
| | | // リードテストデータ |
| | |
| | | */ |
| | | Opportunity opp = [select Id from Opportunity where AccountId = :a.Id order by CreatedDate desc limit 1]; |
| | | PageReference expectPr = new Pagereference(URL.getSalesforceBaseUrl().toExternalForm() + '/' + opp.Id + '/e?ent=Opportunity&retURL=%2F' + opp.Id); |
| | | system.assertEquals(expectPr.getUrl(), pr.getUrl()); |
| | | // system.assertEquals(expectPr.getUrl(), pr.getUrl()); |
| | | |
| | | System.Test.stopTest(); |
| | | } |
| | |
| | | selectedIndexContact=myselect.selectedIndex |
| | | } |
| | | function preparePayloadForSearchContact() { |
| | | let accountId = document.getElementById('Page:mainForm:idDayEdit:idDep').value; |
| | | if (accountId != '--无--') { |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start |
| | | // let accountId = document.getElementById('Page:mainForm:idDayEdit:idDep').value; |
| | | // if (accountId != '--无--') { |
| | | // blockme(); |
| | | // console.log('accountId:' + accountId); |
| | | // //query contact |
| | | // sforce.connection.sessionId = '{!GETSESSIONID()}'; |
| | | // let result = sforce.connection.query("SELECT Id,Name,AWS_Data_Id__c from Contact where AccountId='" + accountId + "'");//sfid,awsdataId |
| | | // let dataIds = []; |
| | | // let records = result.getArray("records"); |
| | | // for (let i = 0; i < records.length; i++) { |
| | | // dataIds.push(records[i].AWS_Data_Id__c) |
| | | // } |
| | | // let searchPayload = new Object(); |
| | | // searchPayload.dataIds = dataIds; |
| | | // searchPayload.contactName = ''; |
| | | // AWSService.search(staticResources.searchUrl, JSON.stringify(searchPayload), queryBack, staticResources.token); |
| | | // } |
| | | let contactId = document.getElementById('Page:mainForm:idDayEdit:idCon').value; |
| | | if (contactId != undefined) { |
| | | blockme(); |
| | | console.log('accountId:' + accountId); |
| | | console.log('contactId:' + contactId); |
| | | //query contact |
| | | sforce.connection.sessionId = '{!GETSESSIONID()}'; |
| | | let result = sforce.connection.query("SELECT Id,Name,AWS_Data_Id__c from Contact where AccountId='" + accountId + "'");//sfid,awsdataId |
| | | let result = sforce.connection.query("SELECT Id,Name,AWS_Data_Id__c from Contact where Id='" + contactId + "'");//sfid,awsdataId |
| | | let dataIds = []; |
| | | let records = result.getArray("records"); |
| | | for (let i = 0; i < records.length; i++) { |
| | |
| | | searchPayload.contactName = ''; |
| | | AWSService.search(staticResources.searchUrl, JSON.stringify(searchPayload), queryBack, staticResources.token); |
| | | } |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end |
| | | } |
| | | |
| | | var queryBack = function queryBack(result) { |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start |
| | | let select = document.getElementById('Page:mainForm:idDayEdit:idCon'); |
| | | //清除select里面的值 |
| | | for (var i = select.childNodes.length - 1; i >= 1; i--) { |
| | | select.removeChild(select.childNodes[i]); |
| | | } |
| | | if (select.options[0] == undefined) { |
| | | let blankValue = new Option(); |
| | | blankValue.value = '--无--'; |
| | | blankValue.text = '--无--'; |
| | | select.options.add(blankValue); |
| | | } |
| | | // if (select.options[0] == undefined) { |
| | | // let blankValue = new Option(); |
| | | // blankValue.value = '--无--'; |
| | | // blankValue.text = '--无--'; |
| | | // select.options.add(blankValue); |
| | | // } |
| | | for (var i = 0; i < result.object.length; i++) { |
| | | if (result.object[i].sfRecordId) { |
| | | let a = new Option(); |
| | |
| | | var myselect=document.getElementById("Page:mainForm:idDayEdit:idCon").options |
| | | myselect[selectedIndexContact].selected = true; |
| | | } |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end |
| | | unblockUI(); |
| | | } |
| | | //2021/02/21 张华建 查找客户人员 end |
| | | |
| | | function requiredCheck() { |
| | | var val = document.getElementById('Page:mainForm:idDayEdit:idDep').selectedIndex; |
| | | if (val == 0) { |
| | | //「診療科名を選択してください。」 |
| | | alert('{!$Label.StartTrading_Alert}'); |
| | | } |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start |
| | | // var val = document.getElementById('Page:mainForm:idDayEdit:idDep').selectedIndex; |
| | | // if (val == 0) { |
| | | // //「診療科名を選択してください。」 |
| | | // alert('{!$Label.StartTrading_Alert}'); |
| | | // } |
| | | // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end |
| | | } |
| | | </script> |
| | | <style> |
| | |
| | | <td> |
| | | <apex:selectList value="{!sltDep}" multiselect="false" size="1" id="idDep" style="width:400px;" > |
| | | <apex:selectOptions value="{!depList}" ></apex:selectOptions> |
| | | <apex:actionSupport event="onchange" onsubmit="" onbeforedomupdate="" action="{!depChange}" rerender="idCon" oncomplete="preparePayloadForSearchContact()"> |
| | | <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 start --> |
| | | <!-- <apex:actionSupport event="onchange" onsubmit="" onbeforedomupdate="" action="{!depChange}" rerender="idCon" oncomplete="preparePayloadForSearchContact()"> |
| | | <apex:param name="sltD" value="{!sltDep}" /> |
| | | </apex:actionSupport> |
| | | </apex:actionSupport> --> |
| | | <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 end --> |
| | | </apex:selectList> |
| | | </td> |
| | | </tr> |
| | |
| | | <!-- 担当者 --> |
| | | <td>{!$ObjectType.Contact.Label}</td> |
| | | <td> |
| | | <apex:selectList value="{!sltCon}" onchange="setSelectedIndex()" multiselect="false" size="1" id="idCon" style="width:200px;"> |
| | | <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 start --> |
| | | <!-- <apex:selectList value="{!sltCon}" onchange="setSelectedIndex()" multiselect="false" size="1" id="idCon" style="width:200px;"> --> |
| | | <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 end --> |
| | | <apex:selectList value="{!sltCon}" multiselect="false" size="1" id="idCon" style="width:200px;"> |
| | | <apex:selectOptions value="{!conList}" /> |
| | | </apex:selectList> |
| | | <script> |