main.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. // var app = angular.module('starter', ['ionic', 'restangular', 'oc.lazyLoad', 'ui-bootstrap']);
  2. var app = angular.module('starter', ['ionic', 'restangular', 'oc.lazyLoad', 'ui.bootstrap']);
  3. // jry微信请求人登录
  4. var serverIp = "http://itsm.whut.edu.cn";
  5. //var serverIp = "http://218.197.116.230:8880";
  6. var reportIp = "";
  7. var inspectIp = "";
  8. var callIp = "";
  9. app.config(function($httpProvider) {
  10. $httpProvider.interceptors.push('sessionInjector');
  11. });
  12. //拦截器
  13. //$httpProvider.interceptors 不能注入$http和引用了$http的服务,否则会报依赖注入错误。
  14. // app.factory('sessionInjector', ['$rootScope', '$q', ' $injector ', function($rootScope, $q, $injector) {
  15. app.factory('sessionInjector', ['$rootScope', '$q', function($rootScope, $q) {
  16. //factory 的两种写法
  17. //第一种写法
  18. var sessionInjector = {
  19. //成功拦截器,发送请求道后台之前执行
  20. 'request': function(request) {
  21. if (sessionStorage.sessionLogin) {
  22. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  23. if (sessionLogin.token && sessionLogin.token != '') {
  24. request.headers['access-token'] = sessionLogin.token;
  25. }
  26. }
  27. return request;
  28. },
  29. //成功拦截器,从后台过来的响应之后执行
  30. 'response': function(response) {
  31. if (response.data.state == 433) {
  32. // window.location.href = '#/tab/index'
  33. window.location.href = '#/err'
  34. }
  35. return response;
  36. },
  37. //失败拦截器,请求发送失败或者被拦截器拒绝
  38. 'requestError': function(requestError) {
  39. var data = requestError.data;
  40. return $q.reject(requestError);
  41. },
  42. //失败拦截器,后台调用失败
  43. 'responseError': function(responseError) {
  44. return $q.reject(responseError);
  45. }
  46. };
  47. return sessionInjector
  48. //第二种写法
  49. // return {
  50. // request: function(config) {
  51. // if (!SessionService.isAnonymus) {
  52. // config.headers['x-session-token'] = SessionService.token;
  53. // }
  54. // return config;
  55. // }
  56. // };
  57. }]);
  58. app.factory('loginService', ['$http', function($http) {
  59. return {
  60. handleLogin: function() {
  61. $http({
  62. method: 'post',
  63. // url: address.serverIp + address.serverIpPort + address.api + '/login',
  64. url: address.serverIp + address.serverIpPort + 'service' + '/login',
  65. headers: { 'Content-Type': 'application/json' },
  66. data: {
  67. 'username': '005298',
  68. 'password': '888888'
  69. }
  70. }).success(function(data, status, headers, config) {
  71. // 当相应准备就绪时调用
  72. console.log("loginService is success");
  73. // console.log(data.url);
  74. if (data.state == 201 && data.state == 200) {
  75. $rootScope.isToken = true;
  76. // $rootScope['access-token'] = headers('access-token');
  77. // $rootScope.user = data.data.user;
  78. var sessionLogin = {
  79. 'user': data.data.requester,
  80. 'token': headers('access-token')
  81. }
  82. //本地数据初始化
  83. sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
  84. $state.go('tab.requesterDashboard');
  85. } else {}
  86. }).error(function(data, status, headers, config) {
  87. // 当响应以错误状态返回时调用
  88. console.log("error");
  89. return
  90. });
  91. }
  92. };
  93. }]);
  94. app.config(['RestangularProvider', function(RestangularProvider) {
  95. RestangularProvider.setBaseUrl('');
  96. }]);
  97. // jry请求人登录
  98. app.factory('jry_CMDBRestangular3', function(Restangular) {
  99. return Restangular.withConfig(function(RestangularConfigurer) {
  100. RestangularConfigurer.setBaseUrl(serverIp + '/service');
  101. });
  102. });
  103. app.factory('jry_api_cmdb3', ['jry_CMDBRestangular3', function(CMDBRestangular) {
  104. var hcService = CMDBRestangular.all("auth");
  105. return {
  106. // 第一次微信验证登陆
  107. jry_getUrl: function(data) {
  108. return hcService.customPOST(data, 'reqwechatlogin', {})
  109. },
  110. // 第二次微信获取code
  111. jry_getCode: function(data) {
  112. return hcService.customPOST(data, 'singlelogin', {})
  113. },
  114. //登录测试
  115. jry_ceshi:function(data){
  116. return hcService.customPOST(data, 'reqlogin', {})
  117. }
  118. }
  119. }]);
  120. app.factory('textRestangular', function(Restangular) {
  121. return Restangular.withConfig(function(RestangularConfigurer) {
  122. RestangularConfigurer.setBaseUrl(inspectIp + ':8088/DeskServer/');
  123. });
  124. });
  125. app.factory('api_text', ['textRestangular', function(textRestangular) {
  126. var loginService = textRestangular.all("comm");
  127. var loginsins = textRestangular.all("tele/agent");
  128. return {
  129. start: function(phone) {
  130. var rdata = "dom=0&epwd=&aid=1000&apwd=e10adc3949ba59abbe56e057f20f883e&adn=" + phone;
  131. return loginService.customPOST(rdata, 'start', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  132. },
  133. exit: function(token) {
  134. var rdata = "dom=0&token=" + token;
  135. return loginService.customPOST(rdata, 'exit', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  136. },
  137. login: function(group, token) {
  138. var rdata = "dom=0&token=" + token + "&aid=1000&acd=" + group + "&skill=-1&mon=false&silent=false";
  139. return loginsins.customPOST(rdata, 'login', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  140. },
  141. logout: function(token) {
  142. var rdata = "dom=0&token=" + token + "&aid=1000";
  143. return loginsins.customPOST(rdata, 'logout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  144. },
  145. dialout: function(token, gid, teleno) {
  146. var rdata = "dom=0&token=" + token + "&teleno=" + teleno + "&gid=" + gid + "&uud=&async=true";
  147. return loginsins.customPOST(rdata, 'dialout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  148. },
  149. callout: function(token, teleno) {
  150. var rdata = "dom=0&token=" + token + "&teleno=" + teleno + "&uud=&async=true";
  151. return loginsins.customPOST(rdata, 'dialout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  152. },
  153. setbusy: function(token) {
  154. var rdata = "dom=0&token=" + token;
  155. return loginsins.customPOST(rdata, 'setbusy', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  156. },
  157. setidle: function(token) {
  158. var rdata = "dom=0&token=" + token;
  159. return loginsins.customPOST(rdata, 'setidle', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  160. },
  161. inittrans: function(telephone, token) {
  162. var rdata = "dom=0&token=" + token + "&teleno=" + telephone + "&uud=&async=true";
  163. return loginsins.customPOST(rdata, 'inittrans', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  164. },
  165. comptrans: function(telephone, token) {
  166. var rdata = "dom=0&token=" + token;
  167. return loginsins.customPOST(rdata, 'comptrans', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  168. },
  169. record: function(token) {
  170. var rdata = "dom=0&token=" + token + "&filename=/tmp/agent.wav&async=true&maxtime=10&termchar=&append=true";
  171. return loginsins.customPOST(rdata, 'record', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  172. },
  173. offhook: function(token) {
  174. var rdata = "dom=0&token=" + token;
  175. return loginsins.customPOST(rdata, 'offhook', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  176. },
  177. onhook: function(token) {
  178. var rdata = "dom=0&token=" + token;
  179. return loginsins.customPOST(rdata, 'onhook', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  180. },
  181. getcdrid: function(token) {
  182. var rdata = "dom=0&token=" + token;
  183. return loginsins.customPOST(rdata, 'getcdrid', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
  184. }
  185. }
  186. }])
  187. app.factory('UserRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
  188. return Restangular.withConfig(function(RestangularConfigurer) {
  189. // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/user/');
  190. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/user/');
  191. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/user/');
  192. });
  193. }]);
  194. app.factory('api_user', ['UserRestangular', function(UserRestangular) {
  195. var basePath = "user/";
  196. return {
  197. };
  198. }]);
  199. app.factory('api_login', ['UserRestangular', function(UserRestangular) {
  200. var loginService = UserRestangular.all("auth");
  201. return {
  202. login: function(username, password) {
  203. return loginService.customPOST({ 'username': username, 'password': password }, 'login', {});
  204. },
  205. // logout: function(sessionid,userid){
  206. // return loginService.customPOST(sessionid + '/' + userid);
  207. // },
  208. sso: function(nickname) {
  209. return loginService.customGET('sso/' + nickname);
  210. },
  211. resetpwd: function(userid) {
  212. return loginService.customGET('resetpwd/' + userid);
  213. },
  214. uppwd: function(data) {
  215. return loginService.customPOST(data, 'uppwd', {});
  216. }
  217. }
  218. }])
  219. app.factory('api_user_data', ['UserRestangular', function(UserRestangular) {
  220. var dataService = UserRestangular.all("data");
  221. return {
  222. validate: function(data) {
  223. return dataService.customPOST(data, 'validate/role', {});
  224. },
  225. importData: function() {
  226. return dataService.one('/importData');
  227. },
  228. fetchDataList: function(model, data) {
  229. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  230. },
  231. fetchData: function(model, data) {
  232. return dataService.customPOST(data, 'fetchData/' + model, {});
  233. },
  234. addData: function(model, data) {
  235. return dataService.customPOST(data, 'addData/' + model, {});
  236. },
  237. updData: function(model, data) {
  238. return dataService.customPOST(data, 'updData/' + model, {});
  239. },
  240. rmvData: function(model, data) {
  241. return dataService.customPOST(data, 'rmvData/' + model, {});
  242. },
  243. downDataModel: function(type, month) {
  244. return dataService.one('downDataModel/' + type + '/' + month);
  245. }
  246. };
  247. }]);
  248. // app.factory('DpmRestangular', function(Restangular) {
  249. // return Restangular.withConfig(function(RestangularConfigurer) {
  250. // RestangularConfigurer.setBaseUrl(serverIp+':9008/data/');
  251. // });
  252. // });
  253. // app.factory('api_bpm_dbca', ['DpmRestangular', function(DpmRestangular){
  254. // var bpm = DpmRestangular.all("bpm");
  255. // return {
  256. // impFileData: function(pdKey){
  257. // return bpm.customPOST( 'impFileData/' + pdKey);
  258. // },
  259. // };
  260. // }]);
  261. // app.factory('BpmRestangular', function(Restangular) {
  262. // return Restangular.withConfig(function(RestangularConfigurer) {
  263. // // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
  264. // // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/bpm');
  265. // RestangularConfigurer.setBaseUrl(serverIp + ':8080/service/api/bpm');
  266. // // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
  267. // // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
  268. // });
  269. // });
  270. app.factory('BpmRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
  271. return Restangular.withConfig(function(RestangularConfigurer) {
  272. // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
  273. // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/bpm');
  274. // RestangularConfigurer.setBaseUrl(serverIp + ':8080/service/api/bpm');
  275. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/bpm');
  276. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/bpm');
  277. // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
  278. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
  279. });
  280. }]);
  281. app.factory('CommonRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
  282. return Restangular.withConfig(function(RestangularConfigurer) {
  283. // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
  284. // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/bpm');
  285. // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
  286. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/common');
  287. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/common');
  288. });
  289. }]);
  290. app.factory('WeChatRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
  291. return Restangular.withConfig(function(RestangularConfigurer) {
  292. // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
  293. // RestangularConfigurer.setBaseUrl("http://192.168.3.49" + ':9680/api/bpm');
  294. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
  295. // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
  296. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/common');
  297. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/bpm');
  298. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/bpm');
  299. });
  300. }]);
  301. app.factory('WeChatApply', ['Restangular', 'ADDRESS', function(Restangular, address) {
  302. return Restangular.withConfig(function(RestangularConfigurer) {
  303. // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
  304. // RestangularConfigurer.setBaseUrl("http://192.168.3.49" + ':9680/api/bpm');
  305. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
  306. // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
  307. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/apply');
  308. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/apply');
  309. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/apply');
  310. });
  311. }]);
  312. app.factory('WeChatApply1', ['Restangular', 'ADDRESS', function(Restangular, address) {
  313. return Restangular.withConfig(function(RestangularConfigurer) {
  314. // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
  315. // RestangularConfigurer.setBaseUrl("http://192.168.3.49" + ':9680/api/bpm');
  316. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
  317. // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
  318. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/apply');
  319. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/apply');
  320. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/apply');
  321. });
  322. }]);
  323. app.factory('api_statistic', ['BpmRestangular', function(BpmRestangular) {
  324. var statistic = BpmRestangular.all("statistic");
  325. return {
  326. query: function(data, rptId) {
  327. return statistic.customPOST(data, 'unidimensional/' + rptId, {});
  328. },
  329. // exportData: function(reportView, uuid, reportfileName){
  330. // return reportService.one('query/rest/export/xls/?exportname='+reportfileName+'xls');
  331. // }
  332. unidimensionalExport: function(rptId) {
  333. return statistic.one('unidimensionalExport/' + rptId);
  334. }
  335. }
  336. }]);
  337. app.factory('api_bpm', ['BpmRestangular', function(BpmRestangular) {
  338. var process = BpmRestangular.all("process");
  339. return {
  340. deploy: function(data) {
  341. return process.customPOST(data, 're/model/deploy', {});
  342. },
  343. list: function() {
  344. return process.customGET('re/model/list');
  345. },
  346. modelsource: function(pdId) {
  347. return process.customGET('re/model/' + pdId + '/source');
  348. },
  349. savemodel: function(pdId, data) {
  350. return process.customPOST(data, 're/model/' + pdId + '/save', {});
  351. },
  352. removemodel: function(modelId) {
  353. return process.customGET('re/model/' + modelId + '/remove');
  354. }
  355. };
  356. }]);
  357. app.factory('api_bpm_domain', ['BpmRestangular', 'CommonRestangular', 'WeChatRestangular', 'WeChatApply','WeChatApply1', function(BpmRestangular, CommonRestangular, WeChatRestangular, WeChatApply,WeChatApply1) {
  358. var bpmService = BpmRestangular.all("bpm");
  359. var commonService = CommonRestangular.all("common");
  360. var weChatService = WeChatRestangular.all("bpm");
  361. var weChatApply = WeChatApply.all("bpm");
  362. var weChatApply1 = WeChatApply1.all("bpm");
  363. // var bpmService = BpmRestangular.all("common");
  364. return {
  365. fetchtask: function(pdKey, data) {
  366. return bpmService.customPOST(data, 'fetchTask/' + pdKey, {});
  367. },
  368. weChatFetchServiceTasks: function(pdKey, data) {
  369. return weChatApply.customPOST(data, 'fetchServiceTasks' + pdKey, {});
  370. },
  371. fetchData: function(model, dataId) {
  372. return weChatApply.customGET('fetchServiceTasks/' + model + '/' + dataId);
  373. },
  374. start: function(pdKey, data) {
  375. return bpmService.customPOST(data, 'start/' + pdKey, {});
  376. },
  377. weChatApplyStart: function(pdKey, data) {
  378. return weChatApply1.customPOST(data, 'addWxIncident', {});
  379. },
  380. setWxProcess: function(data) {
  381. return weChatApply.customPOST(data, 'setWxProcess', {});
  382. },
  383. flowTracing: function(processInstanceId, data) {
  384. return bpmService.customPOST(data, 'flowTracing/' + processInstanceId, {});
  385. },
  386. complete: function(taskId, userId, data) {
  387. return bpmService.customPOST(data, 'completeTask/' + taskId + '/' + userId, {});
  388. },
  389. completeUpgrade: function(data) {
  390. return bpmService.customPOST(data, 'upgradeIncident', {});
  391. },
  392. claimAndCompletedTask: function(taskId, data) {
  393. return bpmService.customPOST(data, 'claimAndCompletedTask/' + taskId, {});
  394. },
  395. save: function(taskId, data) {
  396. return bpmService.customPOST(data, 'saveTaskVar/' + taskId, {});
  397. },
  398. weChatApplySave: function(taskId, data) {
  399. return weChatApply.customPOST(data, 'addWxIncidentDegree/' + taskId, {});
  400. },
  401. claimtask: function(taskId, data) {
  402. return bpmService.customPOST(data, 'claimTask/' + taskId, {});
  403. },
  404. expectedTime: function(taskId) {
  405. return bpmService.customGET('expectedTime/' + taskId);
  406. },
  407. history: function(processId) {
  408. return bpmService.customGET('history/' + processId);
  409. },
  410. upgrade: function(processInstanceId, taskId, data) {
  411. return bpmService.customPOST(data, 'upgradeIncident/' + processInstanceId + '/' + taskId, {});
  412. },
  413. listAttachments: function(processId, data) {
  414. return bpmService.customPOST(data, 'getAttachmentList/' + processId, {});
  415. },
  416. // saveAttachments: function(processId, taskId, userId, data) {
  417. // return bpmService.one('saveAttachments/' + processId + '/' + taskId + '/' + userId);
  418. // },
  419. saveAttachments: function(processId, taskId, userId, data) {
  420. return weChatService.one('saveAttachments/' + processId + '/' + taskId + '/' + userId);
  421. },
  422. uploadAttachment: function(processId, taskId, userId, data) {
  423. return commonService.one('uploadAttachment/' + 'wechatRequesterIncident/' + processId);
  424. },
  425. download: function(attachmentId) {
  426. return bpmService.one('getAttachmentContent/' + attachmentId);
  427. },
  428. downloadWechat: function(token) {
  429. return commonService.one('downloadAttachment/' + token);
  430. },
  431. // download: function(attachmentId){
  432. // return bpmService.customGET('getAttachmentContent/' + attachmentId,{},{'responseType':'arraybuffer'});
  433. // },
  434. attachmentsPreviewUrl: function(attachmentId) {
  435. return bpmService.customGET('attachmentsPreviewUrl/' + attachmentId);
  436. },
  437. startformkey: function(pdKey) {
  438. return bpmService.customGET('startformkey/' + pdKey);
  439. },
  440. taskformkey: function(taskId) {
  441. return bpmService.customGET('taskformkey/' + taskId);
  442. },
  443. workernumber: function(type) {
  444. return bpmService.customGET('restful/' + type);
  445. }
  446. };
  447. }]);
  448. app.factory('api_bpm_data', ['BpmRestangular', function(BpmRestangular) {
  449. var dataService = BpmRestangular.all("data");
  450. var serviceCatalogue = BpmRestangular.all("ServiceCatalogue");
  451. var inspectionProcessActual = BpmRestangular.all("InspectionProcessActual");
  452. return {
  453. impFileData: function() {
  454. return dataService.one('/impFileData/bpm_scheduleorder');
  455. },
  456. importData: function() {
  457. return dataService.one('/impFileData');
  458. },
  459. fetchDataList: function(model, data) {
  460. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  461. },
  462. fetchData: function(model, dataId) {
  463. return dataService.customGET('fetchData/' + model + '/' + dataId);
  464. },
  465. fetchServiceTasks: function(model, data) {
  466. if (!model) {
  467. model = "ALL"
  468. }
  469. return serviceCatalogue.customPOST(data, 'fetchServiceTasks/' + model, {});
  470. },
  471. fetchInspectServiceTasks: function(model, data) {
  472. if (!model) {
  473. model = "ALL"
  474. }
  475. return inspectionProcessActual.customPOST(data, 'fetchServiceTasks/' + model, {});
  476. },
  477. addData: function(model, data) {
  478. return dataService.customPOST(data, 'addData/' + model, {});
  479. },
  480. updData: function(model, data) {
  481. return dataService.customPOST(data, 'updData/' + model, {});
  482. },
  483. rmvData: function(model, data) {
  484. return dataService.customPOST(data, 'rmvData/' + model, {});
  485. },
  486. downDataModel: function(type, month) {
  487. return dataService.one('downDataModel/' + type + '/' + month);
  488. }
  489. };
  490. }]);
  491. app.factory('api_bpm_schedule', ['BpmRestangular', function(BpmRestangular) {
  492. var dataService = BpmRestangular.all("data");
  493. return {
  494. getScheduleClass: function() {
  495. var data = {
  496. "idx": "0",
  497. "sum": "10"
  498. };
  499. return dataService.customPOST(data, 'fetchDataList/scheduleclass', {});
  500. },
  501. fetchList: function(startTime, endTime, userId, queryKey) {
  502. var scheduleOrder = {
  503. "scheduleorder": {
  504. "startTime": startTime,
  505. "endTime": endTime
  506. },
  507. "idx": "0",
  508. "sum": "1000"
  509. };
  510. if (userId) {
  511. scheduleOrder['scheduleorder']['user'] = userId;
  512. }
  513. if (queryKey) {
  514. scheduleOrder['scheduleorder']['description'] = queryKey;
  515. }
  516. return dataService.customPOST(scheduleOrder, 'fetchDataList/scheduleorder', {});
  517. },
  518. fetchData: function(dataId) {
  519. return dataService.customGET('fetchData/scheduleorder/' + dataId);
  520. },
  521. update: function(data) {
  522. return dataService.customPOST(data, 'updData/scheduleorder', {});
  523. },
  524. add: function(data) {
  525. return dataService.customPOST(data, 'addData/scheduleorder', {});
  526. },
  527. remove: function(data) {
  528. return dataService.customPOST(data, 'rmvData/scheduleorder', {});
  529. },
  530. fetchSchedule: function(userId, startTime, endTime) {
  531. var scheduleData = {
  532. "schedulewatch": {
  533. "type": "1",
  534. "user": {
  535. "id": userId
  536. },
  537. "startTime": startTime,
  538. "endTime": endTime
  539. },
  540. "idx": "0",
  541. "sum": "100"
  542. };
  543. return dataService.customPOST(scheduleData, 'fetchDataList/schedulewatch', {});
  544. },
  545. queryRecieveSwitch: function(userId) {
  546. var handleSwitch = {
  547. "schedulewatch": {
  548. "type": "3",
  549. "user": {
  550. "id": userId
  551. }
  552. },
  553. "idx": "0",
  554. "sum": "10"
  555. };
  556. return dataService.customPOST(handleSwitch, 'fetchDataList/schedulewatch', {});
  557. },
  558. queryHandleoutSwitch: function(userId) {
  559. var handleSwitch = {
  560. "schedulewatch": {
  561. "type": "2",
  562. "user": {
  563. "id": userId
  564. }
  565. },
  566. "idx": "0",
  567. "sum": "10"
  568. };
  569. return dataService.customPOST(handleSwitch, 'fetchDataList/schedulewatch', {});
  570. },
  571. handleSchedule: function(data) {
  572. return dataService.customPOST(data, 'updData/schedulewatch', {});
  573. },
  574. querySwitch: function(filterData) {
  575. var switchData = {
  576. "scheduleorder": {
  577. "type": "4"
  578. },
  579. "idx": filterData.idx,
  580. "sum": filterData.sum
  581. };
  582. return dataService.customPOST(switchData, 'fetchDataList/scheduleorder', {});
  583. },
  584. query: function(filterData) {
  585. var switchData = {
  586. "scheduleorder": filterData.scheduleorder,
  587. "idx": filterData.idx,
  588. "sum": filterData.sum
  589. };
  590. return dataService.customPOST(switchData, 'fetchDataList/scheduleorder', {});
  591. }
  592. };
  593. }]);
  594. app.factory('SysinfoRestangular', function(Restangular) {
  595. return Restangular.withConfig(function(RestangularConfigurer) {
  596. // RestangularConfigurer.setBaseUrl('http://testncc.hust.edu.cn/service/api/sysinfo/');
  597. // RestangularConfigurer.setBaseUrl('http://weixintest.dashitech.com/service/sysinfo/');
  598. RestangularConfigurer.setBaseUrl('http://218.197.116.228:8880/service/sysinfo/');
  599. // RestangularConfigurer.setBaseUrl('http://192.168.31.219:8080/service/sysinfo/');
  600. // RestangularConfigurer.setBaseUrl('http://localhost/service/sysinfo/');
  601. // RestangularConfigurer.setBaseUrl('http://192.168.3.155:8080/service/sysinfo/')
  602. });
  603. });
  604. app.factory('api_sysinfo', ['SysinfoRestangular', function(SysinfoRestangular) {
  605. var dataService = SysinfoRestangular.all("data");
  606. return {
  607. fetchDataList: function(model, data) {
  608. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  609. },
  610. addData: function(model, data) {
  611. return dataService.customPOST(data, 'addData/' + model, {});
  612. },
  613. getSerialnumber: function(type, model) {
  614. return dataService.customGET('getSerialnumber/' + type + '/' + model);
  615. }
  616. };
  617. }]);
  618. app.factory('ConfigureRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
  619. return Restangular.withConfig(function(RestangularConfigurer) {
  620. // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/config/');
  621. // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/config/');
  622. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/config/');
  623. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service');
  624. });
  625. }]);
  626. app.factory('api_configure_form', ['ConfigureRestangular', function(ConfigureRestangular) {
  627. var formService = ConfigureRestangular.all("form");
  628. return {
  629. renderForm: function(formKey, userId, processInstanceId) {
  630. if (formKey) {
  631. formKey = formKey + '_weChat'
  632. }
  633. if (processInstanceId) {
  634. return formService.customGET('renderForm/' + formKey + "/" + processInstanceId + "/" + userId);
  635. } else {
  636. return formService.customGET('renderForm/' + formKey + "/000000/" + userId);
  637. }
  638. },
  639. renderList: function(formKey) {
  640. return formService.customGET('renderList/' + formKey);
  641. },
  642. renderTabForm: function(classify) {
  643. return formService.customGET('renderTabForm/' + classify);
  644. }
  645. };
  646. }]);
  647. app.factory('api_configure_data', ['ConfigureRestangular', function(ConfigureRestangular) {
  648. var dataService = ConfigureRestangular.all("data");
  649. return {
  650. fetchDataList: function(model, data) {
  651. return dataService.customPOST(data, 'fetchDataList/' + model, {});
  652. },
  653. fetchDataById: function(model, id) {
  654. return dataService.customGET('fetchData/' + id + '/' + model);
  655. },
  656. fetchData: function(model, data) {
  657. return dataService.customPOST(data, 'fetchData/' + model, {});
  658. },
  659. addData: function(model, data) {
  660. return dataService.customPOST(data, 'addData/' + model, {});
  661. },
  662. updData: function(model, data) {
  663. return dataService.customPOST(data, 'updData/' + model, {});
  664. },
  665. downModels: function(type, id, name) {
  666. return dataService.one('export/' + type + '/' + id + '/' + name);
  667. }
  668. };
  669. }]);
  670. app.factory('SolutionRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
  671. return Restangular.withConfig(function(RestangularConfigurer) {
  672. //RestangularConfigurer.setBaseUrl('http://168.166.203.41:9000/services');
  673. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/solution');
  674. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/solution');
  675. });
  676. }]);
  677. app.factory('api_solution', ['SolutionRestangular', function(SolutionRestangular) {
  678. var jry_solutionService = SolutionRestangular.all("");
  679. var solutionService = SolutionRestangular.all("solution");
  680. var data = SolutionRestangular.all("solutionData");
  681. var history = SolutionRestangular.all("solutionHistory");
  682. var review = SolutionRestangular.all("solution_review");
  683. var typeservice = SolutionRestangular.all("solutionType");
  684. var groupservice = SolutionRestangular.all("solutionGroup");
  685. return {
  686. findSolutionByKeys: function(data) {
  687. var key = data.key,
  688. status = data.status || 0,
  689. pageIndex = data.pageIndex || 0,
  690. pageSum = data.pageSum,
  691. treeIds = data.treeIds,
  692. userId = data.userId;
  693. if (angular.isUndefined(treeIds)) {
  694. return solutionService.customGET('findSolutionByKeys/' + key + '/' + status + '/' + pageIndex + '/' + pageSum + '/' + userId);
  695. } else {
  696. return solutionService.customGET('findSolutionByKeys/' + key + '/' + status + '/' + pageIndex + '/' + pageSum + '/' + treeIds + '/' + userId);
  697. }
  698. },
  699. // searcher: function(data){
  700. // var queryBuilder=data.key, indexname=data.treeIds, type=data.userId;
  701. // return searchservice.customGET('searcher/' + queryBuilder + '/' + indexname + '/' + type );
  702. // },
  703. addSolution: function() {
  704. return solutionService.one('add');
  705. },
  706. addFile: function(data) {
  707. return solutionService.customPOST(data, 'addSolution', {});
  708. },
  709. addModel: function(type, data) {
  710. return solutionService.customPOST(data, 'addModel/' + type, {});
  711. },
  712. updModel: function(type, data) {
  713. return solutionService.customPOST(data, 'updModel/' + type, {});
  714. },
  715. rmModels: function(id, data) {
  716. return solutionService.customPOST(data, 'rmModels/' + id, {});
  717. },
  718. update: function() {
  719. return solutionService.one('update');
  720. },
  721. upload: function() {
  722. return solutionService.one('upload');
  723. },
  724. uploadResponseUri: function() {
  725. return solutionService.one('/');
  726. },
  727. addNotFile: function(data) {
  728. return solutionService.customPOST(data, 'addNotFile', {});
  729. },
  730. updateNotFile: function(data) {
  731. return solutionService.customPOST(data, 'updateNotFile', {});
  732. },
  733. updateSolution: function(data) {
  734. return solutionService.customPOST(data, 'updateSolution', {});
  735. },
  736. searchSolutionByKey: function(key, id) {
  737. return solutionService.customGET('searchSolutionByKey/' + key + '/' + id);
  738. },
  739. findSolutionById: function(id) {
  740. return solutionService.customGET('check/' + id);
  741. },
  742. findSolutions: function(id) {
  743. return solutionService.customGET('check2/' + id);
  744. },
  745. fetchDataList: function(model, data) {
  746. return jry_solutionService.customPOST(data, 'fetchDataList/' + model, {});
  747. },
  748. findSolutionDataByDateById: function(ndate, sid) {
  749. return data.customGET('findSolutionDataByDateById/' + ndate + '/' + sid);
  750. },
  751. findSolutionTypeActions: function(userId) {
  752. return typeservice.customGET('findSolutionTypeActions/' + userId);
  753. },
  754. findSolutionTypesUser: function(data) {
  755. return typeservice.customPOST(data, 'findSolutionTypesUser', {});
  756. },
  757. addTypeUserAll: function(data) {
  758. return typeservice.customPOST(data, 'addTypeUserAll', {});
  759. },
  760. hotRanking: function(num) {
  761. return solutionService.customGET('hotRanking/' + num);
  762. },
  763. scoreRanking: function(num) {
  764. return solutionService.customGET('scoreRanking/' + num);
  765. },
  766. fetchBBSSolutions: function(pageIndex, pageSum, sequence, userId) {
  767. return solutionService.customGET('communicationSolutions/' + pageIndex + '/' + pageSum + '/' + sequence + '/' + userId);
  768. },
  769. queryBBSSolutions: function(pageIndex, pageSum, sequence, userId, key) {
  770. return solutionService.customGET('communicationSolutions/' + pageIndex + '/' + pageSum + '/' + sequence + '/' + userId + '/' + key);
  771. },
  772. updateSolutionStatus: function(data) {
  773. return solutionService.customPOST(data, 'updateSolutionStatus', {});
  774. },
  775. getSolutionNumber: function() {
  776. return solutionService.customGET('getSolutionNumber');
  777. },
  778. addSolutionType: function(data) {
  779. return typeservice.customPOST(data, 'add', {});
  780. },
  781. updateSolutionType: function(data) {
  782. return typeservice.customPOST(data, 'update', {});
  783. },
  784. removeSolutionType: function(id) {
  785. return typeservice.customGET('delete/' + id);
  786. },
  787. getSolutionType: function(id) {
  788. return typeservice.customGET('' + id);
  789. },
  790. getTree: function(typeId, groupId, flag) {
  791. return typeservice.customGET('getTree/' + typeId + '/' + groupId + '/' + flag);
  792. },
  793. checkCommentScoreByUserIds: function(userId, id) {
  794. return review.customGET('findCommentScore/' + userId + '/' + id);
  795. },
  796. addSolutionReview: function(data) {
  797. return solutionService.customPOST(data, 'addScore', {});
  798. },
  799. findSolutionReviewById: function(userid, id, pageIndex, pageSum) {
  800. return solutionService.customGET('findSolutionReviewByType/' + userid + '/' + id + '/' + pageIndex + '/' + pageSum);
  801. },
  802. saveAllUserAuth: function(solutionId, flag) {
  803. return solutionService.customGET('saveAllUserTrees/' + solutionId + '/' + flag);
  804. },
  805. updatermvSolutionType: function(typeId, groupId, userIds, flag) {
  806. return typeservice.customGET('delOrUpdateTrees/' + typeId + '/' + groupId + '/' + userIds + '/' + flag);
  807. },
  808. findSolutionGroup: function(id) {
  809. return groupservice.customGET('findSolutionGroup/' + id);
  810. },
  811. saveSolutionGroup: function(id, data) {
  812. return groupservice.customPOST(data, 'saveSolutionGroup/' + id);
  813. },
  814. // getSolutionDowpath: function(id){
  815. // return solutionService.one('download/'+id);
  816. // }
  817. getSolutionDowpath: function(attachmentId) {
  818. return solutionService.one('download/' + attachmentId + '/file');
  819. }
  820. // getSolutionDowpath: function(attachmentId){
  821. // return solutionService.customGET('download/' + attachmentId);
  822. // }
  823. };
  824. }]);
  825. app.factory('WechatRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
  826. return Restangular.withConfig(function(RestangularConfigurer) {
  827. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/common/');
  828. RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + '/service' + '/common/');
  829. });
  830. }]);
  831. app.factory('api_wechatfile', ['WechatRestangular', function(WechatRestangular) {
  832. var dataService = WechatRestangular.all("common");
  833. return {
  834. listAttachments: function(type, model) {
  835. return dataService.customGET('listAttachment/' + type + "/" + model, {});
  836. // return dataService.one('listAttachment/' + type + "/" + model);
  837. },
  838. downloadAttachment: function(model) {
  839. return dataService.one('downloadAttachment/' + model, {});
  840. },
  841. getDictionary: function(data) {
  842. return dataService.customPOST(data, 'getDictionary', {});
  843. }
  844. };
  845. }]);
  846. app.factory('CMDBRestangular', function(Restangular) {
  847. return Restangular.withConfig(function(RestangularConfigurer) {
  848. RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/cmdb/cmdb/');
  849. });
  850. });
  851. app.factory('api_cmdb', ['CMDBRestangular', function(CMDBRestangular) {
  852. var ciService = CMDBRestangular.all("ci");
  853. var uuidService = CMDBRestangular.all("uuid");
  854. var edgeService = CMDBRestangular.all("edge");
  855. var traversal = CMDBRestangular.all("traversal");
  856. var downloadService = CMDBRestangular.all("download");
  857. var exportService = CMDBRestangular.all("export");
  858. var importService = CMDBRestangular.all("import");
  859. var exportModelService = CMDBRestangular.all("exportModel");
  860. var importDataService = CMDBRestangular.all("importData");
  861. var exportDataService = CMDBRestangular.all("exportData");
  862. var searchService = CMDBRestangular.all("search");
  863. function serializeData(data) {
  864. // If this is not an object, defer to native stringification.
  865. if (!angular.isObject(data)) {
  866. return ((data == null) ? "" : data.toString());
  867. }
  868. var buffer = [];
  869. // Serialize each key in the object.
  870. for (var name in data) {
  871. if (!data.hasOwnProperty(name)) {
  872. continue;
  873. }
  874. var value = data[name];
  875. buffer.push(
  876. encodeURIComponent(name) + "=" + encodeURIComponent((value == null) ? "" : value)
  877. );
  878. }
  879. // Serialize the buffer and clean it up for transportation.
  880. var source = buffer.join("&").replace(/%20/g, "+");
  881. return (source);
  882. }
  883. return {
  884. create: function(data) {
  885. return ciService.customPOST(data, '', {});
  886. },
  887. importData: function() {
  888. return importDataService.one('/nodes');
  889. },
  890. put: function(data, id) {
  891. return ciService.customPUT(data, id, {});
  892. },
  893. remove: function(id) {
  894. return ciService.customDELETE(id);
  895. },
  896. removeByUUId: function(uuid) {
  897. return ciService.customDELETE('uuid/' + id, {}, { 'Content-Type': 'application/json' });
  898. },
  899. removeRefById: function(id) {
  900. return ciService.customDELETE(id + '/ref');
  901. },
  902. find: function(id) {
  903. return ciService.customGET(id);
  904. },
  905. searchkey: function(type, key, idx, sum) {
  906. return searchService.customGET(type + '/' + key + '/' + idx + '/' + sum);
  907. },
  908. findByUUId: function(uuid) {
  909. return ciService.customGET('?uuid=' + uuid);
  910. },
  911. query: function(data) {
  912. return ciService.customGET('query', data);
  913. },
  914. findRefById: function(id) {
  915. return ciService.customGET(id + '/refs');
  916. },
  917. finduuid: function(type, model) {
  918. return uuidService.customGET(type + '/' + model);
  919. },
  920. types: function() {
  921. return CMDBRestangular.customGET('types');
  922. },
  923. createRef: function(data) {
  924. return edgeService.customPOST(data, '', {});
  925. },
  926. putRef: function(data, id) {
  927. return edgeService.customPUT(data, '' + id, {});
  928. },
  929. removeRef: function(id) {
  930. return edgeService.customDELETE(id, {}, { 'Content-Type': 'application/json' });
  931. },
  932. traversal: function(uuid) {
  933. return traversal.customGET(uuid);
  934. },
  935. traversalRel: function(uuid, relation) {
  936. return traversal.customGET(uuid + '/' + relation + '/' + 'none');
  937. },
  938. export: function(label) {
  939. return exportService.customGET('nodes/' + label);
  940. },
  941. import: function() {
  942. return importService.one('/nodes');
  943. },
  944. download: function(label) {
  945. return downloadService.one('/label');
  946. },
  947. exportData: function(type, model) {
  948. return exportDataService.one(model + '/' + type);
  949. },
  950. downModels: function(type, model) {
  951. return exportModelService.one(model + '/' + type);
  952. }
  953. };
  954. }]);
  955. app.factory('MonitorRestangular', function(Restangular) {
  956. return Restangular.withConfig(function(RestangularConfigurer) {
  957. RestangularConfigurer.setBaseUrl(serverIp + ':9004/services');
  958. });
  959. });
  960. app.factory('api_monitor', ['MonitorRestangular', function(MonitorRestangular) {
  961. //http://127.0.0.1:9004/services/ftpFile/monitor/bankTip/
  962. var process = MonitorRestangular.all("ftpFile/monitor");
  963. return {
  964. bankTip: function(id) {
  965. return process.customGET('bankTip/' + id);
  966. },
  967. list: function() {
  968. return process.customGET('list/1000');
  969. },
  970. devList: function(id) {
  971. return process.customGET('devList/' + id);
  972. },
  973. cpuList: function() {
  974. return process.customGET('cpuList/10');
  975. },
  976. memList: function() {
  977. return process.customGET('memList/10');
  978. },
  979. storageList: function() {
  980. return process.customGET('storageList/10');
  981. },
  982. transData: function() {
  983. return process.customGET('transData/5');
  984. },
  985. banklist: function() {
  986. return process.customGET('banklist');
  987. },
  988. app: function(id) {
  989. return process.customGET('app/' + id);
  990. },
  991. beita: function(id) {
  992. return process.customGET('beita/' + id);
  993. },
  994. gongji: function(id) {
  995. return process.customGET('gongji/' + id);
  996. }
  997. };
  998. }]);
  999. app.factory('ReportRestangular', function(Restangular) {
  1000. return Restangular.withConfig(function(RestangularConfigurer) {
  1001. //RestangularConfigurer.setBaseUrl('http://127.0.0.1:9005/api/cmdb/');
  1002. RestangularConfigurer.setBaseUrl(reportIp + ':8080/saiku/rest');
  1003. // RestangularConfigurer.setBaseUrl(serverIp+':8092/saiku/rest');
  1004. //saiku/rest/saiku/api/query/execute/
  1005. });
  1006. });
  1007. app.factory('api_report', ['ReportRestangular', 'Restangular', function(MonitorRestangular, Restangular) {
  1008. var reportService = MonitorRestangular.all("saiku/api");
  1009. var authService = MonitorRestangular.one("saiku/session");
  1010. return {
  1011. getLicenseKey: function() {
  1012. return Restangular.one('assets/').customGET('api/reportToken.js');
  1013. },
  1014. // auth: function(){
  1015. // return authService.customPOST('username=admin&password=admin&language=zh'
  1016. // ,'', {}, {'Content-Type': 'application/x-www-form-urlencoded'});
  1017. // },
  1018. // session: function(){
  1019. // return authService.customGET('');
  1020. // },
  1021. list: function() {
  1022. return reportService.customGET('repository?type=saiku');
  1023. /**
  1024. /saiku/api/repository
  1025. path: /homes/home:admin/itsm_reports
  1026. */
  1027. },
  1028. getMdx: function(path, uuid) {
  1029. var rdata = 'file=' + path + '&formatter=flattened&language=zh';
  1030. return reportService.customPOST(rdata, 'query/' + uuid, {}, { 'Content-Type': 'application/x-www-form-urlencoded' });
  1031. },
  1032. execute: function(data) {
  1033. return reportService.customPOST(data, 'query/execute', {}, { 'Accept': 'application/json, text/javascript, */*' });
  1034. },
  1035. exportData: function(reportView, uuid, reportfileName) {
  1036. return reportService.one('query/rest/export/xls/?exportname=' + reportfileName + 'xls');
  1037. }
  1038. };
  1039. }]);
  1040. //图片展示canvas
  1041. app.directive('ngThumb', ['$window', function($window) {
  1042. var helper = {
  1043. support: !!($window.FileReader && $window.CanvasRenderingContext2D),
  1044. isFile: function(item) {
  1045. return angular.isObject(item) && item instanceof $window.File;
  1046. },
  1047. isImage: function(file) {
  1048. var type = '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|';
  1049. return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
  1050. }
  1051. };
  1052. return {
  1053. restrict: 'A',
  1054. template: '<canvas/>',
  1055. link: function(scope, element, attributes) {
  1056. if (!helper.support) return;
  1057. var params = scope.$eval(attributes.ngThumb);
  1058. if (!helper.isFile(params.file)) return;
  1059. if (!helper.isImage(params.file)) return;
  1060. var canvas = element.find('canvas');
  1061. var reader = new FileReader();
  1062. reader.onload = onLoadFile;
  1063. reader.readAsDataURL(params.file);
  1064. function onLoadFile(event) {
  1065. var img = new Image();
  1066. img.onload = onLoadImage;
  1067. img.src = event.target.result;
  1068. }
  1069. function onLoadImage() {
  1070. var width = params.width || this.width / this.height * params.height;
  1071. var height = params.height || this.height / this.width * params.width;
  1072. canvas.attr({ width: width, height: height });
  1073. canvas[0].getContext('2d').drawImage(this, 0, 0, width, height);
  1074. }
  1075. }
  1076. };
  1077. }]);
  1078. app.factory('getLoginUser', ['$rootScope', '$http', '$q', 'ADDRESS', function($rootScope, $http, $q, address) {
  1079. return {
  1080. query: function() {
  1081. var deferred = $q.defer(); // 声明延后执行,表示要去监控后面的执行
  1082. $http({
  1083. method: 'post',
  1084. // url: address.serverIp + address.serverIpPort + address.api + '/login',
  1085. url: address.serverIp + address.serverIpPort + '/service' + '/login',
  1086. headers: { 'Content-Type': 'application/json' },
  1087. data: {
  1088. 'username': '005298',
  1089. 'password': '888888'
  1090. }
  1091. }).success(function(data, status, headers, config) {
  1092. // 当相应准备就绪时调用
  1093. if (data.state == 201) {
  1094. console.log(headers('access-token'));
  1095. $rootScope.isToken = true;
  1096. $rootScope['access-token'] = headers('access-token');
  1097. if (data.data.user && data.data.user != '') {
  1098. $rootScope.tokenType = 'user';
  1099. var sessionLogin = {
  1100. 'user': data.data.user,
  1101. 'token': headers('access-token'),
  1102. 'tokenType': 'user'
  1103. }
  1104. sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
  1105. } else if (data.data.requester && data.data.requester != '') {
  1106. $rootScope.tokenType = 'requester';
  1107. var sessionLogin = {
  1108. 'user': data.data.requester,
  1109. 'token': headers('access-token'),
  1110. 'tokenType': 'requester'
  1111. }
  1112. sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
  1113. }
  1114. var loginUser = sessionLogin;
  1115. deferred.resolve(loginUser); // 声明执行成功,即http请求数据成功,可以返回数据了
  1116. }
  1117. }).error(function(data, status, headers, config) {
  1118. deferred.reject(data); // 声明执行失败,即服务器返回错误
  1119. });
  1120. return deferred.promise; // 返回承诺,这里并不是最终数据,而是访问最终数据的API
  1121. } // end query
  1122. };
  1123. }]);
  1124. //获取微信公众号配置数据
  1125. app.factory('getWXJsConfig', ['Restangular', 'ADDRESS', function(Restangular, address) {
  1126. // return Restangular.withConfig(function(RestangularConfigurer) {
  1127. // // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/user/');
  1128. // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/user/');
  1129. // });
  1130. // var getWXJsConfig = Restangular.all(address.api + '/');
  1131. var getWXJsConfig = Restangular.all('/service' + '/');
  1132. return {
  1133. getConfig: function(data) {
  1134. return getWXJsConfig.customPOST(data, 'wechat/wechat/getJsConfig');
  1135. }
  1136. };
  1137. }]);
  1138. //获取消息通知数据
  1139. app.factory('getCount', ['Restangular', 'ADDRESS', function(Restangular, address) {
  1140. // var getCount = Restangular.all(address.api + '/');
  1141. var getCount = Restangular.all('/service' + '/');
  1142. return {
  1143. count: function(data, url) {
  1144. return getCount.customPOST(url, data);
  1145. }
  1146. };
  1147. }]);
  1148. //过滤时间
  1149. app.filter('filterTime', function() {
  1150. return function(text) {
  1151. var time = text.split(" ");
  1152. return time[0];
  1153. }
  1154. });