沙世明
2022-04-14 b3d2a744478a41ab0461ba2c7498296c1df2bbe5
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
<apex:page id="Page" standardController="Lead" extensions="StartTradingController" sidebar="false" action="{!init}">
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
    <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
 
    <script type="text/javascript">
        var staticResources = JSON.parse('{!staticResource}');
        var selectedIndexContact = 0;
        function setSelectedIndex(){
            var myselect=document.getElementById("Page:mainForm:idDayEdit:idCon")
            selectedIndexContact=myselect.selectedIndex
        }
        function preparePayloadForSearchContact() {
            // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start
            // let accountId = document.getElementById('Page:mainForm:idDayEdit:idDep').value;
            // if (accountId != '--无--') {
            //     blockme();
            //     console.log('accountId:' + accountId);
            //     //query contact
            //     sforce.connection.sessionId = '{!GETSESSIONID()}';
            //     let result = sforce.connection.query("SELECT Id,Name,AWS_Data_Id__c from Contact where AccountId='" + accountId + "'");//sfid,awsdataId
            //     let dataIds = [];
            //     let records = result.getArray("records");
            //     for (let i = 0; i < records.length; i++) {
            //         dataIds.push(records[i].AWS_Data_Id__c)
            //     }
            //     let searchPayload = new Object();
            //     searchPayload.dataIds = dataIds;
            //     searchPayload.contactName = '';
            //     AWSService.search(staticResources.searchUrl, JSON.stringify(searchPayload), queryBack, staticResources.token);
            // }
            let contactId = document.getElementById('Page:mainForm:idDayEdit:idCon').value;
            if (contactId != undefined) {
                blockme();
                console.log('contactId:' + contactId);
                //query contact
                sforce.connection.sessionId = '{!GETSESSIONID()}';
                let result = sforce.connection.query("SELECT Id,Name,AWS_Data_Id__c from Contact where Id='" + contactId + "'");//sfid,awsdataId
                let dataIds = [];
                let records = result.getArray("records");
                for (let i = 0; i < records.length; i++) {
                    dataIds.push(records[i].AWS_Data_Id__c)
                }
                let searchPayload = new Object();
                searchPayload.dataIds = dataIds;
                searchPayload.contactName = '';
                AWSService.search(staticResources.searchUrl, JSON.stringify(searchPayload), queryBack, staticResources.token);
            }
            // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end
        }
 
        var queryBack = function queryBack(result) {
            // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start
            let select = document.getElementById('Page:mainForm:idDayEdit:idCon');
            //清除select里面的值
            for (var i = select.childNodes.length - 1; i >= 1; i--) {
                select.removeChild(select.childNodes[i]);
            }
            // if (select.options[0] == undefined) {
            //     let blankValue = new Option();
            //     blankValue.value = '--无--';
            //     blankValue.text = '--无--';
            //     select.options.add(blankValue);
            // }
            for (var i = 0; i < result.object.length; i++) {
                if (result.object[i].sfRecordId) {
                    let a = new Option();
                    a.value = result.object[i].sfRecordId;
                    a.text = result.object[i].lastName.replace(/"/g, "");
                    select.options.add(a);
                }
            }
            if(selectedIndexContact !=0 ){
                var myselect=document.getElementById("Page:mainForm:idDayEdit:idCon").options
                myselect[selectedIndexContact].selected = true;
            }
            // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end
            unblockUI();
        }
        //2021/02/21 张华建 查找客户人员 end
 
        function requiredCheck() {
            // 2022-04-13 ssm 紧急应对 科室和客户人员必填 start
            // var val = document.getElementById('Page:mainForm:idDayEdit:idDep').selectedIndex;
            // if (val == 0) {
            //     //「診療科名を選択してください。」
            //     alert('{!$Label.StartTrading_Alert}');
            // }
            // 2022-04-13 ssm 紧急应对 科室和客户人员必填 end
        }
    </script>
    <style>
    </style>
    <!-- リード 取引の開始 -->
    <apex:sectionHeader title="{!$ObjectType.Lead.Label}" subtitle="{!$Label.StartTrading_Subtitle}"/>
    <apex:form id="mainForm">
        <apex:pageMessages id="errorMsg" />
        <apex:pageBlock id="idDayEdit" title="" mode="edit" >
            <apex:pageBlockButtons >
                <!-- 取引の開始 -->
                <apex:commandButton action="{!start}" value="{!$Label.StartTrading_Subtitle}" onclick="requiredCheck();" reRender="mainForm"/>
                <!-- キャンセル -->
                <apex:commandButton action="{!cancel}" value="{!$Label.StartTrading_Cancel}"/>
            </apex:pageBlockButtons>
            <div class="pbSubheader first tertiaryPalette">
                <span class="pbSubExtra"><span class="requiredLegend"><span class="requiredExampleOuter"><span class="requiredExample">&nbsp;</span></span><span class="requiredText"> = 必填信息</span></span></span><!-- 必須情報 -->
                <!-- 基本情報 -->
                <h3>{!$Label.Basic_Information}</h3>
            </div>
            <table>
                <tr>
                    <td width="100px"></td>
                    <!-- 診療科名 -->
                    <td>{!$Label.Department_Name}</td>
                    <td>
                        <apex:selectList value="{!sltDep}" multiselect="false" size="1" id="idDep" style="width:400px;" >
                            <apex:selectOptions value="{!depList}" ></apex:selectOptions>
                            <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 start -->
                            <!-- <apex:actionSupport event="onchange" onsubmit="" onbeforedomupdate="" action="{!depChange}" rerender="idCon" oncomplete="preparePayloadForSearchContact()">
                                <apex:param name="sltD" value="{!sltDep}" />
                            </apex:actionSupport> -->
                            <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 end -->
                        </apex:selectList>
                    </td>
                </tr>
                <tr>
                    <td width="100px"></td>
                    <!-- 担当者 -->
                    <td>{!$ObjectType.Contact.Label}</td>
                    <td>
                        <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 start -->
                        <!-- <apex:selectList value="{!sltCon}" onchange="setSelectedIndex()" multiselect="false" size="1" id="idCon" style="width:200px;"> -->
                        <!-- 2022-04-13 ssm 紧急应对 科室和客户人员必填 end -->
                        <apex:selectList value="{!sltCon}" multiselect="false" size="1" id="idCon" style="width:200px;">
                            <apex:selectOptions value="{!conList}" />
                        </apex:selectList>
                        <script>
                            sfdcPage.appendToOnloadQueue(function () {
                                preparePayloadForSearchContact();
                            });
                        </script>
                    </td>
                </tr>
                <tr>
                    <td width="100px"></td>
                    <td>
                        {!$ObjectType.lead.fields.SI_OppoLeadSec__c.label}
                    </td>
                    <td>
                        <apex:inputField value="{!lead.SI_OppoLeadSec__c}" />
                    </td>
                </tr>
                <tr>
                    <td width="100px"></td>
                    <!-- 是否SI本部共同推进询价 -->
                    <td>是否SI本部共同推进询价</td>
                    <td><apex:inputCheckbox value="{!SI_Flg}" id="SI_Flg" />
                    </td>
                </tr>
            </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>