buli
2023-07-14 e6068da47c1bef5517c9e5fdc8c726766867ad4e
force-app/main/default/pages/NewAndEditLead.page
@@ -1,4 +1,4 @@
<apex:page standardController="Lead" extensions="NewAndEditLeadController" id="page">
<apex:page lightningStylesheets="true" standardController="Lead" extensions="NewAndEditLeadController" id="page">
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
@@ -20,7 +20,8 @@
        var redirectMode = 'Save';//1. Save 2. SaveAndNew
        var requiredAPIToChangedLabelMap = new Map();
        requiredAPIToChangedLabelMap.set('LastName', '{!PIPL_Name_Label}');
        var VLookUpFields = new Set(['Hospital_Name__c', 'Department_Class__c', 'Contact_Name__c', 'Campaign__c', 'Lead_Inquiry_form__c', 'Opp_Name_Search__c', 'Tender_information__c', 'Agency_Opportunity__c']);
        //var VLookUpFields = new Set(['Hospital_Name__c', 'Department_Class__c', 'Contact_Name__c', 'Campaign__c', 'Lead_Inquiry_form__c', 'Opp_Name_Search__c', 'Tender_information__c', 'Agency_Opportunity__c']);
        var VLookUpFields = {! VLookUpFieldsJson};
        function ProcessPI(leadJson, payloadForNewPI) {
            blockme();
            if ({!isNewMode} || {!isCloneMode}) {
@@ -121,12 +122,25 @@
            let result = {}
            result.RecordTypeId = '{!rtTypeId}';
            for (let index = 0; index < nodelist.length; index++) {
                if (VLookUpFields.has(nodelist[index].getAttribute("data-id"))) {
                let tag_name = nodelist[index].tagName.toLowerCase();
                if(tag_name == 'div'){
                    console.log(nodelist[index])
                }
                if (VLookUpFields.indexOf(nodelist[index].getAttribute("data-id")) >= 0) {
                    console.log(nodelist[index].id.indexOf('lkwgt'));
                    if (nodelist[index].id.indexOf('lkwgt') == -1) {
                        let vlookUpNodeId = nodelist[index].id + '_lkid';
                        let vlookUpNodeValue = document.getElementById(vlookUpNodeId).value;
                        result[nodelist[index].getAttribute("data-id")] = vlookUpNodeValue;
                        if (tag_name == 'div') {
                            vlookUpNodeId = nodelist[index].id.substring(0,nodelist[index].id.length-4) + '_lkid';
                        }
                        let vlookUpNodeValue = document.getElementById(vlookUpNodeId);
                        let v = '';
                        if(vlookUpNodeValue){
                            v = vlookUpNodeValue.value;
                        }else{
                            v = nodelist[index].value;
                        }
                        result[nodelist[index].getAttribute("data-id")] = v;
                    }
                } else if (nodelist[index].type == 'checkbox') {
                    result[nodelist[index].getAttribute("data-id")] = nodelist[index].checked;
@@ -245,9 +259,9 @@
        function checkRequiredFieldMsg(formData) {
            let blankRequiredFields = '';
            for (i = 0; i < requiredFieldAPIList.length; i++) {
                if (formData[requiredFieldAPIList[i]] && !VLookUpFields.has(requiredFieldAPIList[i])) {
                if (formData[requiredFieldAPIList[i]] && (VLookUpFields.indexOf(requiredFieldAPIList[i]) == -1)) {
                    continue;
                }else if(VLookUpFields.has(requiredFieldAPIList[i]) && formData[requiredFieldAPIList[i]] != '000000000000000'){
                }else if((VLookUpFields.indexOf(requiredFieldAPIList[i]) != -1) && formData[requiredFieldAPIList[i]] != '000000000000000'&&formData[requiredFieldAPIList[i]] != ''){
                    continue;
                } else {
                    let fieldAPIValue = requiredFieldAPIList[i]
@@ -266,6 +280,22 @@
            return blankRequiredFields;
        }
        function saveLeadProcess(saveMode) {
            // 预测签约日check
            var days = 100;
            var cfdate = document.querySelector("[data-id='Close_Forecasted_Date__c']").value;
            var crdate = '{!LeadCreatedDate}';
            if (cfdate != undefined && cfdate != '') {
                days = (Date.parse(cfdate) - Date.parse(crdate)) / (1000 * 3600 *24);
                // alert(days);
            }
            if (days < 75) {
                if (!confirm('预测签约日对比创建日不能小于75天,请确认是否按75天保存?')){
                    return
                }
            }
            EditButton(true);
            disableButtonStatus();
@@ -288,6 +318,7 @@
                alertErrorMessage('{!Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
                return
            }
            //3. Prepare the payload for New PI API To AWS - To Do
            let payloadForNewPI = getPIPayload(leadJson);
@@ -443,7 +474,7 @@
                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />
                                <h2 class="mainTitle">意向编辑</h2>
                            </td>
                            <td class="pbButton" id="topButtonRow" style="pointer-events: none; opacity: 0.4;">
                            <td class="pbButton" id="topButtonRow" style="pointer-events: none; opacity: 1.0;">
                                <input class="btn" type="Button" value="保存" onclick="saveLeadProcess('Save')" />
                                <input class="btn" type="Button" value="保存并新建" onclick="saveLeadProcess('SaveAndNew')" />
                                <apex:commandButton action="{!cancel}" value="取消" />
@@ -613,9 +644,9 @@
                    
                    unblockUI();
                }
                debugger
                document.getElementById('topButtonRow').style = '';
           document.getElementById('bottomButtonRow').style = '';
           document.getElementById('bottomButtonRow').style = '';
                let previous_value = {};
                    jQuery(".lookupInput input").each(function(i,e){
                        let je =jQuery(e);
@@ -741,7 +772,7 @@
                        <tr>
                            <td class="pbTitle">
                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />&nbsp;</td>
                            <td class="pbButton" id="bottomButtonRow" style="pointer-events: none; opacity: 0.4;">
                            <td class="pbButton" id="bottomButtonRow" style="pointer-events: none; opacity: 1.0;">
                                <input class="btn" type="Button" value="保存" onclick="saveLeadProcess('Save')" />
                                <input class="btn" type="Button" value="保存并新建" onclick="saveLeadProcess('SaveAndNew')" />
                                <apex:commandButton action="{!cancel}" value="取消" />