李彤
2022-05-17 e086d26f5ea28d42f78f836d6a8be5c686c1f36d
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<apex:page id="Page" showHeader="false" sidebar="false" Controller="SetPersonalTargetController" action="{!init}">
<head>
<title>部门担当者目标设定(医院担当)</title>
    
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.jqueryTableFix)}"/>
 
<script type="text/javascript">
//CHAN-BDQBLX  20210125 you start 
var popupBox;
popupBox = new SimpleDialog("CSVImportDialogId", false);  // 不可拖动
popupBox.createDialog();
function openPopupCSV() {
    popupBox.setTitle("导入CSV文件");
    popupBox.importContentNode(document.getElementById("{!$Component.Form.popupBox}"));
    popupBox.show(document.getElementById("{!$Component.Form.popupBox}"));
 function remoteLocationPost() {
    blockme();
    var fbody = document.getElementById("file_input").files[0];
    if (typeof fbody === "undefined") {
        alert("请选择CSV文件");
        return;
    }
    else {
        var reader = new FileReader();
        reader.readAsText(fbody,"gb2312");//在前台改乱码问题
        
        reader.onload = function(val) {
             if(this.result.split("\n").length - 1 > {!detailCountLimit}){
                 alert("文件不可超过" + {!detailCountLimit} + "行");
                 return;
             }
            passToController(this.result);
            popupBox.hide();
        }
        
        
    }
}
//CHAN-BDQBLX  20210125 you end       
function checkMoney(val, id) {
    // changeFlgセット
    j$(escapeVfId('Page:Form:editBlock:changeFlg')).val(1);
    var ids = id.split(":");
    var isChangedid = ids[0] + ":" + ids[1] + ":" + ids[2] + ":" + ids[3] + ":" + ids[4] + ":isChanged";
    j$(escapeVfId(isChangedid)).val("1");
    j$(escapeVfId(id))[0].style.background="#FFFF33";
    if (val != null && val != "") {
        if (isNaN(parseFloat(val))) {
            alert("请输入数值");
            j$(escapeVfId(id)).val("");
            return;
        }
        val = localParseFloat(val);
        val = Math.round(val * 100) / 100;
        j$(escapeVfId(id)).val(toNumComma(val));
    }
    calc();
}
 
function checkAll(checker) {
    for (var i = 0; i < {!pSize}; i++) {
        j$(escapeVfId('Page:Form:headBlock:postRepeat:' + i + ':post'))[0].checked = checker.checked;
    }
    searchByFilterJs();
}
 
function calc() {
    var isorgtbl = j$('div[name=bodyTable]');
    var tbl = document.getElementById('MainTable');
    var datarows = tbl.rows.length;
    // 如果MainTable没有分成4部分
    if (isorgtbl.length == 0) {
        datarows -= 2;
    }
    var allSum = 0;
    var cols = [0, 0, 0, 0, 0, 0, 0, 0];
    // 行
    for (var i = 0; i < datarows; i++) {
        var rowSum = 0;
        // 列
        for (var j = 0; j < 8; j++) {
            var amount = 0;
            
            var raw = j$(escapeVfId('Page:Form:editBlock:dbRepeat:' + i + ':amountRepeat:' + j + ':inAmountValue')).value();
            raw = (raw + '').replace(/[^0-9+\-Ee.]/g, '');
            
            var amount = localParseFloat(raw);
            rowSum = rowSum + amount;
            cols[j] = cols[j] + amount;
            allSum = allSum + amount;
        }
        j$(escapeVfId('Page:Form:editBlock:dbRepeat:' + i + ':totalrow')).text(toNumComma(rowSum));
    }
    // 列
    for (var j = 0; j < 8; j++) {
        j$(escapeVfId('totalcol' + j)).text(toNumComma(cols[j]));
    }
    // 総計
    j$(escapeVfId('totalAll')).text(toNumComma(allSum));
}
 
function saveJs() {
    blockme();
    if (window.confirm('确定要保存吗?')) {
        save();
    } else {
        unblockUI();
    }
}
function DisableAllButtons (actionText) {
    var button = document.getElementById("Page:Form:headBlock:updateToTarget");
    button.disabled = true;
    button.classList.add("btnDisabled");
}
    //20200618 SWAG-BQ7CM9   添加UpdateJs 调用Apex 中Update函数 by ljh
function UpdateJs(actionText) {
    blockme_dark();
    if (window.confirm('确定要反应到目标吗?')) {
        Update();
        // j$(escapeVfId('Page:Form:headBlock:updateToTarget')).attr("disabled",true);
        // alert('请等待提示【反映到目标成功】在做其他操作');
        DisableAllButtons(actionText);
    } else {
        unblockUI();
    }
}
function nextJs() {
    blockme();
    if (j$(escapeVfId('Page:Form:editBlock:changeFlg')).value() == 1) {
        if (window.confirm('目标金额有变化,要保存已做的修改吗?\n点击 [确定] 保存并去下年度\n点击 [取消] 只去下年度,不保存')) {
            next(true);
        } else {
            next(false);
        }
    } else {
        next(false);
    }
}
 
function prevJs() {
    blockme();
    if (j$(escapeVfId('Page:Form:editBlock:changeFlg')).value() == 1) {
        if (window.confirm('目标金额有变化,要保存已做的修改吗?\n点击 [确定] 保存并去上年度\n点击 [取消] 只去上年度,不保存')) {
            prev(true);
        } else {
            prev(false);
        }
    } else {
        prev(false);
    }
}
 
function searchByDptJs() {
    
//    if (val != null && val != "") {
        blockme();
        if (j$(escapeVfId('Page:Form:editBlock:changeFlg')).value() == 1) {
            if (window.confirm('目标金额有变化,要保存已做的修改吗?\n点击 [确定] 保存并继续\n点击 [取消] 不保存')) {
                searchByDpt(true);
            } else {
                searchByDpt(false);
            }
        } else {
            searchByDpt(false);
        }
//    }
}
 
function searchByProvinceJs() {
//    if (val != null && val != "") {
        blockme();
        if (j$(escapeVfId('Page:Form:editBlock:changeFlg')).value() == 1) {
            if (window.confirm('目标金额有变化,要保存已做的修改吗?\n点击 [确定] 保存并继续\n点击 [取消] 不保存')) {
                searchByProvince(true);
            } else {
                searchByProvince(false);
            }
        } else {
            searchByProvince(false);
        }
//    }
}
 
function searchByFilterJs() {
    
//    if (val != null && val != "") {
        blockme();
        if (j$(escapeVfId('Page:Form:editBlock:changeFlg')).value() == 1) {
            if (window.confirm('目标金额有变化,要保存已做的修改吗?\n点击 [确定] 保存并继续\n点击 [取消] 不保存')) {
                searchByFilter(true);
            } else {
                searchByFilter(false);
            }
        } else {
            searchByFilter(false);
        }
//    }
}
//CHAN-BDQBLX  20210125 you start 
function exportJs() {
    /**
    var repFlg = j$(escapeVfId('Page:Form:headBlock:accTypeOptsId')).val();//本部
    var province = j$(escapeVfId('Page:Form:headBlock:province')).val();//省
    var jobCategory = j$(escapeVfId('Page:Form:headBlock:jobCategory')).val();//职种
    var productUserid = j$(escapeVfId('Page:Form:headBlock:productUserid')).val();//医院担当
    var postid='';//职位
    for (var i = 0; i < {!pSize}; i++) {
        postid =j$(escapeVfId('Page:Form:headBlock:postRepeat:' + i + ':post')).checked;
    }
    **/
    if (j$(escapeVfId('Page:Form:editBlock:changeFlg')).value() == 1) {
        if (window.confirm('目标金额有变化,要保存已做的修改吗?\n点击 [确定] 保存并继续\n点击 [取消] 不保存')) {
            return;
        } 
    } 
     //alert('本部'+repFlg+'省'+province+'职种'+jobCategory);  
     exportcsv();
}
//CHAN-BDQBLX  20210125 you end 
</script>
</head>
<!--CHAN-BDQBLX  20210125 you start 
<apex:form id="Form2"> 
    <apex:pageBlock id="headBlock2" tabStyle="Report">
        
         <table id="ButtonTable2" border="0" width="100%">
             <tr>
                <td width="10%" align="right"></td>
                <td width="30%"></td>
                
                <td align="center">
                    <apex:inputfile filename="{!csvAsString}" value="{!csvFileBody}" accept="text/csv">
                </apex:inputfile>
                </td>
 
                <td width="30%">
                    <apex:commandbutton action="{!importCSVFile}" id="import"  value="导入">
                </apex:commandbutton>
                </td>
                 
                 <td width="10%" align="right">
                <apex:commandbutton onclick="exportJs();return false;" id="export" value="导出数据模板">
                </apex:commandbutton>
                </td>
            </tr>
         </table>
        
    </apex:pageBlock>
</apex:form>
CHAN-BDQBLX  20210125 you end  -->
<apex:form id="Form">
    <apex:outputPanel id="MessageP">
        <apex:pagemessages />
    </apex:outputPanel>
<font style="font-size:15px;font-weight:700;">录入担当者各自的目标&nbsp;(注:请输入含税金额)</font>
    <!--CHAN-BDQBLX  20210125 you start -->
     <apex:actionFunction name="exportcsv" action="{!exportBycsv}"/>
     <apex:actionFunction name="passToController" action="{!importCSVFile}" rerender="Form, MessageP" oncomplete="unblockUI();">
         <apex:param name="csvData" value="" />
     </apex:actionFunction>
    <!--CHAN-BDQBLX  20210125 you end -->
    <apex:actionFunction name="save" action="{!saveBtn}" rerender="MessageP,editBlock" oncomplete="unblockUI();" />
    <!-- 20200618 SWAG-BQ7CM9  添加Update action function by ljh -->
    <apex:actionFunction name="Update" action="{!UpdateBtn}" rerender="MessageP,dataBlock" oncomplete="unblockUI();Secin();" />
    <apex:actionFunction name="next" action="{!next}" rerender="Form" oncomplete="unblockUI();">
        <apex:param name="saveFlg" assignTo="{!saveFlg}" value="" />
    </apex:actionFunction>
    <apex:actionFunction name="prev" action="{!previous}" rerender="Form" oncomplete="unblockUI();">
        <apex:param name="saveFlg" assignTo="{!saveFlg}" value="" />
    </apex:actionFunction>
    <apex:actionFunction name="searchByDpt" action="{!searchByDpt}" rerender="Form" oncomplete="unblockUI();">
        <apex:param name="saveFlg" assignTo="{!saveFlg}" value="" />
    </apex:actionFunction>
    <apex:actionFunction name="searchByProvince" action="{!searchByProvince}" rerender="Form" oncomplete="unblockUI();">
        <apex:param name="saveFlg" assignTo="{!saveFlg}" value="" />
    </apex:actionFunction>
    <apex:actionFunction name="searchByFilter" action="{!searchByFilter}" rerender="Form" oncomplete="unblockUI();">
        <apex:param name="saveFlg" assignTo="{!saveFlg}" value="" />
    </apex:actionFunction>
    <!--CHAN-BDQBLX  20210125 you start -->
    <apex:outputPanel style="display:none">
            <apex:outputPanel id="popupBox" layout="block">
                <input type="file" id="file_input" name="attFile" accept=".csv" /><br/>
                <center>
                    <apex:commandButton value="确认" onclick="remoteLocationPost(); return false;" style="width: 20%; margin: 20px 10px 0px 10px" />
                    <apex:commandButton value="取消" onclick="popupBox.hide();" style="width: 20%; margin: 20px 10px 0px 10px" />
                </center>
            </apex:outputPanel>
    </apex:outputPanel>
    <!--CHAN-BDQBLX  20210125 you end -->
    
    <apex:pageBlock id="headBlock" tabStyle="Report">
        <table id="ConditionTable" border="0" width="100%">
            <tr>
                <!-- <apex:outputPanel rendered="{!loginUser.ProfileId == $Label.ProfileId_SystemAdmin}" layout="none"> -->
                <td width="170">本部&nbsp;<apex:selectList id="accTypeOptsId" value="{!salesDpt}" size="1" style="width:120px;" disabled="{!!(loginUser.ProfileId == $Label.ProfileId_SystemAdmin || loginUser.ProfileId == $Label.ProfileId_103 || loginUser.ProfileId == $Label.ProfileId_2s6dashboard )}" onchange="searchByDptJs();return false;"><apex:selectOptions value="{!salesDptOpts}" />
                     <!--<apex:inputHidden id="salesDptOpts1" value="{!salesDptOpts}" />-->
                </apex:selectList>
                 
                </td>
                <!-- </apex:outputPanel> -->
                <td width="179">省&nbsp;<apex:inputField id="province" value="{!loginUser.Province__c}" style="width:140px;" onchange="searchByProvinceJs();return false;"></apex:inputField>
                <script type="text/javascript">
                    var isadmin = {!(loginUser.ProfileId == $Label.ProfileId_SystemAdmin || loginUser.ProfileId == $Label.ProfileId_103 || loginUser.ProfileId == $Label.ProfileId_2s6dashboard)};
                    if (!isadmin) {
                        j$(escapeVfId('Page:Form:headBlock:province')).attr("disabled",true);
                    }
                </script>
                </td>
                <td width="300">
                    职种&nbsp;<apex:selectList id="jobCategory" value="{!loginUser.Job_Category__c}" size="1" style="width:80px;" onchange="searchByFilterJs();return false;">
                        <apex:selectOptions value="{!userJobCategorys}"/>
                    </apex:selectList>&nbsp;&nbsp;&nbsp;
                    医院担当&nbsp;
                    <apex:selectList value="{!productUser}" id="productUserid" size="1" style="width:100px;" onchange="searchByFilterJs();return false;">
                        <apex:selectOptions value="{!productUserOptions}"/>
                    </apex:selectList>&nbsp;&nbsp;&nbsp;
                </td>
                <td width="60"><apex:inputCheckBox id="checkAll" value="{!checkAll}" onchange="checkAll(this);return false;"/><apex:outputLabel value="全选" for="checkAll"/></td>
                <td>
                    <apex:repeat value="{!plist}" var="p" id="postRepeat">
                        <apex:inputCheckBox value="{!p.check}" id="post" onchange="searchByFilterJs();return false;"/><apex:outputLabel value="{!p.positionName}" for="post"/>&nbsp;&nbsp;&nbsp;
                    </apex:repeat>
                </td>
                <td align="right" width="80">
                    <!-- 20200619 add  反应到目标 按钮 -->
                    <apex:commandButton value="反应到目标" id="updateToTarget" style="margin-left: 20px;" rerender="dummy" onclick="UpdateJs(this);return false;" rendered="{!Not(isPast)}"/>
                </td>
                <!--CHAN-BDQBLX  20210125 you start -->
                <td width="80">
                    <apex:commandbutton onclick="exportJs();return false;" id="export" value="导出数据模板">
                </apex:commandbutton>
                </td>
                 <td width="40">
                    <apex:commandButton onclick="openPopupCSV(); return false;" value="导入" rerender="Form"/>
                </td>
                <!--CHAN-BDQBLX  20210125 you end -->
            </tr>
        </table>
        
        <table id="ButtonTable" border="0" width="100%">
            <tr>
                <td  width="10%"></td>
                <td align="center" width="20%">
                    <apex:commandButton value="保存" rerender="dummy" onclick="saveJs();return false;" rendered="{!Not(isPast)}"/>   
                </td>
                
                
                <td width="10%" align="right"><apex:commandButton action="{!backBtn}" value="返回" rerender="dummy"/></td>
 
            </tr>
            <tr>
                <td width="15%" align="left" ><apex:commandLink value="上年度" style="color:blue;" rendered="{!previousRendered}" onclick="prevJs();return false;"/></td>
                <td align="center"><apex:outputText id="Year" value="{!currentPeriod}" style="color:blue;"/></td>
                <td width="15%" align="right"><apex:commandLink value="下年度" style="color:blue;" rendered="{!nextRendered}" onclick="nextJs();return false;"/></td>
            </tr>
               
        </table>
         
    </apex:pageBlock>
 
    <apex:pageBlock id="editBlock" tabStyle="Report">
        <!-- バック側にパラメータを増やしたくないため、1になれないパラメータを入れます -->
        <!-- ここの値は1かどうかの判断のみで使います -->
        <apex:inputHidden id="changeFlg" value="{!saveFlg}"/>
        <table class="list" style="border-bottom-width: 0px;" border="0" cellspacing="0" cellpadding="0" id="MainTable">
            <thead>
                <tr class="headerRow">
                    <th width="70px" class="headerRow  booleanColumn">本部</th>
                    <th width="70px" class="headerRow  booleanColumn">省</th>
                    <th class="headerRow  booleanColumn">角色</th>
                    <th width="70px" class="headerRow  booleanColumn">担当</th>
                    <th width="70px" class="headerRow  booleanColumn">HR通用职级</th>  <!-- 20220517 lt SWAG-CD28H3 Update -->
                    <th width="70px" class="headerRow  booleanColumn">负责<br/>产品分类(主)</th>
                    <!--wangweipeng  20210615-->
                    <th width="70px" class="headerRow  booleanColumn">负责<br/>产品分类(兼)</th>
                    <apex:repeat value="{!opportunity_category}" var="oc" id="opportunityCategoryRepeat">
                        <th width="75px" class="headerRow  booleanColumn"><apex:outputText id="categoryValue" value="{!oc}"></apex:outputText></th>
                    </apex:repeat>
                    <th width="85" class="headerRow  booleanColumn" style="background-color:#AAAACC;">合计</th>
                </tr>
            </thead>
            <tbody>
            <apex:variable value="{!1}" var="cnt" />
                <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" bgcolor="#AAAACC">
                    <td class="dataCell"></td>
                    <td class="dataCell"></td>
                    <td class="dataCell"></td>
                    <td class="dataCell"></td>
                    <td class="dataCell"></td>
                    <!--wangweipeng  20210615-->
                    <td class="dataCell"></td>
                    <td class="dataCell" style="text-align:center;">合计</td>
                    <td class="dataCell" style="text-align:right;" id="totalcol0"></td>
                    <td class="dataCell" style="text-align:right;" id="totalcol1"></td>
                    <td class="dataCell" style="text-align:right;" id="totalcol2"></td>
                    <td class="dataCell" style="text-align:right;" id="totalcol3"></td>
                    <td class="dataCell" style="text-align:right;" id="totalcol4"></td>
                    <td class="dataCell" style="text-align:right;" id="totalcol5"></td>
                    <td class="dataCell" style="text-align:right;" id="totalcol6"></td>
                    <td class="dataCell" style="text-align:right;" id="totalcol7"></td>
                    <td class="dataCell" style="text-align:right;" id="totalAll"></td>
                </tr>
                <apex:repeat value="{!dataBeans}" var="dbs" id="dbRepeat">
                    <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}">
                        <td class="dataCell">{!dbs.user.Salesdepartment__c}</td>
                        <td class="dataCell">{!dbs.user.Province__c}</td>
                        <td class="dataCell">{!dbs.user.UserRole.Name}</td>
                        <td class="dataCell">{!dbs.user.Alias}</td>
                        <td class="dataCell">{!dbs.user.HR_Post__c}</td> <!-- 20220517 lt SWAG-CD28H3 Update -->
                        <td class="dataCell" style="word-wrap:break-word;max-width:70px;">{!SUBSTITUTE(dbs.user.Product_specialist_incharge_product__c, ";", "; ")}</td>
                        <!--wangweipeng  20210615-->
                        <td class="dataCell" style="word-wrap:break-word;max-width:70px;">{!SUBSTITUTE(dbs.user.Responsible_for_Products_Concurrently__c, ";", "; ")}</td>
                        <apex:variable value="{!1}" var="cnt2" />
                        <apex:repeat value="{!dbs.amount}" var="amount" id="amountRepeat">
                            <td class="dataCell" style="text-align:right;">
                                <apex:inputField id="inAmountValue" value="{!amount.Amount}" style="width:92%; text-align:right;" onchange="checkMoney(this.value, this.id);"></apex:inputField>
                                <script type="text/javascript">
                                    var ispast = {!isPast};
                                    if (ispast) {
                                        j$(escapeVfId('Page:Form:editBlock:dbRepeat:' + {!cnt-1} + ':amountRepeat:' + {!cnt2-1} + ':inAmountValue')).attr("disabled",true);
                                    }
                                </script>
                            </td>
                            <apex:variable value="{!cnt2 + 1}" var="cnt2" />
                        </apex:repeat>
                        <td class="dataCell" style="text-align:right; background-color:#AAAACC;">
                            <apex:outputText id="totalrow" style="width:92%;" value="{0,number,#,##0.00}">
                                <apex:param value="" />
                            </apex:outputText>
                            <apex:inputHidden id="isChanged" value="{!dbs.isChanged}"/>
                        </td>
                    </tr>
                    <apex:variable value="{!cnt + 1}" var="cnt" />
                </apex:repeat>
            </tbody>
        </table>
<script type="text/javascript">
j$(function() {
    var blockHeight = j$(window).innerHeight() - j$(escapeVfId('Page:Form:headBlock')).height() - 60;
    j$(escapeVfId('MainTable')).tablefix({height: blockHeight, fixRows: 2, fixCols: 0});
});
calc();
</script>
    </apex:pageBlock>
</apex:form>
</apex:page>