From 1b8c8764c39fc546ca1b85ff1810ae51be74331c Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期四, 31 三月 2022 18:39:23 +0800
Subject: [PATCH] PIPL0331V2Deploy
---
force-app/main/default/pages/StraightBackAddress.page | 222 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 191 insertions(+), 31 deletions(-)
diff --git a/force-app/main/default/pages/StraightBackAddress.page b/force-app/main/default/pages/StraightBackAddress.page
index b7b6bd1..790dde0 100644
--- a/force-app/main/default/pages/StraightBackAddress.page
+++ b/force-app/main/default/pages/StraightBackAddress.page
@@ -1,3 +1,10 @@
+<!--
+ @description :
+ @author : ChangeMeIn@UserSettingsUnder.SFDoc
+ @group :
+ @last modified on : 03-30-2022
+ @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc
+-->
<apex:page controller="StraightBackAddressController" action="{!init}" showHeader="false" sidebar="true" id="allPage" title="鐩磋繑鏀惰揣鍦板潃">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
@@ -10,6 +17,8 @@
var tableDataStr = '';
var staticResource = JSON.parse('{!staticResource}');
var staticResourceContact = JSON.parse('{!staticResourceContact}');
+ var staticResourceRepair = JSON.parse('{!staticResourceRepair}');
+
var PIData = {};
var contactDataIds = [];
var ObjIdDecrypt = '';
@@ -18,6 +27,8 @@
var con_aws_result = '';
var isAddCon = false;
var contactInfoStr = '';
+
+ var addressAwsData = {};
//鏇挎崲vlookup
var newSearchContactWindow = null;
@@ -140,10 +151,7 @@
}
blockme();
console.log('{!insUpdData}')
- if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value //銆愯仈绯讳汉锛堟柊寤猴級銆戜笉涓虹┖
- &&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:CustomerRecordType").value!='{!accOfficeTypeId}'////璁板綍绫诲瀷id 鍔炰簨澶�
- &&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:CustomerRecordType").value!='{!accAgencyTypeId}'//璁板綍绫诲瀷id 璨╁2搴�
- &&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:CustomerRecordType").value!='{!accAgencyContactTypeId}'){//璁板綍绫诲瀷id 缁忛攢鍟嗚仈绯讳汉
+ if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){
//new contact
ProcessPI({},GetEditObj('contact'),'contact',function(){
//new address
@@ -267,8 +275,10 @@
searchBtn('\''+addressName+'\'');
return
}else{
+
for(var i=0;i<result.object.length;i++){
addressDataIds += ',\''+ result.object[i].dataId + '\'';
+ addressAwsData[result.object[i].dataId] = result.object[i];
}
addressDataIds = addressDataIds.substring(1);
resolve('success');
@@ -285,21 +295,155 @@
searchBtn(addressDataIds);
}
}
- //閲囩敤鎸夐挳
- function onAdoptJs(objId){
- if(objId != null){
- //鍒ゆ柇褰撳墠淇悊鍗曟槸鍚﹀凡缁忕敵璇蜂慨鐞�
- var uploadTime = '{!FSEApplyForRepairTime}';
- if(uploadTime != 'null'){
- var prompt = '鐢变簬褰撳墠淇悊鍗曞凡鐢宠淇悊锛岃闂槸鍚﹂噰鐢ㄥ苟涓婁紶鏁版嵁鍒癝AP锛�';
- if(confirm(prompt)){
- blockme();
- adoptSave(objId+"",true);
- }
- }else{
- adoptSave(objId+"",false);
+ //鍔犲瘑瀹㈡埛鍚嶅瓧娈�
+ // function encryptCustomer(e){
+ // let obj = JSON.parse(payloadForNewPI);
+ // let payloadForNewPIJson = JSON.stringify(obj);
+ // let payloadForNewPI = jQuery(e.target).closest("tr").find("a.cusmer__c");
+ // AWSService.update(staticResources.updateUrl, '', payloadForNewPI, updateMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack);
+ // },
+
+ sforce.connection.sessionId = '{!GETSESSIONID()}';
+ function UpdateSobject(staticResource,sobj,transId,callback){
+
+ let result = sforce.connection.update([sobj]);
+ let tobj = {
+ txId: transId
+ };
+ let b = result[0].getBoolean('success');
+ if(b) {
+ console.log('call sf Log Id: ' + result[0].id);
+ tobj.sfRecordId = result[0].id;
+ tobj.isSuccess = 1;
+
+ //return result[0].id;
+ }else {
+ console.log('call sf to insert log');
+ tobj.isSuccess = 0;
+ //return '';
+ }
+
+ AWSService.post(staticResource.transactionUrl,tobj,function(data){
+ if (callback) {
+ data.isSuccess = b;
+ callback(data)
}
- }
+ },staticResource.token);
+ }
+
+
+
+ function adoptSaveJs(address){
+ //鐢变簬瑕佹妸閲囩敤鏃堕棿璁板綍鍒板湴鍧�琛ㄤ腑锛屾墍浠ユ柊寤轰竴涓湴鍧�瀵硅薄
+ // Address__c DatetimeUpdate = new Address__c();
+ // DatetimeUpdate = tableData[i].address;
+ //璇︾粏鍦板潃
+ let address_str = address.Detailed_Address__c.trim();addressAwsData
+ let cityName = '';//甯�
+ //甯備笉涓虹┖锛屽洜涓鸿浣跨敤 __r.Name 濡傛灉涓虹┖锛屼細鎶ラ敊
+ if(address.City__c){
+ cityName = address.City__r.Name.trim();
+ //鐪� 鍚屼笂
+ if(address.Province__c){
+ let ProvinceCity = address.Province__r.name.trim()+cityName;
+ //闃叉璇︾粏鍦板潃閲岄潰甯︾潃鐪佷唤鍜屽競
+ if(address_str.indexOf(ProvinceCity) < 0){
+ address_str = ProvinceCity + address_str;
+ }
+ }
+ }
+ //鑱旂郴浜�
+ let contactsName = '';
+ if(address.Contacts__c){
+ contactsName = address.Contacts__r.Name;
+ }
+ //瀹㈡埛
+ let ContactPerson = '';
+ if(address.Customer__c){
+ ContactPerson = address.Customer__r.Name;
+ }
+ try{
+ //淇濆瓨鏁版嵁鍒颁慨鐞嗚〃涓�
+ let rc = new sforce.SObject('Repair__c');
+ rc.Id='{!RepairId}';
+ rc.address_Contacts__c=contactsName;
+ rc.address_ZipCode__c = address.ZipCode__c;
+ rc.address_City__c = cityName;
+ rc.address_Contacts_Name__c = ContactPerson;
+ //isUpload锛氭槸鍚︿笂浼燬AP FSEApplyForRepairTime锛歋AP淇悊鐢宠鏃堕棿
+ if({!isUpload} && pc.SAP_Transfer_time__c){
+ rc.Address_type__c = 'X';
+ rc.Address_Type_Index__c = rc.Address_Type_Index__c+1;
+ }
+ rc.address_Telephone__c=address.Telephone__c;
+ rc.Detailed_Address__c=address_str;
+
+ let UpdateRepair = function(callback){
+ AWSService.post(staticResourceRepair.updateUrl,[{
+ dataId:'{!pc.AWS_Data_Id__c}',
+ addressContactsName:rc.address_Contacts_Name__c,
+ detailedAddress:rc.Detailed_Address__c
+ }],function(data){
+ if(data && data.object){
+ console.log(data);
+ rc.address_Contacts__c = data.object[0].addressContactsName;
+ rc.Detailed_Address__c = data.object[0].detailedAddress;
+ UpdateSobject(staticResourceRepair,data.txId,callback);
+ }else{
+ alert('鏇存柊淇悊澶辫触');
+ unblockUI();
+ }
+ },staticResourceRepair.token)
+ }
+
+ //淇濆瓨鏁版嵁鍒颁繚鏈夎澶囪〃涓�
+ let UpdateAsset = function(){
+ let ast = new sforce.SObject('Asset');
+ ast.Id = pc.Delivered_Product__c,
+ ast.address_Contacts__c= contactsName,
+ ast.address_ZipCode__c = address.ZipCode__c,
+ ast.address_City__c = cityName,
+ ast.address_Telephone__c = address.Telephone__c,
+ ast.address_Contacts_Name__c = ContactPerson,
+ ast.Detailed_Address__c= address_str
+ let result = sforce.connection.update([ast]);
+ let b = result[0].getBoolean('success');
+ return b;
+ }
+
+
+ let UpdateAddress = function(){
+ let add = new sforce.SObject('Address__c');
+ add.Id = address.Id;
+ //鏈�鍚庢妸褰撳墠鏃堕棿淇濆瓨鍒板湴鍧�琛ㄤ腑锛屼綔涓洪噰鐢ㄦ椂闂�
+ add.Using_Datetime__c = new Date();
+ let result = sforce.connection.update([add]);
+ let b = result[0].getBoolean('success');
+ return b;
+ }
+
+ UpdateAddress
+ //椤甸潰閲嶅畾鍚�
+ //return redirectPag();
+ }catch( e){
+ //澶辫触鎻愮ず
+ //ApexPages.addMessages(e);
+ }
+ }
+ //閲囩敤鎸夐挳
+ function onAdoptJs(e, address){
+
+ //鍒ゆ柇褰撳墠淇悊鍗曟槸鍚﹀凡缁忕敵璇蜂慨鐞�
+ var uploadTime = '{!FSEApplyForRepairTime}';
+ if(uploadTime != 'null'){
+ var prompt = '鐢变簬褰撳墠淇悊鍗曞凡鐢宠淇悊锛岃闂槸鍚﹂噰鐢ㄥ苟涓婁紶鏁版嵁鍒癝AP锛�';
+ if(confirm(prompt)){
+ adoptSaveJs(address);
+ }
+ }else{
+ adoptSaveJs(address);
+ }
+
}
/* function onAdoptJs(){
if(checkedTrue != null){
@@ -465,7 +609,7 @@
createDiv.style.background="#dddddd";
createDiv.style.position = "absolute";
parentNode.appendChild(createDiv);
- parentNode.style.position = "relative";
+ parentNode.style.position = "relative";
}
function hidePIDiv(awsDataId){
@@ -533,11 +677,6 @@
document.getElementById(contactNodeId).value = contactInfo.ContactId;
document.getElementById(closeField).value = contactInfo.Name;
}
- function queryRecordType(){
- if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name').value){
- queryRecordType();
- }
- }
//2022 02 28 寮犲崕寤� display PI Data end
</script>
<apex:form id="allForm">
@@ -558,8 +697,6 @@
</apex:actionFunction>
<!-- 淇濆瓨鍜屼慨鏀规柟娉� -->
<apex:actionFunction name="save" action="{!save}" rerender="oppBlock2,message" onComplete="unblockUI();{!IF(isSearchBtn,'searchBtnJs()',false)};Trans()"></apex:actionFunction>
- <!-- 鏌ヨ瀹㈡埛璁板綍绫诲瀷鏂规硶 -->
- <apex:actionFunction name="queryRecordType" action="{!queryRecordType}" rerender="oppBlock2,message" onComplete="unblockUI();"></apex:actionFunction>
<!-- 鐐瑰嚮淇敼鎸夐挳鑾峰彇淇敼鏁版嵁鏂规硶 -->
<apex:actionFunction name="onEditor" action="{!onEditor}" rerender="oppBlock2,checEventFrame,insUpdDataStr" onComplete="decrypt();unblockUI();">
<apex:param name="UpdId" assignTo="{!UpdId}" value="" />
@@ -646,10 +783,10 @@
<td align="center" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
<apex:outputText value="{!or.address.Address_Classification__c}" />
</td>
- <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
+ <td align="left" class="Customer__c" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
<apex:outputfield value="{!or.address.Customer__c}" />
</td>
- <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;" aws-data-id="{!or.address.AWS_Data_Id__c}">
+ <td align="left" class="address" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;" aws-data-id="{!or.address.AWS_Data_Id__c}">
<!-- <apex:outputfield value="{!or.address.Contacts__c}" id="{!or.address.Contacts__c}_{!or.address.Id}"/> -->
<a href="#" id="{!or.address.Id}" onmouseover="showPIDiv('{!or.address.Id}')" onmouseout="hidePIDiv('{!or.address.Id}')" aws-data-id="{!or.address.Contacts__r.AWS_Data_Id__c}">{!or.address.Contacts__r.Name}</a>
</td>
@@ -675,7 +812,7 @@
<apex:commandButton value=" 澶嶅埗 " onclick="onCopyJs('{!or.address.id}');return false;" style="background: #98c1fbf7;display:{!or.canCopy};"/>
</td>
<td align="center" style="vertical-align: inherit;width:30px;">
- <apex:commandButton value=" 閲囩敤 " onclick="onAdoptJs('{!or.address.id}');return false;" style="background: #98c1fbf7;display:{!or.canAdopt};"/>
+ <apex:commandButton value=" 閲囩敤 " onclick="onAdoptJs(event,JSON.parse('{!or.addressJson}'));return false;" style="background: #98c1fbf7;display:{!or.canAdopt};"/>
</td>
</tr>
<apex:variable value="{!cnt + 1}" var="cnt" />
@@ -695,7 +832,7 @@
<apex:pageBlock id="oppBlock2" tabStyle="Report">
<apex:pageblocksection title="缂栬緫鍦板潃" id="UpdAddressId" rendered="true" columns="4">
<apex:inputfield value="{!insUpdData.Address_Classification__c}" id="Address_Classification__c" />
- <apex:inputfield value="{!insUpdData.Customer__c}" id="Customer__r_Name" required="false" onchange="queryRecordType();" />
+ <apex:inputfield value="{!insUpdData.Customer__c}" id="Customer__r_Name" required="false" />
<!-- Before PIPL 20220308 -->
<!-- <apex:inputfield value="{!insUpdData.Contacts__c}" id="Contacts__c" required="false"/> -->
<!-- Add By Li Jun for PIPL 20220308 Start -->
@@ -722,7 +859,6 @@
<apex:inputHidden id="Telephone_Encrypted__c" value="{!insUpdData.Telephone_Encrypted__c}"/>
<apex:inputHidden id="ZipCode_Encrypted__c" value="{!insUpdData.ZipCode_Encrypted__c}"/>
<apex:inputHidden id="Detailed_Address_Encrypted__c" value="{!insUpdData.Detailed_Address_Encrypted__c}"/>
- <apex:inputHidden id="CustomerRecordType" value="{!accRecordTypeId}"/>
</apex:pageblocksection>
<div style="text-align: center;">
@@ -738,6 +874,30 @@
<apex:outputPanel id="checEventFrame">
<script type="text/javascript">
j$("select option[value='鍔炰簨澶�']")[1].remove();
+ let arr = [];
+ j$('td.address').each(function(i,e){
+ let did = j$(e).attr('aws-data-id');
+ if (did) {
+ arr.push(did);
+ }
+ })
+ if (arr.length) {
+ blockme();
+ AWSService.post(staticResource.searchUrl,{
+ dataIds:arr
+ },function(data){
+ unblockUI();
+ if(data && data.object && data.object.length > 0){
+ for (let di in data.object) {
+ if (data.object[di] && data.object[di].dataId) {
+ addressAwsData[data.object[di].dataId] = data.object[di];
+ }
+ }
+
+ }
+ },staticResource.token)
+ }
+
</script>
</apex:outputPanel>
<script type="javascript/text">
--
Gitblit v1.9.1