1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231 |
- // var app = angular.module('starter', ['ionic', 'restangular', 'oc.lazyLoad', 'ui-bootstrap']);
- var app = angular.module('starter', ['ionic', 'restangular', 'oc.lazyLoad', 'ui.bootstrap']);
- // var serverIp = "http://dswechat.tunnel.2bdata.com"; //"http://218.197.181.211";
- // var serverIp = "http://wechat.tunnel.dashitech.com";
- // var serverIp = "http://testwechat.tunnel.dashitech.com";
- // var serverIp = "http://115.156.150.70";
- // var serverIp = "http://192.168.3.49";
- // var serverIp = "http://192.168.124.18";
- // var reportIp = "http://192.168.3.50";
- // var inspectIp = "http://192.168.3.69";
- // var callIp = "http://192.168.3.49";
- // 本地
- // var serverIp = "http://localhost";
- // var reportIp = "http://localhost";
- // var inspectIp = "http://localhost";
- // var callIp = "http://localhost";
- //var serverIp = "http://218.197.116.230:8880";
- //var reportIp = "http://218.197.116.230:8880";
- //var inspectIp = "http://218.197.116.230:8880";
- //var callIp = "http://218.197.116.230:8880";
- var serverIp = "http://itsm.whut.edu.cn";
- var reportIp = "http://itsm.whut.edu.cn";
- var inspectIp = "http://itsm.whut.edu.cn";
- var callIp = "http://itsm.whut.edu.cn";
- // var serverIp = "http://202.197.144.144";//"http://218.197.181.211";
- // var reportIp= "http://125.220.91.43";
- // var inspectIp= "http://218.197.181.213";
- // var callIp= "http://218.197.181.213";
- app.config(function($httpProvider) {
- $httpProvider.interceptors.push('sessionInjector');
- });
- app.run(['$rootScope', function($rootScope) {
- $rootScope.app = {
- name: '', // name of your project
- };
- }]);
- //拦截器
- //$httpProvider.interceptors 不能注入$http和引用了$http的服务,否则会报依赖注入错误。
- // app.factory('sessionInjector', ['$rootScope', '$q', ' $injector ', function($rootScope, $q, $injector) {
- app.factory('sessionInjector', ['$rootScope', '$q', function($rootScope, $q) {
- //factory 的两种写法
- //第一种写法
- var sessionInjector = {
- //成功拦截器,发送请求道后台之前执行
- 'request': function(request) {
- if (sessionStorage.sessionLogin) {
- var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
- if (sessionLogin.token && sessionLogin.token != '') {
- request.headers['access-token'] = sessionLogin.token;
- }
- }
- return request;
- },
- //成功拦截器,从后台过来的响应之后执行
- 'response': function(response) {
- if (response.data.state == 433) {
- // window.location.href = '#/tab/index'
- window.location.href = '#/err'
- }
- return response;
- },
- //失败拦截器,请求发送失败或者被拦截器拒绝
- 'requestError': function(requestError) {
- var data = requestError.data;
- return $q.reject(requestError);
- },
- //失败拦截器,后台调用失败
- 'responseError': function(responseError) {
- return $q.reject(responseError);
- }
- };
- return sessionInjector
- //第二种写法
- // return {
- // request: function(config) {
- // if (!SessionService.isAnonymus) {
- // config.headers['x-session-token'] = SessionService.token;
- // }
- // return config;
- // }
- // };
- }]);
- app.factory('loginService', ['$http', function($http) {
- return {
- handleLogin: function() {
- $http({
- method: 'post',
- url: address.serverIp + address.serverIpPort + address.api + '/login',
- headers: { 'Content-Type': 'application/json' },
- data: {
- 'username': '005298',
- 'password': '888888'
- }
- }).success(function(data, status, headers, config) {
- // 当相应准备就绪时调用
- console.log("loginService is success");
- // console.log(data.url);
- if (data.state == 201 || data.state == 200) {
- $rootScope.isToken = true;
- // $rootScope['access-token'] = headers('access-token');
- // $rootScope.user = data.data.user;
- // $rootScope.app.name = "网信运维"
- if (data.data.user && data.data.user != '') {
- $rootScope.app.name = "网信运维"
- var sessionLogin = {
- 'user': data.data.user,
- 'token': headers('access-token')
- }
- //本地数据初始化
- sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
- $state.go('tab.incidentHandler');
- } else if (data.data.requester && data.data.requester != '') {
- $rootScope.app.name = "校园网故障报修"
- var sessionLogin = {
- 'user': data.data.requester,
- 'token': headers('access-token')
- }
- //本地数据初始化
- sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
- $state.go('tab.myIncident');
- }
- } else {}
- }).error(function(data, status, headers, config) {
- // 当响应以错误状态返回时调用
- console.log("error");
- return
- });
- }
- };
- }]);
- app.config(['RestangularProvider', function(RestangularProvider) {
- RestangularProvider.setBaseUrl('');
- }]);
- app.factory('textRestangular', function(Restangular) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- RestangularConfigurer.setBaseUrl(inspectIp + ':8088/DeskServer/');
- });
- });
- app.factory('api_text', ['textRestangular', function(textRestangular) {
- var loginService = textRestangular.all("comm");
- var loginsins = textRestangular.all("tele/agent");
- return {
- start: function(phone) {
- var rdata = "dom=0&epwd=&aid=1000&apwd=e10adc3949ba59abbe56e057f20f883e&adn=" + phone;
- return loginService.customPOST(rdata, 'start', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- exit: function(token) {
- var rdata = "dom=0&token=" + token;
- return loginService.customPOST(rdata, 'exit', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- login: function(group, token) {
- var rdata = "dom=0&token=" + token + "&aid=1000&acd=" + group + "&skill=-1&mon=false&silent=false";
- return loginsins.customPOST(rdata, 'login', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- logout: function(token) {
- var rdata = "dom=0&token=" + token + "&aid=1000";
- return loginsins.customPOST(rdata, 'logout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- dialout: function(token, gid, teleno) {
- var rdata = "dom=0&token=" + token + "&teleno=" + teleno + "&gid=" + gid + "&uud=&async=true";
- return loginsins.customPOST(rdata, 'dialout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- callout: function(token, teleno) {
- var rdata = "dom=0&token=" + token + "&teleno=" + teleno + "&uud=&async=true";
- return loginsins.customPOST(rdata, 'dialout', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- setbusy: function(token) {
- var rdata = "dom=0&token=" + token;
- return loginsins.customPOST(rdata, 'setbusy', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- setidle: function(token) {
- var rdata = "dom=0&token=" + token;
- return loginsins.customPOST(rdata, 'setidle', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- inittrans: function(telephone, token) {
- var rdata = "dom=0&token=" + token + "&teleno=" + telephone + "&uud=&async=true";
- return loginsins.customPOST(rdata, 'inittrans', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- comptrans: function(telephone, token) {
- var rdata = "dom=0&token=" + token;
- return loginsins.customPOST(rdata, 'comptrans', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- record: function(token) {
- var rdata = "dom=0&token=" + token + "&filename=/tmp/agent.wav&async=true&maxtime=10&termchar=&append=true";
- return loginsins.customPOST(rdata, 'record', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- offhook: function(token) {
- var rdata = "dom=0&token=" + token;
- return loginsins.customPOST(rdata, 'offhook', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- onhook: function(token) {
- var rdata = "dom=0&token=" + token;
- return loginsins.customPOST(rdata, 'onhook', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- },
- getcdrid: function(token) {
- var rdata = "dom=0&token=" + token;
- return loginsins.customPOST(rdata, 'getcdrid', {}, { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' });
- }
- }
- }])
- app.factory('UserRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/user/');
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/user/');
- });
- }]);
- app.factory('api_user', ['UserRestangular', function(UserRestangular) {
- var basePath = "user/";
- return {
- };
- }]);
- app.factory('api_login', ['UserRestangular', function(UserRestangular) {
- var loginService = UserRestangular.all("auth");
- return {
- login: function(username, password) {
- return loginService.customPOST({ 'username': username, 'password': password }, 'login', {});
- },
- // logout: function(sessionid,userid){
- // return loginService.customPOST(sessionid + '/' + userid);
- // },
- sso: function(nickname) {
- return loginService.customGET('sso/' + nickname);
- },
- resetpwd: function(userid) {
- return loginService.customGET('resetpwd/' + userid);
- },
- uppwd: function(data) {
- return loginService.customPOST(data, 'uppwd', {});
- }
- }
- }])
- app.factory('api_user_data', ['UserRestangular', function(UserRestangular) {
- var dataService = UserRestangular.all("data");
- return {
- validate: function(data) {
- return dataService.customPOST(data, 'validate/role', {});
- },
- importData: function() {
- return dataService.one('/importData');
- },
- fetchDataList: function(model, data) {
- return dataService.customPOST(data, 'fetchDataList/' + model, {});
- },
- fetchData: function(model, data) {
- return dataService.customPOST(data, 'fetchData/' + model, {});
- },
- addData: function(model, data) {
- return dataService.customPOST(data, 'addData/' + model, {});
- },
- updData: function(model, data) {
- return dataService.customPOST(data, 'updData/' + model, {});
- },
- rmvData: function(model, data) {
- return dataService.customPOST(data, 'rmvData/' + model, {});
- },
- downDataModel: function(type, month) {
- return dataService.one('downDataModel/' + type + '/' + month);
- }
- };
- }]);
- // app.factory('DpmRestangular', function(Restangular) {
- // return Restangular.withConfig(function(RestangularConfigurer) {
- // RestangularConfigurer.setBaseUrl(serverIp+':9008/data/');
- // });
- // });
- // app.factory('api_bpm_dbca', ['DpmRestangular', function(DpmRestangular){
- // var bpm = DpmRestangular.all("bpm");
- // return {
- // impFileData: function(pdKey){
- // return bpm.customPOST( 'impFileData/' + pdKey);
- // },
- // };
- // }]);
- // app.factory('BpmRestangular', function(Restangular) {
- // return Restangular.withConfig(function(RestangularConfigurer) {
- // // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
- // // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + ':8080/service/api/bpm');
- // // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
- // // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
- // });
- // });
- app.factory('BpmRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
- // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + ':8080/service/api/bpm');
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
- });
- }]);
- app.factory('CommonRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
- // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/common');
- });
- }]);
- app.factory('WeChatRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
- // RestangularConfigurer.setBaseUrl("http://192.168.3.49" + ':9680/api/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/common');
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/bpm');
- });
- }]);
- app.factory('WeChatApply', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- // RestangularConfigurer.setBaseUrl("http://168.166.3.41"+':9008/api/');
- // RestangularConfigurer.setBaseUrl("http://192.168.3.49" + ':9680/api/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + ':8080/wechat/bpm');
- // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/apply');
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/apply');
- });
- }]);
- app.factory('api_statistic', ['BpmRestangular', function(BpmRestangular) {
- var statistic = BpmRestangular.all("statistic");
- return {
- query: function(data, rptId) {
- return statistic.customPOST(data, 'unidimensional/' + rptId, {});
- },
- // exportData: function(reportView, uuid, reportfileName){
- // return reportService.one('query/rest/export/xls/?exportname='+reportfileName+'xls');
- // }
- unidimensionalExport: function(rptId) {
- return statistic.one('unidimensionalExport/' + rptId);
- }
- }
- }]);
- app.factory('api_bpm', ['BpmRestangular', function(BpmRestangular) {
- var process = BpmRestangular.all("process");
- return {
- deploy: function(data) {
- return process.customPOST(data, 're/model/deploy', {});
- },
- list: function() {
- return process.customGET('re/model/list');
- },
- modelsource: function(pdId) {
- return process.customGET('re/model/' + pdId + '/source');
- },
- savemodel: function(pdId, data) {
- return process.customPOST(data, 're/model/' + pdId + '/save', {});
- },
- removemodel: function(modelId) {
- return process.customGET('re/model/' + modelId + '/remove');
- }
- };
- }]);
- app.factory('api_bpm_domain', ['BpmRestangular', 'CommonRestangular', 'WeChatRestangular', 'WeChatApply', function(BpmRestangular, CommonRestangular, WeChatRestangular, WeChatApply) {
- var bpmService = BpmRestangular.all("bpm");
- var commonService = CommonRestangular.all("common");
- var weChatService = WeChatRestangular.all("bpm");
- var weChatApply = WeChatApply.all("bpm");
- // var bpmService = BpmRestangular.all("common");
- return {
- hasRepair:function(data){
- return weChatApply.customPOST(data, 'hasRepair', {});
- },
- fetchtask: function(pdKey, data) {
- return bpmService.customPOST(data, 'fetchTask/' + pdKey, {});
- },
- weChatFetchServiceTasks: function(pdKey, data) {
- return weChatApply.customPOST(data, 'fetchServiceTasks/' + pdKey, {});
- },
- fetchData: function(model, dataId) {
- return weChatApply.customGET('fetchServiceTasks/' + model + '/' + dataId);
- },
- start: function(pdKey, data) {
- return bpmService.customPOST(data, 'start/' + pdKey, {});
- },
- weChatApplyStart: function(pdKey, data) {
- return weChatApply.customPOST(data, 'start', {});
- },
- setWxProcess: function(data) {
- return weChatApply.customPOST(data, 'setWxProcess', {});
- },
- flowTracing: function(processInstanceId, data) {
- return bpmService.customPOST(data, 'flowTracing/' + processInstanceId, {});
- },
- complete: function(taskId, userId, data) {
- return bpmService.customPOST(data, 'completeTask/' + taskId + '/' + userId, {});
- },
- completeUpgrade: function(data) {
- return bpmService.customPOST(data, 'upgradeIncident', {});
- },
- claimAndCompletedTask: function(taskId, data) {
- return bpmService.customPOST(data, 'claimAndCompletedTask/' + taskId, {});
- },
- save: function(taskId, data) {
- return bpmService.customPOST(data, 'saveTaskVar/' + taskId, {});
- },
- weChatApplySave: function(taskId, data) {
- return weChatApply.customPOST(data, 'addWxIncidentDegree/' + taskId, {});
- },
- claimtask: function(taskId, data) {
- return bpmService.customPOST(data, 'claimTask/' + taskId, {});
- },
- expectedTime: function(taskId) {
- return bpmService.customGET('expectedTime/' + taskId);
- },
- history: function(processId) {
- return bpmService.customGET('history/' + processId);
- },
- upgrade: function(processInstanceId, taskId, data) {
- return bpmService.customPOST(data, 'upgradeIncident/' + processInstanceId + '/' + taskId, {});
- },
- listAttachments: function(processId, data) {
- return bpmService.customPOST(data, 'getAttachmentList/' + processId, {});
- },
- // saveAttachments: function(processId, taskId, userId, data) {
- // return bpmService.one('saveAttachments/' + processId + '/' + taskId + '/' + userId);
- // },
- saveAttachments: function(processId, taskId, userId, data) {
- return weChatService.one('saveAttachments/' + processId + '/' + taskId + '/' + userId);
- },
- uploadAttachment: function(processId, taskId, userId, data) {
- return commonService.one('uploadAttachment/' + 'wechatRequesterIncident/' + processId);
- },
- download: function(attachmentId) {
- return bpmService.one('getAttachmentContent/' + attachmentId);
- },
- downloadWechat: function(token) {
- return commonService.one('downloadAttachment/' + token);
- },
- // download: function(attachmentId){
- // return bpmService.customGET('getAttachmentContent/' + attachmentId,{},{'responseType':'arraybuffer'});
- // },
- attachmentsPreviewUrl: function(attachmentId) {
- return bpmService.customGET('attachmentsPreviewUrl/' + attachmentId);
- },
- startformkey: function(pdKey) {
- return bpmService.customGET('startformkey/' + pdKey);
- },
- taskformkey: function(taskId) {
- return bpmService.customGET('taskformkey/' + taskId);
- },
- workernumber: function(type) {
- return bpmService.customGET('restful/' + type);
- }
- };
- }]);
- app.factory('api_bpm_data', ['BpmRestangular', function(BpmRestangular) {
- var dataService = BpmRestangular.all("data");
- var serviceCatalogue = BpmRestangular.all("ServiceCatalogue");
- var inspectionProcessActual = BpmRestangular.all("InspectionProcessActual");
- return {
- impFileData: function() {
- return dataService.one('/impFileData/bpm_scheduleorder');
- },
- importData: function() {
- return dataService.one('/impFileData');
- },
- fetchDataList: function(model, data) {
- return dataService.customPOST(data, 'fetchDataList/' + model, {});
- },
- fetchData: function(model, dataId) {
- return dataService.customGET('fetchData/' + model + '/' + dataId);
- },
- fetchServiceTasks: function(model, data) {
- if (!model) {
- model = "ALL"
- }
- return serviceCatalogue.customPOST(data, 'fetchServiceTasks/' + model, {});
- },
- fetchInspectServiceTasks: function(model, data) {
- if (!model) {
- model = "ALL"
- }
- return inspectionProcessActual.customPOST(data, 'fetchServiceTasks/' + model, {});
- },
- addData: function(model, data) {
- return dataService.customPOST(data, 'addData/' + model, {});
- },
- updData: function(model, data) {
- return dataService.customPOST(data, 'updData/' + model, {});
- },
- rmvData: function(model, data) {
- return dataService.customPOST(data, 'rmvData/' + model, {});
- },
- downDataModel: function(type, month) {
- return dataService.one('downDataModel/' + type + '/' + month);
- }
- };
- }]);
- app.factory('api_bpm_schedule', ['BpmRestangular', function(BpmRestangular) {
- var dataService = BpmRestangular.all("data");
- return {
- getScheduleClass: function() {
- var data = {
- "idx": "0",
- "sum": "10"
- };
- return dataService.customPOST(data, 'fetchDataList/scheduleclass', {});
- },
- fetchList: function(startTime, endTime, userId, queryKey) {
- var scheduleOrder = {
- "scheduleorder": {
- "startTime": startTime,
- "endTime": endTime
- },
- "idx": "0",
- "sum": "1000"
- };
- if (userId) {
- scheduleOrder['scheduleorder']['user'] = userId;
- }
- if (queryKey) {
- scheduleOrder['scheduleorder']['description'] = queryKey;
- }
- return dataService.customPOST(scheduleOrder, 'fetchDataList/scheduleorder', {});
- },
- fetchData: function(dataId) {
- return dataService.customGET('fetchData/scheduleorder/' + dataId);
- },
- update: function(data) {
- return dataService.customPOST(data, 'updData/scheduleorder', {});
- },
- add: function(data) {
- return dataService.customPOST(data, 'addData/scheduleorder', {});
- },
- remove: function(data) {
- return dataService.customPOST(data, 'rmvData/scheduleorder', {});
- },
- fetchSchedule: function(userId, startTime, endTime) {
- var scheduleData = {
- "schedulewatch": {
- "type": "1",
- "user": {
- "id": userId
- },
- "startTime": startTime,
- "endTime": endTime
- },
- "idx": "0",
- "sum": "100"
- };
- return dataService.customPOST(scheduleData, 'fetchDataList/schedulewatch', {});
- },
- queryRecieveSwitch: function(userId) {
- var handleSwitch = {
- "schedulewatch": {
- "type": "3",
- "user": {
- "id": userId
- }
- },
- "idx": "0",
- "sum": "10"
- };
- return dataService.customPOST(handleSwitch, 'fetchDataList/schedulewatch', {});
- },
- queryHandleoutSwitch: function(userId) {
- var handleSwitch = {
- "schedulewatch": {
- "type": "2",
- "user": {
- "id": userId
- }
- },
- "idx": "0",
- "sum": "10"
- };
- return dataService.customPOST(handleSwitch, 'fetchDataList/schedulewatch', {});
- },
- handleSchedule: function(data) {
- return dataService.customPOST(data, 'updData/schedulewatch', {});
- },
- querySwitch: function(filterData) {
- var switchData = {
- "scheduleorder": {
- "type": "4"
- },
- "idx": filterData.idx,
- "sum": filterData.sum
- };
- return dataService.customPOST(switchData, 'fetchDataList/scheduleorder', {});
- },
- query: function(filterData) {
- var switchData = {
- "scheduleorder": filterData.scheduleorder,
- "idx": filterData.idx,
- "sum": filterData.sum
- };
- return dataService.customPOST(switchData, 'fetchDataList/scheduleorder', {});
- }
- };
- }]);
- app.factory('SysinfoRestangular', function(Restangular) {//
- return Restangular.withConfig(function(RestangularConfigurer) {
- RestangularConfigurer.setBaseUrl(serverIp+'/service/sysinfo/');
- });
- });
- app.factory('api_sysinfo', ['SysinfoRestangular', function(SysinfoRestangular) {
- var dataService = SysinfoRestangular.all("data");
- return {
- fetchDataList: function(model, data) {
- return dataService.customPOST(data, 'fetchDataList/' + model, {});
- },
- addData: function(model, data) {
- return dataService.customPOST(data, 'addData/' + model, {});
- },
- getSerialnumber: function(type, model) {
- return dataService.customGET('getSerialnumber/' + type + '/' + model);
- }
- };
- }]);
- app.factory('ConfigureRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/config/');
- // RestangularConfigurer.setBaseUrl(serverIp + '/wechat/config/');
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/');
- });
- }]);
- app.factory('api_configure_form', ['ConfigureRestangular', function(ConfigureRestangular) {
- var formService = ConfigureRestangular.all("form");
- return {
- renderForm: function(formKey, userId, processInstanceId) {
- if (formKey) {
- formKey = formKey + '_weChat'
- }
- if (processInstanceId) {
- return formService.customGET('renderForm/' + formKey + "/" + processInstanceId + "/" + userId);
- } else {
- return formService.customGET('renderForm/' + formKey + "/000000/" + userId);
- }
- },
- renderList: function(formKey) {
- return formService.customGET('renderList/' + formKey);
- },
- renderTabForm: function(classify) {
- return formService.customGET('renderTabForm/' + classify);
- }
- };
- }]);
- app.factory('api_configure_data', ['ConfigureRestangular', function(ConfigureRestangular) {
- var dataService = ConfigureRestangular.all("data");
- return {
- fetchDataList: function(model, data) {
- return dataService.customPOST(data, 'fetchDataList/' + model, {});
- },
- fetchDataById: function(model, id) {
- return dataService.customGET('fetchData/' + id + '/' + model);
- },
- fetchData: function(model, data) {
- return dataService.customPOST(data, 'fetchData/' + model, {});
- },
- addData: function(model, data) {
- return dataService.customPOST(data, 'addData/' + model, {});
- },
- updData: function(model, data) {
- return dataService.customPOST(data, 'updData/' + model, {});
- },
- downModels: function(type, id, name) {
- return dataService.one('export/' + type + '/' + id + '/' + name);
- }
- };
- }]);
- app.factory('SolutionRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- //RestangularConfigurer.setBaseUrl('http://168.166.203.41:9000/services');
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/solution');
- });
- }]);
- app.factory('api_solution', ['SolutionRestangular', function(SolutionRestangular) {
- var solutionService = SolutionRestangular.all("solution");
- var data = SolutionRestangular.all("solutionData");
- var history = SolutionRestangular.all("solutionHistory");
- var review = SolutionRestangular.all("solution_review");
- var typeservice = SolutionRestangular.all("solutionType");
- var groupservice = SolutionRestangular.all("solutionGroup");
- return {
- findSolutionByKeys: function(data) {
- var key = data.key,
- status = data.status || 0,
- pageIndex = data.pageIndex || 0,
- pageSum = data.pageSum,
- treeIds = data.treeIds,
- userId = data.userId;
- if (angular.isUndefined(treeIds)) {
- return solutionService.customGET('findSolutionByKeys/' + key + '/' + status + '/' + pageIndex + '/' + pageSum + '/' + userId);
- } else {
- return solutionService.customGET('findSolutionByKeys/' + key + '/' + status + '/' + pageIndex + '/' + pageSum + '/' + treeIds + '/' + userId);
- }
- },
- // searcher: function(data){
- // var queryBuilder=data.key, indexname=data.treeIds, type=data.userId;
- // return searchservice.customGET('searcher/' + queryBuilder + '/' + indexname + '/' + type );
- // },
- addSolution: function() {
- return solutionService.one('add');
- },
- addFile: function(data) {
- return solutionService.customPOST(data, 'addSolution', {});
- },
- addModel: function(type, data) {
- return solutionService.customPOST(data, 'addModel/' + type, {});
- },
- updModel: function(type, data) {
- return solutionService.customPOST(data, 'updModel/' + type, {});
- },
- rmModels: function(id, data) {
- return solutionService.customPOST(data, 'rmModels/' + id, {});
- },
- update: function() {
- return solutionService.one('update');
- },
- upload: function() {
- return solutionService.one('upload');
- },
- uploadResponseUri: function() {
- return solutionService.one('/');
- },
- addNotFile: function(data) {
- return solutionService.customPOST(data, 'addNotFile', {});
- },
- updateNotFile: function(data) {
- return solutionService.customPOST(data, 'updateNotFile', {});
- },
- updateSolution: function(data) {
- return solutionService.customPOST(data, 'updateSolution', {});
- },
- searchSolutionByKey: function(key, id) {
- return solutionService.customGET('searchSolutionByKey/' + key + '/' + id);
- },
- findSolutionById: function(id) {
- return solutionService.customGET('check/' + id);
- },
- findSolutions: function(id) {
- return solutionService.customGET('check2/' + id);
- },
- fetchDataList: function(model, data) {
- return solutionService.customPOST(data, 'fetchDataList/' + model, {});
- },
- findSolutionDataByDateById: function(ndate, sid) {
- return data.customGET('findSolutionDataByDateById/' + ndate + '/' + sid);
- },
- findSolutionTypeActions: function(userId) {
- return typeservice.customGET('findSolutionTypeActions/' + userId);
- },
- findSolutionTypesUser: function(data) {
- return typeservice.customPOST(data, 'findSolutionTypesUser', {});
- },
- addTypeUserAll: function(data) {
- return typeservice.customPOST(data, 'addTypeUserAll', {});
- },
- hotRanking: function(num) {
- return solutionService.customGET('hotRanking/' + num);
- },
- scoreRanking: function(num) {
- return solutionService.customGET('scoreRanking/' + num);
- },
- fetchBBSSolutions: function(pageIndex, pageSum, sequence, userId) {
- return solutionService.customGET('communicationSolutions/' + pageIndex + '/' + pageSum + '/' + sequence + '/' + userId);
- },
- queryBBSSolutions: function(pageIndex, pageSum, sequence, userId, key) {
- return solutionService.customGET('communicationSolutions/' + pageIndex + '/' + pageSum + '/' + sequence + '/' + userId + '/' + key);
- },
- updateSolutionStatus: function(data) {
- return solutionService.customPOST(data, 'updateSolutionStatus', {});
- },
- getSolutionNumber: function() {
- return solutionService.customGET('getSolutionNumber');
- },
- addSolutionType: function(data) {
- return typeservice.customPOST(data, 'add', {});
- },
- updateSolutionType: function(data) {
- return typeservice.customPOST(data, 'update', {});
- },
- removeSolutionType: function(id) {
- return typeservice.customGET('delete/' + id);
- },
- getSolutionType: function(id) {
- return typeservice.customGET('' + id);
- },
- getTree: function(typeId, groupId, flag) {
- return typeservice.customGET('getTree/' + typeId + '/' + groupId + '/' + flag);
- },
- checkCommentScoreByUserIds: function(userId, id) {
- return review.customGET('findCommentScore/' + userId + '/' + id);
- },
- addSolutionReview: function(data) {
- return solutionService.customPOST(data, 'addScore', {});
- },
- findSolutionReviewById: function(userid, id, pageIndex, pageSum) {
- return solutionService.customGET('findSolutionReviewByType/' + userid + '/' + id + '/' + pageIndex + '/' + pageSum);
- },
- saveAllUserAuth: function(solutionId, flag) {
- return solutionService.customGET('saveAllUserTrees/' + solutionId + '/' + flag);
- },
- updatermvSolutionType: function(typeId, groupId, userIds, flag) {
- return typeservice.customGET('delOrUpdateTrees/' + typeId + '/' + groupId + '/' + userIds + '/' + flag);
- },
- findSolutionGroup: function(id) {
- return groupservice.customGET('findSolutionGroup/' + id);
- },
- saveSolutionGroup: function(id, data) {
- return groupservice.customPOST(data, 'saveSolutionGroup/' + id);
- },
- // getSolutionDowpath: function(id){
- // return solutionService.one('download/'+id);
- // }
- getSolutionDowpath: function(attachmentId) {
- return solutionService.one('download/' + attachmentId + '/file');
- }
- // getSolutionDowpath: function(attachmentId){
- // return solutionService.customGET('download/' + attachmentId);
- // }
- };
- }]);
- app.factory('WechatRestangular', ['Restangular', 'ADDRESS', function(Restangular, address) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/common/');
- });
- }]);
- app.factory('api_wechatfile', ['WechatRestangular', function(WechatRestangular) {
- var dataService = WechatRestangular.all("common");
- return {
- listAttachments: function(type, model) {
- return dataService.customGET('listAttachment/' + type + "/" + model, {});
- // return dataService.one('listAttachment/' + type + "/" + model);
- },
- downloadAttachment: function(model) {
- return dataService.one('downloadAttachment/' + model, {});
- },
- getDictionary: function(data) {
- return dataService.customPOST(data, 'getDictionary', {});
- }
- };
- }]);
- app.factory('CMDBRestangular', function(Restangular) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/cmdb/cmdb/');
- });
- });
- app.factory('api_cmdb', ['CMDBRestangular', function(CMDBRestangular) {
- var ciService = CMDBRestangular.all("ci");
- var uuidService = CMDBRestangular.all("uuid");
- var edgeService = CMDBRestangular.all("edge");
- var traversal = CMDBRestangular.all("traversal");
- var downloadService = CMDBRestangular.all("download");
- var exportService = CMDBRestangular.all("export");
- var importService = CMDBRestangular.all("import");
- var exportModelService = CMDBRestangular.all("exportModel");
- var importDataService = CMDBRestangular.all("importData");
- var exportDataService = CMDBRestangular.all("exportData");
- var searchService = CMDBRestangular.all("search");
- function serializeData(data) {
- // If this is not an object, defer to native stringification.
- if (!angular.isObject(data)) {
- return ((data == null) ? "" : data.toString());
- }
- var buffer = [];
- // Serialize each key in the object.
- for (var name in data) {
- if (!data.hasOwnProperty(name)) {
- continue;
- }
- var value = data[name];
- buffer.push(
- encodeURIComponent(name) + "=" + encodeURIComponent((value == null) ? "" : value)
- );
- }
- // Serialize the buffer and clean it up for transportation.
- var source = buffer.join("&").replace(/%20/g, "+");
- return (source);
- }
- return {
- create: function(data) {
- return ciService.customPOST(data, '', {});
- },
- importData: function() {
- return importDataService.one('/nodes');
- },
- put: function(data, id) {
- return ciService.customPUT(data, id, {});
- },
- remove: function(id) {
- return ciService.customDELETE(id);
- },
- removeByUUId: function(uuid) {
- return ciService.customDELETE('uuid/' + id, {}, { 'Content-Type': 'application/json' });
- },
- removeRefById: function(id) {
- return ciService.customDELETE(id + '/ref');
- },
- find: function(id) {
- return ciService.customGET(id);
- },
- searchkey: function(type, key, idx, sum) {
- return searchService.customGET(type + '/' + key + '/' + idx + '/' + sum);
- },
- findByUUId: function(uuid) {
- return ciService.customGET('?uuid=' + uuid);
- },
- query: function(data) {
- return ciService.customGET('query', data);
- },
- findRefById: function(id) {
- return ciService.customGET(id + '/refs');
- },
- finduuid: function(type, model) {
- return uuidService.customGET(type + '/' + model);
- },
- types: function() {
- return CMDBRestangular.customGET('types');
- },
- createRef: function(data) {
- return edgeService.customPOST(data, '', {});
- },
- putRef: function(data, id) {
- return edgeService.customPUT(data, '' + id, {});
- },
- removeRef: function(id) {
- return edgeService.customDELETE(id, {}, { 'Content-Type': 'application/json' });
- },
- traversal: function(uuid) {
- return traversal.customGET(uuid);
- },
- traversalRel: function(uuid, relation) {
- return traversal.customGET(uuid + '/' + relation + '/' + 'none');
- },
- export: function(label) {
- return exportService.customGET('nodes/' + label);
- },
- import: function() {
- return importService.one('/nodes');
- },
- download: function(label) {
- return downloadService.one('/label');
- },
- exportData: function(type, model) {
- return exportDataService.one(model + '/' + type);
- },
- downModels: function(type, model) {
- return exportModelService.one(model + '/' + type);
- }
- };
- }]);
- app.factory('MonitorRestangular', function(Restangular) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- RestangularConfigurer.setBaseUrl(serverIp + ':9004/services');
- });
- });
- app.factory('api_monitor', ['MonitorRestangular', function(MonitorRestangular) {
- //http://127.0.0.1:9004/services/ftpFile/monitor/bankTip/
- var process = MonitorRestangular.all("ftpFile/monitor");
- return {
- bankTip: function(id) {
- return process.customGET('bankTip/' + id);
- },
- list: function() {
- return process.customGET('list/1000');
- },
- devList: function(id) {
- return process.customGET('devList/' + id);
- },
- cpuList: function() {
- return process.customGET('cpuList/10');
- },
- memList: function() {
- return process.customGET('memList/10');
- },
- storageList: function() {
- return process.customGET('storageList/10');
- },
- transData: function() {
- return process.customGET('transData/5');
- },
- banklist: function() {
- return process.customGET('banklist');
- },
- app: function(id) {
- return process.customGET('app/' + id);
- },
- beita: function(id) {
- return process.customGET('beita/' + id);
- },
- gongji: function(id) {
- return process.customGET('gongji/' + id);
- }
- };
- }]);
- app.factory('ReportRestangular', function(Restangular) {
- return Restangular.withConfig(function(RestangularConfigurer) {
- //RestangularConfigurer.setBaseUrl('http://127.0.0.1:9005/api/cmdb/');
- RestangularConfigurer.setBaseUrl(reportIp + ':8080/saiku/rest');
- // RestangularConfigurer.setBaseUrl(serverIp+':8092/saiku/rest');
- //saiku/rest/saiku/api/query/execute/
- });
- });
- app.factory('api_report', ['ReportRestangular', 'Restangular', function(MonitorRestangular, Restangular) {
- var reportService = MonitorRestangular.all("saiku/api");
- var authService = MonitorRestangular.one("saiku/session");
- return {
- getLicenseKey: function() {
- return Restangular.one('assets/').customGET('api/reportToken.js');
- },
- // auth: function(){
- // return authService.customPOST('username=admin&password=admin&language=zh'
- // ,'', {}, {'Content-Type': 'application/x-www-form-urlencoded'});
- // },
- // session: function(){
- // return authService.customGET('');
- // },
- list: function() {
- return reportService.customGET('repository?type=saiku');
- /**
- /saiku/api/repository
- path: /homes/home:admin/itsm_reports
- */
- },
- getMdx: function(path, uuid) {
- var rdata = 'file=' + path + '&formatter=flattened&language=zh';
- return reportService.customPOST(rdata, 'query/' + uuid, {}, { 'Content-Type': 'application/x-www-form-urlencoded' });
- },
- execute: function(data) {
- return reportService.customPOST(data, 'query/execute', {}, { 'Accept': 'application/json, text/javascript, */*' });
- },
- exportData: function(reportView, uuid, reportfileName) {
- return reportService.one('query/rest/export/xls/?exportname=' + reportfileName + 'xls');
- }
- };
- }]);
- //图片展示canvas
- app.directive('ngThumb', ['$window', function($window) {
- var helper = {
- support: !!($window.FileReader && $window.CanvasRenderingContext2D),
- isFile: function(item) {
- return angular.isObject(item) && item instanceof $window.File;
- },
- isImage: function(file) {
- var type = '|' + file.type.slice(file.type.lastIndexOf('/') + 1) + '|';
- return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
- }
- };
- return {
- restrict: 'A',
- template: '<canvas/>',
- link: function(scope, element, attributes) {
- if (!helper.support) return;
- var params = scope.$eval(attributes.ngThumb);
- if (!helper.isFile(params.file)) return;
- if (!helper.isImage(params.file)) return;
- var canvas = element.find('canvas');
- var reader = new FileReader();
- reader.onload = onLoadFile;
- reader.readAsDataURL(params.file);
- function onLoadFile(event) {
- var img = new Image();
- img.onload = onLoadImage;
- img.src = event.target.result;
- }
- function onLoadImage() {
- var width = params.width || this.width / this.height * params.height;
- var height = params.height || this.height / this.width * params.width;
- canvas.attr({ width: width, height: height });
- canvas[0].getContext('2d').drawImage(this, 0, 0, width, height);
- }
- }
- };
- }]);
- app.factory('getLoginUser', ['$rootScope', '$http', '$q', 'ADDRESS', function($rootScope, $http, $q, address) {
- return {
- query: function() {
- var deferred = $q.defer(); // 声明延后执行,表示要去监控后面的执行
- $http({
- method: 'post',
- url: address.serverIp + address.serverIpPort + address.api + '/login',
- headers: { 'Content-Type': 'application/json' },
- data: {
- 'username': '005298',
- 'password': '888888'
- }
- }).success(function(data, status, headers, config) {
- // 当相应准备就绪时调用
- if (data.state == 201) {
- console.log(headers('access-token'));
- $rootScope.isToken = true;
- $rootScope['access-token'] = headers('access-token');
- if (data.data.user && data.data.user != '') {
- $rootScope.tokenType = 'user';
- var sessionLogin = {
- 'user': data.data.user,
- 'token': headers('access-token'),
- 'tokenType': 'user'
- }
- sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
- } else if (data.data.requester && data.data.requester != '') {
- $rootScope.tokenType = 'requester';
- var sessionLogin = {
- 'user': data.data.requester,
- 'token': headers('access-token'),
- 'tokenType': 'requester'
- }
- sessionStorage.sessionLogin = JSON.stringify(sessionLogin);
- }
- var loginUser = sessionLogin;
- deferred.resolve(loginUser); // 声明执行成功,即http请求数据成功,可以返回数据了
- }
- }).error(function(data, status, headers, config) {
- deferred.reject(data); // 声明执行失败,即服务器返回错误
- });
- return deferred.promise; // 返回承诺,这里并不是最终数据,而是访问最终数据的API
- } // end query
- };
- }]);
- //获取微信公众号配置数据
- app.factory('getWXJsConfig', ['Restangular', 'ADDRESS', function(Restangular, address) {
- // return Restangular.withConfig(function(RestangularConfigurer) {
- // // RestangularConfigurer.setBaseUrl(serverIp + ':9680/api/user/');
- // RestangularConfigurer.setBaseUrl(address.serverIp + address.serverIpPort + address.api + '/user/');
- // });
- var getWXJsConfig = Restangular.all(address.api + '/');
- return {
- getConfig: function(data) {
- return getWXJsConfig.customPOST(data, 'wechat/wechat/getJsConfig');
- }
- };
- }]);
- //获取消息通知数据
- app.factory('getCount', ['Restangular', 'ADDRESS', function(Restangular, address) {
- var getCount = Restangular.all(address.api + '/');
- return {
- count: function(data, url) {
- return getCount.customPOST(url, data);
- }
- };
- }]);
- //过滤时间
- app.filter('filterTime', function() {
- return function(text) {
- var time = text.split(" ");
- return time[0];
- }
- });
|