From f127c76b19f5316032d4bed127a1dde710c48d74 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期四, 24 三月 2022 10:10:36 +0800
Subject: [PATCH] PIPLFunctionFixBug0324

---
 force-app/main/default/pages/NewAndEditReport.page |   79 +++++++++++++++++++++++++++------------
 1 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/force-app/main/default/pages/NewAndEditReport.page b/force-app/main/default/pages/NewAndEditReport.page
index fe838e7..5c4b6ed 100644
--- a/force-app/main/default/pages/NewAndEditReport.page
+++ b/force-app/main/default/pages/NewAndEditReport.page
@@ -357,6 +357,8 @@
         //鑷畾涔塴ookup鏌ヨ
         function searchContact(contactNodeId,field){
             closeField = field;
+            //searchContactKeyWord
+            let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value
             let accountValue = "";
             if (document.querySelector("[data-id='Hospital_Department__c']")) {
                 let accountNodeId = document.querySelector("[data-id='Hospital_Department__c']").id + '_lkid';
@@ -365,7 +367,7 @@
             console.log(accountValue);
             if(accountValue !='000000000000000'){
                 let baseUrl = "/apex/SearchContactPage";
-                let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
+                let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue+"&searchContactKeyWord=" + searchContactKeyWord;
                 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) {
@@ -373,7 +375,7 @@
                 }
                 return false;
             }else{
-                alertErrorMessage('{!PIPL_Input_Account_Error_Msg}');
+                alertErrorMessage('璇峰厛閫夋嫨绉戝锛�');
             }
         }
         //绐楀彛鍏抽棴鏃跺彂鐢�
@@ -578,35 +580,62 @@
                     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");
+
+                    //濡傛灉鏄疧PD璁″垝杩囨潵鐨�
+                    if('{!no1Name}' != '' && '{!no1Id}' != ''){
+                        console.log('name = '+'{!no1Name}')
+                        console.log('Id = '+'{!no1Id}')
+                        document.querySelector("[data-id='Loaner_request_no1__c']").value = '{!no1Name}'
+                        document.getElementById(document.querySelector("[data-id='Loaner_request_no1__c']").id + '_lkid').value = '{!no1Id}'
+                    }
+
+                    let previous_value = {};
+                    jQuery(".lookupInput input").each(function(i,e){
+                        let je =jQuery(e);
 
                         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;">');
+                        if(['Practitioner1__c','Practitioner2__c','Practitioner3__c','Practitioner4__c','Practitioner5__c','Person_In_Charge__c'].indexOf(dataid) < 0) return;
+
+                        jQuery(e).focus(function(){
+                            previous_value[this.id] = this.value;
+                        })
+
+                        jQuery(e).change(function(){
+                            if (previous_value[this.id] != jQuery(this).val()) {
+                                document.getElementById(this.id+'_lkid').value = '';
+                            }
+                        })
                     })
 
-                    jQuery(".lookupInput").on("mouseenter", "img[generate]", function (e) {
-                        this.className = "closeIconOn";
-                    });
+                    // jQuery(".lookupInput").each(function (i, e) {
+                    //     let je = jQuery(e).find('input');
+                    //     je.attr("readonly", "");
+                    //     je.css("background", "unset");
 
-                    jQuery(".lookupInput").on("mouseleave", "img[generate]", function (e) {
-                        this.className = "closeIcon"
-                    });
+                    //     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("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 = '';
-                            }
-                        }
-                    });
+                    // 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">

--
Gitblit v1.9.1