liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
// main.jsのなかのものをoverrideした。
// DatePicker.prototype.position=function(){
//     for(var a=0,c=0,b=this.myElement;null!=b&&b!=this.calendarDiv.offsetParent;)
//         a+=b.offsetLeft-b.scrollLeft,
//         c+=b.offsetTop-b.scrollTop,
//         b=b.offsetParent;
//     c=getObjY(this.myElement)+this.calendarDiv.offsetHeight>Sfdc.Window.getScrollY()+Sfdc.Window.getWindowHeight()?c-(this.calendarDiv.offsetHeight+1):c+(this.myElement.offsetHeight+1);
//     b="left";
//     if (a + 225 > Sfdc.Window.getWindowWidth()) {
//         a = Sfdc.Window.getWindowWidth() - 225;
//     }
//     LC.isRtlPage()&&(b="right",a=this.calendarDiv.offsetParent.offsetWidth-a-this.myElement.offsetWidth);
//     this.shim.setStyle(b,a+"px");
//     this.shim.setStyle("top",c+"px")
// };
 
// 20170724 追加
function searchGoPageJs() {
    blockme();
    var cnt = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:currentPageRecordCnt').value;
    var isChanged = false;
 
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
    }
 
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并检索\n点击 [取消] 只翻页,放弃保存')) {
            saveAndSearchGoPage(3);
        } else {
            searchGoPage();
        }
    } else {
        searchGoPage();
    }
}
 
// 20170724 追加
function searchNextJs() {
    blockme();
    var cnt = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:currentPageRecordCnt').value;
    var isChanged = false;
 
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
    }
 
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并检索\n点击 [取消] 只翻页,放弃保存')) {
            saveAndSearchNext(4);
        } else {
            searchNext();
        }
    } else {
        searchNext();
    }
}
 
// 20170724 追加
function searchPreviousJs() {
    blockme();
    var cnt = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:currentPageRecordCnt').value;
    var isChanged = false;
 
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
    }
 
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并检索\n点击 [取消] 只翻页,放弃保存')) {
            saveAndSearchPrevious(5);
        } else {
            searchPrevious();
        }
    } else {
        searchPrevious();
    }
}
 
function checkAll() {
 
    var recCount = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:currentPageRecordCnt').value;
 
    if (j$(escapeVfId('checker')).attr('checked') == 'checked') {
        for (var i = 0; i < recCount; i++) {
            var disabled = j$(escapeVfId('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:'+ i + ':rowCheck')).prop('disabled');
            if (disabled == false) {
                j$(escapeVfId('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:'+ i + ':rowCheck')).attr('checked',true);
            }
        }
    } else {
        for (var i = 0; i < recCount; i++) {
            var disabled = j$(escapeVfId('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:'+ i + ':rowCheck')).prop('disabled');
            if (disabled == false) {
                j$(escapeVfId('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:'+ i + ':rowCheck')).attr('checked',false);
            }
        }
    }
}
// function setDisabled() {
//     var count = j$('input#count_hidden').value();
//     for (var i = 0; i < count; i++) {
//         var canEdit = j$(escapeVfId('allPage:allForm:dataBlock:dataline:'+ i + ':canEdit')).value();
//         if (canEdit == 'false') {
//              j$(escapeVfId('allPage:allForm:dataBlock:dataline:'+ i + ':extend_day')).attr('disabled',true);
//              j$(escapeVfId('allPage:allForm:dataBlock:dataline:'+ i + ':extend_reason')).attr('disabled',true);
//         }
//     }
// }
function searchOppJs() {
    blockme();
 
    var cnt = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:currentPageRecordCnt').value;
    var isChanged = false;
    
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
    }
    
    if (isChanged) {
        saveAndSearch(1);
    } else {
        searchOpp();
    }
}
 
function sortTableJs(key) {
 
    if (typeof event.stopPropagation != "undefined") {
        event.stopPropagation();
    } else {
        event.cancelBubble = true;
    }
    blockme();
    var cnt = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:currentPageRecordCnt').value;
    var isChanged = false;
    
    for (var i = 0; i < cnt; i++) {
        if (document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + i + ':changeFlg').value == 1) {
            isChanged = true;
            break;
        }
    }
    
    if (isChanged) {
        if (window.confirm('画面上的数据有变化,要保存所做的变更吗?\n点击 [确定] 保存并排序\n点击 [取消] 只排序,放弃保存')) {
            saveAndSort(2, key);
        } else {
            sortTable(key);
        }
    } else {
        sortTable(key);
    }
}
// 編集チェック
function setChangeFlg(lineno) {
    // with checkbox
    if(document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:' + lineno + ':rowCheck') !=null){
 
        var nowChk = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:' + lineno + ':rowCheck').checked;
        var oldChk = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:' + lineno + ':rowOldCheck').checked;
        if (nowChk || (nowChk != oldChk)) {
            document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + lineno + ':changeFlg').value = 1;
            // reset orderNo
            resetOrderNo();
        }
    }else{
        document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + lineno + ':changeFlg').value = 1;
    }
}
function setRadioChangeFlg(sel, lineno, isNeedCheckEvent) {
    if(document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:' + lineno + ':rowCheck') !=null){
 
        var nowChk = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:' + lineno + ':rowCheck').checked;
        var oldChk = document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable_L:' + lineno + ':rowOldCheck').checked;
        if (nowChk || (nowChk != oldChk)) {
            document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + lineno + ':changeFlg').value = 1;
            // reset orderNo
            resetOrderNo();
        }
    }else{
        document.getElementById('allPage:allForm:cmpid:cmpinnerid:dataBlock:oppTable:' + lineno + ':changeFlg').value = 1;
    }
    var nowChk = sel.checked;
    // 一旦全てをクリアして再チェックする
    j$('.rowchkcls').prop('checked', false);
    j$(sel).prop('checked', nowChk);
    if (isNeedCheckEvent == 'true') {
        blockme();
        checkEvent(lineno);
    }
}
 
function resetOrderNo() {
 
    var i=1;
    j$(".rowchkcls:checkbox:checked").each(function() {
        j$(this).parent().children('.ordernocls').val((i));
        i++;
    });
}
 
function resetOrderNoMoveUpDown(up, line) {
 
    var items = j$(".rowchkcls:checkbox");
    var len = j$(".rowchkcls:checkbox").length;
    var i = line - 1;
    var i1 = line + 1;
    // var tr = j$('#tableData').find('tbody').find('tr:eq(' + (i) + ')');
    if (up == true){
        var tr = j$('#tableData').find('tbody').find('tr:eq(' + (i) + ')');
        if(line != 1) {
            setChangeFlg(i-1);
            j$(items[i - 1]).parent().children('.ordernocls').val(line);
            j$(items[i]).parent().children('.ordernocls').val(i);
        }
        else {
            j$(items[i]).parent().children('.ordernocls').val(line);
        }
        var tr1 = j$(items[i]).parents("tr");
        tr.prev().before(tr);
        tr1.prev().before(tr1);
    }
    else {
        var tr = j$('#tableData').find('tbody').find('tr:eq(' + (i) + ')');
        if(line < len) {
            setChangeFlg(line);
            j$(items[i]).parent().children('.ordernocls').val(i1);
            j$(items[line]).parent().children('.ordernocls').val(line);
        }
        else {
            j$(items[i]).parent().children('.ordernocls').val(line);
        }
        var tr1 = j$(items[i]).parents("tr");
        tr.next().after(tr);
        tr1.next().after(tr1);
    }
}
 
// 置顶置底
function resetOrderNoMoveTopUpDown(up, line) {
 
    var items = j$(".rowchkcls:checkbox");
    var len = j$(".rowchkcls:checkbox").length;
    if (up == true){
        if(line != 1) {
            // j$(items[line-1]).parent().children('.ordernocls').val(0);
            // var first = j$(items[line-1]).parents("tr");
            // var tr = j$('#tableData').find('tbody').find('tr:eq(' + (line-1) + ')');
            // for (i = 1; i < line; i++) {
            //     tr.prev().before(tr);
            //     first.prev().before(first);
            // }
            for (i = 0; i < line-1; i++) {
                resetOrderNoMoveUpDown(true, line-i);
            }
        }
    }
    else {
        if(line < len) {
            // j$(items[line-1]).parent().children('.ordernocls').val(len-1);
            // var end = j$(items[line-1]).parents("tr");
            // var tr = j$('#tableData').find('tbody').find('tr:eq(' + (line-1) + ')');
            // for (i = 0; i < len-line; i++) {
            //     tr.next().after(tr);
            //     end.next().after(end);
            // }
            for (i = 0; i < len-line; i++) {
                resetOrderNoMoveUpDown(false, line+i);
            }
        }
    }
}
// 20230511 ljh start 
function ToggleWidth(obj){
    var colClass = getColClassName(obj);
    j$(obj).toggleClass("colUnHideIcon");
    // j$('<col class="col_Irreplaceable_flag__c">').toggleClass("colUnHideIcon");
    rerenderColWidth(colClass, false);
}
// 20230511 ljh 注释 start 
// list の headerRow の tdに toggleWidth() を追加
/*function bindTdToggleWidth() {
 
    var i = 0;
    j$('body .pbBody table#tableHeader tr.headerRow td').each(function() {
        var colClass = getColClassName(this);
        if (colClass != 'col_Scroll') {
            listColClassWidthMap[colClass] = j$('body .pbBody table.list tr.headerRow td.' + colClass).width();
            if (colClass in listColClassMap) {
                j$(this).addClass("colViewing");
                j$(this).addClass(listColClassMap[colClass]);
            } else {
                j$(this).addClass("colViewing");
            }
            rerenderColWidth(colClass, true);
            j$(this).click(function() {
                j$(this).toggleClass("colUnHideIcon");
                rerenderColWidth(colClass, false);
            });
        }
    });
    windowResize();
    // スクロール連動
    j$('div#in_Div').scroll(function() {
        j$('div#out_Div').scrollLeft(j$(this).scrollLeft());
        j$('div#in_Div_L').scrollTop(j$(this).scrollTop());
    });
    j$('div#out_Div').scroll(function() {
        j$('div#in_Div').scrollLeft(j$(this).scrollLeft());
    });
    j$('div#in_Div_L').scroll(function() {
        j$('div#in_Div').scrollTop(j$(this).scrollTop());
    });
}*/
// 20230511 ljh 注释 start 
function windowResize() {
 
    var heightsp = 0;
    // var heightsp = 38;
    console.log(typeof bottomspace);
    console.log(bottomspace);
    // if( typeof bottomspace != 'undefined' ){
    if( typeof bottomspace != 'undefined' &&  bottomspace != null && bottomspace != ''){
        heightsp = bottomspace;
    }
    blockHeight = j$(window).innerHeight() - j$(escapeVfId('allPage:allForm:searchBlock')).height() - heightAjustment;
    console.log(j$(window).innerHeight() +'-'+ j$(escapeVfId('allPage:allForm:searchBlock')).height() +'-'+ heightAjustment+'-'+heightsp);
    blockHeight = blockHeight - heightsp;
 
    sbwidth = scrollbarWidth();
    // 20230531 ljh start 
    // blockWidth = j$(escapeVfId('allPage:allForm:searchBlock')).width() - j$('div#out_Div_L').width() - widthAjustment - sbwidth - 20;
    blockWidth = j$(escapeVfId('allPage:allForm:searchBlock')).width() - j$('div#out_Div_L').width()- sbwidth-widthAjustment;
    var tableWidth = j$('table#tableData').width();
    // 20230531 ljh end 
    //コンポネートなのでIDを変更
    // 20230519 ljh start
    j$(escapeVfId('allPage:allForm:cmpid:cmpinnerid:dataBlock')).css('height', blockHeight + 48 + 'px');
    // j$(escapeVfId('allPage:allForm:cmpid:cmpinnerid:dataBlock')).css('height', blockHeight  + 48 + 'px');
    // 20230519 ljh end 
    // j$('div#in_Div').css('width', blockWidth + 'px'); // 20230519 ljh 
    // j$('div#out_Div').css('width', blockWidth + 'px'); // 20230519 ljh 
    j$('div#in_Div').css('height', blockHeight+ 'px');
    j$('div#in_Div_L').css('height', blockHeight + 'px');
 
    // Table tr の height をあわせる
    var tbl = document.getElementById('tableData_L');
    var tbl2 = document.getElementById('tableData');
    for (var i = 0; i < tbl2.rows.length; i++) {
        var ht1 = j$(tbl.rows[i]).height()+2;
        var ht2 = j$(tbl2.rows[i]).height()+2;
        // console.log(ht1+'zheli'+ht2);
        if (ht2 < ht1) {
            j$(tbl2.rows[i]).css('height', ht1 + 'px');
            j$(tbl.rows[i]).css('height', ht1 + 'px');
        } else {
            j$(tbl.rows[i]).css('height', ht2 + 'px');
            j$(tbl2.rows[i]).css('height', ht2 + 'px');
        }
    }
 
    if (j$('table#tableData').height() > j$('div#in_Div').height()) {
        console.log('zheli00');
        // 20230519 ljh 增记if判断
        // j$('div#in_Div').css('width', (blockWidth + sbwidth) + 'px');
        if (j$('table#tableData').width() > j$('div#in_Div').width()) {
            j$('div#out_Div').css('width', (blockWidth) + 'px');
            j$('div#in_Div').css('width', (blockWidth + sbwidth) + 'px');
        }
    } else {
        console.log('zheli01');
        // 20230519 ljh 增记if判断
        // j$('div#out_Div').css('width', (blockWidth + sbwidth) + 'px');
        // j$('div#in_Div').css('width', (blockWidth + sbwidth) + 'px');
        // 20230704 ljh start
        if (j$('table#tableData').width() > j$('div#in_Div').width()) {
            j$('div#out_Div').css('width', (blockWidth) + 'px');
            j$('div#in_Div').css('width', (blockWidth) + 'px');
            j$('table#tableData').css('width', (tableWidth) + 'px');
            j$('table#tableHeader').css('width', (tableWidth) + 'px');           
        }
        // 20230704 ljh end
    }
    if (j$('table#tableData').width() > j$('div#in_Div').width()) {
        j$('div#in_Div').css('height', (blockHeight + sbwidth) +'px');
        j$('div#in_Div_L').css('height', blockHeight + 'px');// 20230906 ljh add
    }
 
    j$('div#in_Div').scroll(function() {
        j$('div#out_Div').scrollLeft(j$(this).scrollLeft());
        j$('div#in_Div_L').scrollTop(j$(this).scrollTop());
    });
    j$('div#out_Div').scroll(function() {
        j$('div#in_Div').scrollLeft(j$(this).scrollLeft());
    });
    j$('div#in_Div_L').scroll(function() {
        j$('div#in_Div').scrollTop(j$(this).scrollTop());
    });
 
}
 
function expandAll(){
 
    // list の headerRow の tdに toggleWidth() を追加
    var i = 0;
    j$('body .pbBody table.list tr.headerRow td').each(function() {
        var colClass = getColClassName(this);
        if(j$(this).hasClass("colUnHideIcon")){
            j$(this).toggleClass("colUnHideIcon");
            rerenderColWidth(colClass, false);
        }
    });
    windowResize();
}
// 見た目用の classレベル 変数
var listColClassMap = {};          // colclass ==> colUnHideIcon or colViewing
var listColClassWidthMap = {};     // colclass ==> classのwidth
var blockHeight = 0;
var sbwidth = 0;
var tableWidth = 0;// 20230519 ljh lightning add
window.onresize = windowResize;
 
function rerenderColWidth(colClass, isFirst) {
    // tableWidth = j$('body .pbBody table#tableHeader').width();// 20230519 ljh lightning add
    console.log('555'+tableWidth);
    var headerCol = j$('body .pbBody table.list tr.headerRow td.' + colClass);
    if (headerCol.hasClass("colUnHideIcon")) {
        listColClassMap[colClass] = "colUnHideIcon";
        // 20230519 ljh lightning start
        // tableWidth -= headerCol.width();
        tableWidth -= listColClassWidthMap[colClass];
        // 20230519 ljh lightning end
        // 全部最小化する
        j$('body .pbBody table.list td.' + colClass).children().hide();
        // 20230728 ljh 优化
        // j$('body .pbBody table.list td.' + colClass).width(7).css("font-size", "0");
        j$('body .pbBody table.list td.' + colClass).outerWidth(10).css("font-size", "0");
    } else {
        listColClassMap[colClass] = "colViewing";
        // if (isFirst == false) { // 20230519 ljh lightning  去掉判断
            var hiddenWidth = headerCol.width();
            j$('body .pbBody table.list td.' + colClass).width("").css("font-size", "");
            j$('body .pbBody table.list td.' + colClass).children().show();
            tableWidth += listColClassWidthMap[colClass] + 2 - hiddenWidth;    // 2 is border
        // }
    }
    j$('table#tableData').css('width', (tableWidth + 2) + 'px');
    j$('table#tableHeader').css('width', (tableWidth + 2) + 'px');
}
function getColClassName(pObj) {
 
    var classList = j$(pObj).attr("class").split(' ');
    var rtn = "";
    if (classList.length > 0) {
        for (var i = 0; i < classList.length; i++) {
            if (classList[i].indexOf("col_") >= 0) {
                rtn = classList[i];
                break;
            }
        }
    }
    return rtn;
}