DESKTOP-0K9VGFE\hp
2022-03-11 6d766b0c8e9b31e7e03ffd344a94c2851aa9beb9
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<apex:page id="Page" standardController="Agency_Opportunity__c" sidebar="false">
    <apex:includeScript value="/soap/ajax/40.0/connection.js"/>
    <apex:includeScript value="/soap/ajax/40.0/apex.js"/>
 
    <script type="text/javascript">
        sforce.connection.sessionId = "{!$Api.Session_ID}";
        <!-- 判断是进入SI询价或者正常询价 -->
        function SICheck() {
            var SI_Flg = document.getElementById('Page:mainForm:idDayEdit:SI_Flg').checked;            
            var doubleFlg = false;
            if (!doubleFlg) {
                doubleFlg = true;
                var newflag = true;
                if ('{!Agency_Opportunity__c.Change_To_Opportunity__c}' != '') {
                    newflag = false;
                    alert("已经转成过【OCSM询价】。");
                    Ext.select('*[name=newopp]').set({
                        disabled: 'disabled',
                        class: 'btnDisabled'
                    }, true);
                }
                if (newflag) {
                    var query = "Select QualifiedApiName, EntityDefinition.KeyPrefix, DurableId From FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Opportunity'";
                    records = sforce.connection.query(query).getArray('records');
                    var prefix,
                    fId_Opportunity_Category__c,
                    fId_Close_Forecasted_Date__c,
                    fId_Opportunity_stage__c,
                    fId_Hospital__c,
                    fId_SAP_Province__c,
                    fId_Agency_Opportunity__c,
                    fId_Sales_Root__c,
                    fId_Trade__c,
                    fId_Promise_Class__c,
                    fId_Bid_Planned_Date__c,
                    fId_Opportunity_sub_owner__c;
 
                    for (var i = 0; i < records.length; i++) {
                        var record = records[i];
                        prefix = record.EntityDefinition.KeyPrefix.toString();
                        if (record.QualifiedApiName == 'Opportunity_Category__c')
                            fId_Opportunity_Category__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Close_Forecasted_Date__c')
                            fId_Close_Forecasted_Date__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Opportunity_stage__c')
                            fId_Opportunity_stage__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Hospital__c')
                            fId_Hospital__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'SAP_Province__c')
                            fId_SAP_Province__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Agency_Opportunity__c')
                            fId_Agency_Opportunity__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Sales_Root__c')
                            fId_Sales_Root__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Trade__c')
                            fId_Trade__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Promise_Class__c')
                            fId_Promise_Class__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Bid_Planned_Date__c')
                            fId_Bid_Planned_Date__c = record.DurableId.toString().split('.')[1];
                        if (record.QualifiedApiName == 'Opportunity_sub_owner__c')
                            fId_Opportunity_sub_owner__c = record.DurableId.toString().split('.')[1];
                    }
                    // 格式化时间
                    if("{!Agency_Opportunity__c.Bid_Planned_Date__c}" != null &&
                        "{!Agency_Opportunity__c.Bid_Planned_Date__c}" != ''){
                        var Bid_Planned_Date = new Date("{!Agency_Opportunity__c.Bid_Planned_Date__c}").toLocaleDateString();
                    }else{
                        var Bid_Planned_Date = '';
                    }
 
                    if("{!Agency_Opportunity__c.Close_Forecasted_Date__c}" != null &&
                        "{!Agency_Opportunity__c.Close_Forecasted_Date__c}" != ''){
                        var Close_Forecasted_Date = new Date("{!Agency_Opportunity__c.Close_Forecasted_Date__c}").toLocaleDateString();
                    }else{
                        var Close_Forecasted_Date = '';
                    }
                    if (SI_Flg) {
                        if('' == document.getElementById('Page:mainForm:idDayEdit:SI_OppoLeadSec').value){
                            document.getElementById('ErrorMessage').style.display = '';
                            return;
                            }
                        window.open("/006/e?retURL=%2F{!URLENCODE(Agency_Opportunity__c.Id)}" +
                            "&RecordType=012100000006KMe" + "&ent=Opportunity&opp11=引合" +
                            "&" +
                            fId_Opportunity_Category__c + "={!URLENCODE(Agency_Opportunity__c.Department_Cateogy__c)}" +
                            "&opp3={!Agency_Opportunity__c.Name}" +
                            "&" + fId_Close_Forecasted_Date__c + "=" + Close_Forecasted_Date +
                            "&" + fId_Bid_Planned_Date__c + "=" + Bid_Planned_Date +
                            "&" + fId_Opportunity_stage__c + "={!URLENCODE(Agency_Opportunity__c.StageName__c)}" +
                            "&CF" + fId_Hospital__c + "={!URLENCODE(Agency_Opportunity__c.hosName_opp__c)}" +
                            "&CF" + fId_Hospital__c + "_lkid={!URLENCODE(Agency_Opportunity__c.hosId_opp__c)}" +
                            "&" + fId_SAP_Province__c + "={!URLENCODE($User.Province_Text__c)}" +
                            "&CF" + fId_Agency_Opportunity__c + "_lkid={!URLENCODE(Agency_Opportunity__c.Id)}" +
                            "&CF" + fId_Agency_Opportunity__c + "={!URLENCODE(Agency_Opportunity__c.Name)}" +
                            "&CF" + fId_Opportunity_sub_owner__c +"_lkid=" +
                            document.getElementById('Page:mainForm:idDayEdit:SI_OppoLeadSec_lkid').value +
                            "&CF" + fId_Opportunity_sub_owner__c + "=" +
                            document.getElementById('Page:mainForm:idDayEdit:SI_OppoLeadSec').value +        
                            "&opp6=经销商" +
                            "&" + fId_Sales_Root__c + "=販売店" +
                            "&" + fId_Trade__c + "=内貿" +
                            "&" + fId_Promise_Class__c + "=内貿" +
                            "&opp4={!URLENCODE(Agency_Opportunity__c.hosName_opp__c)}"
                            ,'_self');
                    } else {
                        window.open("/006/e?retURL=%2F{!URLENCODE(Agency_Opportunity__c.Id)}" +
                            "&RecordType=01210000000QekK" +
                            "&ent=Opportunity&opp11=引合" +
                            "&" + fId_Opportunity_Category__c + "={!URLENCODE(Agency_Opportunity__c.Department_Cateogy__c)}" +
                            "&opp3={!Agency_Opportunity__c.Name}" +
                            "&" + fId_Close_Forecasted_Date__c + "=" + Close_Forecasted_Date +
                            "&" + fId_Bid_Planned_Date__c + "=" + Bid_Planned_Date +
                            "&" + fId_Opportunity_stage__c + "={!URLENCODE(Agency_Opportunity__c.StageName__c)}" +
                            "&CF" + fId_Hospital__c + "={!URLENCODE(Agency_Opportunity__c.hosName_opp__c)}" +
                            "&CF" + fId_Hospital__c + "_lkid={!URLENCODE(Agency_Opportunity__c.hosId_opp__c)}" +
                            "&" + fId_SAP_Province__c + "={!URLENCODE($User.Province_Text__c)}" +
                            "&CF" + fId_Agency_Opportunity__c + "_lkid={!URLENCODE(Agency_Opportunity__c.Id)}" +
                            "&CF" + fId_Agency_Opportunity__c + "={!URLENCODE(Agency_Opportunity__c.Name)}" +
                            "&CF" + fId_Opportunity_sub_owner__c +"_lkid=" +
                            document.getElementById('Page:mainForm:idDayEdit:SI_OppoLeadSec_lkid').value +
                            "&CF" + fId_Opportunity_sub_owner__c + "=" +
                            document.getElementById('Page:mainForm:idDayEdit:SI_OppoLeadSec').value +        
                            "&opp6=经销商" +
                            "&" + fId_Sales_Root__c + "=販売店" +
                            "&" + fId_Trade__c + "=内貿" +
                            "&" + fId_Promise_Class__c + "=内貿" +
                            "&opp4={!URLENCODE(Agency_Opportunity__c.hosName_opp__c)}",'_self');
                    }
 
                }
            }
        }
    function reload() {
        window.open("/{!URLENCODE(Agency_Opportunity__c.Id)}",'_self');
    }
    </script>
    <style>
    </style>
    <!-- リード 取引の開始 -->
    <apex:sectionHeader title="{!$ObjectType.Agency_Opportunity__c.Label}" subtitle="{!$Label.StartTrading_Subtitle}"/>
        <apex:form id="mainForm">
            <div id = 'ErrorMessage' style="display: none;">
                <apex:pageMessage summary="转SI询价需要填写询价副担当" title="错误" severity="error" strength="2" />
            </div>
            <apex:pageBlock id="idDayEdit" title="" mode="edit" >
                <apex:pageBlockButtons >
                    <!-- 进行询价 -->
                    <input type="button" class="btn" value="{!$Label.StartTrading_Subtitle}" onclick="SICheck();"/>
                    <!-- 关掉当前窗口 -->
                    <input type="button" class="btn" value="{!$Label.StartTrading_Cancel}" onclick="reload();"/>
                </apex:pageBlockButtons>
                <table>
                    <tr>
                        <td width="100px"></td>
                        <td>
                        {!$ObjectType.lead.fields.SI_OppoLeadSec__c.label}
                        </td>
                        <td>
                            <apex:inputField id="SI_OppoLeadSec" value="{!Agency_Opportunity__c.SI_OppoLeadSec__c}"/>
                        </td>
                    </tr>
                     <tr>
                        <td width="100px"></td>
                        <!-- 是否SI本部共同推进询价 -->
                        <td>是否SI本部共同推进询价</td>
                        <td><apex:inputCheckbox id="SI_Flg" />
                        </td>
                    </tr>
                </table>
            </apex:pageBlock>
        </apex:form>
</apex:page>