高章伟
2022-03-18 4bfe21c4b5ddc089ae5a95f4b10f6cff148b690d
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<apex:page Controller="AgencyHospitalLinkController" sidebar="false" id="allPage" action="{!init}">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
<script>
/*function ClearJs(){
    blockme();
    document.getElementById("allPage:allForm:allBlock:searchBlock:StateMaster").value = "";
    document.getElementById("allPage:allForm:allBlock:searchBlock:CityMaster").value = "";
    document.getElementById("allPage:allForm:allBlock:searchBlock:OCMCategory").value = "";
    searchHospital();
}*/
var selectedSize = 0;
var pageLimit = {!pagesize};
function checkAll() {
    selectedSize = 0;
    var productCount = j$(escapeVfId('allPage:allForm:HospitalInfoSection:hospitalInfoRecoedsviewCount')).value();
    if (j$(escapeVfId('checker')).attr('checked') == 'checked') {
        for (var i = 0; i < productCount; i++) {
            if(selectedSize >= pageLimit){
                window.alert("所选医院不能超过500条");
                return;
            }
            j$(escapeVfId('allPage:allForm:HospitalInfoSection:HospitalInfoListview:' + i + ':consumablesCountproRowCheckbox')).attr('checked',true);
            selectedSize ++;
        }
    } else {
        for (var i = 0; i < productCount; i++) {
            j$(escapeVfId('allPage:allForm:HospitalInfoSection:HospitalInfoListview:' + i + ':consumablesCountproRowCheckbox')).attr('checked',false);
        }
    }
}
 
// 用于选择对应的经销商对象,ET特约店对象,ENG特约店对象
// selfId为触发该方法的选择框的id
// sonId为每行选择框的id
function checkAllOther(selfId,sonId) {
    selectedSize = 0;
    // 获取当前页总条数
    var productCount = j$(escapeVfId('allPage:allForm:HospitalInfoSection:hospitalInfoRecoedsviewCount')).value();
    // 如果当前选择框取消选中,将其以下的所有选择框取消选择
    if (j$(escapeVfId(selfId)).attr('checked') != 'checked') {
        for (var i = 0; i < productCount; i++) {
           // 拿到每一行对应的选择框进行取消选择
           var listId = 'allPage:allForm:HospitalInfoSection:HospitalInfoListview:' + i + ':'+sonId;
           j$(escapeVfId(listId)).attr('checked',false);
        }
        return;
    }    
 
    // checker是名称为选择的选择框的id
    // 如果该选择框被选中,代表全选
    if (j$(escapeVfId('checker')).attr('checked') == 'checked') {
        // 拿到每一条数据
        for (var i = 0; i < productCount; i++) {
            if(selectedSize >= pageLimit){
                window.alert("所选医院不能超过500条");
                return;
            }
            // 将对应的其他对象下的选择框选中
            j$(escapeVfId('allPage:allForm:HospitalInfoSection:HospitalInfoListview:' + i + ':'+sonId)).attr('checked',true);
            selectedSize ++;
        }
    } else {
        // 没有全选的情况下,判断每个选择框是否选中
        for (var i = 0; i < productCount; i++) {
            // 拿到每一个对应的选择框的id
            var listId = 'allPage:allForm:HospitalInfoSection:HospitalInfoListview:' + i + ':'+sonId;
            // 根据医院名称是否勾选对其他对象的选择框进行对应勾选
            if (j$(escapeVfId('allPage:allForm:HospitalInfoSection:HospitalInfoListview:' + i + ':consumablesCountproRowCheckbox')).attr('checked') == 'checked') {
                 j$(escapeVfId(listId)).attr('checked',true);
            }else{
                 j$(escapeVfId(listId)).attr('checked',false);
            }
        }
    }
}
 
function CheckSize(j){
    var a = j.id;
    var productCount = j$(escapeVfId(a)).attr('checked');
    if (productCount == 'checked') {
        if(selectedSize >= pageLimit){
            window.alert("所选医院不能超过500条");
            j$(escapeVfId(a)).attr('checked',false);
            return;
        }
        selectedSize ++;
    } else {
        selectedSize --;
    }
    //alert(selectedSize);
}
 
function checkhospitalInfo(){
    CheckHospitalInfo();
}
 
function saveJs() {
    // var delAgencyLinkSize = j$(escapeVfId('allPage:allForm:HospitalInfoSection:delAgencyLinkSize')).value();
    //if(delAgencyLinkSize > 0){
    //    if(window.confirm("所选医院有在其他经销商下的,确认保存吗?")){
    //        blockme();
    //        save();
    //    }
    //}else{
        blockme();
        save();
    //}
    
}
 
function refreshPageSizeJs() {
    refreshPageSize();
}
 
function searchHospitalJs() {
    blockme();
    searchHospital();
}
 
function showCity() {
    cityload();
}
 
</script>
    <apex:form id="allForm">
        <apex:actionFunction name="refreshPageSize" action="{!refreshPageSize}" status="fetchStatus" reRender="HospitalInfoSection" />
        <apex:actionFunction name="save" action="{!save}" rerender="HospitalInfoSection, message" onComplete="unblockUI();">
        </apex:actionFunction> 
        <apex:actionFunction name="CheckHospitalInfo" action="{!CheckHospitalInfo}" rerender="HospitalInfoSection,message" onComplete="saveJs();">
        </apex:actionFunction>
        <apex:actionFunction name="cityload" action="{!cityload}" rerender="searchBlock">
        </apex:actionFunction>
        <apex:actionFunction name="searchHospital" action="{!searchHospital}" rerender="HospitalInfoSection, message" onComplete="unblockUI();">
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
 
            <apex:pageBlock id="searchBlock">
                <table>
                    <colgroup>
                        <col width="60px"/>
                        <col width="100px"/>
                        <col width="170px"/>
                        <col width="15px"/>
                        <col width="50px"/>
                        <col width="170px"/>
                        <col width="15px"/>
                        <col width="80px"/>
                        <col width="170px"/>
                        <col width="15px"/>
                        <col width="50px"/>
                        <col width="170px"/>
                        <col width="10px"/>
                    </colgroup>
                    <tr>
                        <td/>
                        <td align="right">医院名:</td>
                        <td>
                        <apex:inputtext id="hosptial_name" value="{!category1}" style="width:170px"/>
                        </td>
                        <td/>
                        <td align="right">省:</td>
                        <td style="text-align:left;">
                        <apex:selectList id="StateMaster" value="{!area}" size="1" style="width:170px"  onchange="showCity();return false;">
                            <apex:selectOptions value="{!areaOpts}"/>
                        </apex:selectList>
                        </td>
                        <td/>
                        <td align="right">市:</td>
                        <td style="text-align:left;"><apex:selectList id="CityMaster" value="{!city}" size="1" style="width:170px"><apex:selectOptions value="{!cityOpts}"/></apex:selectList>
                        </td>
                        <td/>
                        <td align="right">区县:</td>
                        <td>
                        <apex:inputtext id="town" value="{!category3}" style="width:170px"/>
                        <!--<apex:selectList id="OCMCategory" value="{!category3}" size="1" style="width:170px"><apex:selectOptions value="{!ocmOpts}"/></apex:selectList>-->
                        </td>
                        <td/>
                        <td align="right"></td>
                        <td><apex:commandButton value="搜索" style="width: 100px;" onclick="searchHospitalJs();return false;" /></td>
                        <!-- <td><input type="button" value="清空" style="width: 100px;" onclick="ClearJs()" class="btn"/></td> -->
                        <td/>
                    </tr>
                </table>
            </apex:pageBlock>
 
            <!-- <apex:outputPanel id="messageText">
                <table>
                        <tr>
                            <td>
                            <div id="ErrorName" style="color: red;font-weight: bold;" >{!alertMessage}</div>
                            </td>
                        </tr>
                </table>
            </apex:outputPanel> -->
            <apex:outputPanel id="message">
                <apex:pageMessages />
            </apex:outputPanel>
 
            <apex:pageBlock title="医院信息" id="HospitalInfoSection">
            <apex:pageBlockButtons location="top">
                全部保存<apex:inputCheckbox value="{!allSave}" id="allSave"  style="width:20px"/>
                <apex:commandButton onclick="checkhospitalInfo();return false;" value="保存" style="margin-left:30px;width:100px" rerender="dummy" rendered="true" />
            </apex:pageBlockButtons>
            <input type="hidden" id="allPage:allForm:HospitalInfoSection:hospitalInfoRecoedsviewCount" value="{!hospitalInfoRecoedsviewCount}" />
            <!-- <apex:inputHidden id="hospitalInfoRecoedsviewCount" value="{!hospitalInfoRecoedsviewCount}"/> -->
            <!-- <apex:inputHidden id="delAgencyLinkSize" value="{!delAgencyLinkSize}"/> -->
                <table class="list" border="0" cellpadding="0" cellspacing="0">
                    <tr class="headerRow">
                        <apex:variable var="v" value="">
                            <th><input type='checkbox' onClick='checkAll()' id='checker'/>选择</th>
                        </apex:variable>
                        <th>医院名称</th>
                        <th>医院管理编码</th>
                        <th>省</th>
                        <th>市</th>
                        <th>区县</th>
                        <th><input type='checkbox' onClick='checkAllOther("checkerag","Agency_Campaign")' id='checkerag'/>{!$ObjectType.Agency_Hospital_Link__c.fields.Agency_Campaign_Obj__c.label}</th>
                        <th><input type='checkbox' onClick='checkAllOther("checkerET","AgencyHos_ET")' id='checkerET'/>{!$ObjectType.Agency_Hospital_Link__c.fields.AgencyHos_ET__c.label}</th>
                        <th><input type='checkbox' onClick='checkAllOther("checkerENG","AgencyHos_ENG")' id='checkerENG'/>{!$ObjectType.Agency_Hospital_Link__c.fields.AgencyHos_ENG__c.label}</th>
                    </tr>
 
                    <apex:repeat value="{!hospitalInfoRecordsview}" var="records" id="HospitalInfoListview">
                        <!-- <apex:repeat value="{!m}" var="records" id="ConsumableorderdetailsTable"> -->
                        <tr class="dataRow">
                            <td>
                                <apex:inputCheckbox value="{!records.check}" onclick="CheckSize(this);" id="consumablesCountproRowCheckbox"/>
                                <apex:inputCheckbox value="{!records.oldCheck}" id="proRowOldCheckbox" style="display:none"/>
                            </td>
                            <td class="dataCell">
                                <apex:outputText value="{!records.acc1.Name}"/>
                            </td>
                            <td class="dataCell">{!records.acc1.Management_Code__c}</td>
                            <td class="dataCell">{!records.acc1.State_Master__r.Name}</td>
                            <td class="dataCell">{!records.acc1.City_Master__r.Name}</td>
                            <td class="dataCell">{!records.acc1.Town__c}</td>
                            <td class="dataCell">
                                <apex:inputField value="{!records.esd.Agency_Campaign_Obj__c}" id="Agency_Campaign"/>
                            </td>
                            <td class="dataCell">
                                <apex:inputField value="{!records.esd.AgencyHos_ET__c}" id="AgencyHos_ET"/>
                            </td>
                            <td class="dataCell">
                                <apex:inputField value="{!records.esd.AgencyHos_ENG__c}" id="AgencyHos_ENG"/>
                            </td>
                        </tr>
                        <!-- </apex:repeat> -->
                    </apex:repeat>
                </table>
 
                <table style="width: 100%">
                    <tr>
                        <td>
                            <!-- Page X of Y -->  
                            <!-- PageNumber:当前页面所在位置,ResultSize:记录总条数,PageSize:每页记录条数 -->  
                            <apex:outputText value="{!(currentpage * pagesize)+1-pagesize}-{!IF((currentpage * pagesize)>totalcount, totalcount,
                             (currentpage * pagesize))} 共 {!totalcount} 个" />  
                        </td>
                        <td align="center">
                            <div class="paginator line1">
                            <span class="prevNextLinks">
                            <span class="prevNext">
                            <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!moveToFirst}" oncomplete="refreshPageSizeJs();" title="首页" >
                            <img src="/s.gif" title="首页" alt="首页" class="{!if((hasPrevious),'first','firstoff')}"/>
                            </apex:commandLink>
                            </span>
                            <span class="prevNext">
                            <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection"  action="{!moveToPrevious}" oncomplete="refreshPageSizeJs();"  title="上一页">
                            <img src="/s.gif" title="上一页" alt="上一页" class="{!if((hasPrevious),'prev','prevoff')}"/>上一页
                            </apex:commandLink>
                            </span>
                            <!--  -->
                            <span class="prevNext" >
                            <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!moveToNext}" oncomplete="refreshPageSizeJs();" title="下一页">下一页
                            <img src="/s.gif" title="下一页" alt="下一页" class="{!if((hasNext),'next','nextoff')}"/>
                            </apex:commandLink>
                            </span>
                            <span class="prevNext">
                            <apex:commandLink status="fetchStatus" reRender="ConsumableorderdetailsSection" action="{!moveToLast}"  oncomplete="refreshPageSizeJs();" title="尾页">
                            <img src="/s.gif" title="尾页" alt="尾页" class="{!if((hasNext),'last','lastoff')}"/>
                            </apex:commandLink>
                            </span>
                            </span>
                            </div>
                         </td>
                         <td align="right" width="20%">
                        </td>
                    </tr>
                </table>
 
 
            </apex:pageBlock>
            
        </apex:outputPanel>
    </apex:form>
</apex:page>