Li Jun
2022-05-11 1f7527ffae293e35c9a53b61f641186150328e4e
force-app/main/default/pages/NewAndEditInquiryForm.page
@@ -1,6 +1,6 @@
<apex:page standardController="Inquiry_form__c" extensions="NewAndEditInquiryFormController" id="page">
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
@@ -69,6 +69,9 @@
                } else {
                    payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
                }
                if('{!rtTypeId}'){
                    payloadJson.RecordTypeId = '{!rtTypeId}';//Add by zhj for Record Type Issue 20220421
                }
                return payloadJson;
            },
            queryBack:function (data) {
@@ -130,9 +133,22 @@
        function ProcessPI(sobjJson, payloadForNewPI) {
            blockme();
            if ({!isNewMode} || {!isCloneMode}) {
               NewPIToAWS(sobjJson, payloadForNewPI)
                NewPIToAWS(sobjJson, payloadForNewPI)
            }else {
                UpdatePIToAWS(sobjJson, payloadForNewPI)
            }
        }
        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");
            }
        }
@@ -153,7 +169,7 @@
        }
        function IsFormElement(tag_name){
            return ['input','select','textarea'].indexOf(tag_name)>-1;
            return ['input','select','textarea','div'].indexOf(tag_name)>-1;
        }
        function getPIPayload(sobjJson) {
@@ -162,22 +178,22 @@
        function validateFieldValueFormate() {
            let error_msg = '';
            let textEmail = "[data-id='Email__c']";
            let textPhone = "[data-id='Phone__c']";
            if (document.querySelector("[data-id='Email__c']").value != "" && document.querySelector("[data-id='Email__c']").value != null) {
                //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='Email__c']";
            // let textPhone = "[data-id='Phone__c']";
            // if (document.querySelector("[data-id='Email__c']").value != "" && document.querySelector("[data-id='Email__c']").value != null) {
            //     //Email
            //     let email = document.querySelector(textEmail);
            //     if(email && !/^[\w-]{3,12}@[\da-zA-Z]{2,16}\.[a-zA-Z]+$/.test(email.value)){
            //         error_msg += ';邮件格式错误';
            //     }
            // }
            if (document.querySelector("[data-id='Phone__c']").value != "" && document.querySelector("[data-id='Phone__c']").value != null) {
                let phone = document.querySelector(textPhone);
                if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
                    error_msg += ';电话号码错误';
                }
            }
            // if (document.querySelector("[data-id='Phone__c']").value != "" && document.querySelector("[data-id='Phone__c']").value != null) {
            //     let phone = document.querySelector(textPhone);
            //     if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
            //         error_msg += ';电话号码错误';
            //     }
            // }
            
            for(let ei in document.getElementsByTagName('select')){
                let e = document.getElementsByTagName('select')[ei];
@@ -213,6 +229,9 @@
                    console.log(ele.id.indexOf('lkwgt'));
                    if (ele.id.indexOf('lkwgt') == -1) {
                        let vlookUpNodeId = ele.id + '_lkid';
                        if (tag_name == 'div') {
                            vlookUpNodeId = ele.id.substring(0,ele.id.length-4) + '_lkid';
                        }
                        let vlook_ele = document.getElementById(vlookUpNodeId);
                        let v = '';
                        if(vlook_ele){
@@ -307,7 +326,9 @@
        function checkRequiredFieldMsg(formData) {
            let blankRequiredFields = '';
            for(i = 0;i<requiredFieldAPIList.length;i++){
                if(formData[requiredFieldAPIList[i]]){
                if(formData[requiredFieldAPIList[i]] && (VLookUpFields.indexOf(requiredFieldAPIList[i]) == -1)){
                    continue;
                }else if((VLookUpFields.indexOf(requiredFieldAPIList[i]) != -1) && formData[requiredFieldAPIList[i]] != '000000000000000'){
                    continue;
                }else{
                    if(blankRequiredFields == ''){
@@ -322,6 +343,7 @@
        }
        //按钮点击方法
        function saveSobjectProcess(save_and_new) {
            EditButton(true);
            if(save_and_new){
                config.SaveAndNew = true;
            }
@@ -360,6 +382,7 @@
            let errorMsgNode = document.getElementById("page:form:block:msgContent");
            errorMsgNode.innerText = errorMsg;
            errorMsgNode.className = 'pbError';
            EditButton(false);
        }
        function hiddenErrorMsgNode() {
            let errorMsgNode = document.getElementById("page:form:block:msgContent");
@@ -416,6 +439,9 @@
            let contactNodeId = document.querySelector("[data-id='Contact_Name__c']").id + '_lkid';
            document.getElementById(contactNodeId).value = contactInfo.ContactId;
            document.querySelector("[data-id='Contact_Name__c']").value = contactInfo.Name;
            //2022-5-7 yjk 增加参数
            document.querySelector("[data-id='Email__c']").value = contactInfo.email;
            document.querySelector("[data-id='Phone__c']").value = contactInfo.phone;
        }
        
        //替换vlookup
@@ -652,7 +678,7 @@
                    jQuery('a[data-id="OwnerId"]').remove();
                    //Updated by Li Jun 20220322 Start
               /*
                    /*
                    
                    jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){
                        this.className = "closeIconOn";
@@ -666,10 +692,10 @@
                        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');
                            input.value = '';
                            let hidden = document.getElementById(id+'_lkid');
                            if(hidden){
                               hidden.value = '';
                                hidden.value = '';
                            }
                        }
                    });*/
@@ -740,9 +766,9 @@
                                }
                            }else {
                               clearVlookup('Department_Class__c');
                                clearVlookup('Department_Class__c');
                                clearVlookup('Hospital__c');
                           }
                            }
                        },
                        { escape: true }
                    );