| | |
| | | <!-- |
| | | @description : |
| | | @author : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | @group : |
| | | @last modified on : 03-30-2022 |
| | | @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc |
| | | --> |
| | | <apex:page standardController="Consum_Apply__c" extensions="NewConsumApplyController" id="page"> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | | <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> |
| | |
| | | var VLookUpFields = new Set(['Loaner_medical_Staff__c', 'Hospital__c', 'Strategic_dept__c', 'Account__c', 'QIS_number__c', 'OPDPlan__c', 'Campaign__c', 'Rental_Apply__c', 'Shipment_address__c', 'Dealer__c', 'Old_Consum_Apply__c', 'DeliverySlip__c', 'OwnerId', 'OPD__c']); |
| | | var userVLookUpFields = ['Person_In_Charge__c', 'applyUser__c', 'CC_EmailUser__c', 'Assign_Person__c', 'Consum_Assistant__c', 'Consum_Assistant2__c', 'Consum_Assistant3__c', 'SalesManager__c', 'ZongjianApprovalManager__c', 'BuchangApprovalManagerSales__c', 'TongkuoZongjian__c']; |
| | | var redirectMode = 'Save'; |
| | | |
| | | function EditButton(isDisabled){ |
| | | var topele = document.getElementById('topButtonRow'); |
| | | var bottomele = document.getElementById('bottomButtonRow'); |
| | | |
| | | if (isDisabled) { |
| | | topele.classList.add("disabledbutton"); |
| | | bottomele.classList.add("disabledbutton"); |
| | | }else { |
| | | topele.classList.remove("disabledbutton"); |
| | | bottomele.classList.remove("disabledbutton"); |
| | | } |
| | | } |
| | | |
| | | //Redirect Required Parameter |
| | | var redirectCallBack = function redirectCallBack(sfId,errorMessage) { |
| | |
| | | |
| | | //Check If Insert Or Update |
| | | var insertOrUpdateBack = function insertOrUpdateBack(payloadJson, result, isNewMode) { |
| | | debugger |
| | | console.log(result); |
| | | let r = result; |
| | | console.log('Result from AWS' + JSON.stringify(r)); |
| | |
| | | payloadJson.Phone_Number_Encrypt__c = r.object[0].phoneNumberEncrypt; |
| | | payloadJson.Direct_Shippment_Address_Encrypt__c = r.object[0].directShippmentAddressEncrypt; |
| | | payloadJson.AWS_Data_Id__c = '{!AWSDataId}'; |
| | | if (isNewMode) { |
| | | if (isNewMode || {!isCloneMode}) { |
| | | payloadJson.AWS_Data_Id__c = r.object[0].dataId; |
| | | delete payloadJson.OwnerId; |
| | | } else { |
| | | payloadJson.AWS_Data_Id__c = '{!AWSDataId}'; |
| | | } |
| | | debugger |
| | | if('{!rtTypeId}'){ |
| | | payloadJson.RecordTypeId = '{!rtTypeId}';//Add by zhj for Record Type Issue 20220421 |
| | | } |
| | | return payloadJson; |
| | | } |
| | | |
| | | // New Or Edit |
| | | function ProcessPI(consumApplyJson, payloadForNewPI) { |
| | | blockme(); |
| | | if ({!isNewMode |
| | | }) { |
| | | if ({!isNewMode} || {!isCloneMode}) { |
| | | NewPIToAWS(consumApplyJson, payloadForNewPI) |
| | | }else { |
| | | UpdatePIToAWS(consumApplyJson, payloadForNewPI) |
| | |
| | | //富文本 |
| | | if(document.querySelector("[aria-describedby = 'cke_34']")){ |
| | | result.HP_received_sign_rich__c = document.querySelector("[aria-describedby = 'cke_34']").contentWindow.document.getElementsByTagName('body')[0].innerHTML |
| | | } |
| | | } |
| | | for (let index = 0; index < nodelist.length; index++) { |
| | | if (VLookUpFields.has(nodelist[index].getAttribute("data-id"))) { |
| | | console.log(nodelist[index].id.indexOf('lkwgt')); |
| | |
| | | } |
| | | } |
| | | for (let i = 0; i < userVLookUpFields.length; i++) { |
| | | let userVlookUpNodeValue = document.querySelector("[data-id='" + userVLookUpFields[i] + "']").children[1].value; |
| | | console.log('userVlookUpNodeValue:'+userVlookUpNodeValue); |
| | | if(userVlookUpNodeValue!='000000000000000'){ |
| | | result[userVLookUpFields[i]] = userVlookUpNodeValue; |
| | | } |
| | | if(document.querySelector("[data-id='" + userVLookUpFields[i] + "']")!=null){ |
| | | let userVlookUpNodeValue = document.querySelector("[data-id='" + userVLookUpFields[i] + "']").children[1].value; |
| | | console.log('userVlookUpNodeValue:'+userVlookUpNodeValue); |
| | | if(userVlookUpNodeValue!='000000000000000'){ |
| | | result[userVLookUpFields[i]] = userVlookUpNodeValue; |
| | | } |
| | | } |
| | | } |
| | | //格式化时间 |
| | | if(result.pickup_time__c){ |
| | | result.pickup_time__c = result.pickup_time__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.Request_Shipping_7days_Before__c){ |
| | | result.Request_Shipping_7days_Before__c = result.Request_Shipping_7days_Before__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.Request_shipping_day__c){ |
| | | result.Request_shipping_day__c = result.Request_shipping_day__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.Consum_Received_Day__c){ |
| | | result.Consum_Received_Day__c = result.Consum_Received_Day__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.Request_demo_time__c){ |
| | | result.Request_demo_time__c = result.Request_demo_time__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.Request_approval_time__c){ |
| | | result.Request_approval_time__c = result.Request_approval_time__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.Application_accept_time__c){ |
| | | result.Application_accept_time__c = result.Application_accept_time__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.Request_answer_time__c){ |
| | | result.Request_answer_time__c = result.Request_answer_time__c.replace(/\//g, '-')+':00'; |
| | | } |
| | | if(result.HP_received_sign_rich__c == '<br>'){ |
| | | result.HP_received_sign_rich__c = ''; |
| | | } |
| | | console.log(JSON.stringify(result)); |
| | | return result; |
| | |
| | | |
| | | //Base Process |
| | | function saveConsumApplyProcess(saveMode) { |
| | | EditButton(true); |
| | | |
| | | redirectMode = saveMode; |
| | | console.log('redirectMode' + redirectMode); |
| | | hiddenErrorMsgNode(); |
| | |
| | | |
| | | //Alert Error Message |
| | | function alertErrorMessage(errorMsg) { |
| | | let errorMsgNode = document.getElementById("page:form:msgContent"); |
| | | let errorMsgNode = document.getElementById("page:form:block:msgContent"); |
| | | errorMsg = '错误:无效数据。' + '\n' + errorMsg; |
| | | errorMsgNode.innerText = errorMsg; |
| | | errorMsgNode.className = 'pbError'; |
| | | unblockUI(); |
| | | EditButton(false); |
| | | } |
| | | |
| | | //Hide Error Message |
| | | function hiddenErrorMsgNode() { |
| | | let errorMsgNode = document.getElementById("page:form:msgContent"); |
| | | let errorMsgNode = document.getElementById("page:form:block:msgContent"); |
| | | errorMsgNode.innerText = ''; |
| | | errorMsgNode.className = ''; |
| | | } |
| | |
| | | let contactsInfo = JSON.parse('{!contactsInfo}'); |
| | | let dataId = contactsInfo[sfId]; |
| | | let url = staticResourcesContact.queryUrl + '?dataId=' + dataId; |
| | | fetch(url, { |
| | | method: 'GET', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | 'pi-token': staticResources.token |
| | | } |
| | | }).then((data) => { |
| | | return data.json(); |
| | | }).then((result) => { |
| | | let queryBackContactName = function queryBackContactName(result){ |
| | | document.querySelector("[data-id='Loaner_medical_Staff__c']").value = result.object.lastName; |
| | | }) |
| | | //document.querySelector("[data-id='LastName']").value = result.object.lastName; |
| | | }; |
| | | AWSService.query(staticResourcesContact.queryUrl, dataId, queryBackContactName, staticResourcesContact.token); |
| | | // fetch(url, { |
| | | // method: 'GET', |
| | | // headers: { |
| | | // 'Content-Type': 'application/json', |
| | | // 'pi-token': staticResources.token |
| | | // } |
| | | // }).then((data) => { |
| | | // return data.json(); |
| | | // }).then((result) => { |
| | | // document.querySelector("[data-id='Loaner_medical_Staff__c']").value = result.object.lastName; |
| | | // }) |
| | | } |
| | | //自定义lookup查询 |
| | | function searchContact(contactNodeId){ |
| | |
| | | let accountNodeId = document.querySelector("[data-id='Account__c']").id + '_lkid'; |
| | | accountValue = document.getElementById(accountNodeId).value; |
| | | } |
| | | let searchContactKeyWord = document.querySelector("[data-id='Loaner_medical_Staff__c']").value; |
| | | 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) { |
| | |
| | | </div> |
| | | <apex:form id="form"> |
| | | <apex:inputHidden value="{!contactId}" id="contactId"/> |
| | | <!-- Error Msg--> |
| | | <apex:outputPanel id="errorMsg"> |
| | | <apex:pageMessages id="msgContent" escape="false" /> |
| | | </apex:outputPanel> |
| | | <apex:pageblock > |
| | | <apex:pageblock id="block"> |
| | | <div class="pbHeader"> |
| | | <table cellspacing="0" cellpadding="0" border="0"> |
| | | <tbody> |
| | |
| | | <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="saveConsumApplyProcess('Save')" /> |
| | | <input class="btn" type="Button" value="保存并新建" onclick="saveConsumApplyProcess('SaveAndNew')" /> |
| | | <apex:commandButton action="{!cancel}" value="取消" /> |
| | |
| | | </tbody> |
| | | </table> |
| | | </div> |
| | | <!-- Error Msg--> |
| | | <div style="text-align: center;"> |
| | | <apex:outputPanel id="errorMsg"> |
| | | <apex:pageMessages id="msgContent" escape="false" /> |
| | | </apex:outputPanel> |
| | | </div> |
| | | <!-- Iterate the layoutSections, which is a list of sections --> |
| | | <apex:repeat value="{!layoutSections}" var="layoutSection"> |
| | | <apex:pageBlockSection title="{!layoutSection.name}" collapsible="{!layoutSection.allowCollapse}" columns="{!layoutSection.columns}"> |
| | | |
| | | <!--Each section has layoutFields, let's iterate them as well--> |
| | | <apex:repeat value="{!layoutSection.layoutFields}" var="layoutField"> |
| | | <apex:inputField html-data-id="{!layoutField.fieldAPI}" value="{!Consum_Apply__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" |
| | | <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Consum_Apply__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}" |
| | | required="{!layoutField.isRequired}" /> |
| | | <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Consum_Apply__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="{!Consum_Apply__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}" |
| | | /> |
| | | <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}"> |
| | | </apex:pageblocksectionitem> |
| | | </apex:repeat> |
| | |
| | | <script> |
| | | //Append Page |
| | | sfdcPage.appendToOnloadQueue(function () { |
| | | debugger |
| | | var layoutSections = JSON.parse('{!layoutSectionsStr}'); |
| | | for (let m = 0; m < layoutSections.length; m++) { |
| | | let layoutSection = layoutSections[m].layoutFields; |
| | | for (let n = 0; n < layoutSection.length; n++) { |
| | | let layoutField = layoutSection[n]; |
| | | if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { |
| | | 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"); |
| | | } |
| | | // let id = 'page:form:block:j_id34:10:j_id35:j_id36:0:j_id37'; |
| | | // let id2 = 'page:form:block:j_id34:9:j_id35:j_id36:0:j_id37' |
| | | // let lookUpSuffix = '_lkwgt'; |
| | | // // if(document.getElementById(id)){ |
| | | // // document.getElementById(id).classList.add("disabledbutton"); |
| | | // // document.getElementById(id + lookUpSuffix).classList.add("disabledbutton"); |
| | | // // } |
| | | // if(document.getElementById(id2)){ |
| | | // document.getElementById(id2 + lookUpSuffix).classList.add("disabledbutton"); |
| | | // } |
| | | if(document.querySelectorAll("[data-id='Old_Consum_Apply__c']")){ |
| | | document.querySelectorAll("[data-id='Old_Consum_Apply__c']")[0].classList.add("disabledbutton") |
| | | document.querySelectorAll("[data-id='Old_Consum_Apply__c']")[1].classList.add("disabledbutton") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //2. Query AWS Data by dataId |
| | | console.log('Mode for consumApply Page:' + {!isNewMode}); |
| | | if (!{!isNewMode}) { |
| | |
| | | //Replace Vlookup Field |
| | | replaceSearchContactLookup(); |
| | | document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton"); |
| | | |
| | | 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(['Loaner_medical_Staff__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").each(function(i,e){ |
| | | // let je =jQuery(e).find('input'); |
| | | // je.attr("readonly",""); |
| | | // je.css("background","unset"); |
| | | |
| | | // let dataid = je.attr('data-id'); |
| | | // if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return; |
| | | // 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("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"> |
| | |
| | | <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="saveConsumApplyProcess('Save')" /> |
| | | <input class="btn" type="Button" value="保存并新建" onclick="saveConsumApplyProcess('SaveAndNew')" /> |
| | | <apex:commandButton action="{!cancel}" value="取消" /> |