buli
2022-03-11 02ddc35714cbd1688b7cb057f770f1410de79dab
force-app/main/default/pages/StartTrading.page
@@ -1,6 +1,65 @@
<apex:page id="Page" standardController="Lead" extensions="StartTradingController" sidebar="false" action="{!init}">
   <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
   <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
   <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
   <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
   <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
    <script type="text/javascript">
      var staticResources = JSON.parse('{!staticResource}');
      var selectedIndexContact = 0;
      function setSelectedIndex(){
         var myselect=document.getElementById("Page:mainForm:idDayEdit:idCon")
         selectedIndexContact=myselect.selectedIndex
      }
      function preparePayloadForSearchContact() {
         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);
         }
      }
      var queryBack = function queryBack(result) {
         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);
         }
         for (var i = 0; i < result.object.length; i++) {
            if (result.object[i].sfRecordId) {
               let a = new Option();
               a.value = result.object[i].sfRecordId;
               a.text = result.object[i].lastName.replace(/"/g, "");
               select.options.add(a);
            }
         }
         if(selectedIndexContact !=0 ){
            var myselect=document.getElementById("Page:mainForm:idDayEdit:idCon").options
            myselect[selectedIndexContact].selected = true;
         }
         unblockUI();
      }
      //2021/02/21 张华建 查找客户人员 end
      function requiredCheck(){
         var val = document.getElementById('Page:mainForm:idDayEdit:idDep').selectedIndex;
         if (val == 0) {
@@ -14,11 +73,11 @@
    <!-- リード 取引の開始 -->
    <apex:sectionHeader title="{!$ObjectType.Lead.Label}" subtitle="{!$Label.StartTrading_Subtitle}"/>
       <apex:form id="mainForm">
           <apex:pageMessages />
      <apex:pageMessages id="errorMsg" />
           <apex:pageBlock id="idDayEdit" title="" mode="edit" >
              <apex:pageBlockButtons >
                 <!-- 取引の開始 -->
                  <apex:commandButton action="{!start}" value="{!$Label.StartTrading_Subtitle}" onclick="requiredCheck();" />
            <apex:commandButton action="{!start}" value="{!$Label.StartTrading_Subtitle}" onclick="requiredCheck();" reRender="mainForm"/>
                  <!-- キャンセル -->
                  <apex:commandButton action="{!cancel}" value="{!$Label.StartTrading_Cancel}"/>
              </apex:pageBlockButtons>
@@ -35,7 +94,7 @@
                      <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">
                     <apex:actionSupport event="onchange" onsubmit="" onbeforedomupdate="" action="{!depChange}" rerender="idCon" oncomplete="preparePayloadForSearchContact()">
                                <apex:param name="sltD" value="{!sltDep}"/>
                            </apex:actionSupport>
                        </apex:selectList>
@@ -45,9 +104,15 @@
                      <td width="100px"></td>
                      <!-- 担当者 -->
                      <td>{!$ObjectType.Contact.Label}</td>
                      <td><apex:selectList value="{!sltCon}" multiselect="false" size="1" id="idCon" style="width:200px;">
               <td>
                  <apex:selectList value="{!sltCon}" onchange="setSelectedIndex()" multiselect="false" size="1" id="idCon" style="width:200px;">
                               <apex:selectOptions value="{!conList}" />
                            </apex:selectList>
                  <script>
                     sfdcPage.appendToOnloadQueue(function () {
                        preparePayloadForSearchContact();
                     });
                  </script>
                    </td>
                   </tr>
                   <tr>