| | |
| | | <apex:page standardController="Opportunity" showHeader="false" sidebar="false"> |
| | | <apex:includeScript value="{!URLFOR($Resource.connection20)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.apex20)}"/> |
| | | <script type="text/javascript"> |
| | | var stage = '{!Opportunity.Last_opportunity_file_stage__c}'; |
| | | var bid = '{!Opportunity.Bid_Date__c}'; |
| | | var closingbid = '{!Opportunity.Closing_Bid_Date__c}'; |
| | | if ((stage == 'A.中标通知/截图' || stage == 'B.采购通知书') && (bid == '' || closingbid == '')) { |
| | | alert('填写询价中的“招标日”和“中标日”'); |
| | | var is_new = '{!Opportunity.IsNew__c}' == 'true'; |
| | | var approval_status = '{!Opportunity.ApprovalStatus_D__c}'; |
| | | var productSegment = '{!Opportunity.ProductSegment__c}'; |
| | | var recordTypeId = '{!Opportunity.RecordTypeId}'; |
| | | |
| | | if (productSegment == 'BS' || productSegment == 'IE' || productSegment == 'RVI' || recordTypeId.substring(0,15) == '01228000000NJt5') { |
| | | if (approval_status == 'Pass' && '{!Opportunity.DealerSelectOwner__c}' != '{!Opportunity.OwnerId}') { |
| | | var oid = "{!Opportunity.Id}"; |
| | | var uid = "{!Opportunity.OwnerId}"; |
| | | |
| | | var rac = new sforce.SObject("Opportunity"); |
| | | rac.Id = "{!Opportunity.Id}"; |
| | | rac.OwnerId = '{!Opportunity.DealerSelectOwner__c}'; |
| | | var result = sforce.connection.update([rac]); |
| | | var messages = getConnectDMLErrorMessages(result); |
| | | if (messages.length > 0) { |
| | | alert(messages.join("\n")); |
| | | } else { |
| | | var rs = sforce.apex.execute("OpportunityWebService", "UpdateShare", {opportunityId: oid, userId: uid}); |
| | | if (rs == '1') { |
| | | window.top.location.reload(); |
| | | } else { |
| | | alert(rs); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | var now_status = '{!Opportunity.Amount_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Budget_Amount_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Cancel_Reason_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Cancel_reason_IsChangedc__c}' == 'true' || |
| | | '{!Opportunity.CloseDate_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Company_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product2_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product3_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product4_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product5_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product6_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product7_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product8_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code2_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code3_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code4_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code5_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code6_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code7_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Competitor_Product_Code8_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Dealer_Sales_Staff_Name_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Dealer_Service_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Expected_delivery_date_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Expected_Order_Date_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Inquiry_result_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Inquiry_result_cancel_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Inquiry_result_lost_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Inquiry_result_order_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.LeadSource_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Lost_competitor_product_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Lost_Reason_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Lost_reason_IsChangedc__c}' == 'true' || |
| | | '{!Opportunity.New_Inquiry_Date_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Phase1Date_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Phase2Date_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Phase3Date_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Sales_Channel_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Sub_Dealer_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Trade_Type_IsChanged__c}' == 'true' || |
| | | '{!Opportunity.Sub_Dealer_IsChanged__c}' == 'true'; |
| | | if ((is_new || now_status) && approval_status != 'Submit') { |
| | | //alert("新建或修改询价信息后,请及时提交审批。"); |
| | | } |
| | | } |
| | | var syncquo = '{!Opportunity.SyncedQuote_No__c}'; |
| | | var uploadquo = '{!Opportunity.the_Upload_of_quotation_number__c}'; |
| | | if (uploadquo != '' && uploadquo != syncquo) { |
| | | alert("同步的报价和最近上传的报价不一致,请上传当前同步的报价。"); |
| | | } |
| | | |
| | | |
| | | function getConnectDMLErrorMessages(results) { |
| | | var messages = [], |
| | | i = 0, |
| | | len = results.length, |
| | | r; |
| | | for (; i < len; i++) { |
| | | r = results[i]; |
| | | if (! r.getBoolean("success")) { |
| | | messages = messages.concat(getConnectDMLMessagesOfAResult(r)); |
| | | } |
| | | } |
| | | return messages; |
| | | }; |
| | | function getConnectDMLMessagesOfAResult(res) { |
| | | var messages = [], |
| | | errors = res.getArray("errors"), |
| | | i = 0, |
| | | len = errors.length, |
| | | e; |
| | | for (; i < len; i++) { |
| | | e = errors[i]; |
| | | messages.push(e.message + " " + getConnectDMLErrorFields(e)); |
| | | } |
| | | return messages; |
| | | }; |
| | | function getConnectDMLErrorFields(error) { |
| | | var fields = error.getArray('fields'); |
| | | if (fields.length > 0) { |
| | | return "[" + fields.join(",") + "]" |
| | | } else { |
| | | return ""; |
| | | } |
| | | }; |
| | | </script> |
| | | </apex:page> |