Li Jun
2022-04-27 24fda5246494953a232b37547fb50bde77bd9886
force-app/main/default/pages/NewOnCall.page
@@ -37,7 +37,7 @@
        var queryBack = function queryBack(data) {
            console.log('data = ' + data);
            //document.querySelector("[id='page:form:pageBlock:pageBlockSection:j_id1:0:j_id2']").value = data.object.callerPhone;
            document.querySelector("[id='page:form:block:j_id34:0:j_id35:j_id36:5:j_id37']").value = data.object.callerPhone;    //20220404  By Chen Yanan
            document.getElementById(api_id_map['Caller_phone__c']).value = data.object.callerPhone;    //20220404  By Chen Yanan
            document.querySelector("[data-id='Responsible_Person_HP__c']").value = data.object.responsiblePersonHP;
            unblockUI();
        };
@@ -54,19 +54,22 @@
            payloadJson.Caller_Phone_Encrypt__c = r.object[0].callerPhoneEncrypt;
            payloadJson.Responsible_PersonHP_Encrypt__c = r.object[0].responsiblePersonHPEncrypt;
            payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
            if (isNewMode|| {!isCloneMode}) {
            if (isNewMode|| {!isCloneMode} ||!'{!AWSDataId}') {//Add by Li Jun for PIPL 20220413
                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(onCallJson, payloadForNewPI) {
            blockme();
            if ({!isNewMode} || {!isCloneMode}) {
            if ({!isNewMode} || {!isCloneMode} ||!'{!AWSDataId}') {//Add by Li Jun for PIPL 20220413
                NewPIToAWS(onCallJson, payloadForNewPI)
            }else {
                UpdatePIToAWS(onCallJson, payloadForNewPI)
@@ -163,9 +166,21 @@
            }
            return blankRequiredFields;
        }
        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");
            }
        }
        //Base Process
        function saveOnCallProcess(saveMode) {
            EditButton(true);
            redirectMode = saveMode;
            console.log('redirectMode' + redirectMode);
            hiddenErrorMsgNode();
@@ -199,6 +214,7 @@
            errorMsgNode.innerText = errorMsg;
            errorMsgNode.className = 'pbError';
            unblockUI();
            EditButton(false);
        }
        //Hide Error Message
@@ -206,6 +222,26 @@
            let errorMsgNode = document.getElementById("page:form:block:msgContent");
            errorMsgNode.innerText = '';
            errorMsgNode.className = '';
        }
        var GetEleApiName = function(ele){
            for(let ci in ele.classList){
                let c = ele.classList[ci];
                if(c.indexOf('PIBackApi'+'_')>-1){
                    return c.replace('PIBackApi'+'_','');
                }
            }
            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);
        }
    </script>
    <div class="bPageTitle">
@@ -238,7 +274,7 @@
                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />
                                <h2 class="mainTitle">OnCall编辑</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="saveOnCallProcess('Save')" />
                                <input class="btn" type="Button" value="保存并新建" onclick="saveOnCallProcess('SaveAndNew')" />
                                <apex:commandButton action="{!cancel}" value="取消" />
@@ -259,8 +295,12 @@
                    <!--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="{!On_Call__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
                       <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!On_Call__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}"
                            required="{!layoutField.isRequired}" />
                        <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!On_Call__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&not(isNewMode)&&layoutField.fieldAPI!='RecordTypeId'}"
                            required="{!layoutField.isRequired}" />
                        <apex:outputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!On_Call__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&not(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}"
                       />
                        <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
                        </apex:pageblocksectionitem>
                    </apex:repeat>
@@ -268,6 +308,17 @@
                </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;
                        }
                    }
                }
                //Append Page
                sfdcPage.appendToOnloadQueue(function () {
                    var layoutSections = JSON.parse('{!layoutSectionsStr}');
@@ -296,6 +347,9 @@
                        QueryOnCallFromAWS();
                    };
                    document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton");
                    document.getElementById('topButtonRow').style = '';
               document.getElementById('bottomButtonRow').style = '';
                    jQuery(".lookupInput").each(function(i,e){
                        let je =jQuery(e).find('input');
@@ -334,7 +388,7 @@
                        <tr>
                            <td class="pbTitle">
                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />&nbsp;</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="saveOnCallProcess('Save')" />
                                <input class="btn" type="Button" value="保存并新建" onclick="saveOnCallProcess('SaveAndNew')" />
                                <apex:commandButton action="{!cancel}" value="取消" />