123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578 |
- 'use strict';
- /**
- * Clip-Two Main Controller
- */
- app.controller('AppCtrl', ['$rootScope', '$scope', '$state', '$translate', '$localStorage', '$cookieStore', '$window', '$modal', '$document', '$timeout', '$filter', '$auth', 'cfpLoadingBar', 'DDP', 'deskNotification', 'Restangular', 'api_login', 'api_text', 'api_user_data', 'api_wechatfile', 'api_bpm_data','jry_out',
- function ($rootScope, $scope, $state, $translate, $localStorage, $cookieStore, $window, $modal, $document, $timeout, $filter, $auth, cfpLoadingBar, DDP, deskNotification, Restangular, api_login, api_text, api_user_data, api_wechatfile, api_bpm_data,jry_out) {
- // Loading bar transition
- // -----------------------------------
- var $win = $($window);
- $rootScope.isMask = false;
- window.onbeforeunload = function () {
- $rootScope.statuscall = 0;
- $rootScope.statecall = 1;
- $rootScope.end();
- }
- // $win.on('beforeunload', function() { return $state.go("login.signin"); });
- // $auth.deleteData('auth_headers')
- // }
- $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
- if (!JSON.parse(sessionStorage.getItem('header'))) {
- if (isEmpty($auth.retrieveData('auth_headers'))) {
- if (toState.name != "login.signin") {
- window.location.href = serviceip;
- document.getElementById("casUserId").value = null;
- event.preventDefault();
- $scope.lodingstyle = 'nodata';
- $rootScope.app.isLoginFixed = true;
- // } else {
- // window.location.href = serviceip;
- // event.preventDefault();
- // $rootScope.app.isLoginFixed = true;
- }
- } else {
- $scope.login_sign();
- }
- } else {
- if (isEmpty($auth.retrieveData('auth_headers'))) {
- sessionStorage.clear();
- window.location.href = serviceip;
- $scope.lodingstyle = 'nodata';
- // $state.go("login.signin");
- } else {
- if (toState.name == "login.signin") {
- // $scope.loginstart();
- }
- }
- }
- if (toState.name != "app.incident.editor" && toState.name != "app.incident.title") {
- if ($scope.login && $rootScope.statecall == 2 && !$rootScope.busy) {
- $rootScope.setidle();
- }
- } else {
- if ($scope.login && !$rootScope.busy) {
- $rootScope.setbusy();
- }
- // $rootScope.isMask = true;
- }
- if (toState.name == "login.signin") {
- $scope.lodingstyle = 'nodata';
- }
- cfpLoadingBar.start();
- $auth.validateUser();
- });
- $rootScope.imUsrMap = {};
- $rootScope.onlineUser = [];
- $rootScope.offlineUser = [];
- $rootScope.me = undefined;
- $rootScope.imscope = {
- sessions: []
- }
- // var ws = new WebSocket('ws://192.168.3.51:8088/events');
- // var register= {"msgtype":"login","adn":"1001"};
- // ws.onopen = function() { ws.send(JSON.stringify(register));}
- // ws.onmessage = function(evt) { console.log(evt.data) }
- var ddp = new DDP('ws://115.156.150.70:3000/websocket');
- $rootScope.getDirectMsgRoomId = function (mdId, toId) {
- //me.id,to.id
- var rid = [mdId, toId].sort().join('');
- return rid;
- };
- $rootScope.sendMessage = function (rid, msg, callback, error) {
- ddp.call('sendMessage', [{ 'rid': rid, 'msg': msg }]).then(callback, error);
- };
- var pushNotification = function (notification) {
- deskNotification.showNotification(notification.title, {
- body: notification.body,
- icon: notification.icon || '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- onClick: notification.callback || function onNotificationClicked() {
- // console.log('Notification clicked.');
- },
- autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)
- }, function onShow(error, hide) {
- if (error) {
- window.alert('Unable to show notification: ' + error.message);
- } else {
- // console.log('Notification Shown.');
- setTimeout(function hideNotification() {
- // console.log('Hiding notification....');
- hide(); //manually close the notification (you can skip this if you use the autoClose option)
- }, 5000);
- }
- });
- }
- // $rootScope.subscribeRoomMessage = function(rid){
- // ddp.subscribe('stream-room-messages',[rid, true]).then(function(){},function(reason){
- // console.log('subscribe stream-room-messages:%o', reason);
- // });
- // }
- $rootScope.filternotifyuser = [];
- $rootScope.$on('openroom', function (event, data, otheruser) {
- ddp.call('createDirectMessage', [otheruser]).then(function () { }, function (reason) {
- // console.log('createDirectMessage', reason);
- });
- ddp.subscribe('stream-room-messages', [data.rid, true]).then(function () { }, function (reason) {
- // console.log('subscribe stream-room-messages:%o', reason);
- });
- if ($rootScope.imUsrMap[data.from]['unread'].msgs) {
- $rootScope.imUsrMap[data.from]['unread'].msgs.clear;
- }
- $rootScope.filternotifyuser.push(data.from);
- });
- $rootScope.$on("clip-two.toggled", function (e, target, newState, sameGroup) {
- if (newState == false && target == 'off-sidebar') {
- $rootScope.$broadcast('chatcloseroom');
- //$rootScope.toggle("users");
- //$rootScope.filternotifyuser = [];
- //ddp.unsubscribe('stream-room-messages');
- }
- });
- $rootScope.$on("closeroom", function (event, data) {
- $rootScope.filternotifyuser = [];
- ddp.unsubscribe('stream-room-messages');
- });
- var initImUser = function (email, token) {
- var ddpconnect = ddp.connect();
- ddpconnect.then(function (data) {
- //console.log(data);
- if (data.session) {
- // ddp.call('createDirectMessage', [data.from, data.rid]).then(function() {}, function(reason) {
- // console.log('subscribe createDirectMessage');
- // });
- ddp.call('login', [{ user: { email: email }, password: token }]).then(function (data) {
- // console.log('login data: %o', data);
- if (data.id) {
- $rootScope.me = {
- id: data.id,
- token: data.token,
- expiry: data.tokenExpires
- };
- //获取在线用户
- ddp.subscribe('activeUsers');
- ddp.subscribe('stream-notify-user', [$rootScope.me.id + '/notification', true]).then(function (result) {
- //console.log(result);
- }, function (reason) {
- // console.log('stream-notify-user error:%s', reason);
- });
- // ddp.subscribe('stream-notify-user',[$rootScope.me.id+'/message',false]).then(function(result){
- // console.log(result);
- // },function(reason){
- // console.log('stream-notify-user error:', reason);
- // });
- ddp.subscribe('messages', [$rootScope.me.id + '/message', true]).then(function () { }, function (reason) {
- // console.log('subscribe messages error:%s', reason);
- });
- //'stream-notify-user',$rootScope.me.id+'/message'
- // ddp.call('sendmessage', []).then(function(msg){
- // })
- //console.log('Logged in!');
- // ddp.subscribe('messages', [{rid:data.id,start:new Date()}]).then(function(submsg){
- // console.log('subscribe messages-%s', submsg);
- // $rootScope.rocketchat_message = ddp.getCollection('rocketchat_message');
- // },function(reason){
- // console.log(reason);
- // })
- }
- }, function (reason) {
- // console.log(reason);
- });
- } else {
- }
- ddp.watch('users', function (changedDoc, message) {
- //console.log('users:%o',changedDoc);
- // if (message == 'method') {
- // console.log("1111111111111111111")
- // }
- if (message == 'added') {
- if (changedDoc.status && ($rootScope.me.id != changedDoc._id)) {
- if (changedDoc.status == 'away') {
- $rootScope.offlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
- } else {
- $rootScope.onlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
- }
- } else {
- //self
- }
- } else if (message == 'changed') {
- if ($rootScope.me.id != changedDoc._id) {
- if (!$rootScope.imUsrMap[changedDoc._id]) {
- if (changedDoc.status == 'away') {
- $rootScope.offlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
- } else {
- $rootScope.onlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
- }
- }
- if (changedDoc.status == 'away') {
- if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
- } else {
- $rootScope.offlineUser.push(changedDoc);
- $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- window._.map(window._.slice($rootScope.onlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
- $rootScope.imUsrMap[item._id].index = n;
- })
- // $rootScope.onlineUser = window._.take($rootScope.onlineUser,$rootScope.imUsrMap[changedDoc._id].index).concat(window._.map(window._.slice($rootScope.onlineUser,$rootScope.imUsrMap[changedDoc._id].index+1),function(item){
- // item.index = item.index - 1;
- // }))
- //.splice($rootScope.imUsrMap[changedDoc.id].index,1);
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.offlineUser.length };
- }
- } else {
- if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
- $rootScope.onlineUser.push(changedDoc);
- $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
- $rootScope.imUsrMap[item._id].index = n;
- })
- // $rootScope.offlineUser = window._.take($rootScope.offlineUser,$rootScope.imUsrMap[changedDoc._id].index).concat(window._.map(window._.slice($rootScope.offlineUser,$rootScope.imUsrMap[changedDoc._id].index+1),function(item){
- // item.index = item.index - 1;
- // }))
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length };
- } else {
- }
- }
- }
- } else if (message == 'removed') {
- if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
- } else {
- $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
- $rootScope.imUsrMap[item._id].index = n;
- });
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length, unread: { total: 0, msgs: [] } };
- }
- }
- });
- ddp.watch('stream-notify-user', function (changedDoc, message) {
- if (message == 'changed') {
- if (changedDoc.eventName) {
- if (changedDoc.eventName.indexOf('/') > -1) {
- var mineId = changedDoc.eventName.split('/');
- var action = mineId;
- if (action == 'notification') {
- angular.forEach(changedDoc.args, function (item) {
- if ($rootScope.filternotifyuser.indexOf(item.payload.sender._id) > -1) {
- } else {
- // console.log("push notify message:%o", item);
- var r = angular.extend(item, { 'date': new Date() })
- $rootScope.imUsrMap[item.payload.sender._id]['unread'].msgs.push(r);
- $rootScope.imUsrMap[item.payload.sender._id]['unread'].total++;
- pushNotification({
- title: "您有新消息-来自" + item.payload.sender.username,
- body: r.text,
- callback: function () {
- window.focus();
- $rootScope.toggle('off-sidebar');
- }
- })
- //toaster.pop('info', "您有新消息-来自"+item.payload.sender.username, r.text);
- }
- })
- }
- }
- }
- } else {
- }
- //console.log('notify message %o, %o', changedDoc, message);
- });
- ddp.watch('stream-room-messages', function (changedDoc, message) {
- if (message == 'changed') {
- //angular.forEach(changedDoc.args,function(item){
- $rootScope.$broadcast(changedDoc.eventName + '-msgs', changedDoc.args);
- //};
- // if(changedDoc.eventName){
- // $rootScope.imUsrMap[eventName]=$rootScope.imUsrMap[eventName]||{};
- // $rootScope.imUsrMap[eventName]['msgs']=$rootScope.imUsrMap[eventName]['msgs']||[];
- // angular.forEach(changedDoc.args,function(item){
- // $rootScope.imUsrMap[eventName].msgs.push(item);
- // })
- // }
- } else {
- }
- // console.log('notify message %o, %o', changedDoc, message);
- });
- ddp.watch('rocketchat_message', function (changedDoc, message) {
- // console.log('recieve rocketchat_message: %o-%o', changedDoc, message);
- });
- });
- }
- window.onunload = function () {
- }
- $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
- //$auth.validateUser();
- //stop loading bar on stateChangeSuccess
- event.targetScope.$watch("$viewContentLoaded", function () {
- cfpLoadingBar.complete();
- });
- // scroll top the page on change state
- $document.scrollTo(0, 0);
- if (angular.element('.email-reader').length) {
- angular.element('.email-reader').animate({
- scrollTop: 0
- }, 0);
- }
- // Save the route title
- $rootScope.currTitle = $state.current.title;
- if (angular.isDefined($state.current.pdKey)) {
- $rootScope.pdKey = $state.current.pdKey;
- }
- // console.log($state.current.title);
- });
- // State not found
- $rootScope.$on('$stateNotFound', function (event, unfoundState, fromState, fromParams) {
- //$rootScope.loading = false;
- if (angular.isUndefined($rootScope.user.id)) {
- $rootScope.loading = false;
- }
- // console.log(unfoundState.to);
- // "lazy.state"
- // console.log(unfoundState.toParams);
- // {a:1, b:2}
- // console.log(unfoundState.options);
- // {inherit:false} + default options
- });
- $rootScope.$on('auth:login-success', function (ev, data) {
- // $state.go('login.signin');
- initImUser(data.email, data.msgUuid);
- getMenus();
- //console.log(data);
- //$rootScope.user = data.user;
- //$rootScope.menus = data.menu;
- });
- //$rootScope.$watch('$auth.user')
- $rootScope.$on('auth:validation-success', function (ev, user) {
- // console.log(user);
- initImUser(user.email, user.msgUuid);
- if ($rootScope.userMenus.length == 0) {
- getMenus();
- }
- //alert('Welcome ', user.email);
- });
- $rootScope.$on('auth:invalid', function (ev) {
- $state.go('login.signin');
- });
- $rootScope.$on('auth:validation-error', function (ev) {
- $state.go('login.signin');
- //alert('Welcome ', user.email);
- });
- $rootScope.$on('auth:session-expired', function (ev) {
- //alert('Welcome ', user.email);
- $state.go('login.signin');
- });
- $rootScope.$on('auth:logout-success', function (ev) {
- //alert('goodbye');
- //delete $rootScope.user;
- //delete $rootScope.menus;
- $state.go('login.signin');
- });
- $rootScope.$on('auth:logout-error', function (ev) {
- $state.go('login.signin');
- });
- $rootScope.pageTitle = function () {
- // if($rootScope.currTitle){
- // return $rootScope.app.name + ' - ' + $filter('translate')($rootScope.currTitle) || $rootScope.app.description;
- // }else{
- // return $rootScope.app.name + ' - ' + $rootScope.app.description
- // }
- var perfix = "sidebar.nav.";
- var toTransKeypageTitle = perfix + $rootScope.currTitle;
- return $rootScope.app.name + ' - ' + ($filter('translate')(toTransKeypageTitle) || $rootScope.app.description);
- };
- // $auth.validateUser();
- // $auth.authenticate('local').then(function(resp){
- // }).catch(function(resp){
- // })
- // if(angular.isDefined($rootScope.nickname)){
- // api_login.sso($rootScope.nickname).then(function(response){
- // var user = Restangular.stripRestangular(response);
- // if (user) {
- // if(angular.isUndefined(user.id)){
- // }else{
- // $rootScope.user = user;
- // }
- // }
- // });
- // }else{
- // var user= $cookieStore.get("userObm");
- // if(user){
- // $rootScope.user = user;
- // $rootScope.menus = $cookieStore.get("menuObm");
- // }else{
- // if(angular.isDefined($rootScope.nickname)){
- // api_login.sso($rootScope.nickname).then(function(response){
- // var data = Restangular.stripRestangular(response);
- // if (data) {
- // if(data.user){
- // if(angular.isUndefined(data.user.id)){
- // }else{
- // $rootScope.user = data.user;
- // $rootScope.menus = data.menu;
- // $cookieStore.put("userObm", $rootScope.user);
- // $cookieStore.put("menuObm", $rootScope.menus);
- // $cookieStore.put("session", data.sessionId);
- // }
- // }
- // }
- // });
- // }else{
- // }
- // }
- //}
- $rootScope.getSession = function () {
- if ($auth.userIsAuthenticated()) {
- return $auth.retrieveData('auth_headers')
- /*return {
- 'access-token':$auth.retrieveData('auth_headers')['access-token'],
- 'expiry':$auth.retrieveData('auth_headers')['expiry']
- };*/
- } else {
- return undefined;
- }
- }
- $scope.includes = [];
- $rootScope.includesState = function (state) {
- //for test
- //return true;
- //return includes;
- if ($rootScope.user) {
- if ($rootScope.user.menu) {
- angular.forEach($rootScope.user.menu, function (item) {
- $scope.includes[item.link] = true;
- });
- }
- }
- return $scope.includes[state];
- }
- // $rootScope.authority=false;
- // console.log($rootScope.user)
- // if($rootScope.user.role){
- // for(var i ;i<$rootScope.user.role.length;i++){
- // if($rootScope.user.role[i].rolecode=='call center') {
- // $rootScope.authority=true;
- // }else{$rootScope.authority=false;}
- // }
- // }
- /* status[已签入:1/通话中:3/来电:2],state[示闲:1,示忙:2] */
- $rootScope.statuscall = 0; //话机状态
- $rootScope.statecall = 1; //示忙示闲
- $scope.login = false; //签入签出
- $rootScope.callout = false; //呼入呼出
- $scope.group = 2000;
- $scope.phone = 1500;
- if ($rootScope.user.LoginExtension) {
- $rootScope.start($rootScope.user.LoginExtension);
- }
- // $scope.runNumber = [{
- // id: 1,
- // name: 1501
- // }, {
- // id: 2,
- // name: 1502
- // }]
- // api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function(data) {
- // if (data.status == 200) {
- // $scope.runNumber = data.list;
- // }
- // })
- // $scope.phone = $scope.runNumber[0].name;
- $rootScope.start = function (phone) {
- api_text.start(phone, $rootScope.user.id).then(function (data) {
- var token = data.token;
- $rootScope.takes = token;
- api_text.logout($rootScope.takes, $rootScope.user.id).then(function (data) { if (data.errno == 0) { } });
- api_text.login($scope.group, token, $rootScope.user.id).then(function (data) {
- if (data.errno == 0) {
- $rootScope.setidle();
- $scope.login = true;
- $rootScope.statuscall = 1;
- $rootScope.callout = false;
- // function hello() {
- // var ws = new WebSocket('ws://192.168.3.49:28088/events');
- // ws.onopen = function() { ws.send(JSON.stringify(register)); };
- // };
- // window.setTimeout("hello()", 1000);
- // var ws = new WebSocket('ws://192.168.77.57:28088/events');
- function reconnect() {
- // var ws = new WebSocket('ws://192.168.3.49:28088/events');
- var ws = new WebSocket('ws://115.156.150.70:28088/events');
- var register = { "msgtype": "login", "adn": phone };
- ws.onopen = function () {
- heartCheck.start();
- ws.send(JSON.stringify(register));
- };
- ws.onmessage = function (evt) {
- heartCheck.reset();
- if (evt.data == "HeartBeat") {
- } else {
- var mydata = JSON.parse(evt.data);
- $scope.filterData = [];
- if (mydata.evttype == "callincome" && mydata.uud != "misc:callback") {
- $rootScope.$apply(function () {
- $rootScope.statuscall = 2;
- $rootScope.callout = false;
- });
- $rootScope.phone = mydata.ano;
- var Notification = window.Notification;
- Notification.requestPermission();
- var n = new Notification("你有来电", {
- body: "来电号码:" + mydata.ano,
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- // onclick: function onNotificationClicked() {
- // console.log('Notification clicked.');
- // }
- });
- } else if (mydata.evttype == "callincome" && mydata.uud == "misc:callback") {
- $rootScope.callout = true;
- } else if (mydata.evttype == "ringstop") {
- // $rootScope.status=7;
- // $rootScope.$apply(function() {
- $rootScope.statuscall = 1;
- // });
- $rootScope.phone = ""
- } else if (mydata.evttype == 'hookchanged' && $rootScope.callout) {
- if (mydata.status && mydata.status == '1') {
- $rootScope.$apply(function () {
- $rootScope.statuscall = 1;
- });
- $rootScope.phone = "";
- } else if (mydata.status && mydata.status != '1') {
- $rootScope.$apply(function () {
- $rootScope.statuscall = 3;
- });
- }
- } else if (mydata.evttype == 'hookchanged' && !$rootScope.callout) {
- if ($rootScope.phone != "") {
- if (mydata.status && mydata.status == '1') { //挂机
- $rootScope.$apply(function () {
- $rootScope.statuscall = 1;
- });
- // console.log("挂机");
- if ($rootScope.statecall == 1 && !$rootScope.isSetidle) {
- $rootScope.setbusy();
- }
- } else if (mydata.status && mydata.status != '1' && $rootScope.statecall != 2 && !$rootScope.callout) { //摘机
- $rootScope.status = 6
- $rootScope.statuscall = 3;
- $rootScope.isSetidle = false;
- $rootScope.app.layout.isSidebarClosed = true;
- // console.log("摘机");
- // console.log(mydata);
- api_text.getcdrid($rootScope.takes).then(function (response) {
- if (response.cdrid) {
- var cdrid = response.cdrid;
- // var response={cdrid:'219023836'}
- var filterData = { "idx": 0, "sum": 10, "requester": { "mphone": $rootScope.phone, "telephone": $rootScope.phone, "selectType": 1 } }
- api_user_data.fetchDataList('requester', filterData).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- // $rootScope.phone="";
- if (myData.list.length == 0) {
- var modalInstance = $modal.open({
- backdrop: "static",
- templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
- controller: function ($scope, $modalInstance, api_user_data, SweetAlert) {
- $scope.title = "新增报修人";
- $scope.requester = {};
- $scope.onChangeadd = function (searchData) {
- $scope.searchKey = searchData.account;
- // $scope.searchDataadd = searchData;
- var requesdata = angular.copy(searchData)
- // if (requesdata.mphone) {
- // delete requesdata.mphone;
- // }
- if (requesdata.telephone) {
- delete requesdata.telephone;
- }
- angular.extend($scope.requester, requesdata);
- }
- $scope.refreshUseradd = function (searchKey) { //请求人搜索
- $scope.requester.account = searchKey;
- $scope.searchData = searchKey;
- serchdataadd(searchKey);
- }
- $scope.getMydata = function (x) {
- var reqestdatap = JSON.parse(x[0])
- // if ($scope.requester.mphone) {
- // delete reqestdatap.mphone;
- // }
- if ($scope.requester.telephone) {
- delete reqestdatap.telephone;
- }
- $scope.searchField = JSON.parse(x[0]).account;
- angular.extend($scope.requester, reqestdatap);
- if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
- api_user_data.fetchDataList('place', { place: { areaId: $scope.requester.areaDTO.id }, idx: 0, sum: 1000 }).then(function (response) {
- if (response.status == 200) {
- $scope.places = response.list;
- }
- })
- }
- }
- $scope.getMydataone = function (x) {
- $scope.searchField = x;
- $scope.requester.account = x;
- }
- serchdataadd();
- function serchdataadd(searchKey) {
- if (searchKey) {
- var filterData = {
- 'requester': {
- 'searchKey': searchKey,
- },
- idx: 0,
- sum: 10
- };
- } else {
- var filterData = {
- idx: 0,
- sum: 10
- };
- }
- api_user_data.fetchDataList('requester', filterData).then(function (response) {
- var myData = response;
- $scope.myData = myData.list;
- });
- }
- api_user_data.fetchDataList('area', { idx: 0, sum: 100 }).then(function (response) {
- if (response.status == 200) {
- $scope.areas = response.list;
- }
- })
- // api_user_data.fetchDataList('place', { idx: 0, sum: 1000 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.places = response.list;
- // }
- // }) //地点
- api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function (response) {
- if (response.status == 200) {
- $scope.networktypes = response.list;
- }
- })
- $scope.requesterAreaid = "";
- $scope.onChange = function (item) {
- $scope.requesterAreaid = item.id;
- $scope.requester.placeDTO = {};
- api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function (response) {
- if (response.status == 200) {
- $scope.places = response.list;
- }
- })
- }
- //地点搜索
- $scope.refresh = function (searchVal) {
- var faildata = {};
- if ($scope.requesterAreaid) {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': { 'areaId': $scope.requesterAreaid, 'place': searchVal, 'selectType': 'pinyin_qs' }
- }
- } else {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': { 'place': searchVal, 'selectType': 'pinyin_qs' }
- }
- }
- api_user_data.fetchDataList('place', faildata).then(function (response) {
- $scope.places = response.list;
- delete $scope.requester.placeDTO;
- })
- }
- $scope.requester = { 'telephone': $rootScope.phone };
- $scope.ok = function () {
- // $modalInstance.close($scope.requester);
- if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
- SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
- } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
- SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
- } else {
- $modalInstance.close($scope.requester);
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- $rootScope.setidle();
- };
- },
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- if (selectedItem.telephone && !selectedItem.mphone) {
- selectedItem.telephone = angular.copy(selectedItem.mphone);
- delete selectedItem.mphone;
- }
- var data = {
- 'requester': selectedItem
- };
- api_user_data.addData('requester', data).then(function (response) {
- if (response.status == 200) {
- var data = { 'model': { 'requestershow': response.data, 'incident': { 'requester': response.data, 'area': response.data.areaDTO, 'place': response.data.placeDTO, 'houseNumber': response.data.houseNumber, 'contactsInformation': response.data.telephone, 'callID': cdrid, 'source': { 'id': 1 } } } }
- $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- }
- })
- }
- });
- } else if (myData.list.length == 1) {
- angular.extend(myData.list[0], { 'telephone': $rootScope.phone });
- var data = { 'model': { 'requestershow': myData.list[0], 'incident': { 'requester': myData.list[0], 'area': myData.list[0].areaDTO, 'place': myData.list[0].placeDTO, 'contactsInformation': myData.list[0].telephone, 'houseNumber': myData.list[0].houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
- $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/createincident.html',
- backdrop: "static",
- controller: function ($scope, $modalInstance, api_user_data) {
- $scope.title = "请确定报修人";
- $scope.requester = myData.list;
- $scope.choice = function (requester) {
- $modalInstance.dismiss('cancel');
- angular.extend(requester, { 'telephone': $rootScope.phone });
- var data = { 'model': { 'requestershow': requester, 'incident': { 'requester': requester, 'area': requester.areaDTO, 'place': requester.placeDTO, 'houseNumber': requester.houseNumber, 'contactsInformation': requester.telephone, 'callID': cdrid, 'source': { 'id': 1 } } } }
- $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- $rootScope.setidle();
- };
- },
- size: "lg"
- });
- }
- });
- }
- })
- }
- }
- }
- }
- };
- var heartCheck = {
- timeout: 12000, //60ms
- timeoutObj: null,
- serverTimeoutObj: null,
- reset: function () {
- clearTimeout(this.timeoutObj);
- clearTimeout(this.serverTimeoutObj);
- this.start();
- },
- start: function () {
- var self = this;
- this.timeoutObj = setTimeout(function () {
- ws.send("HeartBeat");
- self.serverTimeoutObj = setTimeout(function () {
- ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
- }, self.timeout)
- }, this.timeout)
- },
- }
- ws.onclose = function (evt) { reconnect(); }
- ws.onerror = function (evt) { reconnect(); };
- }
- reconnect();
- } else {
- var Notification = window.Notification;
- Notification.requestPermission();
- var n = new Notification("签入失败!", {
- body: data.errmsg,
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- // onclick: function onNotificationClicked() {
- // console.log('Notification clicked.');
- // }
- });
- }
- })
- })
- }
- $scope.onChangeadd = function (searchData) {
- $scope.searchKey = searchData.account;
- // $scope.searchDataadd = searchData;
- var requesdata = angular.copy(searchData)
- $scope.requester = requesdata;
- }
- $scope.refreshUseradd = function (searchKey) { //主题搜索
- $scope.searchData = searchKey;
- reashdata($scope.searchData);
- }
- $scope.getMydata = function (x) {
- $scope.telephone = JSON.parse(x).phone;
- $scope.searchField = $scope.telephone;
- return $scope.searchField;
- }
- $scope.getMydataone = function (x) {
- $scope.telephone = x;
- $scope.searchField = $scope.telephone;
- }
- $scope.fildata = {
- "idx": 0,
- "sum": 10,
- "flag": -1
- }
- function reashdata(item) {
- if (item && item != "") {
- angular.extend($scope.fildata, { 'user': { 'flag': -1, 'phone': item } })
- } else {
- delete $scope.fildata.user;
- }
- api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function (data) {
- if (data.status == 200) {
- $scope.myData = data.list;
- }
- })
- // api_user_data.fetchDataList('user', $scope.fildata).then(function(response) {
- // if (response) {
- // if (response.status = 200) {
- // var myData = response;
- // $scope.myData = myData.list;
- // }
- // }
- // })
- }
- reashdata();
- $rootScope.end = function () {
- api_text.logout($rootScope.takes, $rootScope.user.id).then(function (data) {
- if (data.errno == 0) {
- api_text.exit($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 0;
- $scope.login = false
- // SweetAlert.swal({
- // title: "登出成功",
- // text: "呼叫中心登出成功!",
- // type: "success"
- // });
- // }else{SweetAlert.swal({
- // title: "登出失败",
- // text: "呼叫中心登出失败!",
- // type: "error"
- // });
- }
- })
- }
- })
- }
- $rootScope.dialout = function (gid, teleno) {
- var telephone = "";
- if (teleno && teleno.length > 4) {
- telephone = '9' + teleno;
- } else {
- // telephone = '*01' + teleno + '*';
- telephone = teleno;
- }
- api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
- if (data.errno == 0) {
- // $rootScope.statuscall = 3;
- $rootScope.callout = true;
- $rootScope.login = false;
- // $rootScope.phone=teleno;
- }
- })
- }
- $rootScope.busy = false;
- $rootScope.setbusy = function (key) {
- api_text.setbusy($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statecall = 2;
- if (key && key == 1) {
- $rootScope.busy = true;
- }
- }
- })
- }
- $rootScope.setidle = function () {
- api_text.setidle($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statecall = 1;
- $rootScope.busy = false;
- }
- })
- }
- $rootScope.inittrans = function (telephone) {
- api_text.inittrans(telephone, $rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- // $scope.status=9
- }
- })
- }
- $rootScope.comptrans = function () {
- api_text.comptrans($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 1;
- }
- })
- }
- $rootScope.takeup = function () {
- api_text.offhook($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 3;
- }
- })
- }
- $rootScope.takedown = function () {
- api_text.onhook($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 1;
- }
- })
- }
- $rootScope.saveData = function (selectdata) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/system/tpl/createknowledge.html',
- controller: function ($scope, $modalInstance, api_bpm_data) {
- $scope.worktimedata = {};
- $scope.worktimedata = selectdata;
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- $scope.savercode = function (worktimedata) {
- var fildata = {
- "scheduleclass": {
- "id": selectdata.id,
- "code": worktimedata.code,
- "name": worktimedata.title,
- "person": worktimedata.person,
- "description": worktimedata.description,
- "startTime": worktimedata.startTime,
- "endTime": worktimedata.endTime,
- "shiftTime": selectdata.shiftTime,
- "succeedTime": selectdata.succeedTime,
- "isTemplate": worktimedata.isTemplate
- }
- }
- api_bpm_data.updData('scheduleclass', fildata).then(function (response) {
- if (response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "修改成功!",
- type: "success"
- }, function () {
- // $scope.refreshData('expand-right', defaultFilterData);
- })
- } else {
- SweetAlert.swal({
- title: "修改失败!",
- type: "error"
- })
- }
- }
- })
- $modalInstance.close();
- }
- }
- });
- }
- $rootScope.changepassword = function (data1, size) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/changepassword.html',
- controller: function ($scope, $modalInstance, items, Restangular, SweetAlert) {
- $scope.passwordnull = function (originalPwd, pwd, pwd_2) {
- return originalPwd == undefined || pwd == undefined || pwd_2 == undefined || originalPwd == "" || pwd == "" || pwd_2 == "" || originalPwd == "null" || pwd == "null" || pwd_2 == "null";
- }
- $scope.savepassword = function (originalPwd, pwd, pwd_2) {
- $modalInstance.dismiss('cancel');
- // console.log('pwd=' + pwd + '+' + pwd_2);
- // if(angular.isDefined(pwd)&&angular.isDefined(pwd_2)){
- if (pwd == pwd_2) {
- var data2 = {};
- data2["originalPwd"] = originalPwd;
- data2["userid"] = $rootScope.user.id;
- data2["pwd"] = pwd;
- api_login.uppwd(data2).then(function (response) {
- var myData = Restangular.stripRestangular(response);
- if (myData.status == 200) {
- SweetAlert.swal({
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- });
- } else {
- SweetAlert.swal({
- title: "保存失败!",
- text: "输入旧密码错误,请重新输入!",
- type: "error"
- });
- }
- })
- } else {
- SweetAlert.swal({
- title: "两次输入的新密码不相同!",
- text: "输入错误,请重新输入!",
- type: "error"
- });
- }
- // }else{
- // SweetAlert.swal({
- // title: "密码不能为空!",
- // text: "请输入密码!",
- // type: "error"
- // });
- // }
- }
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) { }
- };
- },
- }
- });
- }
- // $rootScope.getnochildpending = function() {
- // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
- // angular.forEach($rootScope.userMenus, function(item) {
- // item.tipnum = 1;
- // })
- // }
- // }
- // $rootScope.getchildpending = function(cantdata) {
- // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
- // angular.forEach($rootScope.userMenus, function(item) {
- // item.tipnum = 1;
- // angular.forEach(item, function(index) {
- // index.tipnum = 18;
- // })
- // })
- // }
- // }
- function getpending() {
- if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
- if ($rootScope.user.group) {
- api_bpm_data.getCount({ "assignee": $rootScope.user.id, "candidateGroups": $rootScope.user.group[0].id, "idx": 0, "sum": 1000 }).then(function (response) {
- angular.forEach($rootScope.userMenus, function (item, i) {
- item.tipshow = false;
- if (response) {
- if (response.hjzxCount > 0 || response.wechatWarningCount > 0) {
- if (item.id == 58) {
- item.tipshow = true;
- }
- }
- if (response.inspectionCount > 0) {
- if (item.id == 27) {
- item.tipshow = true;
- }
- }
- if (response.incidentCount > 0) {
- if (item.id == 2) {
- item.tipshow = true;
- }
- }
- if ((parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
- if (item.id == 21) {
- item.tipshow = true;
- }
- }
- if (item.children) {
- angular.forEach(item.children, function (index) {
- if (response.hjzxCount && response.hjzxCount > 0) {
- if (index.id == 1208) {
- if (response.hjzxCount < 100) {
- index.tipnum = response.hjzxCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.wechatWarningCount && response.wechatWarningCount > 0) {
- if (index.id == 59) {
- if (response.hjzxCount < 100) {
- index.tipnum = response.wechatWarningCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.inspectionCount && response.inspectionCount > 0) {
- if (index.id == 147) {
- if (response.inspectionCount < 100) {
- index.tipnum = response.inspectionCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.incidentCount && response.incidentCount > 0) {
- if (index.id == 3) {
- if (response.incidentCount < 100) {
- index.tipnum = response.incidentCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.toAuditCount && response.toReleaseCount && (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
- if (index.id == 23) {
- if (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount) < 100) {
- index.tipnum = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
- } else {
- index.tipnum = "99+";
- }
- }
- }
- })
- }
- }
- })
- // return $rootScope.userMenus;
- // $scope.recordpending = response.;
- // $scope.dashboardcount.knowledgedata = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
- })
- } else {
- // SweetAlert.swal("访问数据失败!", "该用户没有分配组", "error");
- }
- }
- // console.log($rootScope.userMenus);
- }
- $rootScope.userMenus = [];
- var getMenus = function () {
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- // data[i].id = Number(data[i].id);
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parentid === "undefined" || datum.parentid == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parentid];
- //We don't need this property, so let's delete it.
- //delete datum.parentid;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- list = window._.sortBy(list, function (o) {
- return o.orders;
- });
- return list;
- }
- //if(userMenus.length==0){
- var userMenus = [];
- var idMapMenu = {};
- if ($rootScope.user) {
- if ($rootScope.user.menu) {
- userMenus = convertParentToChildList($rootScope.user.menu);
- }
- }
- //}
- $rootScope.userMenus = userMenus;
- if ($rootScope.userMenus.length > 0) {
- getpending();
- setInterval(getpending, 30000);
- }
- return userMenus;
- }
- getMenus();
- // console.log("$rootScope.nickname="+JSON.stringify($rootScope));
- $rootScope.logout = function () {
- console.log("ok");
- // var userid =data.id;
- // console.log(' userid='+JSON.stringify( userid));
- // $auth.signOut()
- // .then(function(resp) {
- // document.getElementById("casUserId").value = null;
- // $auth.deleteData('auth_headers')
- // sessionStorage.clear();
- // window.location.href = serviceip;
- // })
- jry_out.jry_remove({})
- .then(function (resp) {
- // console.log(' resp1='+JSON.stringify( resp));
- $rootScope.userMenus = [];
- sessionStorage.clear();
- // handle success response
- })
- .catch(function (resp) {
- // console.log(' resp2='+JSON.stringify( resp));
- $state.go('login.signin');
- // handle error response
- });
- window.location.href = serviceip;
- // .catch(function(resp) {});
- //$cookieStore.remove("userObm");
- //$cookieStore.remove("menuObm");
- //$cookieStore.remove("session");
- //$rootScope.user = undefined;
- //$rootScope.menus = undefined;
- //$rootScope.nickname = undefined;
- //window.location = "http://www.itsm.com:8080/itsm/dev/logout.jsp";
- // //logout: function(noServerLogout){
- // window.sessionStorage.clear();
- // window.location = "https://www.yunwei.com:8443/cas/loginout";
- // //},
- }
- // save settings to local storage
- if (angular.isDefined($localStorage.layout)) {
- $scope.app.layout = $localStorage.layout;
- } else {
- $localStorage.layout = $scope.app.layout;
- }
- $scope.$watch('app.layout', function () {
- // save to local storage
- $localStorage.layout = $scope.app.layout;
- }, true);
- //global function to scroll page up
- $scope.toTheTop = function () {
- $document.scrollTopAnimated(0, 600);
- };
- // angular translate
- // ----------------------
- $scope.language = {
- // Handles language dropdown
- listIsOpen: false,
- // list of available languages
- available: {
- 'en': 'English',
- 'it_IT': 'Italiano',
- 'de_DE': 'Deutsch',
- 'zh_cn': 'Chinese'
- },
- // display always the current ui language
- init: function () {
- var proposedLanguage = $translate.proposedLanguage() || $translate.use();
- var preferredLanguage = $translate.preferredLanguage();
- // we know we have set a preferred one in app.config
- $scope.language.selected = $scope.language.available[(proposedLanguage || preferredLanguage)];
- },
- set: function (localeId, ev) {
- $translate.use(localeId);
- $scope.language.selected = $scope.language.available[localeId];
- $scope.language.listIsOpen = !$scope.language.listIsOpen;
- }
- };
- $scope.language.init();
- // Function that find the exact height and width of the viewport in a cross-browser way
- var viewport = function () {
- var e = window,
- a = 'inner';
- if (!('innerWidth' in window)) {
- a = 'client';
- e = document.documentElement || document.body;
- }
- return {
- width: e[a + 'Width'],
- height: e[a + 'Height']
- };
- };
- // function that adds information in a scope of the height and width of the page
- $scope.getWindowDimensions = function () {
- return {
- 'h': viewport().height,
- 'w': viewport().width
- };
- };
- // Detect when window is resized and set some variables
- $scope.$watch($scope.getWindowDimensions, function (newValue, oldValue) {
- $scope.windowHeight = newValue.h;
- $scope.windowWidth = newValue.w;
- if (newValue.w >= 992) {
- $scope.isLargeDevice = true;
- } else {
- $scope.isLargeDevice = false;
- }
- if (newValue.w < 992) {
- $scope.isSmallDevice = true;
- } else {
- $scope.isSmallDevice = false;
- }
- if (newValue.w <= 768) {
- $scope.isMobileDevice = true;
- } else {
- $scope.isMobileDevice = false;
- }
- }, true);
- // Apply on resize
- $win.on('resize', function () {
- $scope.$apply();
- });
- // if (!isEmpty($auth.retrieveData('auth_headers'))) {
- // } else {
- // $scope.loginstart();
- // }
- // $scope.loginstart = function() {
- // if (!isEmpty($auth.retrieveData('auth_headers'))) {
- // } else {
- $rootScope.app.layout.isNavbarFixed = false;
- $rootScope.app.layout.isSidebarFixed = false;
- $rootScope.app.layout.isFooterFixed = false;
- $scope.choicevalue = 1
- $scope.choicelogin = function (e) {
- $scope.choicevalue = e;
- }
- $scope.loginForm = {
- username: "",
- // account:"",
- password: ""
- }
- $rootScope.app.isLoginFixed = true;
- $scope.validateUsername = function () {
- return $scope.loginForm.username == null || $scope.loginForm.username == "";
- }
- $scope.validatePassword = function () {
- return $scope.loginForm.password == null || $scope.loginForm.password == "";
- }
- $scope.formValid = function () {
- return $scope.loginForm.username == null || $scope.loginForm.username == "" || $scope.loginForm.password == null || $scope.loginForm.password == "";
- }
- $rootScope.$on('auth:invalid', function (ev) {
- $state.go('login.signin');
- });
- $scope.casUserId = { 'password': '888888', 'username': document.getElementById("casUserId").value };
- // $scope.casUserId = { 'password': '123456', 'username': '000003' }
- // $scope.casUserId = { 'password': '18086012425', 'username': 'ncc07' }
- // $scope.casUserId = { 'password': '888888', 'username': '000003' }
- $scope.lodingstyle = 'nodata';
- $scope.login_sign = function (style, loginrole) {
- $scope.lodingstyle = style;
- $rootScope.statuscall = 1;
- if (loginrole && loginrole != '') {
- $scope.casUserId['loginRole'] = loginrole;
- } else {
- delete $scope.casUserId.loginRole;
- }
- $auth.submitLogin($scope.casUserId).then(function (resp) {
- if (resp.error != 501) {
- if (resp.id) {
- $state.go('app.dashboard');
- $rootScope.app.isLoginFixed = false;
- } else {
- window.location.href = servicewechatip;
- // $scope.lodingstyle = 'nodata';
- // $state.go("login.signin");
- // "http://192.168.3.19:8080/wechat/#/tab/requesterIndex";
- }
- } else {
- resp.error = "";
- $scope.loginForm.password = "";
- window.location.href = serviceip;
- // $state.go("login.signin");
- // console.log(serviceip.configuration.baseUrl);
- // SweetAlert.swal("用户名或者密码验证失败,请重试!", "登录错误", "error");
- var n = new Notification("登录错误", {
- body: "用户名或者密码验证失败,请重试!",
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- onclick: function onNotificationClicked() {
- // console.log('Notification clicked.');
- }
- });
- // $scope.lodingstyle = 'nodata';
- }
- })
- .catch(function (resp) {
- $scope.loginForm.password = "";
- window.location.href = serviceip;
- // SweetAlert.swal("系统错误,请重试!", "登录错误", "error");
- var n = new Notification("登录错误", {
- body: "系统错误,请重试!",
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- onclick: function onNotificationClicked() {
- // console.log('Notification clicked.');
- }
- });
- // $scope.lodingstyle = 'nodata';
- });
- }
- var userAgent = window.navigator.userAgent.toLowerCase();
- var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
- var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
- var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
- var isSafari = userAgent.indexOf("Safari") > -1; //判断是否Safari浏览器
- var isChrome = userAgent.indexOf("chrome") > -1; //判断是否Safari浏览器
- if (isOpera) {
- $scope.checkchrome = '当前所用浏览器是Opera浏览器,';
- // return alert("访问失败,当前所用浏览器是Opera浏览器,请用Chrome浏览器访问!");
- }
- if (isIE) {
- $scope.checkchrome = '当前所用浏览器是IE浏览器,';
- // return alert("访问失败,当前所用浏览器是IE浏览器,请用Chrome浏览器访问!");
- }
- if (isFF) {
- $scope.checkchrome = '当前所用浏览器是火狐浏览器,';
- // return alert("访问失败,当前所用浏览器是火狐浏览器,请用Chrome浏览器访问!");
- }
- if (isSafari) {
- $scope.checkchrome = '当前所用浏览器是Safari浏览器,';
- // return alert("访问失败,当前所用浏览器是Safari浏览器,请用Chrome浏览器访问!");
- }
- if (isChrome) {
- // login_sign();
- $rootScope.app.isChrome = false;
- // return alert("访问失败,当前所用浏览器是Chrome浏览器");
- } else {
- $rootScope.app.isChrome = true;
- $scope.checkchrome = '';
- // return alert("访问失败,请用Chrome浏览器访问!");
- }
- // }
- $scope.handleloginEnter = function (e) {
- if (e.keyCode == 13) {
- $scope.handleLoginClick();
- }
- };
- // $scope.isHanderuser = false;
- // $scope.login_sign();
- if (document.getElementById("isWatch").value == "true") {
- $scope.isHanderuser = true;
- } else {
- if (!JSON.parse(sessionStorage.getItem('header'))) {
- $scope.isHanderuser = false;
- $scope.login_sign();
- }
- }
- $scope.viewType = "password";
- $scope.isPassword = true;
- $scope.toggleView = function () {
- $scope.isPassword = !$scope.isPassword;
- $scope.viewType = $scope.isPassword ? "password" : "text";
- }
- $scope.handleSignOutBtnClick = function () {
- $auth.signOut()
- .then(function (resp) {
- // handle success response
- })
- .catch(function (resp) {
- // handle error response
- });
- };
- // }
- // }
- // if (!isEmpty($auth.retrieveData('auth_headers'))) {
- // } else {
- // $scope.loginstart();
- // }
- }
- ]);
|