buli
2022-04-08 f1c525740c6a45b875d8ed96fb0ddb68c97ef3df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<apex:page id="Page" Controller="NewReplacementOpportunityController" sidebar="true" showHeader="true" action="{!init}">
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
 
    <script>
        var staticResource = JSON.parse('{!staticResource}');
        var txId = '';
        function getPIData(){
            let opportunityPayloadList = [];
            let opportunityPIData = new Object();
            opportunityPIData.dealerSalesStaffName = document.getElementById('Page:mainForm:idSearchSetProduct:j_id35:j_id38:opp_DealerSalesStaffName').value
            opportunityPayloadList.push(opportunityPIData);
            return JSON.stringify(opportunityPayloadList);
        }
        function saveJs() {
            blockme();
            new Promise(function(resolve,reject){
                //加密
                let queryPostBack = function(data){
                    document.getElementById('Page:mainForm:idSearchSetProduct:j_id35:j_id38:opp_DealerSalesStaffName').value = data.object[0].dealerSalesStaffName;
                    document.getElementById('Page:mainForm:idSearchSetProduct:j_id35:opportunityAWSDataId').value = data.object[0].dataId;
                    txId = data.txId;
                    resolve('success');
                };
                AWSService.post(staticResource.newUrl,getPIData(),queryPostBack,staticResource.token);
            }).then(function(data){
                saveBtn();
                Trans();
            })
        }
 
        //aws 确认
        function Trans(){
            let b = HasError();
            if(b){
                //清空代理商销售担当者名
                document.getElementById('Page:mainForm:idSearchSetProduct:j_id35:j_id38:opp_DealerSalesStaffName').value=''
            }
            AWSService.post(staticResource.transactionUrl, JSON.stringify({
                    "txId":txId,
                    "isSuccess":b ? 0 : 1
                }), function(result){
                    console.log('Trans result = '+ JSON.stringify(result));
                }, staticResource.token);
        }
 
        function HasError(){
            let e = document.getElementById("Page:mainForm:message");
            return e.children[0]!=null;
        }
 
        function saveYesJs() {
            blockme();
            saveBtnYes();
        }
 
        function saveNoJs() {
            blockme();
            saveBtnNo();
        }
 
        function cancelJs() {
            var baseUrl = '{!baseUrl}';
            var rtUrl = '{!rtUrl}';
            if (rtUrl == 'null' || rtUrl == '') {
                rtUrl = '{!conId}';
            }
            window.location.href = baseUrl + "/" + rtUrl;
        }
    </script>
 
    <apex:form id="mainForm">
        <apex:actionFunction action="{!saveBtn}" name="saveBtn" reRender="mainForm,message" oncomplete="Trans();unblockUI();"/>
        <apex:actionFunction action="{!saveBtnYes}" name="saveBtnYes" reRender="mainForm,message" oncomplete="unblockUI();"/>
        <apex:actionFunction action="{!saveBtnNo}" name="saveBtnNo" reRender="mainForm,message" oncomplete="unblockUI();"/>
 
        <apex:outputPanel id="message">
            <apex:messages styleClass="editListError"/>
        </apex:outputPanel>
 
        <input type="hidden" id="hasError" value="{!hasError}"/>
        <input type="hidden" id="isDealerPage" value="{!isDealerPage}"/>
         <apex:pageBlock id="idSearchSetProduct" title="新建询价" tabStyle="Opportunity">
            <apex:pageBlockButtons location="top">
                <apex:commandButton style="width:50px" onclick="saveJs();" value="保存" rerender="dummy" rendered="{!IF(hasError == true, false, true)}"/>
                <apex:commandButton style="width:50px" onclick="cancelJs();" value="取消" rerender="dummy" rendered="{!IF(hasError == true, false, true)}"/>
                <apex:commandButton style="width:50px" onclick="saveYesJs();" value="是" rerender="dummy" rendered="{!IF(hasError == true, true, false)}"/>
                <apex:commandButton style="width:50px" onclick="saveNoJs();" value="否" rerender="dummy" rendered="{!IF(hasError == true, true, false)}"/>
            </apex:pageBlockButtons>
 
             <apex:pageBlockSection title="询价信息" columns="2">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="询价名称" for="opp_Name"/>
                    <apex:inputField value="{!opp.Name}" id="opp_Name"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="产品分类" for="opp_ProductSegment"/>
                    <apex:inputField value="{!opp.ProductSegment__c}" id="opp_ProductSegment" required="true"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="客户名" for="opp_Account"/>
                    <apex:inputField value="{!opp.AccountId}" id="opp_Account" required="true"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="询价币种" for="opp_CurrencyIsoCode"/>
                    <apex:inputField value="{!opp.CurrencyIsoCode}" id="opp_CurrencyIsoCode"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="类型" for="opp_Type"/>
                    <apex:inputField value="{!opp.Type}" id="opp_Type"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="金额" for="opp_Amount"/>
                    <apex:inputField value="{!opp.Amount}" id="opp_Amount"/>
                </apex:pageBlockSectionItem>
                 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="整机/零件" for="opp_MachineParts"/>
                    <apex:inputField value="{!opp.Machine_Parts__c}" id="opp_MachineParts"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
 
            <apex:pageBlockSection title="附加信息" columns="2">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="内贸 / 外贸" for="opp_TradeType"/>
                    <apex:inputField value="{!opp.TradeType__c}" id="opp_TradeType" required="true"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="销售方式" for="opp_SalesChannel"/>
                    <apex:inputField value="{!opp.SalesChannel__c}" id="opp_SalesChannel" required="true"/>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
 
            <apex:pageBlockSection title="经销商相关信息" columns="2">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="代理商名" for="opp_Dealer"/>
                    <apex:inputField value="{!opp.Dealer__c}" id="opp_Dealer"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="代理商销售担当者名" for="opp_DealerSalesStaffName"/>
                    <apex:inputField value="{!opp.DealerSalesStaffName__c}" id="opp_DealerSalesStaffName" required="true"/>
                </apex:pageBlockSectionItem>
                <apex:inputHidden id="opportunityAWSDataId" value="{!opp.AWS_Data_Id__c}"/>
            </apex:pageBlockSection>
 
        </apex:pageBlock>
 
 
    </apex:form>
</apex:page>