From 226ec1cbf306ab7566e738594d5d8e68bdf98cf7 Mon Sep 17 00:00:00 2001
From: 游畅 <youchang@prec-tech.com>
Date: 星期二, 04 四月 2023 09:45:44 +0800
Subject: [PATCH] 20230329-询价中的今年相关字段增加和修改+现场修理逻辑+停止hr信息同步用户
---
force-app/main/default/pages/NewAndEditLead.page | 155 +++++++++++++++++++++++++++++++++++++--------------
1 files changed, 112 insertions(+), 43 deletions(-)
diff --git a/force-app/main/default/pages/NewAndEditLead.page b/force-app/main/default/pages/NewAndEditLead.page
index 49e4c4e..6f17676 100644
--- a/force-app/main/default/pages/NewAndEditLead.page
+++ b/force-app/main/default/pages/NewAndEditLead.page
@@ -3,7 +3,7 @@
<apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
- <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
+ <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<style>
.disabledbutton {
pointer-events: none;
@@ -13,6 +13,9 @@
<script>
AWSService.sfSessionId = '{!GETSESSIONID()}';
var staticResources = JSON.parse('{!staticResource}');
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+ var staticResourcesV2 = JSON.parse('{!staticResourceV2}');
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
var staticResourcesContact = JSON.parse('{!staticResourceContact}');
var staticResourceInquiryForm = JSON.parse('{!staticResourceInquiryForm}');
var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}');
@@ -20,16 +23,30 @@
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']);
+ //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}) {
- NewPIToAWS(leadJson, payloadForNewPI)
- }else {
- UpdatePIToAWS(leadJson, payloadForNewPI)
- }
+ NewPIToAWS(leadJson, payloadForNewPI)
+ }else {
+ UpdatePIToAWS(leadJson, 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");
+ }
+ }
+
function enableButton(obj) {
obj.classList.remove("btnDisabled");
}
@@ -108,12 +125,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;
@@ -157,16 +187,21 @@
}
var queryBack = function queryBack(data) {
console.log('data = ' + data);
- document.querySelector("[data-id='LastName']").value = data.object.lastName == null ? '' : data.object.lastName;
- document.querySelector("[data-id='Phone']").value = data.object.phone == null ? '' : data.object.phone;
- document.querySelector("[data-id='Email']").value = data.object.email == null ? '' : data.object.email;
+ if(document.querySelector("[data-id='LastName']"))
+ document.querySelector("[data-id='LastName']").value = data.object.lastName == null ? '' : data.object.lastName;
+ if(document.querySelector("[data-id='Phone']"))
+ document.querySelector("[data-id='Phone']").value = data.object.phone == null ? '' : data.object.phone;
+ if(document.querySelector("[data-id='Email']"))
+ document.querySelector("[data-id='Email']").value = data.object.email == null ? '' : data.object.email;
unblockUI();
};
var queryBackIFS = function queryBackIFS(data) {
console.log('data = ' + data);
//document.querySelector("[data-id='LastName']").value = document.querySelector("[data-id='Contact_Name__c']").value
- document.querySelector("[data-id='Phone']").value = data.object.phone == null ? '' : data.object.phone;
- document.querySelector("[data-id='Email']").value = data.object.email == null ? '' : data.object.email;
+ if(document.querySelector("[data-id='Phone']"))
+ document.querySelector("[data-id='Phone']").value = data.object.phone == null ? '' : data.object.phone;
+ if(document.querySelector("[data-id='Email']"))
+ document.querySelector("[data-id='Email']").value = data.object.email == null ? '' : data.object.email;
unblockUI();
};
@@ -178,9 +213,11 @@
payloadJson.LastName = r.object[0].lastName;
payloadJson.Phone = r.object[0].phone;
payloadJson.Email = r.object[0].email;
- payloadJson.Name_Encrypted__c = r.object[0].lastNameEncrypt;
- payloadJson.Phone_Encrypted__c = r.object[0].phoneEncrypt;
- payloadJson.Email_Encrypted__c = r.object[0].emailEncrypt;
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+ // payloadJson.Name_Encrypted__c = r.object[0].lastNameEncrypt;
+ // payloadJson.Phone_Encrypted__c = r.object[0].phoneEncrypt;
+ // Email_Encrypted__c = r.object[0].emailEncrypt;
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
//payloadJson.AWS_Data_Id__c = r.object[0].dataId;
payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
if (isNewMode || {!isCloneMode}) {
@@ -191,6 +228,8 @@
}
if('{!rtTypeId}'){
payloadJson.RecordTypeId = '{!rtTypeId}';//Add by zhj for Record Type Issue 20220421
+ }else{
+ delete payloadJson.RecordTypeId;
}
return payloadJson;
}
@@ -214,18 +253,26 @@
let obj = JSON.parse(payloadForNewPI);
obj[0].dataId = '{!AWSDataId}';
let payloadForNewPIJson = JSON.stringify(obj);
- AWSService.update(staticResources.updateUrl, leadJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack);
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+ //AWSService.update(staticResources.updateUrl, leadJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack);
+ AWSService.update(staticResourcesV2.updateUrl, leadJson, payloadForNewPIJson, controllerSaveMethod, staticResourcesV2.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack);
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
}
function NewPIToAWS(leadJson, payloadForNewPI) {
let controllerSaveMethod = '{!$RemoteAction.NewAndEditLeadController.saveLead}';
- AWSService.insert(staticResources.newUrl, leadJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack);
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+ //AWSService.insert(staticResources.newUrl, leadJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack);
+ AWSService.insert(staticResourcesV2.newUrl, leadJson, payloadForNewPI, controllerSaveMethod, staticResourcesV2.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack);
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
}
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'&&formData[requiredFieldAPIList[i]] != ''){
continue;
} else {
let fieldAPIValue = requiredFieldAPIList[i]
@@ -244,6 +291,23 @@
return blankRequiredFields;
}
function saveLeadProcess(saveMode) {
+
+ // 棰勬祴绛剧害鏃heck
+ 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();
redirectMode = saveMode;
@@ -265,6 +329,7 @@
alertErrorMessage('{!Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
return
}
+
//3. Prepare the payload for New PI API To AWS - To Do
let payloadForNewPI = getPIPayload(leadJson);
@@ -279,6 +344,7 @@
errorMsgNode.innerText = errorMsg;
errorMsgNode.className = 'pbError';
unblockUI();
+ EditButton(false);
}
function hiddenErrorMsgNode() {
let errorMsgNode = document.getElementById("page:form:block:msgContent");
@@ -380,8 +446,10 @@
return;
}
let queryBackContactName = function queryBackContactName(result){
- document.querySelector("[data-id='Contact_Name__c']").value = result.object.lastName;
- document.querySelector("[data-id='LastName']").value = result.object.lastName;
+ if(document.querySelector("[data-id='Contact_Name__c']"))
+ document.querySelector("[data-id='Contact_Name__c']").value = result.object.lastName;
+ if(document.querySelector("[data-id='LastName']"))
+ document.querySelector("[data-id='LastName']").value = result.object.lastName;
};
AWSService.query(staticResourcesContact.queryUrl, dataId, queryBackContactName, staticResourcesContact.token);
}
@@ -417,7 +485,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="鍙栨秷" />
@@ -503,52 +571,53 @@
if ('{!ifc}' != '') {
blockme();
//鐘舵��
- document.querySelector("[data-id='Status']").value = '鏈窡杩�'
+ if(document.querySelector("[data-id='Status']"))
+ document.querySelector("[data-id='Status']").value = '鏈窡杩�'
//浼氳璇㈤棶鍗�
- if ('{!ifc.Id}')
+ if ('{!ifc.Id}' && document.querySelector("[data-id='Lead_Inquiry_form__c']"))
document.getElementById(document.querySelector("[data-id='Lead_Inquiry_form__c']").id+'_lkid').value = '{!ifc.Id}'
- if ('{!ifc.Name}')
+ if ('{!ifc.Name}' && document.querySelector("[data-id='Lead_Inquiry_form__c']"))
document.querySelector("[data-id='Lead_Inquiry_form__c']").value = '{!ifc.Name}'
//瀹㈡埛濮撳悕
- if ('{!ifc.Contact_Id__c}')
+ if ('{!ifc.Contact_Id__c}' && document.querySelector("[data-id='Contact_Name__c']"))
document.getElementById(document.querySelector("[data-id='Contact_Name__c']").id + '_lkid').value = '{!ifc.Contact_Id__c}'
//鍖婚櫌
- if ('{!ifc.Hospital_Name__c}')
+ if ('{!ifc.Hospital_Name__c}' && document.querySelector("[data-id='Hospital_Name__c']"))
document.getElementById(document.querySelector("[data-id='Hospital_Name__c']").id+'_lkold').value = '{!ifc.Hospital_Name__c}'
- if ('{!ifc.Hospital_ID__c}')
+ if ('{!ifc.Hospital_ID__c}' && document.querySelector("[data-id='Hospital_Name__c']"))
document.getElementById(document.querySelector("[data-id='Hospital_Name__c']").id+'_lkid').value = '{!ifc.Hospital_ID__c}'
//鎴樼暐绉戝鍒嗙被
- if ('{!ifc.Department_Class__c}')
+ if ('{!ifc.Department_Class__c}' && document.querySelector("[data-id='Department_Class__c']"))
document.getElementById(document.querySelector("[data-id='Department_Class__c']").id+'_lkold').value = '{!ifc.Department_Class__c}'
- if ('{!ifc.Department_ID__c}')
+ if ('{!ifc.Department_ID__c}' && document.querySelector("[data-id='Department_Class__c']"))
document.getElementById(document.querySelector("[data-id='Department_Class__c']").id+'_lkid').value = '{!ifc.Department_ID__c}'
//宸叉湁璇环鍚嶇О
- if ('{!ifc.Opp_Name_Search__c}')
+ if ('{!ifc.Opp_Name_Search__c}' && document.querySelector("[data-id='Opp_Name_Search__c']"))
document.getElementById(document.querySelector("[data-id='Opp_Name_Search__c']").id + '_lkold').value = '{!ifc.Opp_Name_Search__c}'
- if ('{!ifc.Opp_Name_Search_ID__c}')
+ if ('{!ifc.Opp_Name_Search_ID__c}' && document.querySelector("[data-id='Opp_Name_Search__c']"))
document.getElementById(document.querySelector("[data-id='Opp_Name_Search__c']").id + '_lkid').value = '{!ifc.Opp_Name_Search_ID__c}'
//涓昏瀛︿細
- if ('{!ifc.Campaign__c}')
+ if ('{!ifc.Campaign__c}' && document.querySelector("[data-id='Campaign__c']"))
document.getElementById(document.querySelector("[data-id='Campaign__c']").id +'_lkold').value = '{!ifc.Campaign__c}'
- if ('{!ifc.Campaign_ID__c}')
+ if ('{!ifc.Campaign_ID__c}' && document.querySelector("[data-id='Campaign__c']"))
document.getElementById(document.querySelector("[data-id='Campaign__c']").id +'_lkid').value = '{!ifc.Campaign_ID__c}'
//鍙栨秷鍘熷洜
- if ('{!ifc.Cancel_Reason__c}')
+ if ('{!ifc.Cancel_Reason__c}' && document.querySelector("[data-id='Cancel_Reason__c']"))
document.querySelector("[data-id='Cancel_Reason__c']").value = '{!ifc.Cancel_Reason__c}'
//鐢佃瘽
- if ('{!ifc.Phone__c}')
+ if ('{!ifc.Phone__c}' && document.querySelector("[data-id='Phone']"))
document.querySelector("[data-id='Phone']").value = '{!ifc.Phone__c}'
//閭欢
- if ('{!ifc.Email__c}')
+ if ('{!ifc.Email__c}' && document.querySelector("[data-id='Email']"))
document.querySelector("[data-id='Email']").value = '{!ifc.Email__c}'
//鍜ㄨ鍗曟潵婧�
if ('{!ifc.LeadSource__c}' && document.querySelector("[data-id='LeadSource']"))
document.querySelector("[data-id='LeadSource']").value = '{!ifc.LeadSource__c}'
//鎰忓悜鍖哄垎
- if ('{!ifc.Opportunity_Division__c}')
+ if ('{!ifc.Opportunity_Division__c}' && document.querySelector("[data-id='Opportunity_Division__c']"))
document.querySelector("[data-id='Opportunity_Division__c']").value = '{!ifc.Opportunity_Division__c}'
//濮旀墭浜嬮」
- if ('{!ifc.Request1__c}') {
+ if ('{!ifc.Request1__c}' && document.querySelector("[data-id='Request__c']")) {
var Request1__c = '{!ifc.Request1__c}';
//璧嬪�肩粰绗簩涓閫夋
var array = Request1__c.split(';');
@@ -573,7 +642,7 @@
}
}
//绱ф��
- if ('{!ifc.Urgent__c}')
+ if ('{!ifc.Urgent__c}' && document.querySelector("[data-id='urgent__c']"))
document.querySelector("[data-id='urgent__c']").checked = '{!ifc.Urgent__c}' == 'false' ? false : true;
//鍏徃锛堢瀹わ級 = 绉戝鍚嶇О
if(document.querySelector("[data-id='Company']") && document.querySelector("[data-id='Hospital_Name__c']").value != ''){
@@ -588,7 +657,7 @@
}
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);
@@ -714,7 +783,7 @@
<tr>
<td class="pbTitle">
<img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> </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="鍙栨秷" />
--
Gitblit v1.9.1