From bc1ded4de6761128cff0df6503ca2c0b316b43e4 Mon Sep 17 00:00:00 2001
From: GWY <guweiyi@prec-tech.com>
Date: 星期四, 05 五月 2022 17:59:04 +0800
Subject: [PATCH] AP6更改
---
force-app/main/default/pages/NewAndEditOrder.page | 140 ++++++++++++++++++++++++++++++++--------------
1 files changed, 96 insertions(+), 44 deletions(-)
diff --git a/force-app/main/default/pages/NewAndEditOrder.page b/force-app/main/default/pages/NewAndEditOrder.page
index 4153dd7..04b7129 100644
--- a/force-app/main/default/pages/NewAndEditOrder.page
+++ b/force-app/main/default/pages/NewAndEditOrder.page
@@ -1,10 +1,3 @@
-<!--
-@description :
-@author : ChangeMeIn@UserSettingsUnder.SFDoc
-@group :
-@last modified on : 03-08-2022
-@last modified by : ChangeMeIn@UserSettingsUnder.SFDoc
--->
<apex:page standardController="Order" extensions="NewAndEditOrderController" id="page">
<apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
<script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
@@ -252,7 +245,20 @@
}
return result;
}
- function QuerySobjectFromAWS() {
+ function QuerySobjectFromAWS(EndUserLkid) {
+ if(EndUserLkid){
+ //query contact
+ sforce.connection.sessionId = '{!GETSESSIONID()}';
+ 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) {
@@ -337,7 +343,7 @@
// Check Required Field
let checkRequiredFieldMsgResult = checkRequiredFieldMsg(sobjJson);
if (checkRequiredFieldMsgResult) {
- alertErrorMessage('requiredErrorMsg' + checkRequiredFieldMsgResult);
+ alertErrorMessage('{!$Label.Input_Required_Field_Msg}' + checkRequiredFieldMsgResult);
return
}
// //3. Prepare the payload for New PI API To AWS - To Do
@@ -502,7 +508,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) {
@@ -517,7 +524,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) {
@@ -552,7 +560,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) {
@@ -567,7 +576,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) {
@@ -577,7 +587,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) {
@@ -592,28 +603,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;
}
@@ -649,7 +666,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}" />
@@ -671,8 +688,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>
@@ -689,22 +712,51 @@
}
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();
+ }
+
}
//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">
@@ -713,7 +765,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