|
|
/*! * PageUtil.js * Copyright (c) 2018 CreativeDream * Website: xxx * Version: 1.0.0 (03-05-2018) * Requires: jQuery v1.7.1 or later */ var i18next="undefined"==typeof i18next?parent.top.i18next:i18next,IsWaiting=null,bLeavePage=!1,g_db={SupportLocalStorage:function(){"use strict";return typeof localStorage!="undefined"},SetItem:function(n,t){"use strict";var i=!1;return this.SupportLocalStorage()&&(localStorage.setItem(n,t),i=!0),i},GetItem:function(n){"use strict";var t=null;return this.SupportLocalStorage()&&(t=localStorage.getItem(n)),t},RemoveItem:function(n){"use strict";var t=!1;return this.SupportLocalStorage()&&(localStorage.removeItem(n),t=!0),t},GetDic:function(n){"use strict";var i=null,t;return this.SupportLocalStorage()&&(t=localStorage.getItem(n),null!==t&&(i=JSON.parse(t))),i},SetDic:function(n,t){"use strict";var i=!1;return this.SupportLocalStorage()&&(localStorage.setItem(n,JSON.stringify(t)),i=!0),i}},g_gd={webapilonginurl:"/api/Service/GetLogin",webapiurl:"/api/Cmd/GetData",projectname:"Eurotran",projectver:"Origtek",relpath:"",debugmode:window.location.host==="192.168.1.105",debugcolor:"#732C6B",IsEDU:g_db.GetItem("isedu")==="true"},g_ul={GetToken:function(){"use strict";return g_db.GetItem("token")},SetToken:function(n){"use strict";g_db.SetItem("token",n)},GetSignature:function(){"use strict";return g_db.GetItem("signature")},SetSignature:function(n){"use strict";g_db.SetItem("signature",n)},SetLang:function(n){"use strict";g_db.SetItem("lang",n)},GetLang:function(){"use strict";return g_db.GetItem("lang")},SetLoginMethod:function(n){"use strict";g_db.SetItem("LoginMethod",n)},GetLoginMethod:function(){"use strict";return g_db.GetItem("LoginMethod")},IsEDU:function(){"use strict";return g_db.GetItem("isedu")},RndNum:function(n){var i="",t;for(n=n||10,t=0;t<n;t++)i+=Math.floor(Math.random()*10);return i}},g_api={ConnectLite:function(n,t,i,r,u,f,e){return window.IsWaiting=e,this.ConnectLiteWithoutToken(n,t,i,r,u,f)},ConnectLiteWithoutToken:function(n,t,i,r,u,f){var o={},e={},s=g_ul.GetToken(),h=g_ul.GetLang(),c=g_ul.GetSignature();return e.ORIGID=g_db.GetItem("orgid"),e.USERID=g_db.GetItem("userid"),e.MODULE=n,e.TYPE=t,e.PROJECT=g_gd.projectname,e.PROJECTVER=g_gd.projectver,e.TRACEDUMP=null,i=i||{},g_db.GetItem("dblockDict")!==null&&(i.dblockDict=g_db.GetItem("dblockDict")),e.DATA=i,h!==null&&(e.LANG=h),s!==null&&(e.TOKEN=s),c!==null&&(e.SIGNATURE=c),e.CUSTOMDATA={},window.sProgramId&&(e.CUSTOMDATA.program_id=sProgramId),e.CUSTOMDATA.module_id="webapp",o.url=i.hasOwnProperty("url")?i.url:g_gd.webapiurl,o.successfunc=r,o.dicparameters=e,o.failfunc="function"==typeof u?u:function(n,t,i){alert("ConnectLite Fail jqXHR:"+n+" textStatus:"+t+" errorThrown:"+i)},o.useasync="boolean"==typeof f?f:!0,this.AjaxPost(o)},AjaxPost:function(n){"use strict";var t=$.extend({useasync:!0,successfunc:null,failfunc:null,alwaysfunc:null,url:null,dicparameters:null},n),i=function(n){n.RESULT===-1?layer.alert(i18next.t("message.TokenVerifyFailed"),{icon:0,title:i18next.t("common.Tips")},function(){window.top.location.href="/Page/login.html"}):t.successfunc&&t.successfunc(n)};return $.ajax({type:"POST",url:t.url,data:"="+btoa2(encodeURIComponent(JSON.stringify(t.dicparameters))),success:i,error:t.failfunc,beforeSend:function(n){var i=g_ul.GetToken(),r=$.now(),u=g_ul.RndNum();n.setRequestHeader("orgid",t.dicparameters.ORIGID);n.setRequestHeader("userid",t.dicparameters.USERID);n.setRequestHeader("token",i);n.setRequestHeader("timestamp",r);n.setRequestHeader("nonce",u)},async:!0!==t.useasync?!1:!0}).always(t.alwaysfunc)}},CanDo=function(n,t){"use strict";function r(){i.fn._showWaiting(typeof IsWaiting=="string"?IsWaiting:undefined)}function u(){i.fn._closeWaiting();setTimeout(function(){IsWaiting=null},3e3)}var i=function(n){return new i.fn._init(n)};return i.fn=i.prototype={constructor:i,_init:function(t){var i=this,o={cusBtns:[],goTop:!0,searchBar:!0,goBack:!0,insertGo:!0,updateGo:!0,deleteGo:!0,pageSize:parent.top.SysSet.GridRecords||0,gridPages:parent.top.SysSet.GridPages||15,queryPageidx:1,toFirstPage:!1},s,h,f,e,u,r,c,l;$.extend(o,t);for(s in i._pageParam)h=o[s],h&&(i._pageParam[s]=h);if(i.options=o,i.ids={},i.params={},i.UE_Editor={},i.currentPageValu
|