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/SearchContactPage.page | 147 ++++++++++++++++++++++++++++++++----------------
1 files changed, 98 insertions(+), 49 deletions(-)
diff --git a/force-app/main/default/pages/SearchContactPage.page b/force-app/main/default/pages/SearchContactPage.page
index e7f7624..eac07e6 100644
--- a/force-app/main/default/pages/SearchContactPage.page
+++ b/force-app/main/default/pages/SearchContactPage.page
@@ -1,5 +1,9 @@
-<apex:page controller="SearchContactController" showHeader="false" id="page">
+<apex:page controller="SearchContactController" showHeader="{!showHeader}" id="page">
+ <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
<apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
+ <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
+ <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
+ <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
<head>
</head>
@@ -19,16 +23,16 @@
var staticResources = JSON.parse('{!staticResource}');
var contactAWSIds = JSON.parse('{!contactAWSIds}');
var contactsInfo = JSON.parse('{!contactsInfo}');
- var searchContactName = '';
+ var searchKeyWord = '{!searchKeyWord}';
+ var searchContactName = searchKeyWord;
queryLeadFromAWS();
function searchAWSContact(){
- console.log('Search process!');
- //1. reset table;
+ //1. reset table;
+ blockme();
resetTable();
//2. get contact name value
searchContactName = document.getElementById('page:form:lksrch').value;
queryLeadFromAWS();
-
}
function resetTable(){
let queryResult = document.getElementById('QueryResult');
@@ -46,39 +50,46 @@
function queryLeadFromAWS() {
//1. Prepare the payload for contact search
let requestSearchPayload = preparePayloadForSearchContact();
- console.log('request payload body:'+requestSearchPayload);
//2. Invoke AWS Service
- fetch(staticResources.searchUrl, {
- method: 'POST',
- body: requestSearchPayload,
- headers: {
- 'Content-Type': 'application/json',
- 'pi-token': staticResources.token
- }
- }).then((data) => {
- return data.json();
- }).then((result) => {
- if(result.object&&result.object.length>0){
- initContactTable(result);
- }
- })
+ // fetch(staticResources.searchUrl, {
+ // method: 'POST',
+ // body: requestSearchPayload,
+ // headers: {
+ // 'Content-Type': 'application/json',
+ // 'pi-token': staticResources.token
+ // }
+ // }).then((data) => {
+ // return data.json();
+ // }).then((result) => {
+ // if(result.object&&result.object.length>0){
+ // initContactTable(result);
+ // }
+ // })
+ let queryBackContactName = function queryBackContactName(result){
+ // if(result.object){
+ // initContactTable(result);
+ // }
+ initContactTable(result);
+ };
+ AWSService.search(staticResources.searchUrl,requestSearchPayload,queryBackContactName,staticResources.token)
}
- function redirectToParentPage(obj,Phone,awsDataId) {
+ function redirectToParentPage(obj) {
var winMain = window.opener;
if (null == winMain) {
winMain = window.parent.opener;
}
- console.log('obj = ' + obj)
let value = obj.currentTarget.innerText;
let contactInfo = new Object();
contactInfo.Name = obj.currentTarget.innerText;
contactInfo.ContactId = obj.currentTarget.id;
- contactInfo.Phone = Phone;
- contactInfo.awsDataId = awsDataId;
- var selectedContactNode = winMain.document.getElementById('{!JSENCODE($CurrentPage.parameters.contactId)}');
- selectedContactNode.value = JSON.stringify(contactInfo);
- closeWindow();
+ if({!showHeader}){
+ window.open('\\'+obj.currentTarget.id,'_blank');
+ }else{
+ var selectedContactNode = winMain.document.getElementById('{!JSENCODE($CurrentPage.parameters.contactId)}');
+ selectedContactNode.value = JSON.stringify(contactInfo);
+ closeWindow();
+ }
}
function closeWindow() {
@@ -97,11 +108,12 @@
let tableBody = document.createElement('TBODY');
table.appendChild(tableBody);
let headerTR = document.createElement('TR');
+ let colsHeader = ['濮撳悕','瀹㈡埛鍚嶇О','閭', '鐢佃瘽','鎵嬫満鍙�'];
tableBody.appendChild(headerTR);
- for (let i = 0; i < cols.length; i++) {
+ for (let i = 0; i < colsHeader.length; i++) {
let td = document.createElement('TH');
td.width = '75';
- td.appendChild(document.createTextNode(cols[i]));
+ td.appendChild(document.createTextNode(colsHeader[i]));
headerTR.appendChild(td);
}
//3. Init the AWS data
@@ -112,47 +124,84 @@
for (let j = 0; j < cols.length; j++) {
let td = document.createElement('TD');
td.width = '75';
- if(j == 0 && contactsInfo[contactInfoTemp.AWSDataId]){
- td.id = contactsInfo[contactInfoTemp.AWSDataId].Id;
- }
+ if(contactInfoTemp.pi){
+ if (!contactsInfo.hasOwnProperty(contactInfoTemp.AWSDataId)) {
+ continue;
+ }
+ if(j == 0 && contactsInfo[contactInfoTemp.AWSDataId] ){
+ td.id = contactsInfo[contactInfoTemp.AWSDataId].Id;
+ }
+ }else{
+ td.id = contactInfoTemp.sfRecordId;
+ }
td.appendChild(document.createTextNode(contactInfoTemp[cols[j]]!=null?contactInfoTemp[cols[j]]:''));
if (cols[j] == 'Name') {
td.addEventListener("click", function (obj) {
- console.log('contactInfoList[i] = ' + contactInfoList[i])
- redirectToParentPage(obj,contactInfoList[i].Phone,contactInfoList[i].AWSDataId);
+ redirectToParentPage(obj);
});
}
tr.appendChild(td);
}
}
myTableDiv.appendChild(table);
+ unblockUI();
}
function initContactTable(data) {
- let cols = ['Name', 'Email', 'Phone'];
+ let cols = ['Name','AccountName', 'Email', 'Phone','MobilePhone'];
let contactInfoList = [];
let awsDataIds = [];
- for(var i=0;i<data.object.length;i++){
- if(data.object[i].dataId){
- let contactInfo = new Object();
- contactInfo.Name = data.object[i].lastName;
- contactInfo.Email = data.object[i].email;
- contactInfo.Phone = data.object[i].phone;
- contactInfo.AWSDataId = data.object[i].dataId;
- awsDataIds.push(contactInfo.AWSDataId);
- contactInfo.sfRecordId = '';
- contactInfoList.push(contactInfo);
- }
+ if(data.object){
+ for(var i=0;i<data.object.length;i++){
+ if(data.object[i].dataId){
+ let contactInfo = new Object();
+ contactInfo.Name = data.object[i].lastName;
+ contactInfo.Email = data.object[i].email;
+ contactInfo.MobilePhone = data.object[i].mobilePhone;
+ contactInfo.Phone = data.object[i].phone;
+ contactInfo.AWSDataId = data.object[i].dataId;
+ contactInfo.pi = true;
+ awsDataIds.push(contactInfo.AWSDataId);
+ contactInfo.sfRecordId = '';
+ contactInfoList.push(contactInfo);
+ }
+ }
}
let AWSIdToSFIdMapValue = {};
- console.log(awsDataIds);
//Invoke SF BackEnd
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.SearchContactController.searchContacts}',
- JSON.stringify(awsDataIds),
+ JSON.stringify(awsDataIds),searchContactName,'{!aId}',
function (result, event) {
if(event.status){
if(result.status = 'success'){
- contactsInfo = JSON.parse(result.message.replace(/("\;)/g,"\""));
+ if(result.message){
+ contactsInfo = JSON.parse(result.message.replace(/("\;)/g,"\""));
+ if(Object.keys(contactsInfo).length>0){
+ for(let i=0;i<contactInfoList.length;i++){
+ let contactFromSF = contactsInfo[contactInfoList[i]['AWSDataId']];
+ if(contactFromSF){
+ contactInfoList[i].sfRecordId = contactFromSF['Id'];
+ contactInfoList[i].AccountName = contactFromSF['Account']['Name'];
+ }
+ }
+ }
+ }
+ //1. get SF 闈炴晱鎰熺殑鑱旂郴浜轰俊鎭�
+ if(result.noPIContactList){
+ var noPIInfo = JSON.parse(result.noPIContactList.replace(/("\;)/g,"\""));
+ for(let f in noPIInfo){
+ let contactInfo = new Object();
+ contactInfo.Name = noPIInfo[f].Name!=null?noPIInfo[f].Name:'';
+ contactInfo.Email = noPIInfo[f].Email!=null?noPIInfo[f].Email:'';
+ contactInfo.Phone = noPIInfo[f].Phone!=null?noPIInfo[f].Phone:'';
+ contactInfo.MobilePhone = noPIInfo[f].MobilePhone!=null?noPIInfo[f].MobilePhone:'';
+ contactInfo.AWSDataId = '';
+ contactInfo.sfRecordId = noPIInfo[f].Id!=null?noPIInfo[f].Id:'';
+ contactInfo.AccountName = noPIInfo[f]['Account']['Name'];
+ contactInfo.pi = false;
+ contactInfoList.push(contactInfo);
+ }
+ }
refreshTable(cols,contactInfoList);
}else{
console.log('No result');
--
Gitblit v1.9.1