From 2ecb63062fe10bbfb6853e37a38a74dcc10291db Mon Sep 17 00:00:00 2001
From: 彭锟 <pengkun@prec-tech.com>
Date: 星期二, 22 三月 2022 17:42:00 +0800
Subject: [PATCH] NFM624修改

---
 force-app/main/default/pages/StraightBackAddress.page |  508 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 491 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/pages/StraightBackAddress.page b/force-app/main/default/pages/StraightBackAddress.page
index 8a6b4c6..b7b6bd1 100644
--- a/force-app/main/default/pages/StraightBackAddress.page
+++ b/force-app/main/default/pages/StraightBackAddress.page
@@ -3,29 +3,238 @@
     <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
     <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
     <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
+    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
+    <apex:includeScript value="/soap/ajax/40.0/connection.js"/>
     <script type="text/javascript">
         var checkedTrue;
-        window.onload = () => {
+        var tableDataStr = '';
+        var staticResource = JSON.parse('{!staticResource}');
+        var staticResourceContact = JSON.parse('{!staticResourceContact}');
+        var PIData = {};
+        var contactDataIds = [];
+        var ObjIdDecrypt = '';
+        var closeField = '';
+        var add_aws_result = '';
+        var con_aws_result = '';
+        var isAddCon = false;
+        var contactInfoStr = '';
+
+        //鏇挎崲vlookup
+        var newSearchContactWindow = null;
+        window.onload = function () {
             document.getElementById("tab01").style.height  =  screen.availHeight*0.07+'px';
             document.getElementById("tab02").style.height  =  screen.availHeight*0.53+'px';
             document.getElementById("tab03").style.height  =  screen.availHeight*0.25+'px';
         }
          //缂栬緫鎸夐挳
          function onEditorJs(ObjId){
+            ObjIdDecrypt = ObjId;
             onEditor(ObjId); 
          }
         //澶嶅埗鎸夐挳
         function onCopyJs(ObjId){
+            ObjIdDecrypt = ObjId;
             if(ObjId == ''){
                 onCopy('绌�');//璁剧疆涓虹┖锛屼究浜庡悗绔仛鏁版嵁澶勭悊
             }else{
                 onCopy(ObjId);
             }
         }
+        //aws 纭
+        function Trans(){
+            let b = HasError();
+            if(b){
+                //娓呯┖鐢佃瘽鍦板潃閭紪
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value=''
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value=''
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value=''
+            }
+            AWSService.post(staticResource.transactionUrl, JSON.stringify({
+                    "txId":add_aws_result.txId,
+                    "isSuccess":b ? 0 : 1
+                }), function(result){
+                    if(isAddCon){
+                        AWSService.post(staticResourceContact.transactionUrl, JSON.stringify({
+                            "txId":con_aws_result.txId,
+                            "isSuccess":b ? 0 : 1
+                        }), function(result){
+                            if(!b)
+                            window.location.reload();
+                        }, staticResourceContact.token);
+                    }else{
+                        if(!b)
+                        window.location.reload();
+                    }
+                }, staticResource.token);
+            
+        }
+
+        function HasError(){
+            // if (IsAddmessage) {
+            //     return true;
+            // }
+            let e = document.getElementById("allPage:allForm:message");
+            if (!e) {
+                return false;
+            }
+
+            let divs = j$(e).find("div.message");
+            for (let i = 0; i < divs.length; i++) {
+                for (let j = 0; j < divs[i].classList.length; j++) {
+                    for(let cls in divs[i].classList){
+                        if (cls.indexOf('error')>-1) {
+                            return true;
+                        }
+                    }
+                    
+                }
+                
+            }
+
+
+            return false;
+        }
+        //瑙e瘑
+        function decrypt(){
+            if(PIData[ObjIdDecrypt] == null){
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').value = '';
+                //document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:contactIdValue').value = '000000000000000';
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = '';
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = '';
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = '';
+            }else{
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').value = PIData[ObjIdDecrypt].lastName!=null?PIData[ObjIdDecrypt].lastName:'';
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = PIData[ObjIdDecrypt].telephone;
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = PIData[ObjIdDecrypt].zipCode;
+                document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = PIData[ObjIdDecrypt].detailedAddress;
+            }
+        }
+        function getPIPayload() {
+            let leadPayloadList = [];
+            var telePhone = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value;
+            var zipCode = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value;
+            var detailedAddress = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value;
+            let leadPIData = new Object();
+            leadPIData.telePhone = telePhone;
+            leadPIData.zipCode = zipCode;
+            leadPIData.detailedAddress = detailedAddress;
+            leadPIData.sfRecordId = '';
+            leadPayloadList.push(leadPIData);
+            console.log(JSON.stringify(leadPayloadList));
+            return JSON.stringify(leadPayloadList);
+        }
         //淇濆瓨鏂规硶
         function savaJs(){
+            //blockme();
+            if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c').value != ''){
+                isAddCon = true;
+            }
+            document.getElementById("errorMsg").innerHTML = '';
+            
+            if(!document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Contacts__c").value&&!document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){
+                document.getElementById("errorMsg").innerHTML = '<strong>銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃朵负绌猴紒</strong> ';
+                return;
+            }else if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Contacts__c").value&&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){
+                document.getElementById("errorMsg").innerHTML = '<strong>銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃舵湁鍊硷紒</strong> ';
+                return;
+            }
             blockme();
-            save();
+            console.log('{!insUpdData}')
+            if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value //銆愯仈绯讳汉锛堟柊寤猴級銆戜笉涓虹┖
+                &&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:CustomerRecordType").value!='{!accOfficeTypeId}'////璁板綍绫诲瀷id  鍔炰簨澶�
+                &&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:CustomerRecordType").value!='{!accAgencyTypeId}'//璁板綍绫诲瀷id  璨╁2搴�
+                &&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:CustomerRecordType").value!='{!accAgencyContactTypeId}'){//璁板綍绫诲瀷id  缁忛攢鍟嗚仈绯讳汉
+                //new contact
+                ProcessPI({},GetEditObj('contact'),'contact',function(){
+                    //new address
+                    ProcessPI({},
+                    GetEditObj('address'),'address',function(){
+                        save();
+                    });
+                });
+            }else{
+                //new address
+                ProcessPI({},GetEditObj('address'),'address',function(){
+                    save();
+                });
+            }
+        }
+
+        function ProcessPI(sobjJson, payloadForNewPI,type,callback) {
+            var sr = ''
+            if(type == 'contact'){
+                sr = staticResourceContact
+            }
+            if(type == 'address'){
+                sr = staticResource
+            }
+            let url = sr.newUrl
+            /*if (now_edit_id) {
+                url = sr.updateUrl
+            }*/
+            AWSService.post(url, payloadForNewPI, function(result){
+                if(type == 'contact'){
+                    con_aws_result = result
+                }if(type == 'address'){
+                    add_aws_result = result
+                }
+                SetEditObj(type);
+                if(callback){
+                    callback();
+                }
+            }, sr.token);
+        }
+        function SetEditObj(type){
+            let obj = GetAWSResultObj(type);
+            if(obj){
+                if(type=='contact'){
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Con_AWS_Data_Id__c").value      = obj.dataId;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value      = obj.lastName;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:LastName_Encrypted__c").value   = obj.lastNameEncrypt;
+                }
+                if(type=='address'){
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Add_AWS_Data_Id__c").value              = obj.dataId;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value                    = obj.telephone;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone_Encrypted__c").value          = obj.telephoneEncrypt;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value                      = obj.zipCode;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode_Encrypted__c").value            = obj.zipCodeEncrypt;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value             = obj.detailedAddress;
+                    document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address_Encrypted__c").value   = obj.detailedAddressEncrypt;
+                }
+            }
+            
+        }
+        function GetAWSResultObj(type){
+            if(type == 'contact'){
+                if(con_aws_result && con_aws_result.object && con_aws_result.object.length > 0){
+                    return con_aws_result.object[0];
+                }
+            }
+            if(type == 'address'){
+                if(add_aws_result && add_aws_result.object && add_aws_result.object.length > 0){
+                    return add_aws_result.object[0];
+                }
+            }
+            return null;
+        }
+        function GetEditObj(type){
+            if(type=='contact'){
+                //new contact
+                return JSON.stringify([{
+                    lastName : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value,
+                    dataId : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Con_AWS_Data_Id__c").value,
+                }]);
+            }
+            if(type == 'address'){
+                //new address
+                return JSON.stringify([{
+                    dataId : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Add_AWS_Data_Id__c").value,
+                    telephone : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value,
+                    zipCode : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value,
+                    detailedAddress : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value,
+                }]);
+            }
+            
         }
 
         //澶嶉�夋閫変腑瑙﹀彂浜嬩欢
@@ -48,7 +257,33 @@
         }
         function searchBtnJs(){
             blockme();
-            searchBtn();
+            var addressDataIds = '';
+            //鏌ヨ鍦板潃
+            if(document.getElementById('allPage:allForm:searchBlock:txtAddressId').value != ''){
+                //鍙戦�乤ws璇锋眰锛岀劧鍚庡啀鍙戦�佺粰controller
+                new Promise(function(resolve, reject){
+                    let queryBack = function queryBack(result){
+                        if(result.object==null || result.object.length==0){
+                            searchBtn('\''+addressName+'\'');
+                            return
+                        }else{
+                            for(var i=0;i<result.object.length;i++){
+                                addressDataIds += ',\''+ result.object[i].dataId + '\'';
+                            }
+                            addressDataIds = addressDataIds.substring(1);
+                            resolve('success');
+                        }
+                    };
+                    var addressName = document.getElementById('allPage:allForm:searchBlock:txtAddressId').value;
+                    AWSService.queryAddress('https://sfpi-mebg-test.olympuschina.com/api/address/search',addressName.trim(),queryBack,staticResource.token);
+                }).then(function(data){
+                    console.log('data = '+data)
+                    console.log('addressDataIds = '+addressDataIds)
+                    searchBtn(addressDataIds);
+                });
+            }else{
+                searchBtn(addressDataIds);
+            }
         }
         //閲囩敤鎸夐挳
         function onAdoptJs(objId){
@@ -99,26 +334,238 @@
         function refreshJs(){
             window.location.reload();
         }
+
+        //2022 02 28 寮犲崕寤� display PI Data start
+        
+        //queryPI();
+        function q1(){
+            var index = 0;
+            var correct = 0;
+            var p = new Promise(function(resolve, reject){
+                //鏌ヨ鍦板潃鐨凱I鏁版嵁
+                let searchCallBack = function searchCallBack(result,Id,awsDataId){
+                    index++;
+                    let contacts = result.object;
+                    if(contacts == null){
+                        console.log('contacts == null')
+                        return;
+                    }
+                    let temp = {}
+                    temp.telephone = result.object.telephone;
+                    temp.zipCode = result.object.zipCode;
+                    temp.detailedAddress = result.object.detailedAddress;
+                    temp.awsDataId = awsDataId;
+                    PIData[Id] = temp;
+                };
+                for(var i=0;i<tableDataStr.length;i++){
+                    if(tableDataStr[i].address.AWS_Data_Id__c){
+                        correct++;
+                        AWSService.queryRepair(staticResource.queryUrl,
+                                                tableDataStr[i].address.AWS_Data_Id__c,
+                                                tableDataStr[i].address.Id,
+                                                tableDataStr[i].address.Contacts__r.AWS_Data_Id__c,
+                                                searchCallBack,
+                                                staticResource.token);
+                    } 
+                }
+                var interval=self.setInterval(function (){
+                    console.log('setInterval index= ' + index);
+                    if(index == correct){
+                        console.log('PIDATA = ' + JSON.stringify(PIData))
+                        resolve('success')
+                        clearInterval(interval)
+                    }
+                },1000);
+            });
+            return p;
+        }
+
+        function q2(){
+            sforce.connection.sessionId = '{!GETSESSIONID()}';
+            var p = new Promise(function(resolve, reject){
+                //鏌ヨ鑱旂郴浜虹殑鏁版嵁
+                let queryBack = function queryBack(result) {
+                    let contacts = result.object;
+                    if(contacts == null){
+                        return;
+                    }
+                    for(var i=0;i<result.object.length;i++){
+                        for(let key in PIData){
+                            if(result.object[i].dataId == PIData[key].awsDataId){
+                                PIData[key].lastName = result.object[i].lastName;
+                            }
+                        }
+                    }
+                }
+                var condition = ''
+                for(var i=0;i<tableDataStr.length;i++){
+                    if(tableDataStr[i].address.Contacts__c){
+                        condition += "," + "\'"+tableDataStr[i].address.Contacts__c+"\'";
+                    }
+                }
+                condition = condition.substr(1);
+                console.log('condition = ' + condition);
+                var record = sforce.connection.query("select AWS_Data_Id__c from Contact where id in("+condition+")");
+                var records = record.getArray("records");
+                for(var i =0;i<records.length;i++){
+                    if(records[i].AWS_Data_Id__c){
+                        contactDataIds.push(records[i].AWS_Data_Id__c);
+                    }
+                }
+                let searchPayload = new Object();
+                searchPayload.dataIds = contactDataIds;
+                searchPayload.contactName = '';
+                console.log('contactDataIds = ' + contactDataIds);
+                AWSService.search(staticResourceContact.searchUrl, JSON.stringify(searchPayload), queryBack, staticResourceContact.token);
+            });
+        }
+        //鏌ヨ鏁忔劅瀛楁
+        function queryPI(){
+            //blockme();
+            tableDataStr = JSON.parse(document.getElementById('allPage:allForm:tableValueFrontEnd').value);
+            PIData = {};
+            contactDataIds = [];
+            console.log(tableDataStr)
+            q1().then(function(data){
+                        return q2(data);
+                    })
+            //unblockUI();
+        }
+        
+
+        function showPIDiv(awsDataId){
+            if(awsDataId.length == 0 || PIData[awsDataId]==null){
+                return
+            }
+            console.log('awsDataId Value:'+awsDataId);
+            let parentNode = document.getElementById(awsDataId);
+            let createDiv = document.createElement("div");  
+            createDiv.id = awsDataId+"_PI";  
+            let piInformation = '';
+            
+            if(PIData[awsDataId].lastName){
+                piInformation = '鑱旂郴浜�: '+PIData[awsDataId].lastName+
+                '\n鐢佃瘽: '+PIData[awsDataId].telephone+
+                '\n閭紪: '+PIData[awsDataId].zipCode+
+                '\n璇︾粏鍦板潃: '+PIData[awsDataId].detailedAddress
+            }else{
+                piInformation = '鑱旂郴浜�: null'+
+                '\n鐢佃瘽: '+PIData[awsDataId].telephone+
+                '\n閭紪: '+PIData[awsDataId].zipCode+
+                '\n璇︾粏鍦板潃: '+PIData[awsDataId].detailedAddress
+            }
+            //let piInformation = 'Name:'+contact['943114607025717249'].lastName +'\n' +'Phone:'+contact['943114607025717249'].phone
+            createDiv.innerText = piInformation;
+            let x=window.event.x;
+            let y=window.event.y; 
+            createDiv.style.left=x;  
+            createDiv.style.top=y;  
+            createDiv.style.height='100px';  
+            createDiv.style.width='100px'; 
+            createDiv.style.background="#dddddd";
+            createDiv.style.position = "absolute";
+            parentNode.appendChild(createDiv);  
+            parentNode.style.position = "relative";
+        }
+
+        function hidePIDiv(awsDataId){
+            if(awsDataId.length == 0 || PIData[awsDataId]==null){
+                return
+            }
+            document.getElementById(awsDataId+'_PI').remove();
+        }
+
+        function replaceSearchContactLookup() {
+            if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c') != null){
+                let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:oppBlock2:UpdAddressId:Contacts__c\')" alt="Reference Document Number Lookup" class="lookupIcon"  title="Reference Document Number Lookup (New Window)"/>';
+                let lookUpNode = htmlToElement(contactHtmlString);
+                console.log(lookUpNode);
+                let parentNode = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').parentNode;
+                parentNode.appendChild(lookUpNode);
+                if(contactInfoStr){
+                    console.log('closePopup:'+contactInfoStr);
+                    let contactInfo = JSON.parse(contactInfoStr);
+                    let contactNodeId = 'allPage:allForm:oppBlock2:UpdAddressId:contactIdValue';
+                    document.getElementById(contactNodeId).value = contactInfo.ContactId;
+                    document.getElementById(closeField).value = contactInfo.Name; 
+                }                 
+            }
+        }
+
+        function htmlToElement(html) {
+            var template = document.createElement('template');
+            html = html.trim(); // Never return a text node of whitespace as the result
+            template.innerHTML = html;
+            return template.content.firstChild;
+        }
+
+        //鑷畾涔塴ookup鏌ヨ
+        function searchContact(contactNodeId,field){
+            closeField = field;
+            let accountValue = "";
+            if (document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name')!=null) {
+                let accountNodeId = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name').id + '_lkid';
+                accountValue = document.getElementById(accountNodeId).value;   
+            } 
+            console.log(accountValue);
+            if(accountValue !='000000000000000'){
+                let baseUrl = "/apex/SearchContactPage";
+                let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
+                let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
+                newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam);
+                if (window.focus) {
+                    newSearchContactWindow.focus();
+                }
+                return false;
+            }else{
+                console.log('璇峰厛閫夋嫨瀹㈡埛鍐嶉�夋嫨鑱旂郴浜�')
+            }
+        }
+
+        function closePopupWindow() {
+            if (null != newSearchContactWindow) {
+                newSearchContactWindow.close();
+            }
+            contactInfoStr = document.getElementById('allPage:allForm:contactId').value;
+            console.log('closePopup:'+contactInfoStr);
+            let contactInfo = JSON.parse(contactInfoStr);
+            let contactNodeId = 'allPage:allForm:oppBlock2:UpdAddressId:contactIdValue';
+            document.getElementById(contactNodeId).value = contactInfo.ContactId;
+            document.getElementById(closeField).value = contactInfo.Name;     
+        }
+        function queryRecordType(){
+            if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name').value){
+                queryRecordType();
+            }
+        }
+        //2022 02 28 寮犲崕寤� display PI Data end
     </script>
     <apex:form id="allForm">
-        <div id="tab01">
+        <apex:inputHidden id="tableValueFrontEnd" value="{!tableDataStr}"/>
+        <apex:inputHidden value="{!contactId}" id="contactId"/>
+        <apex:inputHidden value="{!insUpdDataStr}" id="insUpdDataStr"/>
+        <div id="tab01">            
             <!-- 椤甸潰鏁版嵁鍒濆鍖栨柟娉� -->
             <apex:actionFunction name="init" action="{!init}" rerender="oppBlock1,message,checEventFrame" onComplete="unblockUI();"></apex:actionFunction>
             <!-- 妫�绱㈡暟鎹煡璇㈡柟娉� -->
-            <apex:actionFunction name="searchBtn" action="{!searchBtn}" rerender="oppBlock1,message,checEventFrame" onComplete="unblockUI();"></apex:actionFunction>
+            <apex:actionFunction name="searchBtn" action="{!searchBtn}" rerender="oppBlock1,message,checEventFrame,tableValueFrontEnd" onComplete="unblockUI();">
+                <apex:param name="addressDataIds" assignTo="{!addressDataIds}" value=""></apex:param>
+            </apex:actionFunction>
             <!-- 閲囩敤鏂规硶 -->
             <apex:actionFunction name="adoptSave" action="{!adoptSave}" rerender="oppBlock2,message" onComplete="unblockUI();">
                 <apex:param name="adoptId" assignTo="{!adoptId}" value="" />
                 <apex:param name="isUpload" assignTo="{!isUpload}" value="" />
             </apex:actionFunction>
             <!-- 淇濆瓨鍜屼慨鏀规柟娉� -->
-            <apex:actionFunction name="save" action="{!save}" rerender="oppBlock2,message" onComplete="unblockUI();{!IF(isSearchBtn,'searchBtnJs()',false)}"></apex:actionFunction>
+            <apex:actionFunction name="save" action="{!save}" rerender="oppBlock2,message" onComplete="unblockUI();{!IF(isSearchBtn,'searchBtnJs()',false)};Trans()"></apex:actionFunction>
+            <!-- 鏌ヨ瀹㈡埛璁板綍绫诲瀷鏂规硶 -->
+            <apex:actionFunction name="queryRecordType" action="{!queryRecordType}" rerender="oppBlock2,message" onComplete="unblockUI();"></apex:actionFunction>
             <!-- 鐐瑰嚮淇敼鎸夐挳鑾峰彇淇敼鏁版嵁鏂规硶 -->
-            <apex:actionFunction name="onEditor" action="{!onEditor}" rerender="oppBlock2,checEventFrame" onComplete="unblockUI();">
+            <apex:actionFunction name="onEditor" action="{!onEditor}" rerender="oppBlock2,checEventFrame,insUpdDataStr" onComplete="decrypt();unblockUI();">
                 <apex:param name="UpdId" assignTo="{!UpdId}" value="" />
             </apex:actionFunction>
             <!-- 澶嶅埗鏂规硶 -->
-            <apex:actionFunction name="onCopy" action="{!onCopy}" rerender="oppBlock2,checEventFrame" onComplete="unblockUI();">
+            <apex:actionFunction name="onCopy" action="{!onCopy}" rerender="oppBlock2,checEventFrame," onComplete="decrypt();unblockUI();">
                 <apex:param name="UpdId" assignTo="{!UpdId}" value="" />
             </apex:actionFunction>
             <!-- 杩斿洖鐖堕〉闈� -->
@@ -148,7 +595,7 @@
                             </a>
                         </td>
                         <td style="width: 20%">
-                            <apex:commandButton onclick="searchBtnJs();return false;"  rendered="true" value="妫�绱�" style="width:60px;"/>
+                            <apex:commandButton onclick="searchBtnJs();return false;"  rendered="true" value="妫�绱�" style="width:60px;"  onComplete="unblockUI();"/>
                             &nbsp;&nbsp;
                             <!-- <apex:commandButton onclick="onAdoptJs();return false;"  rendered="true" value="閲囩敤" style="width:60px;background:#98c1fbf7"/>
                             &nbsp;&nbsp; -->
@@ -202,8 +649,9 @@
                                         <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;">
-                                            <apex:outputfield value="{!or.address.Contacts__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>
                                         </td>
                                         <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                             <apex:outputText value="{!or.address.Telephone__c}" />
@@ -220,9 +668,9 @@
                                         <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
                                             <apex:outputText value="{!or.address.Detailed_Address__c}" />
                                         </td>
-                                        <td align="center" style="vertical-align: inherit;width:30px;">
+                                        <!-- <td align="center" style="vertical-align: inherit;width:30px;">
                                             <apex:commandButton value=" 缂栬緫 " onclick="onEditorJs('{!or.address.id}');return false;" style="background:#98c1fbf7;display:{!or.canEdit};"/>
-                                        </td>
+                                        </td> -->
                                         <td align="center" style="vertical-align: inherit;width:30px;">
                                             <apex:commandButton value=" 澶嶅埗 " onclick="onCopyJs('{!or.address.id}');return false;" style="background: #98c1fbf7;display:{!or.canCopy};"/>
                                         </td>
@@ -233,17 +681,28 @@
                                     <apex:variable value="{!cnt + 1}" var="cnt" />
                                 </apex:repeat>
                             </tbody>
+                            <script>
+                                console.log('queryPI();')
+                                queryPI();
+                            </script>
                         </table>
                     </apex:outputPanel>
                 </apex:pageblocksection>
             </apex:pageBlock>
+            
         </div>
         <div id="tab03">
             <apex:pageBlock id="oppBlock2" tabStyle="Report">
                 <apex:pageblocksection title="缂栬緫鍦板潃" id="UpdAddressId" rendered="true" columns="4">
                     <apex:inputfield value="{!insUpdData.Address_Classification__c}" id="Address_Classification__c" />
-                    <apex:inputfield value="{!insUpdData.Customer__c}" id="Customer__r_Name" required="false" />
-                    <apex:inputfield value="{!insUpdData.Contacts__c}" id="Contacts__c" required="false"/>
+                    <apex:inputfield value="{!insUpdData.Customer__c}" id="Customer__r_Name" required="false" onchange="queryRecordType();" />
+                    <!-- Before PIPL 20220308 -->
+                    <!-- <apex:inputfield value="{!insUpdData.Contacts__c}" id="Contacts__c" required="false"/> -->
+                    <!-- Add By Li Jun for PIPL 20220308 Start -->
+                    <apex:inputText label="鑱旂郴浜�" disabled="true" value="{!contactNameValue}" id="Contacts__c">                       
+                    </apex:inputText>
+                    <apex:inputHidden id="contactIdValue" value="{!contactIdValue}"/>
+                     <!-- Add By Li Jun for PIPL 20220308 End -->
                     <apex:inputfield value="{!insUpdData.Create_Contacts__c}" id="Create_Contacts__c" required="false"/>
 
                     <apex:inputfield value="{!insUpdData.Province__c}" id="Province__r_Name" style="" />
@@ -253,13 +712,28 @@
                     <!-- <apex:pageblockSectionItem /> -->
                     <!-- <apex:inputTextarea value="{!insUpdData.Detailed_Address__c}" id="Detailed_Address__c" style="resize:vertical;width: 90%" rows="3" cols="3"/> -->
                     <apex:inputfield value="{!insUpdData.Detailed_Address__c}" id="Detailed_Address__c" style="resize:vertical;width: 98%"/>
+
+                    <div id="errorMsg" class="errorMsg"></div>
+
+                    <apex:inputHidden id="LastName_Encrypted__c"         value="{!newCon.LastName_Encrypted__c}"/>
+                    <apex:inputHidden id="Con_AWS_Data_Id__c"            value="{!newCon.AWS_Data_Id__c}"/>
+
+                    <apex:inputHidden id="Add_AWS_Data_Id__c"            value="{!insUpdData.AWS_Data_Id__c}"/>
+                    <apex:inputHidden id="Telephone_Encrypted__c"        value="{!insUpdData.Telephone_Encrypted__c}"/>
+                    <apex:inputHidden id="ZipCode_Encrypted__c"          value="{!insUpdData.ZipCode_Encrypted__c}"/>
+                    <apex:inputHidden id="Detailed_Address_Encrypted__c" value="{!insUpdData.Detailed_Address_Encrypted__c}"/>
+                    <apex:inputHidden id="CustomerRecordType"            value="{!accRecordTypeId}"/>
                 </apex:pageblocksection>
 
                 <div style="text-align: center;">
-                    <apex:commandButton value="淇濆瓨" onclick="savaJs();return false;" rendered="true" />
+                    <apex:commandButton immediate="true" value="淇濆瓨" onclick="savaJs();" rerender="dummy"  />
                 </div>
+                <script>
+                    replaceSearchContactLookup();
+                </script>
             </apex:pageBlock>
-        </div>
+        </div>        
+        
     </apex:form>
     <apex:outputPanel id="checEventFrame">
       <script type="text/javascript">

--
Gitblit v1.9.1