张宇恒
2022-04-28 ddf52e1dd6e4041756854ee3ea914d568e98922e
【委托】 【新需求】询价页面增加新对象
6个文件已添加
132 ■■■■■ 已修改文件
force-app/main/default/classes/AdvanceOpportunityController.cls 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AdvanceOpportunityController.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AdvanceOpportunityTest.cls 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AdvanceOpportunityTest.cls-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/AdvanceOpportunity.page 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/AdvanceOpportunity.page-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/AdvanceOpportunityController.cls
New file
@@ -0,0 +1,22 @@
public with sharing class AdvanceOpportunityController {
    public AdvanceOpportunityController(ApexPages.StandardController stdController) {
        AdOpportunity = new Advance_Opportunity__c();
    }
    public Advance_Opportunity__c AdOpportunity{get; set;}
    public void init(){
        String aoId = ApexPages.currentPage().getParameters().get('id');
        List<Advance_Opportunity__c> aoList = [SELECT Id,MarketAdvance__c,AddOpportunity__c,BigContract__c,GradePro__c,AddPrice__c,Opportunity__c FROM Advance_Opportunity__c WHERE Opportunity__c = :aoId];
        if (aoList.size() == 0) {
        } else{
            AdOpportunity = aoList[0];
        }
    }
    public void save(){
        if (String.isBlank(AdOpportunity.Opportunity__c)) {
            AdOpportunity.Opportunity__c = ApexPages.currentPage().getParameters().get('id');
        }
        // AdOpportunity.Name = 'ceshi';
        upsert AdOpportunity;
    }
}
force-app/main/default/classes/AdvanceOpportunityController.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>41.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/classes/AdvanceOpportunityTest.cls
New file
@@ -0,0 +1,62 @@
@isTest
private class AdvanceOpportunityTest {
    static final String RC_BYOUIN = '病院';
    static final String RC_HANBAOITEN = '販売店';
    static final String RC_KEIYAKU = '契約';
    static testMethod void testMethod1() {
    }
    @isTest
    static void test_1(){
        RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name=:RC_BYOUIN limit 1];
        Account hospital = new Account(Name = 'テスト病院');
        hospital.RecordTypeId = recByoin.id;
        hospital.Site = 'テスト病院部門';
        hospital.Alias_Name2__c = 'テスト病院別名';
        insert hospital;
        RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name=:RC_HANBAOITEN limit 1];
        Account sellerA = new Account(Name = '販売店');
        sellerA.RecordTypeId = recHanbaiten.id;
        sellerA.Hospital__c = hospital.id;
        sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20);
        insert sellerA;
        RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name=:RC_KEIYAKU limit 1];
        Account contractA = new Account(Name = '*');
        contractA.RecordTypeId = recKeiyaku.id;
        contractA.Agent_Ref__c = sellerA.id;
        contractA.ParentId = sellerA.id;
        insert contractA;
        System.Test.startTest();
        Opportunity opp = new Opportunity( Name='aiueo', StageName='contact', CloseDate=Date.today());
        opp.Trade__c = '内貿';
        //opp.CurrencyIsoCode = CurrencyIso;
        opp.Sales_Root__c = '販売店';
        opp.StageName = '引合';
        opp.Fixed_Check__c = false;
        opp.owner_not_automatically_update__c = true;
        //opp.Pricebook2Id = pricebook.id;
        opp.Purchase_Type__c = '一般引合';
        opp.Promise_Class__c = '内貿';
        opp.Fund_Basis__c = '政府資金';
        opp.AccountId = contractA.id;
        opp.Hospital__c = contractA.id;
        opp.Agency1__c = sellerA.id;
        opp.Wholesale_Price__c = 9000;
        opp.Opportunity_stage__c = '还没申请预算';
        opp.Close_Forecasted_Date__c = Date.today().addDays(50);
        opp.Special_Opp_lanhai__c = false;
        insert opp;
        AdvanceOpportunityController aoc = new AdvanceOpportunityController(new ApexPages.StandardController(opp));
        Advance_Opportunity__c ado = new Advance_Opportunity__c();
        // ado.Name = 'test';
        ado.Opportunity__c = opp.Id;
        insert ado;
        aoc.init();
        ado.BigContract__c = true;
        upsert ado;
        aoc.save();
    }
}
force-app/main/default/classes/AdvanceOpportunityTest.cls-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>41.0</apiVersion>
    <status>Active</status>
</ApexClass>
force-app/main/default/pages/AdvanceOpportunity.page
New file
@@ -0,0 +1,33 @@
<apex:page standardController="Opportunity" extensions="AdvanceOpportunityController" showChat="false" showHeader="false" sidebar="false" action="{!init}" id="Page">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="/soap/ajax/29.0/connection.js"/>
<apex:includeScript value="/soap/ajax/29.0/apex.js"/>
<head>
<title>询价推进</title>
    <script type="text/javascript">
        function save(){
            blockme();
            alert("保存成功");
            allSave();
            // save();
        }
    </script>
</head>
<apex:form>
<apex:inputField value="{!AdOpportunity.MarketAdvance__c}">市场共同推进</apex:inputField>
<br />
<apex:inputField value="{!AdOpportunity.AddOpportunity__c}">新增询价</apex:inputField>
<br />
<apex:inputField value="{!AdOpportunity.BigContract__c}">大合同</apex:inputField>
<br />
<apex:inputField value="{!AdOpportunity.GradePro__c}">等级提升</apex:inputField>
<br />
<apex:inputField value="{!AdOpportunity.AddPrice__c}">增加金额</apex:inputField>
<br />
<apex:commandButton action="{!save}" onclick="save();return false;" value="保存"></apex:commandButton>
</apex:form>
</apex:page>
force-app/main/default/pages/AdvanceOpportunity.page-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>41.0</apiVersion>
    <label>AdvanceOpportunity</label>
</ApexPage>