<apex:page controller="SearchContactForAgencyOppController" docType="html-5.0" showHeader="false" id="page" lightningStylesheets="true">
|
<apex:slds />
|
<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)}" />
|
<apex:stylesheet value="{!URLFOR($Resource.StyleUtilCss)}"/>
|
<head>
|
</head>
|
<style>
|
/* 1. 定义表单样式 To Do Later*/
|
table {
|
border-collapse: collapse;
|
border-spacing: 0;
|
width: 98%;
|
margin-left: 5px;
|
font-family: sans-serif;
|
left;
|
white-space: nowrap;
|
}
|
th {
|
height: 25px;
|
text-align: left;
|
background: rgb(240 238 238);
|
border-width: 1px 1px 1px 1px;
|
border-color: #e0e3e5;
|
font-size:0.75rem;
|
font-weight: 700;
|
color: black;
|
white-space: nowrap;
|
}
|
td {
|
/* background: #f2f3f3; */
|
height: 29px;
|
border-width: 1px 1px 1px 1px;
|
border-color: #e0e3e5;
|
font-size: inherit;
|
/*font-weight: bold;*/
|
color: black;
|
text-align: center;
|
left;
|
white-space: nowrap;
|
/* font-size: 13px; */
|
}
|
/* div{
|
padding-left: 10px;
|
padding-right: 10px;
|
} */
|
tr.dataRow:hover {
|
background-color: #e3f3ff;
|
}
|
</style>
|
|
<body id="body" class="lookupTab" >
|
<script type="text/javascript">
|
|
var searchKeyWord = '{!searchKeyWord}';
|
var accountId = '{!accountId}';
|
searchAWSContact(searchKeyWord,accountId);
|
|
function searchAWSContactFromPop(){
|
// var inputword = '{!searchKeyWord}';
|
var inputword = document.getElementById('lksrch').value;
|
var hosId = '{!accountId}';
|
if(inputword == null || inputword == ''){
|
window.alert("请输入搜索关键字!");
|
}
|
searchAWSContact(inputword,hosId);
|
}
|
|
function searchAWSContact(searchKeyWord,hosId){
|
console.log(searchKeyWord+hosId);
|
let queryResult = document.getElementById('QueryResult');
|
let table = document.getElementById('table');
|
if(table){
|
queryResult.removeChild(table);
|
}
|
var staticResourceContact = JSON.parse('{!staticResource}');
|
let searchPayload = new Object();
|
var contactAWSIds = JSON.parse('{!contactAWSIds}');
|
searchPayload.dataIds = [];
|
searchPayload.name = searchKeyWord;
|
let resBody = JSON.stringify(searchPayload);
|
AWSService.search(staticResourceContact.searchUrl, resBody , function(data){
|
if(data && data.object){
|
console.log(data.object.length);
|
if(data.object.length > 15000){
|
let newObj = [];
|
for(var i = 0; i < 15000; i++){
|
newObj.push(data.object[i]);
|
}
|
data.object = newObj;
|
}
|
console.log('object:'+JSON.stringify(data.object));
|
Visualforce.remoting.Manager.invokeAction(
|
'{!$RemoteAction.SearchContactForAgencyOppController.searchContacts}',
|
JSON.stringify(data.object),searchKeyWord,hosId,
|
function (result, event) {
|
if(event.status){
|
console.log("result:"+JSON.stringify(result));
|
refreshTable(result);
|
}
|
},
|
{ escape: true }
|
);
|
}
|
}, staticResourceContact.token);
|
}
|
|
function refreshTable(contactInfoList){
|
let cols = ['Name','Hospital_Name__c', 'Type__c', 'Doctor_Division1__c'];
|
let myTableDiv = document.getElementById("QueryResult");
|
let table = document.createElement('TABLE');
|
table.border = '1';
|
table.id = 'table'
|
let tableBody = document.createElement('TBODY');
|
table.appendChild(tableBody);
|
let headerTR = document.createElement('TR');
|
headerTR.setAttribute("class","headerRow");
|
let colsHeader = ['姓名','医院名称','分类', '职务'];
|
tableBody.appendChild(headerTR);
|
for (let i = 0; i < colsHeader.length; i++) {
|
let td = document.createElement('TH');
|
td.width = '75';
|
td.style = 'text-align: left;';
|
td.appendChild(document.createTextNode(colsHeader[i]));
|
headerTR.appendChild(td);
|
}
|
//3. Init the AWS data
|
for (let i = 0; i < contactInfoList.length; i++) {
|
let tr = document.createElement('TR');
|
tr.setAttribute("class","dataRow");
|
tableBody.appendChild(tr);
|
let contactInfoTemp = contactInfoList[i]
|
for (let j = 0; j < cols.length; j++) {
|
let td = document.createElement('TD');
|
td.setAttribute("class","dataCell");
|
td.width = '75';
|
td.style = 'text-align: left;';
|
td.awsId = contactInfoTemp.AWS_Data_Id__c;
|
td.recordId = contactInfoTemp.Id;
|
td.conName = contactInfoTemp.Name;
|
td.appendChild(document.createTextNode(contactInfoTemp[cols[j]]!=null?contactInfoTemp[cols[j]]:''));
|
if (cols[j] == 'Name') {
|
td.width = '120';
|
}
|
if (cols[j] == 'Name') {
|
td.addEventListener("click", function (obj) {
|
let awsId = obj.currentTarget.awsId;
|
let recordId = obj.currentTarget.recordId;
|
let conName = obj.currentTarget.conName;
|
let domId = "{!domId}";
|
console.log('obj:'+awsId+conName+recordId+domId);
|
// var dom = document.getElementById('')
|
var winMain = window.opener;
|
if (null == winMain) {
|
winMain = window.parent.opener;
|
}
|
var domArr = winMain.document.querySelectorAll("input[field-api='Agency_Contact__c']");
|
var domArr1 = winMain.document.querySelectorAll("[field-api='AwsId']");
|
var domArr2 = winMain.document.querySelectorAll("[field-api='RecordId']");
|
console.log(domArr.length);
|
console.log(domArr1.length);
|
console.log(domArr2.length);
|
for(var j = 0; j < domArr.length; j++){
|
var domname = domArr[j].parentNode.parentNode.id;
|
if(domname == domId){
|
console.log('domId:'+domId);
|
domArr[j].value = conName;
|
domArr1[j].value = awsId;
|
domArr2[j].value = recordId;
|
}
|
}
|
winMain.closePopupWindow();
|
window.close();
|
});
|
td.setAttribute("style","color:rgba(1, 118, 211, 1);text-align: left;cursor: pointer;");
|
}
|
tr.appendChild(td);
|
}
|
}
|
myTableDiv.appendChild(table);
|
}
|
</script>
|
<apex:form id="form">
|
<!-- Search Filter-->
|
<div style="padding-left: 10px;padding-right: 10px;height:200px;max-height:200px;">
|
<apex:inputHidden value="{!searchKeyWord}" id="searchKeyWord" />
|
<div class="lookup">
|
<div class="content" style="text-align: center;font-size:18px;">
|
<h1>{!ObjectTypeLabel}</h1>
|
</div>
|
<div>
|
<apex:outputText value="{!ObjectTypeLabel}" style="width: 500px;" />
|
</div>
|
<div class="pBody">
|
<label class="assistiveText" for="lksrch">Search</label>
|
<apex:inputText styleClass="slds-input" id="lksrch" html-placeholder="请输入..." value="{!searchKeyWord}" style="width: 500px;height:32px;" />
|
<apex:commandButton styleClass="slds-button slds-button_neutral" value=" 检索 " style="margin-left:10px;height:32px;" onclick="searchAWSContactFromPop();" oncomplete="unblockUI();" />
|
</div>
|
</div>
|
<div><br/></div>
|
<div id="QueryResult" style="height:480px;overflow:scroll;">
|
</div>
|
</div>
|
</apex:form>
|
</body>
|
</apex:page>
|