fs-danaus
2023-12-01 0f032347696aff30cfe09c357adda15939499f4d
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
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
var isLoadSelect = true;// 表示是否是加载的时候选择tab
var isLast="";//保存刷新系统前最后选择的页卡
var myFresh={}//关闭页卡获取面板和格线内容是否有改变。
var tabindex=0;//多个页卡的元素,用来区分页卡
myFresh.panel=new Array();//关闭页卡获取面板内容是否有改变。
myFresh.grids={};//关闭页卡获取格线内容是否有改变。
myFresh.formType=0;//关闭页卡排除的窗体类型。
myFresh.clickNode=false;//表示点击了树节点
var copyLink=new Array();//复制对应单据的链接=--- 2018-9-4 17:48:59 xin
var hostUrlCopy="";//复制链接用到
var copyUrl=""; //复制链接用到
var panelHeight=0;//tabs页卡里面的panel高度
var tabWidth=0;//设置页卡内容里的页卡(496窗体页卡)的宽度
//针对切换页卡后滚动条被置顶的问题设置两个属性 xin 2020-10-14 09:33:04
var scrollMap = new scrollTopMap();
var subPageScrollHeight=0;
var gridFileInputRow={};//针对格线附件控件的属性 xin 2022-3-1 09:19:18
var gridFileInputVal;//针对格线附件控件的值 xin 2022-3-1 09:20:43
var isFileInputImage;//针对附件控件图片放大 xin 2022-3-1 09:20:43
var treeTab=[];
//---end
myFresh.type=0;
$( function() {
    $("#nagigation").tabs( {
        tools : [ {
            iconCls :'icon-back',
            handler : function() {
                $('body').layout('collapse', 'west');
            }
        } ],
        border :true
    });
    
    $('#homePageTree')
            .tree(
                    {
                        animate :true,
                        dnd :false,
                        cascadeCheck :true,
                        url :'/getUserMenu.do?menuId=1',
                        onBeforeExpand : function(node, param) {
                            // session失效后弹出登录框,flag为true时表示已经失效
                            if(checkSession()){
                                return false;
                            }
                            $('#homePageTree').tree('options').url = "/getUserMenu.do?menuId="
                                + node.id;
                        },
                        onClick : function(node) {
                            var obj = node.attributes;
                            if (obj.formid == "" || obj.formid == "null")
                                return;
                            addTab('', obj.formid, obj.formtype);
                        },
                        onMouseDown : function(node) {// hq添加新函数
                            // clickNode=node;
                    },
                    onMyDorpStart : function() {
                        // if(clickNode!=null)
                        // $('#homePageTree').tree('collapse',clickNode.target);
                    },
                    onDblClick : function(node) {
                        $('#homePageTree').tree('toggle', node.target);
                    }
                    });
    
    $('#homeJumpHelp')
    .tree(
            {
                animate :true,
                dnd :false,
                cascadeCheck :true,
                url :'/getUserMenu.do?menuId=1',
                onBeforeExpand : function(node, param) {
                    $('#homeJumpHelp').tree('options').url = "/getUserMenu.do?menuId="
                            + node.id;
                },
                onClick : function(node) {
                    var obj = node.attributes;
                    if (obj.formid == "" || obj.formid == "null")
                        return;                    
                    var dbid=$.cookie('dbid');                    
                    var hostUrl=$("#hostURL").val();                    
                    var url=hostUrl+"/app/"+dbid+"/0/cnzh/"+obj.formid+"/"+obj.formtype+"/help.jsp";
                    $("#helpIframe").attr("src",url);                    
                },
                onMouseDown : function(node) {// hq添加新函数
            },
            onMyDorpStart : function() {
            },
            onDblClick : function(node) {
                $('#homeJumpHelp').tree('toggle', node.target);
            }
            });
    
    
    $('#homePageTree2')
            .tree(
                    {
                        animate :true,
                        dnd :false,
                        cascadeCheck :true,
                        url :'/getChildWebMenuTree.do?menuid=0',
                        onBeforeExpand : function(node, param) {
                            $('#homePageTree2').tree('options').url = "/getChildWebMenuTree.do?menuid="
                                    + node.id;
                        },
                        onClick : function(node) {
                            var obj = node.attributes;
                            if (obj.formid == "" || obj.formid == "null")
                                return;
                            addTab('', obj.formid, obj.formtype);
                        },
                        onDblClick : function(node) {
                            $('#homePageTree2').tree('toggle', node.target);
                        }
                    });
    $('#flowChartTree')
            .tree(
                    {
                        animate :true,
                        dnd :false,
                        cascadeCheck :true,
                        url :'/getChildWebMenu2.do',
                        onBeforeExpand : function(node, param) {
                            var obj = node.attributes;
                            $('#flowChartTree').tree('options').url = "/getChildWebMenu2.do?rowid="
                                    + obj.rowid;
                        },
                        onClick : function(node) {
                            var obj = node.attributes;
                            $.post("/checkHasFlowchart.do?rowid=" + obj.rowid,
                                    "", function(d) {
                                        if ($.trim(d) == "true") {
                                            addTab(node.text + "-流程图", '', '',
                                                    '',
                                                    "/mxgraph/showFlowChart.jsp?rowid="
                                                            + obj.rowid, "", {
                                                        isFlowChart :true
                                                    });
                                        } else {
                                            alert("该节点没有配置流程图!");
                                        }
 
                                    });
                        },
                        onDblClick : function(node) {
                            $('#flowChartTree').tree('toggle', node.target);
                        }
                    });
    $('#home-tabs').tabs(
            {
                onSelect : function(tt, index) {//当用户选择一个标签页面板(tab panel)时触发。
                    tabindex = index;
                    //----解决页卡切换后 滚动条被置顶的问题 xin 2020-10-14 09:18:13
                    var val = scrollMap.get(tabindex);
                    if (val!=null && val!=0) {
                        $("#home-tabs > div").eq(1).children("div").eq(tabindex).find("iframe")[0].contentWindow.scrollTo(0,val);
                    }
                    //------end
                    lastTabs = $.grep(lastTabs, function(n, i) {
                        return n != tt;
                    }); // 移除 tt
                    lastTabs.push(tt); // 重新压入,保证 最新的在最上面
 
                    var sTab = $("#home-tabs").tabs("getTab", index);
                    if (!isLoadSelect) {// 在循环添加cookie里面的tab改变改值
                        /* 第一次点击加载 */
                        // var info=$.cookie("lastSelectedTab");
                        tabWidth=(this.clientWidth-100);//针对496窗体页卡获取宽度
                        myFresh.formType=$(sTab).find('iframe').attr("type");
                        var sContent = $(sTab.panel("options").content);
                        if (isLast && isLast != ""
                                && isLast == sContent.attr("id")) {
                        } else {
                            var url = sContent.attr("url");
                            if (url && url != "") {
                                sContent.attr("src", url).attr("url", "");
                                $("#home-tabs").tabs("update", {
                                    tab : sTab,
                                    options : {
                                        content : sContent[0]
                                    }
                                });
                            }
                        }
                        $.cookie("lastSelectedTab", $($.parseHTML(tt)).attr(
                                "frameid"));// 设置最后选择的选项卡到cookie
                        panelHeight=sTab[0].clientHeight;//panel面板高度
                    }
                    if(treeTab.length>0){
                        let iframe = $(sTab).find('iframe');
                        let name = iframe[0].id;
                        let index = $.inArray(name, treeTab);
                        if (index != -1) {
                            $(iframe).attr('src', $(iframe).attr('src'));
                            treeTab.splice(index, 1);
                        }
                    }
                    // var grid=$("#home-tabs > div").eq(1).children("div").eq(tabindex).find("iframe")[0].contentWindow.Grids;
                    // if(grid!=undefined&&grid[0]){
                    //     grid[0].SetScrollTop (grid.currScrollTop);
                    // }
                    // if (sTab){
                    //     var iframe=$(sTab).find('iframe');
                    //     var type=iframe.attr("type");
                    //     if (type!=null && type==496){
                    //         $(iframe).attr('src', $(iframe).attr('src')); //刷新
                    //     }
                    // }
                },
                onBeforeClose : function(title, index) {//当一个标签页面板(tab panel)被关闭前触发,返回 false 就取消关闭动作。
                    var target = this;
                    if (myFresh.panel[index] != 2 && myFresh.panel[index] != 1
                            && myFresh.panel[index] != 16
                            && myFresh.panel[index] != 22
                            && myFresh.panel[index] != 20
                            && myFresh.panel[index] != 18
                            && myFresh.panel[index] != 38
                            && myFresh.panel[index] != 3
                            && myFresh.panel[index] != 10) {
                        if (myFresh.panel[index + '-t']
                                || getGrid(myFresh.grids)) {
                            $.messager.confirm('确认',
                                    '页面内容已有改动,关闭操作将会丢失数据,您确定要关闭当前页面吗?',
                                    function(r) {
                                        if (r) {
                                            var opts = $(target)
                                                    .tabs('options');
                                            var bc = opts.onBeforeClose;
                                            opts.onBeforeClose = function() {
                                            };
                                            $(target).tabs('close', index);
                                            opts.onBeforeClose = bc;
                                            approvedDoc.excludeDocs=""//清空排除下一单的单号 xin 2022-7-30 17:30:59
                                            delCTab($($.parseHTML(title)).attr(
                                                    "frameid"));
                                            myFresh.panel[index+'-t']=false;
                                        }
                                    });
                            return false; // 阻止关闭
                        } else {
                            approvedDoc.excludeDocs=""//清空排除下一单的单号 xin 2022-7-30 17:30:59
                            delCTab($($.parseHTML(title)).attr("frameid"));
                        }
                    } else {
                        approvedDoc.excludeDocs=""//清空排除下一单的单号 xin 2022-7-30 17:30:59
                        delCTab($($.parseHTML(title)).attr("frameid"));
                    }
                    myFresh.formType = (myFresh.Type == 0 ? myFresh.formType
                            : myFresh.Type);
                    myFresh.Type = 0;
                },
                onAdd:function(title,index){//当一个新的标签页面板(tab panel)被添加时触发复制链接。
                    var titleCopy=(title.indexOf("-")!=-1?title.split("-")[0].split("=")[1].replace(/\"/g, ""):title);
                    copyLink[index]=hostUrlCopy+"?"+encodeText(copyUrl+"&formname="+titleCopy);//复制对应单据的链接地址-----赋值 2018-9-4 17:48:59 xin
                    copyUrl="";
 
                },
                onUnselect:function(title,index) {//当用户未选择一个标签页面板(tab panel)时触发
                    //解决页卡切换后 滚动条被置顶的问题 xin 2020-10-14 09:50:44
                    if (tabindex > 0) {
                        scrollMap.put(index, subPageScrollHeight);
                    }
 
                    //  var grid=$("#home-tabs > div").eq(1).children("div").eq(tabindex).find("iframe")[0].contentWindow.Grids;
                    //  if(grid!=undefined&&grid[0]){
                    //      grid[0].currScrollTop=grid[0].GetScrollTop();
                   // }
                },
                onClose:function(title,index){//当用户关闭一个标签页面板(tab panel)时触发。
                    //console.log("tabs->onClose:"+title);
                },
                onUpdate:function(title,index){
                    //console.log("tabs->onUpdate:"+title);
                }
            });
    try{
    index = getCookieIndex();
    }catch(e){}
    setTimeout("eachCTab()", 1000);//刷新后执行加载之前打开没关闭的页卡
    $("#home_north .easyui-menubutton").hover( function() {
        $(this).find(".l-btn-text").css("color", "black");
    }, function() {
            $(this).find(".l-btn-text").css("color", "#EBEBEB");
    });
    $('.menu').hover( function() {
        if (this.id=='mm2'){
            $('#home_north #homehelp').find('.l-btn-text').css('color', 'black');
        }else{
            $('#home_north #shortcuts').find('.l-btn-text').css('color', 'black');
        }
    },function(){
        $('#home_north .easyui-menubutton').find('.l-btn-text').css('color', '#EBEBEB');
    });
    doAddContextMenu2tab();
    tabContextMenuEvent();
    //智能小助手  2019-12-19 09:41:17
    var Dom = {
        helpIcon: $('.help-icon-container'), // 帮助按钮
        helpContent: $('.ai-container'), // 帮助内容层
        helpCloseIcon: $('i.close-dialog'), //帮助内容层关闭按钮
        msgsList: $('.ai-content .msgs-ul'), //帮助内容层关闭按钮
        repairLayout: $('#repairLayout'), // 解决布局等问题开关
        reloadLayout: $('#reloadLayout') //
    }
          initHelpPosition();
          var isDrag = false;
          // 图标的显隐
          Dom.helpIcon.on('mouseup', function () {
            if (isDrag) return;
            $(this).fadeOut(300);
            setTimeout(function () {
              Dom.helpContent.fadeIn();
            },300)
          });
          Dom.helpCloseIcon.on('click', function () {
            Dom.helpContent.fadeOut(300);
            setTimeout(function () {
              Dom.helpIcon.fadeIn();
            },300)
          });
          // 帮助图标拖动
          Dom.helpIcon.on('mousedown', function (ev) {
            var disX = ev.clientX - Dom.helpIcon.offset().left;
            var disY = ev.clientY - Dom.helpIcon.offset().top;
            var height = $(document).height() - Dom.helpIcon.height();
            var width = $(document).width() - Dom.helpIcon.width();
            var extentX = 0;
            var extentY = 0;
            Dom.helpIcon.css('cursor','move');
            $(document).on('mousemove', function (ev) {
              isDrag = true;
              extentX = ev.clientX - disX;
              extentY = ev.clientY - disY;
              // 限制可移动范围
              extentX < 0 ? extentX = 0 : '';
              extentX > width ? extentX = width : '';
              extentY < 0 ? extentY = 0 : '';
              extentY > height ? extentY = height : '';
              Dom.helpIcon.css('left',extentX);
              Dom.helpIcon.css('top',extentY);
            });
            $(document).on('mouseup',function () {
              $(this).off();
              if (isDrag){
                // 存储位置
                var positionX = extentX;
                var positionY = extentY;
                localStorage.setItem('helpPositionX', positionX);
                localStorage.setItem('helpPositionY', positionY);
                // console.log('ddd',positionX,positionY);
              }
              isDrag = false;
              Dom.helpIcon.css('cursor','pointer');
            })
            $(document).on(' mouseout',function () {
              $(this).off();              
            })         
          });
          Dom.repairLayout.on('click',function () {
            // 在这里发送请求处理布局等问题
              var Tab = $("#home-tabs").tabs("getTab", tabindex);
              var loading=$(Tab).find("div");
              var iframe=$(Tab).find('iframe');              
              var formid=iframe.attr("src");              
              if(formid.indexOf('app/')!=-1){
                  if(formid.indexOf('/app')==0){
                      //有些情况是以/app开始  by danaus 2021-9-15
                      formid=formid.split('/')[5];
                  }else{
                      //有些页面是以app/开始,需要区分
                    formid=formid.split('/')[4];
              }
              }else{//待办事宜进入-xin 2020-3-18 13:49:34
                  try{
                      formid=formid.toLowerCase().replace(/\s+/g,"");
                        if(formid.indexOf('formid=')!=-1){
                            formid=formid.split('formid=')[1];
                            formid=formid.split('&')[0];
                        }
                  }catch(e){
                      formid=0;
                  }                  
              }
              if(isNaN(formid)){
                $(iframe).attr('src', $(iframe).attr('src')); //刷新
                var str = '<li class="msgs-li">\n' +
                    '          <i class="iconfont icon-kefu1 avator"></i>\n' +
                    '          <div class="msg-content">\n' +
                    '            当前页面不能操作,请进入具体功能页面操作生成!\n' +
                    '          </div>\n' +
                    '        </li>';
                Dom.msgsList.append(str);
                  return;
            }
              $.ajax({
                  url: '/buildv2.do?formID='+formid,
                  dataType: 'html',
                  beforeSend: function() {
                      $(loading).show();
                      //showLoading();
                  },
                  complete: function() {
                      $(loading).hide();
                      //closeLoading();
                  },
                  success: function(data) {
                    var icon="error";
                    var hider=false;
                    if(data!=null&&data.indexOf("成功")>0){
                        data='生成成功,即将打开页面!';
                        icon="info";
                        hider=3000;
                    }
                      $.toast({
                        text: data, // Text that is to be shown in the toast
                        //text:'生成成功,即将打开页面!',
                        // heading: '提示', // Optional heading to be shown on the toast
 
                        icon: icon, // Type of toast icon
                        showHideTransition: 'fade', // fade, slide or plain
                        allowToastClose: true, // Boolean value true or false
                        hideAfter: hider, // false to make it sticky or number representing the miliseconds as time after which toast needs to be hidden
                        stack: 5, // false if there should be only one toast at a time or a number representing the maximum number of toasts to be shown at a time
                        position: 'mid-center', // bottom-left or bottom-right or bottom-center or top-left or top-right or top-center or mid-center or an object representing the left, right, top, bottom values
 
                        textAlign: 'left',  // Text alignment i.e. left, right or center
                        loader: true,  // Whether to show loader or not. True by default
                        loaderBg: '#9ec600',  // Background color of the toast loader
                        beforeShow: function () {
                        }, // will be triggered before the toast is shown
                        afterShown: function () {
                        }, // will be triggered after the toat has been shown
                        beforeHide: function () {
                        }, // will be triggered before the toast gets hidden
                        afterHidden: function () {
                            $(iframe).attr('src', $(iframe).attr('src')); //刷新
                            replyMsg();
                        }  // will be triggered after the toast has been hidden
                    });
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                }
            });
            // console.log('发送请求');
        });
    Dom.reloadLayout.on('click', function () {
        // 在这里发送请求处理布局等问题
        var Tab = $("#home-tabs").tabs("getTab", tabindex);
        var loading = $(Tab).find("div");
        var iframe = $(Tab).find('iframe');
        var formid = iframe.attr("src");
        if (formid.indexOf('app/') != -1) {
            if (formid.indexOf('/app') == 0) {
                //有些情况是以/app开始  by danaus 2021-9-15
                formid = formid.split('/')[5];
            } else {
                //有些页面是以app/开始,需要区分
                formid = formid.split('/')[4];
            }
        } else {//待办事宜进入-xin 2020-3-18 13:49:34
            try {
                formid = formid.toLowerCase().replace(/\s+/g, "");
                if (formid.indexOf('formid=') != -1) {
                    formid = formid.split('formid=')[1];
                    formid = formid.split('&')[0];
                }
            } catch (e) {
                formid = 0;
            }
        }
        if (isNaN(formid)) {
            $(iframe).attr('src', $(iframe).attr('src')); //刷新
            var str = '<li class="msgs-li">\n' +
                '          <i class="iconfont icon-kefu1 avator"></i>\n' +
                '          <div class="msg-content">\n' +
                '            当前页面不能操作,请进入具体功能页面操作生成!\n' +
                '          </div>\n' +
                '        </li>';
            Dom.msgsList.append(str);
            return;
        }
        $.ajax({
            url: '/grid/clearCookie.do?cookieType=PC&formid=' + formid,
            dataType: 'html',
            beforeSend: function () {
                $(loading).show();
                //showLoading();
            },
            complete: function () {
                $(loading).hide();
                //closeLoading();
            },
            success: function (data) {
                var icon = "error";
                var hider = false;
                if (data != null && data.indexOf("成功") > 0) {
                    data = '还原成功,刷新当前页面!';
                    icon = "info";
                    hider = 3000;
                }
                $.toast({
                    text: data, // Text that is to be shown in the toast
                    //text:'生成成功,即将打开页面!',
                    // heading: '提示', // Optional heading to be shown on the toast
 
                    icon: icon, // Type of toast icon
                    showHideTransition: 'fade', // fade, slide or plain
                    allowToastClose: true, // Boolean value true or false
                    hideAfter: hider, // false to make it sticky or number representing the miliseconds as time after which toast needs to be hidden
                    stack: 5, // false if there should be only one toast at a time or a number representing the maximum number of toasts to be shown at a time
                    position: 'mid-center', // bottom-left or bottom-right or bottom-center or top-left or top-right or top-center or mid-center or an object representing the left, right, top, bottom values
 
                    textAlign: 'left',  // Text alignment i.e. left, right or center
                    loader: true,  // Whether to show loader or not. True by default
                    loaderBg: '#9ec600',  // Background color of the toast loader
                    beforeShow: function () {
                    }, // will be triggered before the toast is shown
                    afterShown: function () {
                    }, // will be triggered after the toat has been shown
                    beforeHide: function () {
                    }, // will be triggered before the toast gets hidden
                    afterHidden: function () {
                        $(iframe).attr('src', $(iframe).attr('src')); //刷新
                        replyMsg();
                    }  // will be triggered after the toast has been hidden
                });
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
        // console.log('发送请求');
    })
 
    // 初始化帮助图标的位置
    function initHelpPosition() {
        var positionX = localStorage.getItem('helpPositionX');
        var positionY = localStorage.getItem('helpPositionY');
        Dom.helpIcon.fadeIn(2000);
        if (positionX && positionY) {
            let winLeft = document.body.offsetWidth;
            let winTop = document.body.offsetHeight;
            if (winLeft != null && winTop != null) {
                positionX = positionX > winLeft ? (winLeft - 70) : (winLeft - positionX > 70 ? positionX : (winLeft - 70));
                positionY = positionY > winTop ? (winTop - 65) : (winTop - positionY > 65 ? positionY : (winTop - 65));
            }
            Dom.helpIcon.css({
                left: parseInt(positionX),
                top: parseInt(positionY)
            });
        }
}
function replyMsg() {
  var str = '<li class="msgs-li">\n' +
      '          <i class="iconfont icon-kefu1 avator"></i>\n' +
      '          <div class="msg-content">\n' +
      '            是否解决了您的问题?如果没有请联系我们的人工客服!\n' +
      '          </div>\n' +
      '        </li>';
  Dom.msgsList.append(str);
}
});
 
index = 0;
var rot="";
var changFrame = "";// 更改的框架名称 特指父框架
var thisFrame = "";// 创建页卡时的框架名称 特指子框架
var postToThis = "";// 接受字段 父页面
var panelToPost = "";// 所需字段 子页面
var panel_onlyOne="";
var T_Grid = "";
var lastTabs = new Array(); // 当用户关闭tab时,自动切换到前一个tab不至于让用户看到空的界面。
 
function addTab(title, formId, formType, para, url, id, obj,gridObj,panelObj) {
    //by danaus 2022/7/25 11:22 gridObj参数是处理三点弹出时,刷新当前页面再选择问题
 
    var flag = checkSession();//session失效后弹出登录框,flag为true时表示已经失效
    if(flag){
        return;
    }
    var encode = true;
    if (obj) {
        if (typeof (obj.encode) != "undefined") {
            encode = obj.encode;
        }
    }
    if ($.trim(formId + "").length > 0) {
        checkFormIdExsist(formId, function(d) {
            if (d.exists) {
                if(para==undefined||para==""){
                      para="";
                      para+=d.query_string;
                
                }else{
                      para+=(d.query_string==""?d.query_string:" and ( "+d.query_string+" )");
                }                
              addTab$(d.menuname, formId, formType, para, true, url, "",encode, obj,gridObj,panelObj);
            } else {
                alert("在系统菜单里没有该功能号的设置!");
            }
        });
    } else {
        if (typeof (obj) == 'undefined' || typeof (obj.encode) == "undefined") {
            encode = false;
        }
        addTab$(title, '', formType, '', false, url, id, encode, obj,gridObj,panelObj);
    }
}
/** **tabs右键菜单start*** */
function doAddContextMenu2tab() {
    $("body").on('contextmenu',".tabs-inner", function(e) {
        $('#tabContextMenu').menu('show', {
            left :e.pageX,
            top :e.pageY
        });
        var title = $(this).find("span.tabs-title").html();
        $('#tabContextMenu').data("currTitle", title);
        return false;
    });
}
 
var sysTabTitle = "桌面";
function tabContextMenuEvent() {
    $("#tabclose").click( function() {// 关闭当前
                // var t = getCt();
                // if(sysTabTitle!=t){
                // closeTabByFrameId($(t).attr("frameid"));
                // }
                var ct = getCt();
                var t;
                $('#home-tabs').find(".tabs li").each( function() {
                    t = $(this).find(".tabs-title").html();
                    if (t == ct) {
                        $(this).find('.tabs-close').click();
                    }
                });
            });
    $("#tabcloseall").click( function() {// 关闭所有
                // var t;
                // $('#home-tabs').find(".tabs li").each(function(){
                // t=$(this).find(".tabs-title").html();
                // if(sysTabTitle!=t){
                // closeTabByFrameId($(t).attr("frameid"));
                // }
                // });
                $("#home-tabs").find(".tabs-close").each( function(i) {
                    $(this).click();
                });
            });
    $("#tabcloseother").click( function() {// 除此之外关闭所有
                var ct = getCt();
                var t;
                $('#home-tabs').find(".tabs li").each( function() {
                    t = $(this).find(".tabs-title").html();
                    if (sysTabTitle != t && t != ct) {
                        // closeTabByFrameId($(t).attr("frameid"));
                        $(this).find('.tabs-close').click();
                    }
                });
            });
 
    $("#tabcloseleft").click( function() {// 关闭左侧
                var prev = $('#home-tabs').find(".tabs .tabs-selected")
                        .prevAll();
                var ct = getCt();
                var t;
                prev.each( function() {
                    t = $(this).find(".tabs-title").html();
                    if (sysTabTitle != t && t != ct) {
                        $(this).find('.tabs-close').click();
                        //closeTabByFrameId($(t).attr("frameid"));
                    }
                });
            });
 
    $("#tabcloseright").click( function() {// 关闭右侧
                var next = $('#home-tabs').find(".tabs .tabs-selected")
                        .nextAll();//.tabs('getSelected')
                var ct = getCt();
                var t;
                next.each( function() {
                    t = $(this).find(".tabs-title").html();
                    if (sysTabTitle != t && t != ct) {
                        $(this).find('.tabs-close').click();
                        //closeTabByFrameId($(t).attr("frameid"));
                    }
                });
            });
}
function getCt() {
    return $('#tabContextMenu').data("currTitle");
}
/**
 * 获取当前页卡格线是否有内容改动
 * @param grids
 * @returns
 */
function getGrid(grids){
    try{
        if(grids!=null){
           for(var g=0;g<grids.length;g++){
                if(grids[g].checkData()){
                    return grids[g].checkData();
                    break;
                }
           }
        }
    }catch(e){
        return false;
    }    
    return false;
}
/** **tabs右键菜单end*** */
function openByFormId(obj) {// 打开选项卡通过formid
    if (!obj || !obj.formId || !obj.formType) {
        alert("功能号(formId)、功能类型(formType)必须传递!");
        return;
    }
    // alert($);
    // var tempObj = $.extends({parameter:"",encode:true},obj);
    // alert(tempObj.parameter);
}
var title4operaOld = null;// 解决opera 3点返回值后不选择选项卡
var title4operaNew = null;
function addTab$(title, formId, formType, para, isFunc, url, id, isEncode, paraObj,gridObj,panelObj) {
    var tabCount = $('#home-tabs').tabs('tabs').length;
    if (tabCount > 20) {
        $.messager.alert("系统提示", '您当前打开了太多的页面,如果继续打开,会造成程序运行缓慢,无法流畅操作!',
                "error");
    }
    if (tabCount > 20)
        return;
    var undf = "undefined";
    if (typeof (id) != undf && $.trim(id) != "") {
        thisFrame = id;
    } else {
        index++;
        thisFrame = "home_ye" + index;
    }
    if (isFunc) {
        
        // 调用拿选项卡标题的方法
        title = getT(para, formType, formId, title);
        var ti = title;
        if (ti.length > 10)
            ti = title.substring(0, 10) + "..";
        title = "<a   title=\"" + title + "\" frameid=\"" + thisFrame + "\">"
                + ti + "</a>";
    }
    if (undefined == url || $.trim(url) == "") {
        url = "/app" + spellPath + formId + "/" + formType + "/index.jsp";
         copyUrl=url;
        if (para != undefined && para != null && para.length > 0) {
            para = $.trim(para);
            if (true == isEncode){
                url += "?" + encodeText(para);
                copyUrl=url;//复制链接用到
            }else{
                copyUrl=url+ "?" + encodeText(para);//复制链接用到
                url += "?" + para;
            }
        }
    } else {
        copyUrl=url;
        if (!isFunc && true == isEncode){
            url = encodeURL(url);
            copyUrl=encodeURL(url);
        }
    }
    if (title.indexOf("frameid=") == -1
            && (typeof (paraObj) == undf
                    || typeof (paraObj.isFlowChart) == undf || !paraObj.isFlowChart)) {
        title += "<span class='hidden'>" + Math.round(Math.random() * 100000)
                + "</span>";
    }
    if (typeof (paraObj) != undf&&paraObj!=null) {
        if (typeof (paraObj.isFlowChart) != undf) {// 如果是isFlowChart类型的每次选择都刷新
            var tab = $("#home-tabs").tabs("getTab", title);
            if (tab != null) {
                $("#home-tabs").tabs("select", title);
                var selectt = $("#home-tabs").tabs("getSelected");
                $("#home-tabs").tabs("update", {
                    tab :selectt,
                    options : {
                        content :selectt.panel("options").content
                    }
                });
                return;
            }
        }
    }
    /* 解决首次打开cookie里面保存的选项卡时不加载 */
    var urlt = "";
    if (isLoadSelect) {// 首次加载
        urlt = url;
        //url = "";//by danaus 15/9/8 处理加载最后tab时空白问题
    }
    /* end */
    //var tid=Math.round(Math.random()*10000)
    
    //设置新页卡的高度为指定高度px(不能使用 100%),如果不设置指定高度px,遇到 chrome 低版本时(如 for xp )时页面只显示上半截 ,Added by Johns Wang,2018-12-04
    var iFrameHeight = $('#home-tabs').height() ;
    //var barHeight = window.innerHeight - document.body.clientHeight ;
    //AI智能小手指loading xin 2019-12-20 15:11:59
    var loading="<div id=\"ailoading\" class=\"ailoading\" style=\"display: none\"><p class=\"ailoadingMsg\">AI小助手解决中,请稍等...</p></div>"
    if(gridObj) {
        changFrame = gridObj.frameName;
        T_Grid = gridObj.T_Grid;
    }else if(panelObj){
        changFrame = panelObj.frameName;
        panelToPost = panelObj.panelToPost;
        postToThis = panelObj.postToThis;
    }else{
        if(T_Grid!=undefined&&T_Grid!=""){
            try {
                var tGrid = JSON.parse(T_Grid);
                if((tGrid.formP==""&&tGrid.toP=="")||(tGrid.formP=="null"&&tGrid.toP=="null")){
                    T_Grid="";
                }
            }catch (e){}
        }
    }
    $('#home-tabs').tabs('add',    {
                        id:thisFrame,
                        title :title,
                        content :loading+"<iframe  pframe='"+ changFrame+ "' posttothis='"+ postToThis+ "' paneltopost='"+ panelToPost+ "" +
                                "' t_grid='"+ T_Grid+ "' panel_onlyone='"+ panel_onlyOne+ "' id='"+ thisFrame+ "' name='"+ thisFrame+ "" +
                                "' type=\""+formType+"\" src=\""+ url    + "\" url=\""+ urlt    + "\" frameborder='0' width='100%'   height='" + (parseInt(iFrameHeight)-40) + "px'   " +
                                "onload='toScrollFrameM(\"#"+thisFrame+"\");'></iframe>",
                        closable :true
                    });
    changFrame = "";
    panelToPost = "";
    postToThis = "";
    T_Grid = "";
    if (isFunc) {
        addCTab(thisFrame, title, url,formType);
        setCookieIndex(index);
    }
    let treeArr = [2, 3, 4, 9, 17, 20, 30, 238, 497];//特殊窗体
    if ($.inArray(parseInt(formType), treeArr) != -1) {//是特殊窗体 xin 2022-4-16 17:31:56
        treeTab.push(thisFrame);
    }
}
 
var para1="";
function formNum(num){
    para1=num;
}
 
// TW_跟据窗体类型加载选项卡的标题:功能名+功能号+列表+(详情)+(单号)
function getT(para, formType, formId, title) {
    var oddnum;// 单号
    var numid = parent.numId;//在encode.js中取值
    if(numid.indexOf("doccode")!=-1 && numid.trim()!="''" && numid.length<20){
        if(numid.substring(numid.indexOf("doccode")+8,numid.indexOf("doccode")+10)!="''"){
            oddnum = numid.substring(numid.indexOf("'")+1,numid.length-1);
        }
    }
    if(para1!="" && para1!=null){
        oddnum=para1;
    }
    if ($.trim(para).length > 3 && para1=="") {
        oddnum = para.substring(para.indexOf("'") + 1, para.length - 1);// 因为单号存在para这个条件语句里面,所以要从里面截取出来
    }
    para1=""
    if (formType == 5 || formType == 8 || formType == 16 || formType == 496
            || formType == 498) {
        if (oddnum != null) {
            title = $.trim(title) + "-明细-" + formId + "-" + oddnum;
        } else {
            title = $.trim(title) + "-明细-" + formId;
        }
    } else if (formType == 1 || formType == 15 || formType == 17
            || formType == 18 || formType == 497 || formType == 499
            || formType == 7 || formType == 10 || formType == 9) {
        title = $.trim(title) + "-列表-" + formId;
    } else {
        title = $.trim(title) + "-" + formId;
    }
    return title;
}
// TW
 
function resetTabName(t) {
    var tab = getTabSelected();
    if (tab == null)
        return;
    var ti = t;
    if (t.length > 10)
        ti = t.substring(0, 10) + "..";
    var frameid = $(getTabSelected().panel("options").title).attr("frameid");
    $("#home-tabs .tabs-selected .tabs-title")
            .html(
                    "<a title=\"" + t + "\" frameid=\"" + frameid + "\">" + ti
                            + "</a>");
}
function closeTab(fun) {
    // var t=getTabSelected().panel("options").title;
    // $("#home-tabs").tabs("close",t);
    $('#home-tabs').find('.tabs-selected').find('.tabs-close').click();// pengbei
    // add
    if (typeof fun == "function") {
        fun();
    } else if (typeof fun != "undefined") {
        alert(fun);
    }
}
function closeTabByFrameId(id) {
    $("#home-tabs").find(".tabs-title>a").each(
            function() {
                if (id == $(this).attr("frameid")) {
                    var t = $(this);
                    $("#home-tabs").tabs(
                            "close",
                            "<a title=\"" + t.attr("title") + "\" frameid=\""
                                    + id + "\">" + t.text() + "</a>");
                    return false;
                }
            });
}
 
function getIframeAttr(str) {
    var v_ = "";
    var select = getTabSelected();
    if (select != null) {
        v_ = select.find("iframe").attr(str);
    }
    return v_;
}
function getTabSelected() {
    return $("#home-tabs").tabs("getSelected");
}
 
function selectTab(info){
    //$("#home-tabs").find(".tabs-title>a").each(function(){
    //    if(info==$(this).attr("frameid")){
    //        var t=$(this);
            //$("#home-tabs").tabs("select","<a title=\""+t.attr("title")+"\" frameid=\""+info+"\">"+t.text()+"</a>");
    //        $(this).click();
    //        return false;
    //    }
    //});
    $("#home-tabs a[frameid='"+info+"']").click();
}
var topFrame = {// 兼容旧系统parent.topFrame.funcLink
    funcLink : function(f, t, sf, lf, lk, sd, ld, isp, ef, mes, ref, clo,
            autoSave,sortid,messageTip,rowid) {//rowid 表格当前行id
        var tempFrame = getTabSelected().find("iframe")[0];
        tempFrame.contentWindow.funcLink(f, t, sf, lf, lk, sd, ld, isp, ef,
                mes, ref, clo, autoSave,sortid,messageTip,rowid);
    }
};
//---------------解决页卡切换后 滚动条被置顶的问题 xin 2020-10-14 09:16:55
$(window).scroll(function(){ 
    //父页面值
    if ($(document).scrollTop() > 0) {
        parent.subPageScrollHeight = $(document).scrollTop();
    }
});
function scrollTopMap() {
    var struct = function(key, value) {
        this.key = key;
        this.value = value
    };
    var put = function(key, value) {
        for (var i = 0; i < this.arr.length; i++) {
            if (this.arr[i].key === key) {
                this.arr[i].value = value;
                return
            }
        }
        this.arr[this.arr.length] = new struct(key, value)
    };
    var get = function(key) {
        for (var i = 0; i < this.arr.length; i++) {
            if (this.arr[i].key === key) {
                return this.arr[i].value
            }
        }
        return null
    };
    var remove = function(key) {
        var v;
        for (var i = 0; i < this.arr.length; i++) {
            v = this.arr.pop();
            if (v.key === key) {
                continue
            }
            this.arr.unshift(v)
        }
    };
    var getAllValues = function() {
        var tmp = new Array();
        for (var i = 0; i < this.arr.length; i++) {
            tmp[i] = this.arr[i].value
        }
        return tmp
    };
    var getAllKeys = function() {
        var tmp = new Array();
        for (var i = 0; i < this.arr.length; i++) {
            tmp[i] = this.arr[i].key
        }
        return tmp
    };
    var size = function() {
        return this.arr.length
    };
    var isEmpty = function() {
        return this.arr.length <= 0
    };
    var removeAll = function() {
        this.arr = []
    };
    this.getFirstValue = function() {
        return this.arr[0].value
    };
    this.getFirstKey = function() {
        return this.arr[0].key
    };
    this.arr = new Array();
    this.get = get;
    this.put = put;
    this.remove = remove;
    this.size = size;
    this.isEmpty = isEmpty;
    this.removeAll = removeAll;
    this.getAllValues = getAllValues;
    this.getAllKeys = getAllKeys;
};
//----------------------------end