<apex:page standardController="loaner_user__c" extensions="NewLoanerUserController" id="allPage" showHeader="true" sidebar="false" action="{!init}" title="新建样机借用客户">
|
<!-- <apex:page standardController="loaner_user__c" extensions="NewLoanerUserController" showHeader="true" sidebar="false" action="{!init}" title="新建样机借用客户"> -->
|
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
|
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
|
<!-- Update 20220317 By Yang Kaiyu Start -->
|
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
|
<apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
|
<apex:includeScript value="/soap/ajax/40.0/connection.js"/>
|
<script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
|
<!-- Update 20220317 By Yang Kaiyu End -->
|
<script>
|
// Update 20220317 By Yang Kaiyu Start
|
AWSService.sfSessionId = '{!GETSESSIONID()}';
|
var staticResource = JSON.parse('{!staticResource}');
|
var staticResourceContact = JSON.parse('{!staticResourceContact}');
|
var aws_data = {};
|
let conList = [];
|
//替换vlookup
|
var closeField = '';
|
var newSearchContactWindow = null;
|
var contactInfoStr = '';
|
var conValue = ''
|
//自定义lookup查询
|
function searchContact(contactNodeId,field,conValue,conid){
|
closeField = conid;
|
this.conValue = conValue;
|
let accountValue = "";
|
if (document.getElementById(field)!=null) {
|
accountValue = document.getElementById(field).value;
|
}
|
console.log(accountValue);
|
if(accountValue !='000000000000000'){
|
let baseUrl = "/apex/SearchContactPage";
|
let searchContactKeyWord = document.getElementById(conid).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) {
|
newSearchContactWindow.focus();
|
}
|
return false;
|
}else{
|
alert('请先选择客户再选择联系人')
|
}
|
}
|
var dataLinesJson;
|
function replaceSearchContactLookup() {
|
conList = JSON.parse('{!conListJson}');
|
dataLinesJson = JSON.parse('{!dataLinesJson}');
|
console.log('dataLinesJson = ' + dataLinesJson);
|
for(var i = 0;i<dataLinesJson.length;i++){
|
let ii = i;
|
document.getElementById('allPage:allForm:allBlock:lines:'+ii+':contact').addEventListener('click',function(){
|
searchContact('allPage:allForm:contactId','allPage:allForm:allBlock:lines:'+ii+':customer_lkid','allPage:allForm:allBlock:lines:'+ii+':contactId_Hidden','allPage:allForm:allBlock:lines:'+ii+':contact');
|
});
|
}
|
|
|
}
|
function htmlToElement(html) {
|
var template = document.createElement('template');
|
html = html.trim(); // Never return a text node of whitespace as the result
|
template.innerHTML = html;
|
return template.content.firstChild;
|
}
|
function closePopupWindow() {
|
if (null != newSearchContactWindow) {
|
newSearchContactWindow.close();
|
}
|
contactInfoStr = document.getElementById('allPage:allForm:contactId').value;
|
console.log('closePopup:'+contactInfoStr);
|
let contactInfo = JSON.parse(contactInfoStr);
|
let contactNodeId = conValue;
|
document.getElementById(contactNodeId).value = contactInfo.ContactId;
|
document.getElementById(closeField).value = contactInfo.Name;
|
}
|
function DecryptAll(){
|
let dataIds = [];
|
|
//"{!conList}".each((i,e)=>{
|
// console.log('------------------')
|
// console.log(e);
|
// let v = "{!conList}"[i].contactIdValue;
|
// if (v) {
|
// dataIds.push(v);
|
// }
|
//});
|
conList = JSON.parse('{!conListJson}');
|
if(conList){
|
for(var i=0 ;i<conList.length;i++){
|
if(conList[i]!=null){
|
let v = conList[i].contactIdValue;
|
if (v) {
|
dataIds.push(v);
|
}
|
}
|
}
|
}
|
|
Decrypt(dataIds);
|
}
|
j$(function(){
|
DecryptAll();
|
|
})
|
function Decrypt(dataIds){
|
let Foo = function(){
|
for (const id in dataIds) {
|
if (aws_data.hasOwnProperty(dataIds[id])) {
|
let d = aws_data[dataIds[id]];
|
let $e =j$("[aws-id='"+d.dataId+ "']");
|
//$e.html(d[$e.attr("aws-id")]);
|
$e.each(function(i,e){
|
j$(e).val(d.lastName);
|
})
|
}
|
}
|
}
|
let ids = [];
|
//for (const id in dataIds) {
|
// if (!aws_data.hasOwnProperty(id)) {
|
// ids.push(id);
|
// }
|
//}
|
for(var i =0 ;i<dataIds.length;i++){
|
if (!aws_data.hasOwnProperty(dataIds[i])) {
|
ids.push(dataIds[i]);
|
}
|
}
|
if (ids.length > 0) {
|
blockme();
|
AWSService.search(staticResourceContact.searchUrl,
|
JSON.stringify({
|
"dataIds":ids
|
}),
|
function(data){
|
unblockUI();
|
if(data.object && data.object.length > 0){
|
|
for(let d in data.object){
|
console.log('----------------')
|
console.log(d);
|
if(data.object[d].dataId){
|
aws_data[data.object[d].dataId] = data.object[d];
|
}
|
}
|
Foo();
|
}
|
},
|
staticResourceContact.token);
|
}else{
|
Foo();
|
}
|
}
|
// Update 20220317 By Yang Kaiyu End
|
function saveJs() {
|
if(confirm('联系人和客户为必填信息,如果为空将不保存此条记录,是否已确认所有需要保存的信息该字段都不为空?')){
|
blockme();
|
updateUser();
|
}
|
}
|
</script>
|
|
|
|
<style type="text/css">
|
.dateFormat{
|
display: none;
|
}
|
</style>
|
|
<apex:form id="allForm">
|
<!-- Update 20220317 By Yang Kaiyu Start -->
|
<apex:inputHidden value="{!contactId}" id="contactId" />
|
<!-- Update 20220317 By Yang Kaiyu End -->
|
<apex:actionFunction name="updateUser" action="{!updateUser}" rerender="allForm,message,allPanel" onComplete="unblockUI();"></apex:actionFunction>
|
<apex:outputPanel id="message">
|
<apex:messages />
|
</apex:outputPanel>
|
|
<apex:outputPanel id="allPanel">
|
<apex:pageBlock id="allBlock">
|
<table style="width: 100%;">
|
<tr>
|
<th style="text-align: left;font-size: 20px;">
|
新建样机借用客户
|
</th>
|
<th style="text-align: right;">
|
<apex:commandButton action="{!cancelBtn}" value="返回" rerender="dummy" style="width: 70px;"/>
|
<apex:commandButton onclick="saveJs();" value="确认" rerender="allForm" style="width: 70px;"/>
|
</th>
|
</tr>
|
</table>
|
<div style="overflow: scroll;height: 300px;width: 1260px; ">
|
<apex:variable value="{!1}" var="cnt" />
|
<apex:repeat value="{!dataLines}" var="line" id="lines">
|
<div style="width: 1260px;">
|
{!$ObjectType.loaner_user__c.fields.Customer__c.label}:
|
<!-- Update 20220317 By Yang Kaiyu Start -->
|
<apex:inputField id="customer" value="{!line.Customer__c}" />
|
<!-- Update 20220317 By Yang Kaiyu End -->
|
{!$ObjectType.loaner_user__c.fields.Contact__c.label}:
|
<!-- Update 20220317 By Yang Kaiyu Start -->
|
<!-- <apex:inputField id="contact" value="{!line.Contact__c}" html-aws-id="{!line.Contact__r.AWS_Data_Id__c}" /> -->
|
<apex:inputText id="contact" html-aws-id="{!line.Contact__r.AWS_Data_Id__c}" disabled="false" value="{!line.Contact__r.LastName}" ></apex:inputText>
|
<apex:inputText id="contactId_Hidden" value="{!line.Contact__c}" style="display:none"/>
|
<!-- Update 20220317 By Yang Kaiyu End -->
|
|
{!$ObjectType.loaner_user__c.fields.FromThePeriod__c.label}:
|
<apex:inputField value="{!line.FromThePeriod__c}"/>
|
{!$ObjectType.loaner_user__c.fields.EndThePeriod__c.label}:
|
<apex:inputField value="{!line.EndThePeriod__c}"/>
|
{!$ObjectType.loaner_user__c.fields.Follow_UP_Opp__c.label}:
|
<apex:inputField value="{!line.Follow_UP_Opp__c}"/>
|
{!$ObjectType.loaner_user__c.fields.Remarks__c.label}:
|
<apex:inputField value="{!line.Remarks__c}"/>
|
<apex:variable value="{!cnt + 1}" var="cnt" />
|
</div>
|
</apex:repeat>
|
<!-- Update 20220317 By Yang Kaiyu Start -->
|
<script>
|
sfdcPage.appendToOnloadQueue(function () {
|
//Replace Vlookup Field
|
|
replaceSearchContactLookup();
|
})
|
</script>
|
<!-- Update 20220317 By Yang Kaiyu End -->
|
</div>
|
|
</apex:pageBlock>
|
</apex:outputPanel>
|
|
</apex:form>
|
|
|
</apex:page>
|