| | |
| | | |
| | | var addressAwsData = {}; |
| | | |
| | | var isBlocking = false; |
| | | function b(){ |
| | | if (!isBlocking) { |
| | | blockme(); |
| | | isBlocking = true; |
| | | } |
| | | } |
| | | |
| | | function ub(){ |
| | | if (isBlocking) { |
| | | unblockUI(); |
| | | isBlocking = false; |
| | | } |
| | | } |
| | | |
| | | //替换vlookup |
| | | var newSearchContactWindow = null; |
| | | window.onload = function () { |
| | |
| | | document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value='' |
| | | document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value='' |
| | | } |
| | | |
| | | //{!IF(isSearchBtn,'searchBtnJs()',false)}; |
| | | let b1= false; |
| | | let b2= false; |
| | | |
| | | let Foo = function(){ |
| | | if (b1 && b2 && !b) { |
| | | window.location.reload(); |
| | | } |
| | | } |
| | | |
| | | AWSService.post(staticResource.transactionUrl, JSON.stringify({ |
| | | "txId":add_aws_result.txId, |
| | | "txId":add_aws_result.txId, |
| | | "isSuccess":b ? 0 : 1 |
| | | }), function(result){ |
| | | b1 = true; |
| | | Foo(); |
| | | }, staticResource.token); |
| | | |
| | | if(isAddCon){ |
| | | AWSService.post(staticResourceContact.transactionUrl, JSON.stringify({ |
| | | "txId":con_aws_result.txId, |
| | | "isSuccess":b ? 0 : 1 |
| | | }), function(result){ |
| | | if(isAddCon){ |
| | | AWSService.post(staticResourceContact.transactionUrl, JSON.stringify({ |
| | | "txId":con_aws_result.txId, |
| | | "isSuccess":b ? 0 : 1 |
| | | }), function(result){ |
| | | if(!b) |
| | | window.location.reload(); |
| | | }, staticResourceContact.token); |
| | | }else{ |
| | | if(!b) |
| | | window.location.reload(); |
| | | } |
| | | }, staticResource.token); |
| | | b2 = true; |
| | | Foo(); |
| | | }, staticResourceContact.token); |
| | | }else{ |
| | | b2 = true; |
| | | Foo(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | //保存方法 |
| | | function savaJs(){ |
| | | //blockme(); |
| | | //b(); |
| | | if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c').value != ''){ |
| | | isAddCon = true; |
| | | } |
| | |
| | | document.getElementById("errorMsg").innerHTML = '<strong>【联系人】和【联系人(新建)】不能同时有值!</strong> '; |
| | | return; |
| | | } |
| | | blockme(); |
| | | b(); |
| | | console.log('{!insUpdData}') |
| | | if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){ |
| | | //new contact |
| | |
| | | } |
| | | } |
| | | function searchBtnJs(){ |
| | | blockme(); |
| | | b(); |
| | | var addressDataIds = ''; |
| | | //查询地址 |
| | | if(document.getElementById('allPage:allForm:searchBlock:txtAddressId').value != ''){ |
| | |
| | | } |
| | | }; |
| | | var addressName = document.getElementById('allPage:allForm:searchBlock:txtAddressId').value; |
| | | AWSService.queryAddress('https://sfpi-mebg-test.olympuschina.com/api/address/search',addressName.trim(),queryBack,staticResource.token); |
| | | AWSService.post(staticResource.searchUrl,{ |
| | | detailedAddress:addressName.trim() |
| | | },queryBack,staticResource.token); |
| | | }).then(function(data){ |
| | | console.log('data = '+data) |
| | | console.log('addressDataIds = '+addressDataIds) |
| | |
| | | |
| | | |
| | | |
| | | function adoptSaveJs(address){ |
| | | function adoptSaveJs(address,isUpload){ |
| | | //由于要把采用时间记录到地址表中,所以新建一个地址对象 |
| | | // Address__c DatetimeUpdate = new Address__c(); |
| | | // DatetimeUpdate = tableData[i].address; |
| | | //详细地址 |
| | | let address_str = address.Detailed_Address__c.trim();addressAwsData |
| | | let address_str = address.Detailed_Address__c.trim(); |
| | | if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) { |
| | | address_str = addressAwsData[address.AWS_Data_Id__c].detailedAddress; |
| | | } |
| | | 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; |
| | | let ProvinceCity = address.Province__r.Name.trim()+cityName; |
| | | //防止详细地址里面带着省份和市 |
| | | if(address_str.indexOf(ProvinceCity) < 0){ |
| | | address_str = ProvinceCity + address_str; |
| | |
| | | if(address.Contacts__c){ |
| | | contactsName = address.Contacts__r.Name; |
| | | } |
| | | |
| | | if (addressAwsData.hasOwnProperty(address.Contacts__r.AWS_Data_Id__c)) { |
| | | contactsName = addressAwsData[address.Contacts__r.AWS_Data_Id__c].lastName; |
| | | } |
| | | |
| | | //客户 |
| | | let ContactPerson = ''; |
| | | if(address.Customer__c){ |
| | |
| | | rc.address_ZipCode__c = address.ZipCode__c; |
| | | rc.address_City__c = cityName; |
| | | rc.address_Contacts_Name__c = ContactPerson; |
| | | let AddressTypeIndex = {!AddressTypeIndex}; |
| | | //isUpload:是否上传SAP FSEApplyForRepairTime:SAP修理申请时间 |
| | | if({!isUpload} && pc.SAP_Transfer_time__c){ |
| | | 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_Type_Index__c = AddressTypeIndex+1; |
| | | } |
| | | rc.address_Telephone__c=address.Telephone__c; |
| | | rc.Detailed_Address__c=address_str; |
| | | |
| | | if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) { |
| | | rc.address_Telephone__c=addressAwsData[address.AWS_Data_Id__c].telephone; |
| | | rc.address_ZipCode__c=addressAwsData[address.AWS_Data_Id__c].zipCode; |
| | | } |
| | | |
| | | let UpdateRepair = function(callback){ |
| | | AWSService.post(staticResourceRepair.updateUrl,[{ |
| | | dataId:'{!pc.AWS_Data_Id__c}', |
| | | addressContactsName:rc.address_Contacts_Name__c, |
| | | addressContacts:rc.address_Contacts__c, |
| | | addressTelephone:rc.address_Telephone__c, |
| | | addressZipCode:rc.address_ZipCode__c, |
| | | detailedAddress:rc.Detailed_Address__c |
| | | }],function(data){ |
| | | if(data && data.object){ |
| | | console.log(data); |
| | | rc.address_Contacts__c = data.object[0].addressContactsName; |
| | | rc.address_Contacts_Name__c = data.object[0].addressContactsName; |
| | | rc.Address_Contacts_Name_Encrypt__c = data.object[0].addressContactsNameEncrypt; |
| | | rc.address_Contacts__c = data.object[0].addressContacts; |
| | | rc.Address_Contacts_Encrypt__c = data.object[0].addressContactsEncrypt; |
| | | rc.address_Telephone__c = data.object[0].addressTelephone; |
| | | rc.Address_Telephone_Encrypt__c = data.object[0].addressTelephoneEncrypt; |
| | | rc.address_ZipCode__c = data.object[0].addressZipCode; |
| | | rc.Address_ZipCode_Encrypt__c = data.object[0].addressZipCodeEncrypt; |
| | | rc.Detailed_Address__c = data.object[0].detailedAddress; |
| | | UpdateSobject(staticResourceRepair,data.txId,callback); |
| | | rc.Detailed_Address_Encrypt__c = data.object[0].detailedAddressEncrypt; |
| | | |
| | | UpdateSobject(staticResourceRepair,rc,data.txId,callback); |
| | | }else{ |
| | | alert('更新修理失败'); |
| | | unblockUI(); |
| | | alert('AWS更新修理失败'); |
| | | ub(); |
| | | } |
| | | },staticResourceRepair.token) |
| | | } |
| | |
| | | //保存数据到保有设备表中 |
| | | let UpdateAsset = function(){ |
| | | let ast = new sforce.SObject('Asset'); |
| | | ast.Id = pc.Delivered_Product__c, |
| | | 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 |
| | | if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) { |
| | | ast.address_ZipCode__c=addressAwsData[address.AWS_Data_Id__c].zipCode; |
| | | ast.address_Telephone__c=addressAwsData[address.AWS_Data_Id__c].telephone; |
| | | } |
| | | let result = sforce.connection.update([ast]); |
| | | let b = result[0].getBoolean('success'); |
| | | return b; |
| | |
| | | return b; |
| | | } |
| | | |
| | | UpdateAddress |
| | | b(); |
| | | UpdateRepair(function(data){ |
| | | if (data.isSuccess) { |
| | | let b = UpdateAsset(); |
| | | if (b) { |
| | | b = UpdateAddress(); |
| | | if (b) { |
| | | window.location.href = '/{!RepairId}'; |
| | | }else{ |
| | | ub(); |
| | | alert('采用失败'); |
| | | } |
| | | }else{ |
| | | ub(); |
| | | alert('采用失败'); |
| | | } |
| | | }else{ |
| | | |
| | | ub(); |
| | | alert('SF更新修理失败'); |
| | | } |
| | | }) |
| | | |
| | | //页面重定向 |
| | | //return redirectPag(); |
| | | }catch( e){ |
| | |
| | | |
| | | //判断当前修理单是否已经申请修理 |
| | | var uploadTime = '{!FSEApplyForRepairTime}'; |
| | | if(uploadTime != 'null'){ |
| | | if(uploadTime != 'null' && uploadTime){ |
| | | var prompt = '由于当前修理单已申请修理,请问是否采用并上传数据到SAP?'; |
| | | if(confirm(prompt)){ |
| | | adoptSaveJs(address); |
| | | adoptSaveJs(address,true); |
| | | } |
| | | }else{ |
| | | adoptSaveJs(address); |
| | | adoptSaveJs(address,false); |
| | | } |
| | | |
| | | } |
| | | /* function onAdoptJs(){ |
| | | if(checkedTrue != null){ |
| | | blockme(); |
| | | b(); |
| | | var lawtable = document.getElementById("tableHeader_L");//获取id为tableHeader_L的table |
| | | var rows = lawtable.rows;//获取所有行 |
| | | var InputObj = rows[checkedTrue].cells[0].getElementsByTagName("input")[0]; |
| | |
| | | } |
| | | //查询敏感字段 |
| | | function queryPI(){ |
| | | //blockme(); |
| | | //b(); |
| | | tableDataStr = JSON.parse(document.getElementById('allPage:allForm:tableValueFrontEnd').value); |
| | | PIData = {}; |
| | | contactDataIds = []; |
| | |
| | | q1().then(function(data){ |
| | | return q2(data); |
| | | }) |
| | | //unblockUI(); |
| | | //ub(); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | //2022 02 28 张华建 display PI Data end |
| | | </script> |
| | | <script type="text/javascript"> |
| | | |
| | | function DecryptAddress(){ |
| | | let arr1 = [];let a1=false; |
| | | let arr2 = [];let a2=false; |
| | | j$('td.oraddress').each(function(i,e){ |
| | | let did = j$(e).attr('address-data-id'); |
| | | if (did) { |
| | | arr1.push(did); |
| | | } |
| | | |
| | | did = j$(e).attr('contact-data-id'); |
| | | if (did) { |
| | | arr2.push(did); |
| | | } |
| | | }) |
| | | |
| | | if (arr1.length) { |
| | | b(); |
| | | AWSService.post(staticResource.searchUrl,{ |
| | | dataIds:arr1 |
| | | },function(data){ |
| | | ub(); |
| | | 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) |
| | | } |
| | | |
| | | if (arr2.length) { |
| | | b(); |
| | | AWSService.post(staticResourceContact.searchUrl,{ |
| | | dataIds:arr2 |
| | | },function(data){ |
| | | ub(); |
| | | 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]; |
| | | } |
| | | } |
| | | |
| | | } |
| | | },staticResourceContact.token) |
| | | } |
| | | } |
| | | </script> |
| | | <apex:form id="allForm"> |
| | | <apex:inputHidden id="tableValueFrontEnd" value="{!tableDataStr}"/> |
| | | <apex:inputHidden value="{!contactId}" id="contactId"/> |
| | | <apex:inputHidden value="{!insUpdDataStr}" id="insUpdDataStr"/> |
| | | <div id="tab01"> |
| | | <!-- 页面数据初始化方法 --> |
| | | <apex:actionFunction name="init" action="{!init}" rerender="oppBlock1,message,checEventFrame" onComplete="unblockUI();"></apex:actionFunction> |
| | | <apex:actionFunction name="init" action="{!init}" rerender="oppBlock1,message,checEventFrame" onComplete="ub();"></apex:actionFunction> |
| | | <!-- 检索数据查询方法 --> |
| | | <apex:actionFunction name="searchBtn" action="{!searchBtn}" rerender="oppBlock1,message,checEventFrame,tableValueFrontEnd" onComplete="unblockUI();"> |
| | | <apex:actionFunction name="searchBtn" action="{!searchBtn}" rerender="oppBlock1,message,checEventFrame,tableValueFrontEnd" onComplete="ub();DecryptAddress();"> |
| | | <apex:param name="addressDataIds" assignTo="{!addressDataIds}" value=""></apex:param> |
| | | </apex:actionFunction> |
| | | <!-- 采用方法 --> |
| | | <apex:actionFunction name="adoptSave" action="{!adoptSave}" rerender="oppBlock2,message" onComplete="unblockUI();"> |
| | | <apex:actionFunction name="adoptSave" action="{!adoptSave}" rerender="oppBlock2,message" onComplete="ub();"> |
| | | <apex:param name="adoptId" assignTo="{!adoptId}" value="" /> |
| | | <apex:param name="isUpload" assignTo="{!isUpload}" value="" /> |
| | | </apex:actionFunction> |
| | | <!-- 保存和修改方法 --> |
| | | <apex:actionFunction name="save" action="{!save}" rerender="oppBlock2,message" onComplete="unblockUI();{!IF(isSearchBtn,'searchBtnJs()',false)};Trans()"></apex:actionFunction> |
| | | <apex:actionFunction name="save" action="{!save}" rerender="oppBlock2,message" onComplete="ub();Trans()"></apex:actionFunction> |
| | | <!-- 点击修改按钮获取修改数据方法 --> |
| | | <apex:actionFunction name="onEditor" action="{!onEditor}" rerender="oppBlock2,checEventFrame,insUpdDataStr" onComplete="decrypt();unblockUI();"> |
| | | <apex:actionFunction name="onEditor" action="{!onEditor}" rerender="oppBlock2,checEventFrame,insUpdDataStr" onComplete="decrypt();ub();"> |
| | | <apex:param name="UpdId" assignTo="{!UpdId}" value="" /> |
| | | </apex:actionFunction> |
| | | <!-- 复制方法 --> |
| | | <apex:actionFunction name="onCopy" action="{!onCopy}" rerender="oppBlock2,checEventFrame," onComplete="decrypt();unblockUI();"> |
| | | <apex:actionFunction name="onCopy" action="{!onCopy}" rerender="oppBlock2,checEventFrame," onComplete="decrypt();ub();"> |
| | | <apex:param name="UpdId" assignTo="{!UpdId}" value="" /> |
| | | </apex:actionFunction> |
| | | <!-- 返回父页面 --> |
| | | <apex:actionFunction name="redirectPag" action="{!redirectPag}" rerender="true" onComplete="unblockUI();"></apex:actionFunction> |
| | | <apex:actionFunction name="redirectPag" action="{!redirectPag}" rerender="true" onComplete="ub();"></apex:actionFunction> |
| | | <apex:pageBlock id="searchBlock" tabStyle="Report"> |
| | | <table style="border-bottom-width: 0px; font-size:12px;width:100%"> |
| | | <tr> |
| | |
| | | </a> |
| | | </td> |
| | | <td style="width: 20%"> |
| | | <apex:commandButton onclick="searchBtnJs();return false;" rendered="true" value="检索" style="width:60px;" onComplete="unblockUI();"/> |
| | | <apex:commandButton onclick="searchBtnJs();return false;" rendered="true" value="检索" style="width:60px;" onComplete=""/> |
| | | |
| | | <!-- <apex:commandButton onclick="onAdoptJs();return false;" rendered="true" value="采用" style="width:60px;background:#98c1fbf7"/> |
| | | --> |
| | |
| | | <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" class="address" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;" aws-data-id="{!or.address.AWS_Data_Id__c}"> |
| | | <td align="left" class="oraddress" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;" address-data-id="{!or.address.AWS_Data_Id__c}" contact-data-id="{!or.address.Contacts__r.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> |
| | |
| | | <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;"> |
| | | <apex:outputText value="{!or.address.Detailed_Address__c}" /> |
| | | </td> |
| | | <!-- <td align="center" style="vertical-align: inherit;width:30px;"> |
| | | <td align="center" style="vertical-align: inherit;width:30px;"> |
| | | <apex:commandButton value=" 编辑 " onclick="onEditorJs('{!or.address.id}');return false;" style="background:#98c1fbf7;display:{!or.canEdit};"/> |
| | | </td> --> |
| | | </td> |
| | | <td align="center" style="vertical-align: inherit;width:30px;"> |
| | | <apex:commandButton value=" 复制 " onclick="onCopyJs('{!or.address.id}');return false;" style="background: #98c1fbf7;display:{!or.canCopy};"/> |
| | | </td> |
| | |
| | | </apex:form> |
| | | <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) |
| | | } |
| | | DecryptAddress(); |
| | | |
| | | </script> |
| | | </apex:outputPanel> |
| | | <script type="javascript/text"> |
| | | |
| | | </script> |
| | | |
| | | </apex:page> |