From 03a6b8730cde75e4c42634b676c96dd9caeda07f Mon Sep 17 00:00:00 2001 From: Li Jun <buli@deloitte.com.cn> Date: 星期四, 21 四月 2022 13:48:14 +0800 Subject: [PATCH] ReportRecordTypeIssue --- force-app/main/default/pages/NewAndEditReport.page | 309 ++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 231 insertions(+), 78 deletions(-) diff --git a/force-app/main/default/pages/NewAndEditReport.page b/force-app/main/default/pages/NewAndEditReport.page index fe838e7..691a68c 100644 --- a/force-app/main/default/pages/NewAndEditReport.page +++ b/force-app/main/default/pages/NewAndEditReport.page @@ -46,6 +46,15 @@ errorMsgNode.className = ''; } + function getCKEinstance(api_name){ + let t = jQuery("label[for$='textAreaDelegate_"+api_name+"']").parent().next().find("textarea")[0]; + if(t && t.id){ + return CKEDITOR.instances[t.id] + + } + return null; + } + //1銆傝幏鍙栨墍鏈夊瓧娈靛�� function getReportInformation() { let nodelist = document.querySelectorAll("[data-id]"); @@ -63,11 +72,36 @@ result[nodelist[index].getAttribute("data-id")] = nodelist[index].checked; } else if (nodelist[index].type == 'select-multiple') { //nodelist[index].getAttribute("data-id") + //let targets = document.querySelector("[data-id=" + multiple + "]").nextSibling.children[0].children[1].children[2].innerText; + //Before Update By Li Jun 20220411 + // let targets = document.querySelector("[data-id=" + multiple + "]").parentNode.children[2].children[0].children[1].children[2].children[0].innerText; + // targets = targets.replace(/\n/g, ";"); + // console.log('targets = ' + targets); + // result[nodelist[index].getAttribute("data-id")] = targets; + //Before Update By Li Jun 20220411 + + //After Update By Li Jun 20220411 Start let multiple = nodelist[index].getAttribute("data-id"); - let targets = document.querySelector("[data-id=" + multiple + "]").nextSibling.children[0].children[1].children[2].innerText; - targets = targets.replace(/\n/g, ";"); - console.log('targets = ' + targets); - result[nodelist[index].getAttribute("data-id")] = targets; + let targets = document.querySelector("[data-id=" + multiple + "]").options; + let selValues = []; + for(i=0; i < targets.length; i++){ + if(targets[i].selected){ + selValues.push(targets[i].value); + } + } + let setValuesStr = JSON.stringify(selValues); + setValuesStr = setValuesStr.substring(1,setValuesStr.length-1); + if(setValuesStr){ + setValuesStr = setValuesStr.replace(/"/g,""); + if(setValuesStr.indexOf(',')!=-1){ + setValuesStr = setValuesStr.replace(/,/g,";"); + } + } + console.log('targets = ' + setValuesStr); + result[nodelist[index].getAttribute("data-id")] = setValuesStr; + //After Update By Li Jun 20220411 End + + } else { result[nodelist[index].getAttribute("data-id")] = nodelist[index].value; } @@ -77,38 +111,65 @@ } } //鎵嬫湳鍒嗙被1 - result.Technical_Category1__c = document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:2:j_id38')!=null?document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:2:j_id38').value:''; + if(api_id_map['Technical_Category1__c']){ + result.Technical_Category1__c = document.getElementById(api_id_map['Technical_Category1__c']).value!='_\x01_'?document.getElementById(api_id_map['Technical_Category1__c']).value:''; + } + //result.Technical_Category1__c = document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:2:j_id38')!=null?document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:2:j_id38').value:''; //鎵嬫湳鍒嗙被2 - result.Technical_Category2__c = document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:4:j_id38')!=null?document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:4:j_id38').value:''; + if(api_id_map['Technical_Category2__c']){ + result.Technical_Category2__c = document.getElementById(api_id_map['Technical_Category2__c']).value!='_\x01_'?document.getElementById(api_id_map['Technical_Category2__c']).value:''; + } + //result.Technical_Category2__c = document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:4:j_id38')!=null?document.getElementById('page:form:j_id5:j_id35:4:j_id36:j_id37:4:j_id38').value:''; //鐩殑2 - if(document.getElementById('page:form:j_id5:j_id35:2:j_id36:j_id37:1:j_id38')){ - result.Purpose2__c = document.getElementById('page:form:j_id5:j_id35:2:j_id36:j_id37:1:j_id38').value; + if(api_id_map['Purpose2__c']){ + result.Purpose2__c = document.getElementById(api_id_map['Purpose2__c']).value; } + // if(document.getElementById('page:form:j_id5:j_id35:2:j_id36:j_id37:1:j_id38')){ + // result.Purpose2__c = document.getElementById('page:form:j_id5:j_id35:2:j_id36:j_id37:1:j_id38').value; + // } //瀵屾枃鏈璧嬪�� + if(getCKEinstance('Customer_sigh_photo__c')){ + result.Customer_sigh_photo__c = getCKEinstance('Customer_sigh_photo__c').getData() + } + if(getCKEinstance('Photo1__c')){ + result.Photo1__c = getCKEinstance('Photo1__c').getData() + } + if(getCKEinstance('Photo2__c')){ + result.Photo2__c = getCKEinstance('Photo2__c').getData() + } + if(getCKEinstance('Photo3__c')){ + result.Photo3__c = getCKEinstance('Photo3__c').getData() + } + if(getCKEinstance('VOC_follow_up_result__c')){ + result.VOC_follow_up_result__c = getCKEinstance('VOC_follow_up_result__c').getData() + } + if(getCKEinstance('VOC_follow_up_result1__c')){ + result.VOC_follow_up_result1__c = getCKEinstance('VOC_follow_up_result1__c').getData() + } //鐢ㄦ埛绛惧瓧鐨勭収鐗� - if(document.querySelector("[aria-describedby = 'cke_34']")){ - result.Customer_sigh_photo__c = document.querySelector("[aria-describedby = 'cke_34']").contentWindow.document.getElementsByTagName('body')[0].innerHTML - } - //鐓х墖1 Photo1__c - if(document.querySelector("[aria-describedby = 'cke_42']")){ - result.Photo1__c = document.querySelector("[aria-describedby = 'cke_42']").contentWindow.document.getElementsByTagName('body')[0].innerHTML - } - //鐓х墖2 Photo2__c - if(document.querySelector("[aria-describedby = 'cke_75']")){ - result.Photo2__c = document.querySelector("[aria-describedby = 'cke_75']").contentWindow.document.getElementsByTagName('body')[0].innerHTML - } - //鐓х墖3 Photo3__c - if(document.querySelector("[aria-describedby = 'cke_108']")){ - result.Photo3__c = document.querySelector("[aria-describedby = 'cke_108']").contentWindow.document.getElementsByTagName('body')[0].innerHTML - } - //瀵瑰簲缁撴灉 VOC_follow_up_result__c cke_38 - if(document.querySelector("[aria-describedby = 'cke_38']")){ - result.VOC_follow_up_result__c = document.querySelector("[aria-describedby = 'cke_38']").contentWindow.document.getElementsByTagName('body')[0].innerHTML - } - //瀵瑰簲缁撴灉绗竴娆� VOC_follow_up_result1__c cke_71 - if(document.querySelector("[aria-describedby = 'cke_71']")){ - result.VOC_follow_up_result1__c = document.querySelector("[aria-describedby = 'cke_71']").contentWindow.document.getElementsByTagName('body')[0].innerHTML - } + // if(document.querySelector("[aria-describedby = 'cke_34']")){ + // result.Customer_sigh_photo__c = document.querySelector("[aria-describedby = 'cke_34']").contentWindow.document.getElementsByTagName('body')[0].innerHTML + // } + // //鐓х墖1 Photo1__c + // if(document.querySelector("[aria-describedby = 'cke_42']")){ + // result.Photo1__c = document.querySelector("[aria-describedby = 'cke_42']").contentWindow.document.getElementsByTagName('body')[0].innerHTML + // } + // //鐓х墖2 Photo2__c + // if(document.querySelector("[aria-describedby = 'cke_75']")){ + // result.Photo2__c = document.querySelector("[aria-describedby = 'cke_75']").contentWindow.document.getElementsByTagName('body')[0].innerHTML + // } + // //鐓х墖3 Photo3__c + // if(document.querySelector("[aria-describedby = 'cke_108']")){ + // result.Photo3__c = document.querySelector("[aria-describedby = 'cke_108']").contentWindow.document.getElementsByTagName('body')[0].innerHTML + // } + // //瀵瑰簲缁撴灉 VOC_follow_up_result__c cke_38 + // if(document.querySelector("[aria-describedby = 'cke_38']")){ + // result.VOC_follow_up_result__c = document.querySelector("[aria-describedby = 'cke_38']").contentWindow.document.getElementsByTagName('body')[0].innerHTML + // } + // //瀵瑰簲缁撴灉绗竴娆� VOC_follow_up_result1__c cke_71 + // if(document.querySelector("[aria-describedby = 'cke_71']")){ + // result.VOC_follow_up_result1__c = document.querySelector("[aria-describedby = 'cke_71']").contentWindow.document.getElementsByTagName('body')[0].innerHTML + // } if(result.From__c){ result.From__c = result.From__c.replace(/\//g, '-')+':00'; } @@ -122,24 +183,24 @@ function validateFieldValueFormate() { //VOC_Informer_Contact__c,Caller_phone_c__c let error_msg = ''; - let textEmail = "[data-id=' Follow_staff_email__c']"; - let textPhone1 = "[data-id='VOC_Informer_Contact__c']"; - let textPhone2 = "[data-id='Caller_phone_c__c']"; - //Email - let email = document.querySelector(textEmail); - if(email && !/^[\w-]{3,12}@[\da-zA-Z]{2,16}\.[a-zA-Z]+$/.test(email.value)){ - error_msg += ';瀵瑰簲鑰�(閭)鏍煎紡閿欒'; - } + // let textEmail = "[data-id=' Follow_staff_email__c']"; + // let textPhone1 = "[data-id='VOC_Informer_Contact__c']"; + // let textPhone2 = "[data-id='Caller_phone_c__c']"; + // //Email + // let email = document.querySelector(textEmail); + // if(email && !/^[\w-]{3,12}@[\da-zA-Z]{2,16}\.[a-zA-Z]+$/.test(email.value)){ + // error_msg += ';瀵瑰簲鑰�(閭)鏍煎紡閿欒'; + // } - let phone1 = document.querySelector(textPhone1); - if(phone1 && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone1.value)){ - error_msg += ';淇℃伅鎻愪緵浜鸿仈绯绘柟寮忥紙鐢佃瘽锛夊彿鐮侀敊璇�'; - } + // let phone1 = document.querySelector(textPhone1); + // if(phone1 && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone1.value)){ + // error_msg += ';淇℃伅鎻愪緵浜鸿仈绯绘柟寮忥紙鐢佃瘽锛夊彿鐮侀敊璇�'; + // } - let phone2 = document.querySelector(textPhone2); - if(phone2 && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone2.value)){ - error_msg += ';鑱旂郴鐢佃瘽鍙风爜閿欒'; - } + // let phone2 = document.querySelector(textPhone2); + // if(phone2 && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone2.value)){ + // error_msg += ';鑱旂郴鐢佃瘽鍙风爜閿欒'; + // } for(let e of document.getElementsByTagName('select')){ for(let op of e.options){ @@ -174,6 +235,33 @@ return blankRequiredFields; } + var GetEleByClass = function(class_name){ + let eles = document.getElementsByClassName(class_name); + if(eles.length > 0) return eles[0]; + return null; + } + + var GetEleApiName = function(ele){ + for(let ci in ele.classList){ + let c = ele.classList[ci]; + if(c.indexOf('{!ApiPrefix}'+'_')>-1){ + return c.replace('{!ApiPrefix}'+'_',''); + } + } + return ''; + } + + function IsFormTag(tag_name){ + if (!tag_name) { + return false; + } + return ['input','select','textarea'].indexOf(tag_name.toLowerCase())>-1; + } + + function IsFormElement(e){ + return IsFormTag(e.tagName); + } + //4.鑾峰彇瑕佸姞瀵嗙殑瀛楁 function getPIPayload(reportJson) { let reportPayloadList = []; @@ -202,7 +290,7 @@ //5.鏂板缓鎴栫紪杈� function ProcessPI(reportJson, payloadForNewPI) { blockme(); - if ({!isNewMode}) { + if ({!isNewMode} || {!isCloneMode} || !'{!AWSDataId}') {//Add by Li Jun for PIPL 20220413 NewPIToAWS(reportJson, payloadForNewPI) }else { UpdatePIToAWS(reportJson, payloadForNewPI) @@ -357,6 +445,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 +455,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 +463,7 @@ } return false; }else{ - alertErrorMessage('{!PIPL_Input_Account_Error_Msg}'); + alertErrorMessage('璇峰厛閫夋嫨绉戝锛�'); } } //绐楀彛鍏抽棴鏃跺彂鐢� @@ -437,10 +527,14 @@ payloadJson.age_Encrypted__c = result.object[0].ageEncrypt; payloadJson.Medical_History_Encrypted__c = result.object[0].medicalHistoryEncrypt; payloadJson.sex_Encrypted__c = result.object[0].sexEncrypt; - if (isNewMode) { + if (isNewMode || {!isCloneMode}||!'{!AWSDataId}') {//Add by Li Jun for PIPL 20220413 payloadJson.AWS_Data_Id__c = result.object[0].dataId; + delete payloadJson.OwnerId; } else { payloadJson.AWS_Data_Id__c = '{!AWSDataId}'; + } + if('{!rtTypeId}'){ + payloadJson.RecordTypeId = '{!rtTypeId}';//Add by Li Jun for Record Type Issue 20220421 } return payloadJson; } @@ -522,7 +616,7 @@ <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> <h2 class="mainTitle">鎶ュ憡涔︾紪杈�</h2> </td> - <td class="pbButton" id="topButtonRow"> + <td class="pbButton" id="topButtonRow" style="pointer-events: none; opacity: 0.4;"> <input class="btn" type="Button" value="淇濆瓨" onclick="saveReportProcess('Save')" /> <input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveReportProcess('SaveAndNew')" /> <apex:commandButton action="{!cancel}" value="鍙栨秷" /> @@ -545,8 +639,14 @@ <!--Each section has layoutFields, let's iterate them as well--> <apex:repeat value="{!layoutSection.layoutFields}" var="layoutField"> - <apex:inputField html-data-id="{!layoutField.fieldAPI}" styleClass="{!layoutField.fieldAPI}" value="{!Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" + <!-- <apex:inputField html-title="{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" value="{!Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" + required="{!layoutField.isRequired}" /> --> + <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}" required="{!layoutField.isRequired}" /> + <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI!='RecordTypeId'}" + required="{!layoutField.isRequired}" /> + <apex:outputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}" + /> <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}"> </apex:pageblocksectionitem> </apex:repeat> @@ -554,6 +654,18 @@ </apex:pageBlockSection> </apex:repeat> <script> + var init_nodes = document.getElementsByClassName("PIBackApi"); + var api_id_map={}; + for(let ei in init_nodes){ + let e = init_nodes[ei]; + if(IsFormElement(e)){ + if(e.getAttribute("multiple") != 'multiple' || e.style.display == 'none' && e.id.indexOf('selected') < 0){ + api_id_map[GetEleApiName(e)] = e.id; + } + + } + } + console.log(api_id_map); sfdcPage.appendToOnloadQueue(function () { //鍒ゆ柇鏄惁涓哄彧璇婚�夐」 var layoutSections = JSON.parse('{!layoutSectionsStr}'); @@ -562,7 +674,16 @@ for (let n = 0; n < layoutSection.length; n++) { let layoutField = layoutSection[n]; if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { - document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField); + let e = document.querySelector("[data-id='"+layoutField.fieldAPI+"']"); + e.disabled = !(layoutField.editableField); + if (!(layoutField.editableField)) { + if (e.getAttribute("multiple") && e.getAttribute("multiple") == 'multiple') { + e.parentNode.classList.add("disabledbutton"); + } + if (e.tagName == 'DIV') { + e.classList.add("disabledbutton"); + } + } } } } @@ -578,35 +699,67 @@ 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}') + if(document.querySelector("[data-id='Loaner_request_no1__c']")){ + document.querySelector("[data-id='Loaner_request_no1__c']").value = '{!no1Name}' + document.getElementById(document.querySelector("[data-id='Loaner_request_no1__c']").id + '_lkid').value = '{!no1Id}' + } + } + + document.getElementById('topButtonRow').style = ''; +聽 聽 聽 聽 聽 聽 聽document.getElementById('bottomButtonRow').style = ''; + + 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"> @@ -615,7 +768,7 @@ <tr> <td class="pbTitle"> <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> </td> - <td class="pbButtonb" id="bottomButtonRow"> + <td class="pbButtonb" id="bottomButtonRow" style="pointer-events: none; opacity: 0.4;"> <input class="btn" type="Button" value="淇濆瓨" onclick="saveReportProcess('Save')" /> <input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveReportProcess('SaveAndNew')" /> <apex:commandButton action="{!cancel}" value="鍙栨秷" /> -- Gitblit v1.9.1