app.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. 'use strict';
  2. /**
  3. * @ngdoc overview
  4. * @name app [smartadminApp]
  5. * @description
  6. * # app [smartadminApp]
  7. *
  8. * Main module of the application.
  9. */
  10. angular.module('app', [
  11. 'ngSanitize',
  12. 'ngAnimate',
  13. 'restangular',
  14. 'ui.router',
  15. 'ui.bootstrap',
  16. // Smartadmin Angular Common Module
  17. 'SmartAdmin',
  18. // App
  19. 'app.agile',
  20. 'app.auth',
  21. 'app.layout',
  22. 'app.chat',
  23. 'app.dashboard',
  24. 'app.calendar',
  25. 'app.inbox',
  26. 'app.graphs',
  27. 'app.tables',
  28. 'app.forms',
  29. 'app.ui',
  30. 'app.widgets',
  31. 'app.maps',
  32. 'app.appViews',
  33. 'app.misc',
  34. 'app.smartAdmin',
  35. 'app.eCommerce',
  36. 'angularFileUpload',
  37. 'app.system',
  38. 'app.business',
  39. 'app.basic',
  40. 'app.camera',
  41. 'app.nvr',
  42. 'app.act',
  43. 'app.task',
  44. 'app.process',
  45. // 'app.qualitycheck',
  46. 'app.alert',
  47. 'app.supervise',
  48. 'app.cameraRecord',
  49. 'app.alarm',
  50. // 'app.safeproduce',
  51. //'app.foodbasicinfo',
  52. 'app.qualityDlag',
  53. 'app.cameraGroup',
  54. //'app.storehouse',
  55. // 'app.keeper',
  56. 'app.cameraSetting',
  57. // 'app.payment',
  58. 'app.storage',
  59. 'app.numbermanage',
  60. 'app.synth',
  61. 'multi-select-tree',
  62. 'app.dynamicForm',
  63. 'app.intelligent',
  64. 'app.log',
  65. 'app.additionalHome'
  66. ])
  67. .config(function ($provide, $httpProvider, RestangularProvider) {
  68. // Intercept http calls.
  69. $provide.factory('ErrorHttpInterceptor', function ($q) {
  70. var errorCounter = 0;
  71. function notifyError(rejection) {
  72. if (rejection.status == 601) {
  73. $.bigBox({
  74. title: rejection.status + ' ' + rejection.statusText,
  75. content: "登录超时,请重新登录!",
  76. color: "#C46A69",
  77. icon: "fa fa-warning shake animated",
  78. timeout: 6000
  79. });
  80. } else {
  81. $.bigBox({
  82. title: rejection.status + ' ' + rejection.statusText,
  83. content: rejection.data,
  84. color: "#C46A69",
  85. icon: "fa fa-warning shake animated",
  86. number: ++errorCounter,
  87. timeout: 6000
  88. });
  89. }
  90. }
  91. return {
  92. // On request failure
  93. requestError: function (rejection) {
  94. // show notification
  95. notifyError(rejection);
  96. // Return the promise rejection.
  97. return $q.reject(rejection);
  98. },
  99. // On response failure
  100. responseError: function (rejection) {
  101. // show notification
  102. if (rejection.status != 601) {
  103. // 如果是登录超时,就不报错.
  104. notifyError(rejection);
  105. }
  106. // Return the promise rejection.
  107. return $q.reject(rejection);
  108. }
  109. };
  110. });
  111. // Add the interceptor to the $httpProvider.
  112. $httpProvider.interceptors.push('ErrorHttpInterceptor');
  113. // 增加http拦截器.
  114. $httpProvider.interceptors.push('httpInterceptor');
  115. RestangularProvider.setBaseUrl(location.pathname.replace(/[^\/]+?$/, ''));
  116. // Use x-www-form-urlencoded Content-Type
  117. $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
  118. // Override $http service's default transformRequest
  119. $httpProvider.defaults.transformRequest = [function(data) {
  120. return angular.isObject(data) && String(data) !== '[object File]' ? $.param(data) : data;
  121. }];
  122. //$httpProvider.defaults.withCredentials = true;跨越session失效
  123. // 默认表单验证参数
  124. $.validator.setDefaults({
  125. errorElement: 'em',
  126. errorClass: 'invalid',
  127. highlight: function(element, errorClass, validClass) {
  128. $(element).addClass(errorClass).removeClass(validClass);
  129. $(element).parent().addClass('state-error').removeClass('state-success');
  130. },
  131. unhighlight: function(element, errorClass, validClass) {
  132. $(element).removeClass(errorClass).addClass(validClass);
  133. $(element).parent().removeClass('state-error').addClass('state-success');
  134. },
  135. errorPlacement : function(error, element) {
  136. error.insertAfter(element.parent());
  137. }
  138. })
  139. // 默认日期控件参数
  140. $.extend($.datepicker.regional, {
  141. 'zh-CN' : {
  142. closeText: '关闭',
  143. prevText: '<',
  144. nextText: '>',
  145. currentText: '今天',
  146. monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
  147. monthNamesShort: ['一','二','三','四','五','六','七','八','九','十','十一','十二'],
  148. dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
  149. dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
  150. dayNamesMin: ['日','一','二','三','四','五','六'],
  151. weekHeader: '周',
  152. dateFormat: 'yy-mm-dd',
  153. firstDay: 0,
  154. isRTL: false,
  155. showMonthAfterYear: true,
  156. yearSuffix: '年'
  157. }
  158. });
  159. $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
  160. $.DateTimePicker.i18n["zh-CN"] = $.extend($.DateTimePicker.i18n["zh-CN"], {
  161. language: "zh-CN",
  162. labels: {
  163. 'year': '年',
  164. 'month': '月',
  165. 'day': '日',
  166. 'hour': '时',
  167. 'minutes': '分',
  168. 'seconds': '秒',
  169. 'meridiem': '午'
  170. },
  171. dateTimeFormat: "yyyy-MM-dd HH:mm",
  172. dateFormat: "yyyy-MM-dd",
  173. timeFormat: "HH:mm",
  174. shortDayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
  175. fullDayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
  176. shortMonthNames: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
  177. fullMonthNames: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
  178. titleContentDate: "设置日期",
  179. titleContentTime: "设置时间",
  180. titleContentDateTime: "设置日期和时间",
  181. setButtonContent: "设置",
  182. clearButtonContent: "清除",
  183. formatHumanDate: function (oDate, sMode, sFormat) {
  184. if (sMode === "date")
  185. return oDate.dayShort + ", " + oDate.yyyy + "年" + oDate.month +"月" + oDate.dd + "日";
  186. else if (sMode === "time")
  187. return oDate.HH + "时" + oDate.mm + "分" + oDate.ss + "秒";
  188. else if (sMode === "datetime")
  189. return oDate.dayShort + ", " + oDate.yyyy + "年" + oDate.month +"月" + oDate.dd + "日 " + oDate.HH + "时" + oDate.mm + "分";
  190. }
  191. });
  192. $.DateTimePicker.defaults.language = 'zh-CN', //指定中文
  193. String.prototype.replaceAll = function(s1,s2){
  194. return this.replace(new RegExp(s1,"gm"),s2);
  195. }
  196. })
  197. .constant('APP_CONFIG', window.appConfig)
  198. .run(function ($rootScope, $state, $stateParams,
  199. permissions, enumService, userService) {
  200. $rootScope.$state = $state;
  201. $rootScope.$stateParams = $stateParams;
  202. $rootScope.baseUrl = window.appConfig.baseUrl;
  203. // editableOptions.theme = 'bs3';
  204. // 前置监听器.
  205. $rootScope.$on('$stateChangeStart',
  206. function(event, toState, toParams, fromState, fromParams) {
  207. //处理路由跳转时,海康视频插件没有自动关闭
  208. if ($rootScope.webCtrl != null){
  209. $rootScope.webCtrl.JS_HideWnd(); // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  210. $rootScope.webCtrl.JS_Disconnect().then(function(){ // 断开与插件服务连接成功
  211. },
  212. function() { // 断开与插件服务连接失败
  213. });
  214. }
  215. // 如果路由地址是userLogin,判断是否已经登录,已经登录了就跳到首页.
  216. if (toState.name == "userLogin") {
  217. // 通过java后台方法来判断是否超时,因为通过刷新页面跳转到登录页的,$rootScope中不一定会有userInfo信息.
  218. userService.getLoginInfo().then(function(data) {
  219. if (data.userInfo != null) {
  220. $rootScope.userInfo = data.userInfo;
  221. $rootScope.orgInfo = data.orgInfo;
  222. $rootScope.depotInfo = data.depotInfo;
  223. $rootScope.depotId = data.depotId;
  224. }
  225. if ($rootScope.userInfo != null) {
  226. userRoleType = $rootScope.userInfo.status;
  227. if(userRoleType == "2"){//经营人员
  228. $state.go("app.additionalHome.businessHome");
  229. }else if(userRoleType == "3"){//仓储人员
  230. $state.go("app.additionalHome.storageHome");
  231. }else if(userRoleType == "4"){//质检人员
  232. $state.go("app.additionalHome.qualityCheckHome");
  233. }else if(userRoleType == "5"){//保卫人员
  234. $state.go("app.additionalHome.defendHome");
  235. }else if(userRoleType == "6"){//中转人员
  236. $state.go("app.additionalHome.transferHome");
  237. }else{
  238. $state.go("app.dashboard");
  239. }
  240. event.preventDefault();
  241. }
  242. });
  243. }else if (toState.name != "emergencyLogin" && window.location.hash.indexOf('#/province') == -1){//其它路由时(排除应急端登录和省级跳转路由)判断用户信息是否失效了,失效了就跳转登录界面
  244. // 通过浏览器刷新时,由于后台查询的速度限制,导致$rootScope.userInfo不一定有信息,所以通过前端获取session里的信息
  245. if ($rootScope.userInfo == null) {
  246. $rootScope.userInfo = "<%=session.getAttribute('userInfo')%>";
  247. $rootScope.orgInfo = "<%=session.getAttribute('orgInfo')%>";
  248. $rootScope.depotInfo = "<%=session.getAttribute('depotInfo')%>";
  249. $rootScope.depotId = "<%=session.getAttribute('depotId')%>";
  250. }
  251. // 通过java后台方法来判断是否超时,因为通过刷新页面跳转到登录页的,$rootScope中不一定会有userInfo信息.
  252. userService.getLoginInfo().then(function(data) {
  253. if (data.userInfo != null) {
  254. $rootScope.userInfo = data.userInfo;
  255. $rootScope.orgInfo = data.orgInfo;
  256. $rootScope.depotInfo = data.depotInfo;
  257. $rootScope.depotId = data.depotId;
  258. }else{
  259. $rootScope.userInfo = null;
  260. $rootScope.orgInfo = null;
  261. $rootScope.depotInfo = null;
  262. $rootScope.depotId = null;
  263. $state.go("userLogin");
  264. }
  265. });
  266. }
  267. })
  268. $rootScope.$on("$stateChangeSuccess", function(event, toState, toParams, fromState, fromParams) {
  269. // to be used for back button //won't work when page is reloaded.
  270. $rootScope.previousState_name = fromState.name;
  271. $rootScope.previousState_params = fromParams;
  272. if ($state.current.url!='/dashboard' && $state.current.url.indexOf("/additionalHome") == -1) {
  273. $rootScope.isIndexPage = false;
  274. }
  275. });
  276. //back button function called from back button's ng-click="back()"
  277. $rootScope.back = function() {//实现返回的函数
  278. $state.go($rootScope.previousState_name,$rootScope.previousState_params);
  279. };
  280. // 字典数据
  281. $rootScope.dicDataList = enumData.parentMap;
  282. $rootScope.dicData = enumData.enumMap;
  283. // 用户id 用户姓名 对应数据map.
  284. $rootScope.userInfoData = userInfoMapData;
  285. // 取权限数据
  286. permissions.setPermissions(permissionList);
  287. /*if (window.location.hash == '') {
  288. // 为空的情况下,也不用调用getLoginInfo方法.
  289. } else */if (window.location.hash != null && ((window.location.hash == '#/userLogin') || (window.location.hash.indexOf('#/province') != -1))) {
  290. // 如果是#/userLogin,就不调用getLoginInfo方法.
  291. } else if (window.location.hash != null && (window.location.port === '9028')){
  292. if((window.location.hash === '#/emergencyLogin') || (window.location.hash == "")){
  293. location.hash = '#/emergencyLogin';
  294. }
  295. } else {
  296. permissions.getLoginInfo();
  297. }
  298. //把当前连接添加到信任站点
  299. var hostname = window.location.hostname;
  300. try {
  301. var WshShell=null;
  302. WshShell = new ActiveXObject("WScript.Shell");
  303. var str = [];  
  304. for(var i = 1;i < 2000;i++){ //循环注册表
  305. try{
  306. str[i] = WshShell.RegRead("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range" + i + "\\:Range");
  307. }catch(e){
  308.   }
  309. }
  310. var count = false; 
  311. for(var i = 1;i < str.length;i++){  //循环与ip比较
  312.     if(str[i] == undefined){
  313.     continue;
  314.     }else{
  315.     if(str[i] == hostname){
  316.     count = true;
  317.     break;
  318. }
  319. }
  320. }
  321. if(!count){// 添加信任站点
  322. WshShell=new ActiveXObject("WScript.Shell");
  323. var num=108;
  324. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range"+num+"\\","");
  325. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range"+num+"\\http","2","REG_DWORD");
  326. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range"+num+"\\:Range",""+hostname+"");
  327. /*WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range"+(num+1)+"\\","");
  328. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range"+(num+1)+"\\https","2","REG_DWORD");
  329. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range"+(num+1)+"\\:Range",""+hostname+"");*/
  330. //修改IE ActiveX安全设置
  331. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\1001","0","REG_DWORD");
  332. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\1004","0","REG_DWORD");
  333. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\1200","0","REG_DWORD");
  334. WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\1201","0","REG_DWORD");
  335.         WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\1405","0","REG_DWORD");
  336.         WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\2201","0","REG_DWORD");
  337.         WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\1609","0","REG_DWORD");
  338.         WshShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\1A04","0","REG_DWORD");
  339.         WshShell.RegWrite("HKCU\\Software\\Microsoft\\Internet Explorer\\New Windows\\PopupMgr","no");
  340. if(confirm("浏览器初始化成功,请重新打开浏览器!")){
  341. window.close();
  342. }
  343. }
  344. } catch (e) {
  345. }
  346. })
  347. .factory('permissions', function ($rootScope, $state, powerService, roleService, userService, StorehouseService,WareHouseBasicInfoService,basicStationSetService,basicStationTypeService,warehouseService,agentTemperatureService,agentStorehouseService,TankService,agentTankService) {
  348. return {
  349. // 获取用户登录信息
  350. getLoginInfo: function() {
  351. userService.getLoginInfo().then(function(data) {
  352. // 如用户信息为空,跳转到登录页
  353. if (!data.userInfo) {
  354. //$state.go("userLogin");
  355. } else {
  356. // 当前登录用户
  357. $rootScope.userInfo = data.userInfo;
  358. // 当前用户所属组织
  359. $rootScope.orgInfo = data.orgInfo;
  360. // 当前用户所属粮库
  361. $rootScope.depotInfo = data.depotInfo;
  362. // 当前用户所属粮库编号
  363. $rootScope.depotId = data.depotId;
  364. //每次刷新都给变量赋值,防止因为刷新丢失
  365. userRoleType = $rootScope.userInfo.status;
  366. //获取角色列表和角色Map
  367. roleService.getRoleTree().then(function(data){
  368. $rootScope.rolelist = data.roleList;
  369. $rootScope.roleObj = data.roleNameObj;
  370. },function(data){
  371. console.log(data);
  372. });
  373. StorehouseService.getStorehouseList($rootScope.orgInfo.orgId, "0").then(function(data){
  374. //除去代储仓房的本库仓房 getAgentHouseId
  375. agentStorehouseService.getAgentHouseId().then(function(houseIdData){
  376. if(houseIdData!=null && houseIdData.length>0){
  377. for (var i = 0; i < houseIdData.length; i++) {
  378. for (var j = 0; j < data.houseList.length; j++) {
  379. if(houseIdData[i] == data.houseList[j].storehouseId){
  380. data.houseList.splice(j,1);
  381. break;
  382. }
  383. }
  384. }
  385. $rootScope.storeAgentlist = data.houseList;
  386. }else{
  387. $rootScope.storeAgentlist = data.houseList;
  388. }
  389. },function(houseIdData){
  390. console.log(houseIdData);
  391. });
  392. },function(data){
  393. console.log(data);
  394. });
  395. TankService.getPageInfoTrack($rootScope.orgInfo.orgId).then(function (YGData) {
  396. //除去代储油罐的本库油罐
  397. agentTankService.getAgentTankId().then(function(tankIdData){
  398. if(tankIdData!=null && tankIdData.length>0){
  399. for (var i = 0; i < tankIdData.length; i++) {
  400. for (var j = 0; j < YGData.tank_list.length; j++) {
  401. if(tankIdData[i] == YGData.tank_list[j].storehouseId){
  402. YGData.tank_list.splice(j,1);
  403. break;
  404. }
  405. }
  406. }
  407. $rootScope.agentYGList = YGData.tank_list;
  408. }else{
  409. $rootScope.agentYGList = YGData.tank_list;
  410. }
  411. },function(tankIdData){
  412. console.log(tankIdData);
  413. });
  414. },function(YGData){
  415. console.log(YGData);
  416. });
  417. // 获取仓房列表
  418. StorehouseService.getStorehouseList($rootScope.orgInfo.orgId, "0").then(function(data){
  419. $rootScope.storelist = data.houseList;
  420. $rootScope.storehouseObj = data.houseObj;
  421. $rootScope.storeHouseCodeObj = data.houseCodeObj;
  422. //接收仓房和油罐放在一个对象里面的集合list(里面的ID都是String类型的)
  423. $rootScope.house_and_tank_list = data.house_and_tank_list;
  424. // 仓房油罐列表合并
  425. TankService.getPageInfoTrack($rootScope.orgInfo.orgId).then(function (YGData) {
  426. $rootScope.storeYGList = [];
  427. // 油罐列表
  428. $rootScope.YGList = YGData.tank_list;
  429. for (var idx in data.houseList) {
  430. $rootScope.storeYGList.push(data.houseList[idx]);
  431. }
  432. for (var idx in YGData.tank_list) {
  433. $rootScope.storeYGList.push(YGData.tank_list[idx]);
  434. }
  435. var key;
  436. var val;
  437. //仓房和油罐数据按ID转换大对象
  438. $rootScope.storeYG_id_obj = data.houseObj;
  439. for (var index in YGData.tank_id_Obj) {
  440. key = index;
  441. val = YGData.tank_id_Obj[index];
  442. $rootScope.storeYG_id_obj[key] = val;
  443. }
  444. //仓房和油罐数据按code转换大对象
  445. $rootScope.storeYG_code_obj = data.houseCodeObj;
  446. for (var index in YGData.tank_code_Obj) {
  447. key = index;
  448. val = YGData.tank_code_Obj[index];
  449. $rootScope.storeYG_code_obj[key] = val;
  450. }
  451. });
  452. },function(data){
  453. console.log(data);
  454. });
  455. // 获取货位列表
  456. warehouseService.getStorehouse(data.depotId,null, "0").then(function(data){
  457. $rootScope.wareList = data.wareList;
  458. $rootScope.wares = data.wares;
  459. //获取货位ID为String类型的货位数据列表
  460. $rootScope.ware_list = data.ware_list;
  461. //除去代储货位的本库货位 getAgentWareId
  462. agentStorehouseService.getAgentWareId().then(function(wareIdData){
  463. if(wareIdData!=null && wareIdData.length>0){
  464. for (var i = 0; i < wareIdData.length; i++) {
  465. for (var j = 0; j < data.wareList.length; j++) {
  466. if(wareIdData[i] == data.wareList[j].warehouseId){
  467. data.wareList.splice(j,1);
  468. break;
  469. }
  470. }
  471. }
  472. $rootScope.wareAgentlist = data.wareList;
  473. }else{
  474. $rootScope.wareAgentlist = data.wareList;
  475. }
  476. },function(wareIdData){
  477. console.log(wareIdData);
  478. });
  479. },function(data){
  480. console.log(data);
  481. });
  482. // 所有的油罐列表
  483. TankService.getPageInfo(null,null,null,null).then(function (data) {
  484. // 所有的油罐列表
  485. $rootScope.allYGList = data.list;
  486. },function(data){
  487. console.log(data);
  488. });
  489. // 获取仓房基本信息
  490. WareHouseBasicInfoService.WareHouseBasicInfo(data.orgInfo.orgId, "0").then(function(data){
  491. $rootScope.storehouseCode = data.storehouseCode;
  492. },function(data){
  493. console.log(data);
  494. });
  495. // 获取油罐基本信息
  496. WareHouseBasicInfoService.YGBasicInfo(data.orgInfo.orgId).then(function(data){
  497. $rootScope.storehouseCodeYG = data.storehouseCodeYG;
  498. },function(data){
  499. console.log(data);
  500. });
  501. //获取站点数据信息
  502. basicStationSetService.getStations(data).then(function(data){
  503. $rootScope.stations = data.data;
  504. },function(data){
  505. console.log(data);
  506. });
  507. //获取设备类型数据
  508. basicStationTypeService.getBasicStationType(data).then(function(data){
  509. $rootScope.stationType = data.data;
  510. },function(data){
  511. console.log(data);
  512. });
  513. // 获取代储点仓房基础信息
  514. agentTemperatureService.getAgentStoreInfoMap().then(function(data){
  515. $rootScope.agentStoreCode = data.agentStoreCode;
  516. },function(data){
  517. console.log(data);
  518. });
  519. // 所有用户id与用户姓名map.
  520. $.get(appConfig.businessUrl+"/userInfo/findAllUserMapByOrgId", function(data) {
  521. $rootScope.userInfoAllData = data;
  522. });
  523. // 所有组织的id与组织的名称map.
  524. $.get(appConfig.businessUrl+"/orgInfo/findAllOrgMap", function(data) {
  525. $rootScope.orgInfoAllData = data;
  526. console.log(data+".......");
  527. });
  528. // 用户id与用户姓名map.
  529. $.get(appConfig.systemUrl+"/userInfo/findAllUserMapByOrgId", function(data) {
  530. userInfoMapData = data;
  531. $rootScope.userInfoData = userInfoMapData;
  532. sessionStorage.setItem("userInfoMapData", angular.toJson(data));
  533. });
  534. // 判断当前环境是外网还是库内网
  535. $.get(appConfig.systemUrl+"/userInfo/environmentalJudgement", function(data) {
  536. localOrCloud = data.localOrCloud;
  537. displayType = data.displayType;
  538. if(data.depotUrl != null && data.depotUrl != "" && $rootScope.orgInfo.orgClassId == "5318"){
  539. appConfig.intelligentUrl = data.depotUrl;
  540. }
  541. });
  542. }
  543. })
  544. },
  545. setPermissions: function(permissions) {
  546. permissionList = permissions;
  547. $rootScope.$broadcast('permissionsChanged')
  548. },
  549. hasPermission : function(btnId) {
  550. var flag = false;
  551. angular.forEach(permissionList, function(item) {
  552. if (item.btnId == parseInt(btnId)) {
  553. flag = true;
  554. }
  555. })
  556. return flag;
  557. },
  558. // 验证功能权限
  559. hasFunc : function(funcId) {
  560. var flag = false;
  561. angular.forEach(hasFuncList, function(item) {
  562. if (item.funcId == parseInt(funcId)) {
  563. flag = true;
  564. }
  565. })
  566. return flag;
  567. },
  568. // 智能仓房按钮权限
  569. hasBotton : function(typeId) {
  570. var flag = false;
  571. if (parseInt(localOrCloud) == parseInt(typeId)) {
  572. flag = true;
  573. }
  574. return flag;
  575. }
  576. };
  577. })
  578. .factory('httpInterceptor',function($q, $injector, $rootScope, APP_CONFIG) {
  579. var httpInterceptor = {
  580. 'request':function(config){
  581. /*var rootScope = $injector.get('$rootScope');
  582. if (rootScope.userInfo == undefined || rootScope.userInfo == null) {
  583. //alert("session过期!");
  584. console.log(config.url + "前台userInfo session过期");
  585. window.location.href = APP_CONFIG.baseUrl + "#/userLogin";
  586. }*/
  587. // 增加httpType属性,后台获取后可判断请求是否来自angular.
  588. config.headers['httpType'] = "angularJs";
  589. return config ||$q.when(config);
  590. },
  591. 'responseError' : function(response) {
  592. if (response.status == 401) {
  593. var rootScope = $injector.get('$rootScope');
  594. var state = $injector.get('$rootScope').$state.current.name;
  595. rootScope.stateBeforLogin = state;
  596. rootScope.$state.go("login");
  597. return $q.reject(response);
  598. } else if (response.status === 404) {
  599. return $q.reject(response);
  600. } else if (response.status == 601) {
  601. // 设置为true,下次再因为session超时只会提示一次:登录超时,跳转到登录页后,设置false.
  602. if ($rootScope.isSessionOverTime != true) {
  603. $rootScope.isSessionOverTime = true;
  604. $rootScope.userInfo = null;
  605. window.alert("登录超时,请重新登录!");
  606. /*if (confirm("session失效,是否返回登录页面")) { // 弹出框或者选择框.
  607. window.location.href = "#/userLogin";
  608. }*/
  609. }
  610. window.location.href = "#/userLogin";
  611. return $q.reject(response);
  612. }
  613. },
  614. 'response' : function(response) {
  615. return response;
  616. }
  617. }
  618. return httpInterceptor;
  619. });