From 4420517bbbffea48cabe7a7dcdf2e1c4b440fc85 Mon Sep 17 00:00:00 2001
From: GWY <guweiyi@prec-tech.com>
Date: 星期一, 30 五月 2022 16:15:26 +0800
Subject: [PATCH] 两个LS特殊条件在说明的增减
---
force-app/main/default/pages/NewAndEditOrder.page | 169 ++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 128 insertions(+), 41 deletions(-)
diff --git a/force-app/main/default/pages/NewAndEditOrder.page b/force-app/main/default/pages/NewAndEditOrder.page
index 54bf8cc..672905c 100644
--- a/force-app/main/default/pages/NewAndEditOrder.page
+++ b/force-app/main/default/pages/NewAndEditOrder.page
@@ -11,7 +11,7 @@
}
</style>
<script>
-
+ sforce.connection.sessionId = '{!GETSESSIONID()}';
var config = {};
config = {
SobjectName : "{!SobjectName}",
@@ -137,6 +137,19 @@
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");
+ }
+ }
var GetEleByClass = function(class_name){
let eles = document.getElementsByClassName(class_name);
@@ -176,7 +189,7 @@
}
let phone = document.querySelector(textPhone);
- if(false && phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
+ if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
error_msg += ';鐢佃瘽鍙风爜閿欒';
}
@@ -220,9 +233,9 @@
v = ele.value;
}
- if(v && v != "000000000000000"){
+ //if(v && v != "000000000000000"){
result[field_api_name] = v;
- }
+ //}
}
} else if (ele.type == 'checkbox') {
@@ -245,7 +258,19 @@
}
return result;
}
- function QuerySobjectFromAWS() {
+ function QuerySobjectFromAWS(EndUserLkid) {
+ if(EndUserLkid){
+ //query contact
+ let result = sforce.connection.query("SELECT AWS_Data_Id__c from Contact where id = '" + EndUserLkid + "'");
+ let records = result.getArray("records");
+ let awsDataId = records[0].AWS_Data_Id__c;
+ let queryContactBack = function(data){
+ console.log('ContactData = ' + data.object);//To Do later
+ document.querySelector("[data-id='EndUser__c']").value = data.object.lastName;
+ unblockUI();
+ }
+ AWSService.query(staticResourcesContact.queryUrl, awsDataId, queryContactBack, staticResources.token);
+ }
AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token);
}
function queryBack(data) {
@@ -297,7 +322,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 == ''){
@@ -311,6 +338,7 @@
return blankRequiredFields;
}
function saveSobjectProcess(save_and_new) {
+ EditButton(true);
if(save_and_new){
config.SaveAndNew = true;
}
@@ -349,6 +377,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");
@@ -495,7 +524,8 @@
}
if (accountValue != ''){
let baseUrl = "/apex/SearchContactPage";
- let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
+ let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value;
+ 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) {
@@ -510,7 +540,8 @@
accountValue = ForeignTradeCompanyValue;
}
let baseUrl = "/apex/SearchContactPage";
- let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
+ let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value;
+ 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) {
@@ -545,7 +576,8 @@
}
if (accountValueD != ''){
let baseUrl = "/apex/SearchContactPage";
- let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD;
+ let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value;
+ let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD+"&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) {
@@ -560,7 +592,8 @@
accountValueD = ForeignTradeCompanyDValue;
}
let baseUrl = "/apex/SearchContactPage";
- let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD;
+ let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value;
+ let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD+"&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) {
@@ -570,7 +603,8 @@
}
} else {
let baseUrl = "/apex/SearchContactPage";
- let suffixUrl = "?contactId="+contactNodeId;
+ let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value;
+ let suffixUrl = "?contactId="+contactNodeId+"&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) {
@@ -585,28 +619,34 @@
if (null != newSearchContactWindow) {
newSearchContactWindow.close();
}
- if(document.querySelector("[data-id='SpecialDeliveryContact2__c']") != null){
- if (null != newSearchContactWindow) {
- newSearchContactWindow.close();
- }
- let contactInfoStr = document.getElementById('page:form:contactId').value;
- console.log('closePopup:'+contactInfoStr);
- let contactInfo = JSON.parse(contactInfoStr);
- let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid';
- document.getElementById(contactNodeId).value = contactInfo.ContactId;
- document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name;
- }
- if(document.querySelector("[data-id='SpecialDeliveryContact2_D__c']") != null){
- if (null != newSearchContactWindow) {
- newSearchContactWindow.close();
- }
- let contactInfoStr = document.getElementById('page:form:contactId').value;
- console.log('closePopup:'+contactInfoStr);
- let contactInfo = JSON.parse(contactInfoStr);
- let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid';
- document.getElementById(contactNodeId).value = contactInfo.ContactId;
- document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name;
- }
+ // if(document.querySelector("[data-id='SpecialDeliveryContact2__c']") != null){
+ // if (null != newSearchContactWindow) {
+ // newSearchContactWindow.close();
+ // }
+ // let contactInfoStr = document.getElementById('page:form:contactId').value;
+ // console.log('closePopup:'+contactInfoStr);
+ // let contactInfo = JSON.parse(contactInfoStr);
+ // let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid';
+ // document.getElementById(contactNodeId).value = contactInfo.ContactId;
+ // document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name;
+ // }
+ // if(document.querySelector("[data-id='SpecialDeliveryContact2_D__c']") != null){
+ // if (null != newSearchContactWindow) {
+ // newSearchContactWindow.close();
+ // }
+ // let contactInfoStr = document.getElementById('page:form:contactId').value;
+ // console.log('closePopup:'+contactInfoStr);
+ // let contactInfo = JSON.parse(contactInfoStr);
+ // let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid';
+ // document.getElementById(contactNodeId).value = contactInfo.ContactId;
+ // document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name;
+ // }
+ let contactInfoStr = document.getElementById('page:form:contactId').value;
+ console.log('closePopup:'+contactInfoStr);
+ let contactInfo = JSON.parse(contactInfoStr);
+ let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid';
+ document.getElementById(contactNodeId).value = contactInfo.ContactId;
+ document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name;
}
@@ -642,7 +682,7 @@
<img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />
<h2 class="mainTitle">{! SobjectLabel}<apex:outputText rendered="{!isNewMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode)}">{!$Label.Edit}</apex:outputText></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="{!$Label.Save}" onclick="saveSobjectProcess()" />
<input class="btn" type="Button" value="{!$Label.SaveAndNew}" onclick="saveSobjectProcess(1)" />
<apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" />
@@ -664,8 +704,14 @@
<!--Each section has layoutFields, let's iterate them as well-->
<apex:repeat value="{!layoutSection.layoutFields}" var="layoutField">
- <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
- required="{!layoutField.isRequired}" />
+ <!-- <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
+ required="{!layoutField.isRequired}" /> -->
+ <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}"
+ required="{!layoutField.isRequired}" />
+ <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[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="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}"
+ />
<apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
</apex:pageblocksectionitem>
</apex:repeat>
@@ -682,22 +728,63 @@
}
console.log(api_id_map);
sfdcPage.appendToOnloadQueue(function () {
+ 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");
+ }
+ }
+ }
+ }
+ }
//1. Set Last Name label
//document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '濮撳悕';
//2. Query AWS Data by dataId
console.log('Mode for Sobject Page:' + {!isNewMode});
+ var EndUserLkid = '000000000000000';
+ if(document.querySelector("[data-id='EndUser__c']")){
+ EndUserLkid = document.getElementById(document.querySelector("[data-id='EndUser__c']").id + '_lkid').value;
+ }
if (!{!isNewMode}) {
blockme();
- QuerySobjectFromAWS();
+ if(EndUserLkid!='000000000000000'){
+ QuerySobjectFromAWS(EndUserLkid);
+ }else{
+ QuerySobjectFromAWS();
+ }
+ }
+
+ //瑙e瘑鏈�缁堢敤鎴�.
+ if(document.querySelector("[data-id='EndUserD__c']")){
+ EndUserDLkid = document.getElementById(document.querySelector("[data-id='EndUserD__c']").id + '_lkid').value;
+ //query contact
+ let result = sforce.connection.query("SELECT AWS_Data_Id__c from Contact where id = '" + EndUserDLkid + "'");
+ let records = result.getArray("records");
+ let awsDataId = records[0].AWS_Data_Id__c;
+ let queryContactBack = function(data){
+ document.querySelector("[data-id='EndUserD__c']").value = data.object.lastName;
+ }
+ AWSService.query(staticResourcesContact.queryUrl, awsDataId, queryContactBack, staticResources.token);
}
//Replace Vlookup Field
replaceSearchContactLookup();
//3. Set Readonly Attribute
- document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton");
- document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton");
+ // document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton");
+ // document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton");
-
+ document.getElementById('topButtonRow').style = '';
+ document.getElementById('bottomButtonRow').style = '';
});
</script>
<div class="pbBottomButtons">
@@ -706,7 +793,7 @@
<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="{!$Label.Save}" onclick="saveSobjectProcess()" />
<input class="btn" type="Button" value="{!$Label.SaveAndNew}" onclick="saveSobjectProcess()" />
<apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" />
--
Gitblit v1.9.1