xinyb
2024-09-19 18ffbca9acaccd5099a7a63652f52210f59a7e40
WebRoot/js/index/index.js
@@ -7,13 +7,18 @@
myFresh.formType=0;//关闭页卡排除的窗体类型。
myFresh.clickNode=false;//表示点击了树节点
var copyLink=new Array();//复制对应单据的链接=--- 2018-9-4 17:48:59 xin
var hostUrl="";//复制链接用到
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=[];
var layoutTitle="自定义控件";
//---end
myFresh.type=0;
$( function() {
@@ -35,8 +40,12 @@
                  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;
                        + node.id;
                  },
                  onClick : function(node) {
                     var obj = node.attributes;
@@ -156,6 +165,13 @@
               lastTabs.push(tt); // 重新压入,保证 最新的在最上面
               var sTab = $("#home-tabs").tabs("getTab", index);
               let layoutT = tt.split(">");//自定义控件页卡名 xin 2024-4-25 15:00:43
               if (layoutT.length > 1) {
                  layoutT = layoutT[1].split("-");
                  if (layoutT.length > 1) {
                     layoutTitle = layoutT[0] + layoutT[1];
                  }
               }
               if (!isLoadSelect) {// 在循环添加cookie里面的tab改变改值
                  /* 第一次点击加载 */
                  // var info=$.cookie("lastSelectedTab");
@@ -180,6 +196,15 @@
                        "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);
@@ -201,7 +226,14 @@
                     && myFresh.panel[index] != 18
                     && myFresh.panel[index] != 38
                     && myFresh.panel[index] != 3
                     && myFresh.panel[index] != 10) {
                     && myFresh.panel[index] != 10
                     && myFresh.formType!=1000
                     && myFresh.formType!=1001
                     && myFresh.formType!=1002
                     && myFresh.formType!=1003
                     && myFresh.formType!=1004
                     && myFresh.formType!=1005//by danaus 2024-06-01 11:17
               ) {
                  if (myFresh.panel[index + '-t']
                        || getGrid(myFresh.grids)) {
                     $.messager.confirm('确认',
@@ -215,6 +247,7 @@
                                 };
                                 $(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;
@@ -222,9 +255,11 @@
                           });
                     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
@@ -233,7 +268,7 @@
            },
            onAdd:function(title,index){//当一个新的标签页面板(tab panel)被添加时触发复制链接。
               var titleCopy=(title.indexOf("-")!=-1?title.split("-")[0].split("=")[1].replace(/\"/g, ""):title);
               copyLink[index]=hostUrl+"?"+copyUrl+"&formName="+encodeURI(titleCopy);//复制对应单据的链接地址-----赋值 2018-9-4 17:48:59 xin
               copyLink[index]=hostUrlCopy+"?"+encodeText(copyUrl+"&formname="+titleCopy);//复制对应单据的链接地址-----赋值 2018-9-4 17:48:59 xin
               copyUrl="";
            },
@@ -249,7 +284,10 @@
               // }
            },
            onClose:function(title,index){//当用户关闭一个标签页面板(tab panel)时触发。
               //console.log("tabs->onClose:"+title);
            },
            onUpdate:function(title,index){
               //console.log("tabs->onUpdate:"+title);
            }
         });
   try{
@@ -274,12 +312,13 @@
   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') // 解决布局等问题开关
         }
      helpIcon: $('.help-icon-container'), // 帮助按钮
      helpContent: $('.ai-container'), // 帮助内容层
      helpCloseIcon: $('i.close-dialog'), //帮助内容层关闭按钮
      msgsList: $('.ai-content .msgs-ul'), //帮助内容层关闭按钮
      repairLayout: $('#repairLayout'), // 解决布局等问题开关
      reloadLayout: $('#reloadLayout') //
   }
         initHelpPosition();
         var isDrag = false;
         // 图标的显隐
@@ -340,8 +379,14 @@
            var loading=$(Tab).find("div");
            var iframe=$(Tab).find('iframe');            
            var formid=iframe.attr("src");            
            if(formid.indexOf('app')!=-1){
               formid=formid.split('/')[5];
            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,"");
@@ -378,52 +423,192 @@
                 success: function(data) {
               var icon="error";
               var hider=false;
               if(data!=null&&data.indexOf("成功")>0){
               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
                  text: data, // Text that is to be shown in the toast
                  //text:'生成成功,即将打开页面!',
                  // heading: '提示', // Optional heading to be shown on the toast
                         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){
  Dom.helpIcon.css({
    left: parseInt(positionX),
    top: parseInt(positionY)
  });
                  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;
            }
            //删除表格cookie,by danaus 2024-04-18 15:00
            //cookie path:/app/3688/0/cnzh/120255/18
            let path=($(iframe[0]).attr("url")+"").replace("/index.jsp","");
            deleteCookie(path);
            $.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 deleteCookie(path){
   //--处理单据5,8,496,499类型,需要同时清除列表和明细
   let array=path.split('/');
   let formType=array[array.length-1];
   if(formType==5||formType==9||formType==15||formType==8||formType==496||formType==497||formType==498||formType==499){
      $.cookie("Grids",null,{path:path});//只删除对应path的cookie
      let newFormType=0;
      switch (parseInt(formType)){
         case 5:
            newFormType=9
            break;
         case 9:
            newFormType=5
            break;
         case 15:
            newFormType=8
            break;
         case 8:
            newFormType=15
            break;
         case 496:
            newFormType=497
            break;
         case 497:
            newFormType=496
            break;
         case 498:
            newFormType=499
            break;
         case 499:
            newFormType=498
            break;
      }
      $.cookie("Grids",null,{path:path.replace("/"+formType,"/"+newFormType)});
   }else {
      //非单据
      $.cookie("Grids",null,{path:path});//只删除对应path的cookie
   }
}
   // 初始化帮助图标的位置
   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' +
@@ -446,7 +631,9 @@
var T_Grid = "";
var lastTabs = new Array(); // 当用户关闭tab时,自动切换到前一个tab不至于让用户看到空的界面。
function addTab(title, formId, formType, para, url, id, obj) {
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;
@@ -467,7 +654,7 @@
             }else{
                  para+=(d.query_string==""?d.query_string:" and ( "+d.query_string+" )");
             }            
           addTab$(d.menuname, formId, formType, para, true, url, "",encode, obj);
           addTab$(d.menuname, formId, formType, para, true, url, "",encode, obj,gridObj,panelObj);
         } else {
            alert("在系统菜单里没有该功能号的设置!");
         }
@@ -476,7 +663,7 @@
      if (typeof (obj) == 'undefined' || typeof (obj.encode) == "undefined") {
         encode = false;
      }
      addTab$(title, '', formType, '', false, url, id, encode, obj);
      addTab$(title, '', formType, '', false, url, id, encode, obj,gridObj,panelObj);
   }
}
/** **tabs右键菜单start*** */
@@ -595,8 +782,7 @@
}
var title4operaOld = null;// 解决opera 3点返回值后不选择选项卡
var title4operaNew = null;
function addTab$(title, formId, formType, para, isFunc, url, id, isEncode,
      paraObj) {
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("系统提示", '您当前打开了太多的页面,如果继续打开,会造成程序运行缓慢,无法流畅操作!',
@@ -647,7 +833,7 @@
      title += "<span class='hidden'>" + Math.round(Math.random() * 100000)
            + "</span>";
   }
   if (typeof (paraObj) != undf) {
   if (typeof (paraObj) != undf&&paraObj!=null) {
      if (typeof (paraObj.isFlowChart) != undf) {// 如果是isFlowChart类型的每次选择都刷新
         var tab = $("#home-tabs").tabs("getTab", title);
         if (tab != null) {
@@ -671,13 +857,32 @@
   }
   /* end */
   //var tid=Math.round(Math.random()*10000)
   let panel_onlyOne="";
   //设置新页卡的高度为指定高度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;
      panel_onlyOne=panelObj.panel_onlyOne || "";
   }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+ "" +
@@ -692,6 +897,10 @@
   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);
   }
}
@@ -797,10 +1006,10 @@
}
var topFrame = {// 兼容旧系统parent.topFrame.funcLink
   funcLink : function(f, t, sf, lf, lk, sd, ld, isp, ef, mes, ref, clo,
         autoSave,sortid,messageTip) {
         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);
            mes, ref, clo, autoSave,sortid,messageTip,rowid);
   }
};
//---------------解决页卡切换后 滚动条被置顶的问题 xin 2020-10-14 09:16:55