session.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /**本地缓存 */
  2. var SessionOperation = {
  3. type:'session',
  4. setType:function(){
  5. if(this.type == 'session'){
  6. return window.sessionStorage;
  7. }
  8. if(this.type == 'local'){
  9. return window.localStorage;
  10. }
  11. console.log('类型错误!');
  12. },
  13. set:function($key,$value){
  14. this.setType().setItem($key,$value);
  15. },
  16. get:function($key){
  17. return this.setType().getItem($key)
  18. },
  19. clearAll:function(){
  20. if(this.type == 'session'){
  21. window.sessionStorage.clear();
  22. }
  23. if(this.type == 'local'){
  24. window.localStorage.clear();
  25. }
  26. console.log('类型错误!');
  27. },
  28. setToken:function(token){
  29. this.set("TOKEN", token);
  30. },
  31. getToken:function(){
  32. return this.get("TOKEN");
  33. },
  34. setUserId:function(userId){
  35. this.set("userId", userId);
  36. },
  37. getUserId:function(){
  38. return this.get("userId");
  39. },
  40. setPersonnelId:function(personnelId){
  41. this.set("personnelId", personnelId);
  42. },
  43. getPersonnelId:function(){
  44. return this.get("personnelId");
  45. },
  46. setUserDeps:function(userDeps){
  47. this.set("UserDeps", userDeps);
  48. },
  49. getUserDeps:function(){
  50. return this.get("UserDeps");
  51. },
  52. setRealName:function(realname){
  53. this.set("RealName", realname);
  54. },
  55. getRealName:function(){
  56. return this.get("RealName");
  57. },
  58. setUserName:function(username){
  59. this.set("UserName", username);
  60. },
  61. getUserName:function(){
  62. return this.get("UserName");
  63. },
  64. setOrgnizeId(id){
  65. this.set("OrgnizeId", id);
  66. },
  67. getOrgnizeId(){
  68. return this.get("OrgnizeId");
  69. },
  70. setOrgnizeName(name){
  71. this.set("OrgnizeName", name);
  72. },
  73. getOrgnizeName(){
  74. return this.get("OrgnizeName");
  75. }
  76. };
  77. function getQueryVariable(variable){
  78. var query = window.location.search.substring(1);
  79. var vars = query.split("&");
  80. for (var i=0;i<vars.length;i++) {
  81. var pair = vars[i].split("=");
  82. if(pair[0] == variable){
  83. return pair[1];
  84. }
  85. }
  86. return(false);
  87. }
  88. //map型看板滚动
  89. //-------------------开始-----------------------
  90. function beginFun(chartsID,dataMap,autoTime,timeName,grid){
  91. return function(){autoInitDate(chartsID,dataMap,autoTime,timeName,grid)}
  92. }
  93. function autoInitDate(chartsID,dataMap,autoTime,timeName,grid){
  94. let DataList = [];
  95. for(let key in dataMap) {
  96. DataList.push([key, dataMap[key]]);
  97. }
  98. if(DataList.length < 1){
  99. return;
  100. }
  101. let lsit = DataList.slice(pageIndex, pageSize);
  102. pageIndex = pageSize;
  103. pageSize = pageSize + initSize;
  104. let map = {}
  105. for(let key in lsit) {
  106. map[lsit[key][0]] = lsit[key][1];
  107. }
  108. ChartsService.initCommonBar(chartsID,map,grid);
  109. if(DataList.length <= initSize){
  110. return;
  111. }
  112. timeName = setInterval(beginFun2(chartsID,DataList,timeName,grid),autoTime);
  113. }
  114. function beginFun3(chartsID,dataMap,autoTime,timeName,grid){
  115. return function(){autoInitDate2(chartsID,dataMap,autoTime,timeName,grid)}
  116. }
  117. function autoInitDate2(chartsID,dataMap,autoTime,timeName,grid){
  118. let DataList = [];
  119. for(let key in dataMap) {
  120. DataList.push([key, dataMap[key]]);
  121. }
  122. if(DataList.length < 1){
  123. return;
  124. }
  125. let lsit = DataList.slice(pageIndex, pageSize);
  126. pageIndex = pageSize;
  127. pageSize = pageSize + initSize;
  128. let map = {}
  129. for(let key in lsit) {
  130. map[lsit[key][0]] = lsit[key][1];
  131. }
  132. ChartsService.initCommonBar2(chartsID,map,grid);
  133. if(DataList.length <= initSize){
  134. return;
  135. }
  136. timeName = setInterval(beginFun2(chartsID,DataList,timeName,grid),autoTime);
  137. }
  138. function beginFun2(chartsID,DataList,timeName,grid){
  139. return function(){autoLoadDate(chartsID,DataList,timeName,grid)}
  140. }
  141. function autoLoadDate(chartsID,DataList,timeName,grid){
  142. if(DataList.length <= initSize){
  143. clearInterval(timeName);
  144. }
  145. if(pageIndex >= DataList.length){
  146. pageSize = initSize;
  147. pageIndex = 0;
  148. }
  149. let lsit = DataList.slice(pageIndex, pageSize);
  150. // console.log(pageIndex+"---1---"+pageSize);
  151. pageIndex = pageSize;
  152. pageSize = pageSize + initSize;
  153. let map = {}
  154. for(let key in lsit) {
  155. map[lsit[key][0]] = lsit[key][1];
  156. }
  157. ChartsService.initCommonBar(chartsID,map,grid);
  158. }
  159. function beginFunA(chartsID,dataMap,autoTime,timeName,grid){
  160. return function(){autoInitDateA(chartsID,dataMap,autoTime,timeName,grid)}
  161. }
  162. function autoInitDateA(chartsID,dataMap,autoTime,timeName,grid){
  163. let DataListA = [];
  164. for(let key in dataMap) {
  165. DataListA.push([key, dataMap[key]]);
  166. }
  167. if(DataListA.length < 1){
  168. return;
  169. }
  170. let lsitA = DataListA.slice(pageIndexA, pageSizeA);
  171. pageIndexA = pageSizeA;
  172. pageSizeA = pageSizeA + initSize;
  173. let map = {}
  174. for(let key in lsitA) {
  175. map[lsitA[key][0]] = lsitA[key][1];
  176. }
  177. ChartsService.initCommonBar(chartsID,map,grid);
  178. if(DataListA.length <= initSize){
  179. return;
  180. }
  181. timeName = setInterval(beginFun2A(chartsID,DataListA,timeName,grid),autoTime);
  182. }
  183. function beginFun2A(chartsID,DataListA,timeName,grid){
  184. return function(){autoLoadDateA(chartsID,DataListA,timeName,grid)}
  185. }
  186. function autoLoadDateA(chartsID,DataListA,timeName,grid){
  187. if(DataListA.length <= initSize){
  188. clearInterval(timeName);
  189. }
  190. if(pageIndexA >= DataListA.length){
  191. pageSizeA = initSize;
  192. pageIndexA = 0;
  193. }
  194. let lsitA = DataListA.slice(pageIndexA, pageSizeA);
  195. // console.log(pageIndexA+"---2---"+pageSizeA);
  196. pageIndexA = pageSizeA;
  197. pageSizeA = pageSizeA + initSize;
  198. let map = {}
  199. for(let key in lsitA) {
  200. map[lsitA[key][0]] = lsitA[key][1];
  201. }
  202. ChartsService.initCommonBar(chartsID,map,grid);
  203. }
  204. //map型看板滚动
  205. //-------------------结束-----------------------