main.js 51 KB

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