From 2d5b6ced9bbcb7a30159fd892b39d27a7e048b82 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期日, 24 四月 2022 09:41:45 +0800
Subject: [PATCH] BatchForAgencyContact
---
force-app/main/default/pages/NewAndEditCase.page | 172 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 137 insertions(+), 35 deletions(-)
diff --git a/force-app/main/default/pages/NewAndEditCase.page b/force-app/main/default/pages/NewAndEditCase.page
index 8dd8253..05c55c7 100644
--- a/force-app/main/default/pages/NewAndEditCase.page
+++ b/force-app/main/default/pages/NewAndEditCase.page
@@ -24,7 +24,7 @@
//鍒ゆ柇insert or update
function ProcessPI(caseJson, payloadForNewPI) {
blockme();
- if ({!isNewMode}) {
+ if ({!isNewMode} || {!isCloneMode}) {
NewPIToAWS(caseJson, payloadForNewPI)
}else {
UpdatePIToAWS(caseJson, payloadForNewPI)
@@ -103,11 +103,27 @@
let nodelist = document.querySelectorAll("[data-id]");
let result = {}
result.RecordTypeId = '{!rtTypeId}'
+ //瀵屾枃鏈�
+ var describedbyAll = document.querySelectorAll("[aria-describedby = 'cke_34']");
+ if(describedbyAll){
+ for (let idx = 0; idx < describedbyAll.length; idx++) {
+ let describedby = describedbyAll[idx];
+ if (describedby.title.indexOf('Text_attachement__c') > 0){
+ result.Text_attachement__c = describedby.contentWindow.document.getElementsByTagName('body')[0].innerHTML;
+ if (result.Text_attachement__c == '<br>') {
+ result.Text_attachement__c = '';
+ }
+ }
+ }
+ }
for (let index = 0; index < nodelist.length; index++) {
if (VLookUpFields.has(nodelist[index].getAttribute("data-id"))) {
console.log(nodelist[index].id.indexOf('lkwgt'));
if (nodelist[index].id.indexOf('lkwgt') == -1) {
let vlookUpNodeId = nodelist[index].id + '_lkid';
+ if (nodelist[index].getAttribute("data-id") == 'Field1_staff__c') {
+ vlookUpNodeId = nodelist[index].id.substring(0,nodelist[index].id.length-4) + '_lkid';
+ }
let vlookUpNodeValue = document.getElementById(vlookUpNodeId).value;
result[nodelist[index].getAttribute("data-id")] = vlookUpNodeValue;
}
@@ -128,12 +144,6 @@
index++;
}
}
- //閽堝id鐨勬墜鍔ㄦ坊鍔�
- if (document.getElementById("page:form:block:j_id31:0:j_id32:j_id33:1:j_id34_lkid") && (!result.hasOwnProperty("Field1_staff__c") || !result["Field1_staff__c"])){
- if(document.getElementById("page:form:block:j_id31:0:j_id32:j_id33:1:j_id34_lkid").value != '000000000000000'){
- result["Field1_staff__c"] = document.getElementById("page:form:block:j_id31:0:j_id32:j_id33:1:j_id34_lkid").value;
- }
- }
return result;
}
@@ -144,9 +154,15 @@
//闇�瑕佽В瀵嗗瓧娈�
var queryBack = function queryBack(data) {
console.log('data = ' + data);
- document.querySelector("[data-id='cic_telephone__c']").value = data.object.cicTelephone;
- document.querySelector("[data-id='CASE_CUSTOMER__c']").value = data.object.caseCustomer;
- document.querySelector("[data-id='Customer_manual__c']").value = data.object.customerManual;
+ if (document.querySelector("[data-id='cic_telephone__c']")) {
+ document.querySelector("[data-id='cic_telephone__c']").value = data.object.cicTelephone;
+ }
+ if (document.querySelector("[data-id='CASE_CUSTOMER__c']")) {
+ document.querySelector("[data-id='CASE_CUSTOMER__c']").value = data.object.caseCustomer;
+ }
+ if (document.querySelector("[data-id='Customer_manual__c']")) {
+ document.querySelector("[data-id='Customer_manual__c']").value = data.object.customerManual;
+ }
};
var insertOrUpdateBack = function insertOrUpdateBack(payloadJson, result, isNewMode) {
@@ -162,10 +178,13 @@
payloadJson.Customer_manual_Encrypted__c = r.object[0].customerManualEncrypt;
//payloadJson.AWS_Data_Id__c = r.object[0].dataId;
payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
- if (isNewMode) {
+ if (isNewMode || {!isCloneMode}) {
payloadJson.AWS_Data_Id__c = r.object[0].dataId;
} else {
payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
+ }
+ if('{!rtTypeId}'){
+ payloadJson.RecordTypeId = '{!rtTypeId}';//Add by zhj for Record Type Issue 20220421
}
return payloadJson;
}
@@ -227,6 +246,7 @@
//1. Get Case Information from Form
let caseJson = getCaseInformation();
//2. Validate the Case field value formate, for example the email formate or phone formate
+ /*
let validationResultMessage = validateFieldValueFormate();
console.log(validationResultMessage);
if (!validationResultMessage) {
@@ -235,6 +255,7 @@
alertErrorMessage('鎵嬫満鏍煎紡杈撳叆鏈夎锛岃閲嶆柊杈撳叆锛�');
return
}
+ */
// Check Required Field
let checkRequiredFieldMsgResult = checkRequiredFieldMsg(caseJson);
if (checkRequiredFieldMsgResult) {
@@ -277,9 +298,14 @@
accountValue = document.getElementById(accountNodeId).value;
}
console.log(accountValue);
- if(accountValue !='000000000000000'){
+ if(accountValue !='000000000000000' || true){
+ if (accountValue == '000000000000000') {
+ accountValue = '';
+ }
+
let baseUrl = "/apex/SearchContactPage";
- let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
+ let searchContactKeyWord = document.querySelector("[data-id='ContactId']").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) {
@@ -320,25 +346,25 @@
let sfId = document.getElementById(document.querySelector("[data-id='ContactId']").id + '_lkid').value;
let contactsInfo = JSON.parse('{!contactsInfo}');
let dataId = contactsInfo[sfId];
- // let queryContactBack = function(data){
- // //To Do later
- // console.log('ContactData = ' + data.object);
+ let queryContactBack = function(data){
+ //To Do later
+ console.log('ContactData = ' + data.object);
- // document.querySelector("[data-id='ContactId']").value = data.object.lastName;
- // }
- // AWSService.query(staticResourcesContact.queryUrl, dataId, queryContactBack, staticResources.token);
- let url = staticResourcesContact.queryUrl + '?dataId=' + dataId;
- fetch(url, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- 'pi-token': staticResources.token
- }
- }).then((data) => {
- return data.json();
- }).then((result) => {
- document.querySelector("[data-id='ContactId']").value = result.object.lastName;
- })
+ document.querySelector("[data-id='ContactId']").value = data.object.lastName;
+ }
+ AWSService.query(staticResourcesContact.queryUrl, dataId, queryContactBack, staticResources.token);
+ // let url = staticResourcesContact.queryUrl + '?dataId=' + dataId;
+ // fetch(url, {
+ // method: 'GET',
+ // headers: {
+ // 'Content-Type': 'application/json',
+ // 'pi-token': staticResources.token
+ // }
+ // }).then((data) => {
+ // return data.json();
+ // }).then((result) => {
+ // document.querySelector("[data-id='ContactId']").value = result.object.lastName;
+ // })
}
</script>
<div class="bPageTitle">
@@ -372,7 +398,7 @@
<img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />
<h2 class="mainTitle">CIC缂栬緫</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="淇濆瓨" onclick="saveCaseProcess('Save')" />
<input class="btn" type="Button" value="淇濆瓨骞跺叧闂�" onclick="saveCaseProcess('SaveAndClose')" />
<input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveCaseProcess('SaveAndNew')" />
@@ -394,8 +420,10 @@
<apex:pageBlockSection title="{!layoutSection.name}" showHeader="{!layoutSection.useHeader}" collapsible="{!layoutSection.allowCollapse}" columns="{!layoutSection.columns}">
<!--Each section has layoutFields, let's iterate them as well-->
<apex:repeat value="{!layoutSection.layoutFields}" var="layoutField">
- <apex:inputField html-data-id="{!layoutField.fieldAPI}" value="{!Case[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
- required="{!layoutField.isRequired}" />
+ <apex:inputField html-data-id="{!layoutField.fieldAPI}" value="{!Case[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}" required="{!layoutField.isRequired}" />
+ <apex:inputField html-data-id="{!layoutField.fieldAPI}" value="{!Case[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI!='RecordTypeId'}" required="{!layoutField.isRequired}" />
+ <apex:outputField html-data-id="{!layoutField.fieldAPI}" value="{!Case[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}" />
+
<apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
</apex:pageblocksectionitem>
</apex:repeat>
@@ -403,6 +431,28 @@
</apex:repeat>
<script>
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");
+ }else if (e.tagName == 'DIV') {
+ e.classList.add("disabledbutton");
+ }else if (VLookUpFields.indexOf(layoutField.fieldAPI) >= 0) {
+ e.parentNode.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
@@ -417,8 +467,60 @@
//3. Set Readonly Attribute
document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton");
document.querySelector("[data-id='RecordTypeId']").classList.add("disabledbutton");
+
+ document.getElementById('topButtonRow').style = '';
+ document.getElementById('bottomButtonRow').style = '';
//闇�瑕侀殣钘�
// document.querySelector("[data-id='SuppliedEmail']").classList.add("displayblock");
+
+ jQuery('a[data-id="OwnerId"]').remove();
+
+ let previous_value = {};
+ jQuery(".lookupInput input").each(function(i,e){
+ let je =jQuery(e);
+
+ let dataid = je.attr('data-id');
+ if(['ContactId'].indexOf(dataid) < 0) return;
+
+ jQuery(e).focus(function(){
+ previous_value[this.id] = this.value;
+ })
+
+ jQuery(e).change(function(){
+ if (previous_value[this.id] != jQuery(this).val()) {
+ document.getElementById(this.id+'_lkid').value = '';
+ }
+ })
+ })
+ // jQuery(".lookupInput").each(function(i,e){
+ // let je =jQuery(e).find('input');
+ // je.attr("readonly","");
+ // je.css("background","unset");
+
+ // let dataid = je.attr('data-id');
+ // if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return;
+ // jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">');
+ // })
+
+ // jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){
+ // this.className = "closeIconOn";
+ // });
+
+ // jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){
+ // this.className = "closeIcon"
+ // });
+
+ // jQuery(".lookupInput").on("click","img[generate]",function(e){
+ // let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id");
+ // let input = document.getElementById(id);
+ // if(input){
+ // input.value = '';
+ // let hidden = document.getElementById(id+'_lkid');
+ // if(hidden){
+ // hidden.value = '';
+ // }
+ // }
+ // });
});
</script>
<div class="pbBottomButtons">
@@ -427,7 +529,7 @@
<tr>
<td class="pbTitle">
<img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> </td>
- <td class="pbButton" id="bottomButtonRow">
+ <td class="pbButton" id="bottomButtonRow" style="pointer-events: none; opacity: 0.4;">
<input class="btn" type="Button" value="淇濆瓨" onclick="saveCaseProcess('Save')" />
<input class="btn" type="Button" value="淇濆瓨骞跺叧闂�" onclick="saveCaseProcess('SaveAndClose')" />
<input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveCaseProcess('SaveAndNew')" />
--
Gitblit v1.9.1