1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106 |
- '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', 'api_msg', 'Myservice', '$interval', 'jry_api_bpm',
- 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, api_msg, Myservice, $interval, jry_api_bpm) {
- // 未读消息数量seimin
- $rootScope.getMsgNum = function (id) {
- api_msg.msgDataList({ idx: 0, sum: 1, messageStation: { readStatus: 0, userId: id } }).then(function (data) {
- if (data.status == 200) {
- $rootScope.noReadData = data.totalNum;
- }
- return $rootScope.noReadData
- })
- }
- // Loading bar transition
- // -----------------------------------
- // console.log("haha");
- $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
- $rootScope.isFuwutai = JSON.parse(localStorage.getItem("isFuwutai")) ? true : false;
- console.log($rootScope.user)
- if ($rootScope.user) {
- $rootScope.getMsgNum($rootScope.user.id);
- }
- var $win = $($window);
- $rootScope.isMask = false;
- window.onbeforeunload = function () {
- $rootScope.statuscall = 0;
- $rootScope.statecall = 1;
- }
- // 所有列表自动刷新
- $rootScope.refreshTime = 30000;
- $interval(function () {
- $scope.jry_year = new Date().getFullYear();
- $scope.jry_month = new Date().getMonth() + 1;
- $scope.jry_data = new Date().getDate();
- $scope.jry_hours = new Date().getHours();
- $scope.jry_minute = new Date().getMinutes();
- $scope.jry_second = new Date().getSeconds();
- // console.log($scope.jry_month)
- }, 1000)
- // $win.on('beforeunload', function() { return $state.go("login.signin"); });
- // $auth.deleteData('auth_headers')
- // }
- // 监听路由
- $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
- console.log(event, toState, toParams, fromState, fromParams, 'cao')
- if ((toState.name == 'app.incident.chart' || toState.name == 'app.incident.editor') &&
- fromState.name) {
- console.log($rootScope.jry_state);
- $scope.isShixian = false;
- if($rootScope.jry_state == 'shixian'){
- $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
- //进入页面强制示忙
- if (tlwsa) {
- // tlwsa.tlaForceacw($rootScope.phoneNumber);
- setTimeout(()=>{
- tlwsa.tlaAcw();
- },0)
- }
- }
- }
- if ((fromState.name == 'app.incident.chart' || fromState.name == 'app.incident.editor') &&
- toState.name != 'app.incident.chart' && toState.name != 'app.incident.editor'
- ) {
- console.log($rootScope.jry_state);
- // $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
- //进入页面强制示闲
- $scope.isShixian = true;
- // if (tlwsa) {
- // // tlwsa.tlaForcewca($rootScope.phoneNumber);
- // tlwsa.tlaWca();
- // }
- }
- if (isEmpty($auth.retrieveData('auth_headers'))) {
- // if (toState.name != "login.signin" && toState.name != "echart") {
- // event.preventDefault();
- // $rootScope.app.isLoginFixed = true;
- // // $scope.lodingstyle = 'nodata';
- // return $state.go("login.signin");
- // }
- }
- // if (toState.name == "app.system.user.user") {
- // var isgoto = false;
- // if ($rootScope.user && $rootScope.user.menu) {
- // angular.forEach($rootScope.user.menu, function(item) {
- // if (item.link == toState.name) {
- // isgoto = true;
- // } else {}
- // })
- // }
- // if (isgoto) {
- // } else {
- // $state.go("app.dashboard");
- // }
- // }
- // if (toState.name != "app.incident.editor" && toState.name != "echart") {
- // if ($rootScope.status == 2 || $rootScope.status == 4 || $rootScope.status == 9) {
- // $rootScope.setidle();
- // }
- // }
- 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) {
- console.log(newState)
- 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, action] = changedDoc.eventName.split('/');
- 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.isMousedown = false;
- $rootScope.changeRemoveClass = function (e) {
- $rootScope.isMousedown = true
- }
- $rootScope.returnRemoveClass = function (e) {
- $rootScope.isMousedown = false;
- }
- $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{
- // }
- // }
- //}
- //选择坐席号
- $scope.changeWorkId = function () {
- event.stopPropagation();
- }
-
- $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.opendashbord = function () {
- $state.go('echart');
- }
- // $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] */
- // if (window.location.href && window.location.href.hash == "#/echart") {
- // } else {
- // // }
- // // 东经呼叫中心开始
- // $rootScope.statuscall = 0; //话机状态
- // $rootScope.statecall = 1; //示忙示闲
- // $scope.login = false; //签入签出
- // $rootScope.callout = false; //呼入呼出
- // $scope.group = 2000;
- // $scope.phone = 1500;
- // $rootScope.start = function(phone, group) {
- // 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("挂机");
- // console.log(mydata);
- // } else if (mydata.status && mydata.status != '1' && $rootScope.statecall != 2) { //摘机
- // $rootScope.statuscall = 3;
- // api_text.setbusy($rootScope.takes).then(function(data) {
- // if (data.errno == 0) {
- // $rootScope.statecall = 2;
- // $scope.busy = 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({
- // templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
- // controller: function($scope, $modalInstance, api_user_data) {
- // $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);
- // }
- // $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
- // };
- // }
- // // serchdataadd(searchKey)
- // // if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
- // // angular.extend(filterData.requester, { 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO })
- // // }
- // api_user_data.fetchDataList('requester', filterData).then(function(response) {
- // var myData = response;
- // $scope.myData = myData.list;
- // });
- // }
- // // if ((/^1[34578]\d{9}$/.test($rootScope.phone))) {
- // // $scope.requester = { 'mphone': $rootScope.phone };
- // // } else {
- // // $scope.requester = { 'telephone': $rootScope.phone };
- // // }
- // $scope.requester = { 'telephone': $rootScope.phone };
- // $scope.ok = function() {
- // $modalInstance.close($scope.requester);
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // });
- // 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.areaDTO, 'place': response.placeDTO, 'houseNumber': response.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
- // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- // }
- // })
- // }
- // });
- // } else if (myData.list.length == 1) {
- // var data = { 'model': { 'requestershow': myData.list[0], 'incident': { 'requester': myData.list[0], 'area': myData.list[0].areaDTO, 'place': myData.list[0].placeDTO, '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',
- // controller: function($scope, $modalInstance, api_user_data) {
- // $scope.title = "请确定报修人";
- // $scope.requester = myData.list;
- // $scope.choice = function(requester) {
- // $modalInstance.dismiss('cancel');
- // var data = { 'model': { 'requestershow': requester, 'incident': { 'requester': requester, 'area': requester.areaDTO, 'place': requester.placeDTO, 'houseNumber': requester.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
- // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // 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.');
- // // }
- // });
- // }
- // })
- // })
- // }
- // // 东经呼叫中心结束
- //话机呼叫中心--开始
- // 1是老的呼叫中心
- // 2是2021年12月29日新增的呼叫中心
- $rootScope.seiminHj = 2;
- $rootScope.getExtnDirect = function () {
- $rootScope['getExtnDirect' + $rootScope.seiminHj]();
- }
- // --------------------------1------------------------------
- $rootScope.getExtnDirect1 = function () {
- var jry_data_dictionary = {
- key: "hjzx_cornet",
- type: "list"
- }
- api_wechatfile.getDictionary(jry_data_dictionary).then(function (res) {
- var websocket_url = "ws://192.168.3.122:29003/ola_socket";
- var ola_queue = "10009"; //通话配置-队列配置-队列ID
- // var ola_extn = "1001"; //个人信息-座席分机号
- $rootScope.jry_extnNumberSelect = [];
- $rootScope.jry_extnNumberObj = {};
- $rootScope.jry_extnNumberSelect = res;
- $rootScope.jry_extnNumberObj.jry_extnNumber = $rootScope.jry_extnNumberSelect[0];
- function log(msg) {
- //IE has no console
- if ('console' in window) console.log(msg);
- }
- function websocket_connect() {
- ola.connect(websocket_url);
- ola.onConnect = onConnect;
- ola.onClose = onClose;
- ola.onMessage = onMessage;
- }
- $(document).ready(function () {
- // if(ola_extn!=""){
- if ($rootScope.jry_extnNumberObj.jry_extnNumber) {
- websocket_connect();
- }
- });
- /* callbacks */
- function onMessage(evt) {
- var phoneData = JSON.parse(evt.data);
- if (phoneData.event_type == "agent_state") {
- console.log(phoneData);
- if (phoneData.state == "busy") {
- $('#agent_state').append(" (" + phoneData.private_data + ")");
- // 来电
- if (phoneData.private_data == "ring") {
- console.log(phoneData);
- $rootScope.jry_state = "laidian";
- var Notification = window.Notification;
- Notification.requestPermission();
- var n = new Notification("你有来电", {
- body: "来电号码:" + phoneData.ani,
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- });
- // 摘机
- } else if (phoneData.private_data == "answered") {
- $rootScope.jry_state = "tonghuazhong";
- var jry_findPhone = "";
- if (phoneData.ani) {
- jry_findPhone = phoneData.ani
- } else if (phoneData.dnis && phoneData.other_answered) {
- jry_findPhone = phoneData.dnis
- }
- var filterData = {
- "idx": 0,
- "sum": 100,
- "requester": {
- "mphone": jry_findPhone,
- "telephone": jry_findPhone,
- "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({
- templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
- controller: function ($scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
- $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);
- }
- $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_wechatfile.getDictionary({
- "key": "requester_type",
- "type": "list"
- }).then(function (response) {
- // if (response.status == 200) {
- $scope.networktypes = response;
- // }
- })
- $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': jry_findPhone
- };
- $scope.ok = function () {
- var reg1 = /^1[3456789][0-9]{9}$/; //手机号
- var reg2 = /^((0\d{2,3})-)*(\d{7,8})(-(\d{3,}))?$/; //座机号
- var flag1 = reg1.test($scope.requester.mphone);
- var flag2 = reg2.test($scope.requester.mphone);
- console.log($scope.requester)
- if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
- SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
- } else if (angular.isUndefined($scope.requester.requesterType)) {
- 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');
- };
- },
- });
- 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,
- // 'callID': cdrid,
- 'source': {
- 'id': 1547
- }
- }
- }
- }
- $state.go('app.incident.title', {
- 'model': JSON.stringify(data)
- });
- }
- })
- }
- });
- } else if (myData.list.length == 1) {
- var data = {
- 'model': {
- 'requestershow': myData.list[0],
- 'incident': {
- 'requester': myData.list[0],
- 'area': myData.list[0].areaDTO,
- 'place': myData.list[0].placeDTO,
- 'houseNumber': myData.list[0].houseNumber,
- // 'callID': cdrid,
- 'source': {
- 'id': 1547
- }
- }
- }
- }
- $state.go('app.incident.title', {
- 'model': JSON.stringify(data)
- });
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/createincident.html',
- controller: function ($scope, $modalInstance, api_user_data) {
- $scope.title = "请确定报修人";
- $scope.requester = myData.list;
- $scope.choice = function (requester) {
- $modalInstance.dismiss('cancel');
- var data = {
- 'model': {
- 'requestershow': requester,
- 'incident': {
- 'requester': requester,
- 'area': requester.areaDTO,
- 'place': requester.placeDTO,
- 'houseNumber': requester.houseNumber,
- // 'callID': cdrid,
- 'source': {
- 'id': 1547
- }
- }
- }
- }
- $state.go('app.incident.title', {
- 'model': JSON.stringify(data)
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: "lg"
- });
- }
- });
- }
- // 挂机
- } else if (phoneData.state == "login") {
- go_ready()
- } else if (phoneData.state == "logout") {
- $rootScope.jry_state = "weiqianru";
- } else if (phoneData.state == "ready") {
- // 来电挂机
- if (phoneData.old_state == "busy" && phoneData.private_data == "answered") {
- go_break()
- } else {
- $rootScope.jry_state = "shixian";
- }
- }
- // else if (data.old_state == "busy") {
- // }
- } else if (phoneData.event_type == "agent_caller_state") {
- // special feature, never mind
- if (phoneData.action == "in") {
- } else {
- }
- } else if (phoneData.event_type == "command/reply") {
- if (phoneData.phoneData && phoneData.phoneData.state) {
- }
- }
- }
- function onConnect() {
- console.log("websocket connected!");
- // ola._extn = ola_extn;
- // ola.subscribe('ola.queue.' + ola_queue + '.' + ola_extn);
- // ola.subscribe('ola.caller.' + ola_extn);
- // ola.get_agent_state(ola_extn);
- ola._extn = $rootScope.jry_extnNumberObj.jry_extnNumber.name;
- ola.subscribe('ola.queue.' + ola_queue + '.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
- ola.subscribe('ola.caller.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
- ola.get_agent_state($rootScope.jry_extnNumberObj.jry_extnNumber.name);
- };
- function onClose() {
- }
- function login() {
- // ola.login(ola_queue, ola_extn, {type: "onhook"});
- console.log($rootScope.jry_extnNumberObj.jry_extnNumber);
- ola.login(ola_queue, $rootScope.jry_extnNumberObj.jry_extnNumber.name, { type: "onhook" });
- }
- function logout() {
- ola.logout();
- }
- function go_ready() {
- ola.go_ready();
- }
- function go_break() {
- ola.go_break($('#break_reason').val());
- $rootScope.jry_state = "shimang";
- }
- function answer() {
- ola.answer();
- }
- function dial(dst) {
- ola.dial(dst);
- }
- $rootScope.dial = function (dst) {
- ola.dial(dst);
- }
- function conference(dst) {
- ola.conference(dst);
- }
- function conference_uuid(channel_uuid) {
- ola.conference_uuid(channel_uuid);
- }
- function hangup() {
- ola.hangup();
- }
- function take_call(uuid) {
- // ola.take_call(ola_extn, uuid);
- ola.take_call($rootScope.jry_extnNumberObj.jry_extnNumber.name, uuid);
- }
- // 签入
- $rootScope.jry_qianru = function () {
- login();
- }
- // 示闲
- $rootScope.jry_shixian = function () {
- go_ready()
- }
- // 示忙
- $rootScope.jry_shimang = function () {
- go_break()
- }
- // 签出
- $rootScope.jry_qianchu = function () {
- logout()
- }
- $rootScope.jry_bohao = function (res) {
- if ($rootScope.jry_state == "weiqianru") {
- // SweetAlert.swal({
- // title: "拨打失败",
- // text: "请先签入!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- } else if ($rootScope.jry_state == "shimang") {
- // SweetAlert.swal({
- // title: "拨打失败",
- // text: "请先示闲!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- } else {
- dial(res);
- }
- }
- })
- }
- // ------------------------------2--------------------------
- $rootScope.getExtnDirect2 = function () {
- var jry_data_dictionary = {
- key: "hjzx_cornet",
- type: "list"
- }
- api_wechatfile.getDictionary(jry_data_dictionary).then(function (res) {
- sessionStorage.setItem('phones',JSON.stringify(res.map(v=>v.name)));
- var websocket_url = $rootScope.seiminCallIp;
- $rootScope.jry_extnNumberSelect = [];
- $rootScope.jry_extnNumberObj = {};
- $rootScope.jry_extnNumberSelect = angular.copy(res);
- $rootScope.jry_extnNumberObj.jry_extnNumber = {};
- var fenjiNumber = localStorage.getItem('fenjiNumber');
- if(fenjiNumber){
- $rootScope.jry_extnNumberSelect.forEach(ress=>{
- if(ress.name == fenjiNumber){
- $rootScope.jry_extnNumberObj.jry_extnNumber = ress;
- }
- })
- }
- // $rootScope.jry_extnNumberObj.jry_extnNumber = angular.copy(res[0]);//绑定分机对象
- // $rootScope.jry_extnNumberObj.tel1 = angular.copy(res[0]);//目的号码对象
- // $rootScope.jry_extnNumberObj.tel2 = angular.copy(res[0]);//转接坐席对象
- $rootScope.preState = '';//最近一次示忙还是示闲的状态
- //连接
- tlwsa.tlaOpen(websocket_url);
- // 强制示忙
- $scope.qShimang = function(state){
- if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
- //进入页面,强制示忙
- // tlwsa.tlaForceacw($rootScope.phoneNumber);
- setTimeout(()=>{
- tlwsa.tlaAcw();
- },0)
- }else{
- $scope.getState(state);
- }
- }
- // 获取状态
- $scope.getState = function (state) {
- // if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
- // if(state != 2&&state != 0){
- // //进入页面,强制示忙
- // // tlwsa.tlaForceacw($rootScope.phoneNumber);
- // setTimeout(()=>{
- // tlwsa.tlaAcw();
- // },3000)
- // }
- // }
- // var agcount = tlwsa.tlaGetagentcount();
- // var flag = true;
- // for (var i = 0; i < agcount; i++) {
- // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
- // flag = false;
- // var state = Number(tlwsa.tlaGetagentstate(i));
- // console.log(state);
- switch (state) {
- case 0:
- $rootScope.jry_state = 'weiqianru';
- break;
- case 1:
- $rootScope.jry_state = 'shixian';
- break;
- case 2:
- $rootScope.jry_state = 'shimang';
- break;
- case 3:
- $rootScope.jry_state = 'laidian';
- break;
- case 5:
- $rootScope.jry_state = 'tonghuazhong';
- break;
- case 6:
- $rootScope.jry_state = 'zhengzaiwaihu';
- break;
- case 7:
- $rootScope.jry_state = 'zhengzaizhuanyi';
- break;
- }
- // }
- // console.log('agnet No. ' + i + ' workid is ' + tlwsa.tlaGetagentwid(i) + ' state is ' + tlwsa.tlaGetagentstate(i) + ' ' + getStateInfo(tlwsa.tlaGetagentstate(i)))
- // }
- // if (flag) {
- // $rootScope.jry_state = 'weiqianru';
- // }
- }
- // 状态回调函数
- // TLWSA.onStatechange = onstatechange;
- // function onstatechange() {
- // console.log('事件:状态变化----------------------------------------------------');
- // $scope.getState();
- // }
- //连接呼叫中心回调函数
- TLWSA.onOpenreturn = onopenreturn;
- function onopenreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('呼叫中心连接成功-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫中心连接成功'
- });
- //如果设置过话机
- if (localStorage.getItem('phoneNumber')) {
- //强制签出,然后签入
- tlwsa.tlaKillworkid(localStorage.getItem('phoneNumber'));
- }
- } else {
- console.log('呼叫中心连接失败-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫中心连接失败'
- });
- }
- }
- //绑定分机回调函数
- TLWSA.onSetphonenumberreturn = onsetphonenumberreturn;
- function onsetphonenumberreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('绑定分机成功-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '绑定分机成功'
- });
- localStorage.setItem('phoneNumber', $rootScope.phoneNumber);
- localStorage.setItem('fenjiNumber', $rootScope.jry_extnNumberObj.jry_extnNumber.name);
- $scope.qShimang(1);
- } else {
- console.log('绑定分机失败-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '绑定分机失败'
- });
- }
- }
- //强制示忙回调函数
- // TLWSA.onAcw = onacw;
- // function onacw(err) {
- // err = Number(err);
- // if (!err) {
- // console.log('强制示忙成功-----seimin');
- // $scope.getState(2);
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示忙成功'
- // });
- // } else {
- // console.log('强制示忙失败-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示忙失败'
- // });
- // }
- // }
- // //强制示闲回调函数
- // TLWSA.onWca = onwca;
- // function onwca(err) {
- // console.log(err)
- // err = Number(err);
- // if (!err) {
- // console.log('强制示闲成功-----seimin');
- // $scope.getState(1);
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示闲成功'
- // });
- // } else {
- // console.log('强制示闲失败-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示闲失败'
- // });
- // }
- // }
- //与服务器网络连接中断回调函数
- TLWSA.onClosed = onclosed;
- function onclosed() {
- $scope.getState(0);
- console.log('与服务器网络连接中断-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '与服务器网络连接中断,2分钟后重连'
- });
- console.log('2分钟后自动重连-----seimin')
- $timeout(function () {
- //连接
- tlwsa.tlaOpen(websocket_url);
- }, 120000)
- }
- //签入回调函数
- TLWSA.onLoginreturn = onloginreturn;
- function onloginreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('签入成功-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签入成功'
- });
- setTimeout(function () {
- console.log($rootScope.jry_extnNumberObj.jry_extnNumber.name,1111)
- var fenjiNumber = $rootScope.jry_extnNumberObj.jry_extnNumber.name || localStorage.getItem('fenjiNumber');
- console.log('开始绑定分机【' + fenjiNumber + '】-----seimin');
- tlwsa.tlaSetphonenumber(fenjiNumber);
- }, 0)
- } else if (err == 9011) {
- console.log('签入失败,该分机已登录-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签入失败,该分机已登录'
- });
- } else {
- console.log('签入失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签入失败'
- });
- }
- // tlwsa.tlaSubscribestateinfo(2);
- }
- // 强制签出回调函数
- TLWSA.onKillreturn = onkillreturn;
- function onkillreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('强制签出成功-----seimin');
- $scope.getState(0);
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '强制签出成功'
- // });
- } else {
- console.log('强制签出失败,该分机不是签入状态-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '强制签出失败'
- // });
- }
- //如果设置过话机
- if (localStorage.getItem('phoneNumber')) {
- // 签入并绑定分机
- $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
- tlwsa.tlaLogin($rootScope.phoneNumber, 1, -1);
- }
- }
- // 签出回调函数
- TLWSA.onLogoffreturn = onlogoffreturn;
- function onlogoffreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('签出成功-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签出成功'
- });
- localStorage.removeItem('phoneNumber');
- localStorage.removeItem('fenjiNumber');
- $rootScope.jry_extnNumberObj.jry_extnNumber = {};
- } else {
- console.log('签出失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签出失败'
- });
- }
- }
- //示忙回调函数
- TLWSA.onAcwreturn = onacwreturn;
- function onacwreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('示忙成功-----seimin');
- if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
- $scope.isShixian = false;
- }else{
- $scope.isShixian = true;
- }
- $scope.getState(2);
- $rootScope.preState = 2;
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '示忙成功'
- });
- } else {
- console.log('示忙失败-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示忙失败'
- // });
- }
- }
- //示闲回调函数
- TLWSA.onWcareturn = onwcareturn;
- function onwcareturn(err) {
- err = Number(err);
- if (!err) {
- console.log('示闲成功-----seimin');
- $scope.getState(1);
- $rootScope.preState = 1;
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '示闲成功'
- });
- } else {
- console.log('示闲失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '示闲失败'
- });
- }
- }
- //呼叫坐席回调函数
- TLWSA.onCallreturn = oncallreturn;
- function oncallreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('呼叫成功,请摘机-----seimin');
- $scope.getState(6);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫成功,请摘机'
- });
- } else {
- console.log('呼叫失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫失败'
- });
- }
- }
- //呼叫坐席被接听回调函数
- TLWSA.onCallresult = oncallresult;
- function oncallresult(jso) {
- console.log(jso);
- var err = Number(jso.err);
- if (!err) {
- console.log('呼叫被接听成功-----seimin');
- $scope.getState(5);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫被接听成功'
- });
- } else {
- console.log('呼叫被接听失败-----seimin');
- $scope.qShimang(1);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫被接听失败'
- });
- }
- }
- //挂断回调函数
- TLWSA.onCallend = oncallend;
- function oncallend(jso) {
- console.log(jso);//lmm
- if (jso) {
- console.log('挂断成功-----seimin');
- console.log('最近一次话机状态',$rootScope.preState);
- $scope.qShimang($rootScope.preState);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '挂断成功'
- });
- } else {
- console.log('挂断失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '挂断失败'
- });
- }
- }
- //呼入回调函数
- TLWSA.onCallin = oncallin;
- function oncallin(jso) {
- console.log(jso);//lmm
- $rootScope.callInPhoneNumber = jso.caller;//来电的电话
- $rootScope.sockid = jso.crs;//来电的话机id
- if (jso) {
- console.log('呼入坐席成功,请摘机-----seimin');
- $scope.getState(3);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入坐席成功,请摘机'
- });
- console.log('来电了!电话号码是【' + $rootScope.callInPhoneNumber + '】');
- } else {
- console.log('呼入坐席失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入坐席失败'
- });
- }
- }
- //呼入摘机应答回调函数
- TLWSA.onAnswer = onanswer;
- function onanswer(err) {
- err = Number(err);
- if (!err) {
- console.log('呼入摘机应答成功-----seimin');
- $scope.getState(5);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入摘机应答成功'
- });
- //根据电话号码反查报修人,如果是坐席号码,则不用
- // console.log(sessionStorage.getItem('phones'));
- // var phones = JSON.parse(sessionStorage.getItem('phones'));
- // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
- // if(isHuajihao){
- // return;
- // }
- var postData = { "idx": 0, "sum": 10, "requester": { hjzxPhone: $rootScope.callInPhoneNumber } };
- api_user_data.fetchDataList('requester', postData).then(function (result) {
- if (result.status == 200) {
- console.log(result.list);
- var requesters = result.list;
- if (requesters.length === 0) {
- //未匹配到报修人,则弹窗添加报修人yeye
- $state.go('app.incident.chart', {
- model: JSON.stringify({
- model: {
- incident: {
- requester: {
- hjzxPhone: $rootScope.callInPhoneNumber
- },
- sockid: $rootScope.sockid
- }
- }
- })
- });
- } else if (requesters.length === 1) {
- //匹配到一个报修人
- $state.go('app.incident.chart', {
- model: JSON.stringify({
- model: {
- incident: {
- requester: requesters[0],
- contactsInformation: requesters[0].mphone,
- sockid: $rootScope.sockid
- },
- }
- })
- });
- } else {
- //匹配到多个报修人
- $modal.open({
- templateUrl: 'assets/views/incident/tpl/tel.html',
- controller: function ($scope, $modalInstance, $timeout, SweetAlert) {
- $scope.list = requesters;
- $scope.selectedItem = 0;
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- $scope.changeBxr = function (id) {
- $scope.selectedItem = id;
- }
- $scope.save = function () {
- var item = $scope.list.find(v => v.id == $scope.selectedItem);
- if (item) {
- $scope.cancel();
- $state.go('app.incident.chart', {
- model: JSON.stringify({
- model: {
- incident: {
- requester: item,
- contactsInformation: item.mphone,
- sockid: $rootScope.sockid
- },
- }
- })
- });
- } else {
- SweetAlert.swal({
- title: "请选择报修人!",
- type: "error"
- })
- }
- }
- }
- });
- }
- }
- })
- } else {
- console.log('呼入摘机应答失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入摘机应答失败'
- });
- }
- }
- //呼入未摘机应答回调函数
- TLWSA.onMisscall = onmisscall;
- function onmisscall(err) {
- err = Number(err);
- if (!err) {
- console.log('呼入未摘机应答成功-----seimin');
- $scope.getState(1);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入未摘机应答成功'
- });
- } else {
- console.log('呼入未摘机应答失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入未摘机应答失败'
- });
- }
- }
- //转接开始回调函数
- TLWSA.onTransferreturn = ontransferreturn;//调用转移方法之后,返回该事件 如果错误码为0,仅仅表示开始转移,不代表转移目标已经接听或已经拒绝
- function ontransferreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('转接坐席开始成功-----seimin');
- $scope.getState(7);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席开始成功'
- });
- } else {
- console.log('转接坐席开始失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席开始失败'
- });
- }
- }
- //转接结果回调函数
- TLWSA.onTransferresult = ontransferresult;
- function ontransferresult(err) {
- err = Number(err);
- if (!err) {
- console.log('转接坐席结果成功-----seimin');
- $scope.getState(1);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席结果成功'
- });
- } else {
- console.log('转接坐席结果失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席结果失败'
- });
- }
- }
- // 签入
- $rootScope.jry_qianru = function () {
- console.log($rootScope.jry_extnNumberObj.jry_extnNumber)
- if(Object.keys($rootScope.jry_extnNumberObj.jry_extnNumber).length === 0){
- $.toaster({
- priority: 'info',
- title: '警告',
- message: '绑定分机不能为空'
- });
- return;
- }
- // 签入并绑定分机
- // $rootScope.jry_extnNumberObj.jry_extnNumber.name 分机号
- // $rootScope.user.id 坐席号(用户id)
- tlwsa.tlaLogin($rootScope.user.id, 1, -1);
- $rootScope.phoneNumber = $rootScope.user.id;
- }
- // 示闲
- $rootScope.jry_shixian = function () {
- tlwsa.tlaWca();
- }
- // 示忙
- $rootScope.jry_shimang = function () {
- tlwsa.tlaAcw();
- }
- // 签出
- $rootScope.jry_qianchu = function () {
- tlwsa.tlaLogoff();
- }
- // 呼叫坐席
- // $scope.tlaCallagc = function () {
- // tlwsa.tlaCallagc($rootScope.jry_extnNumberObj.tel1)
- // }
- // 呼叫外线
- $scope.tlaCallout = function () {
- // 选择目的号码
- var reg1 = /^[0][1-9]{2,3}-[0-9]{5,10}$/;
- var reg2 = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
- if(!reg1.test($rootScope.jry_extnNumberObj.tel1)&&!reg2.test($rootScope.jry_extnNumberObj.tel1)){
- $.toaster({
- priority: 'info',
- title: '警告',
- message: '请输入正确的手机号或座机号'
- });
- return;
- }
- tlwsa.tlaCallout($rootScope.jry_extnNumberObj.tel1,$rootScope.jry_extnNumberObj.jry_extnNumber.name,0)
- }
- // // 转移坐席
- // $scope.tlaTransfertoagc = function () {
- // tlwsa.tlaTransfertoagc($rootScope.jry_extnNumberObj.tel2)
- // }
- // 转移外线
- $scope.tlaTransferout = function () {
- // 选择转接号码
- var reg1 = /^[0][1-9]{2,3}-[0-9]{5,10}$/;
- var reg2 = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
- if(!reg1.test($rootScope.jry_extnNumberObj.tel2)&&!reg2.test($rootScope.jry_extnNumberObj.tel2)){
- $.toaster({
- priority: 'info',
- title: '警告',
- message: '请输入正确的手机号或座机号'
- });
- return;
- }
- tlwsa.tlaTransferout($rootScope.jry_extnNumberObj.tel2,$rootScope.jry_extnNumberObj.jry_extnNumber.name,0)
- }
- })
- }
- $rootScope.jry_state = 'weiqianru';
- window.addEventListener('load', function () {
- if ($rootScope.isFuwutai) {
- $rootScope.getExtnDirect();//seiminHj----1
- }
- })
- //话机呼叫中心--结束
- // 未接来电
- $scope.jry_getUnanswered = function () {
- var jry_data = {
- idx: 0,
- sum: 999,
- "callRecord": {
- "todayTime": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 00:00:00",
- "todayTimeEnd": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 23:59:59",
- }
- }
- api_bpm_data.fetchDataList("callRecord", jry_data).then(function (data) {
- // fo0h
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].createdTime = new Date(data.list[i].createdTime).getFullYear() + "-" + (new Date(data.list[i].createdTime).getMonth() + 1) + "-" + new Date(data.list[i].createdTime).getDate() + " " + new Date(data.list[i].createdTime).getHours() + ":" + new Date(data.list[i].createdTime).getMinutes() + ":" + new Date(data.list[i].createdTime).getSeconds()
- }
- $rootScope.jry_unansweredData = data.list;
- });
- }
- // $scope.jry_getUnanswered();
- // 来电号码回拨
- $scope.jry_callBack = function (data) {
- var callBackData = {
- "callRecord": {
- "id": data.id,
- "isAnswered": "1"
- }
- };
- api_bpm_data.updData("callRecord", callBackData).then(function (res) {
- if (res) {
- $scope.jry_getUnanswered();
- dial(data.callerIdNumber)
- }
- });
- if (data.department.id && data.requester) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'requester': data.requester, 'contacts': data.requester.name, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else if (data.department.id) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- };
- // ws.send("{\"type\":\"1\",\"phone\":\""+data.phone+"\"}");
- }
- //来电号码生成事件
- $scope.jry_callToIncident = function (data) {
- if (data.department.id && data.requester) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'requester': data.requester, 'contacts': data.requester.name, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else if (data.department.id) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- }
- }
- $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;
- // }
- // }
- // })
- }
- if (window.location && window.location.hash == "#/echart") {
- } else {
- 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.phone=teleno;
- }
- })
- }
- // $scope.busy=false;
- $rootScope.setbusy = function () {
- api_text.setbusy($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statecall = 2;
- $scope.busy = true;
- }
- })
- }
- $rootScope.setidle = function () {
- api_text.setidle($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statecall = 1;
- $scope.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;
- // })
- // })
- // }
- // }
- $rootScope.getpending = function () {
- if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
- if ($rootScope.user.group) {
- var groupArr = [];
- for (var i = 0; i < $rootScope.user.group.length; i++) {
- groupArr.push($rootScope.user.group[i].id)
- }
- api_bpm_data.getCount({ "assignee": $rootScope.user.id, "candidateGroups": groupArr.join(), "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 (response.releaseCount > 0) {
- if (item.id == 1215) {
- item.tipshow = true;
- }
- }
- if (response.solutionCount > 0) {
- if (item.id == 21) {
- item.tipshow = true;
- }
- }
- if (response.changeCount > 0) {
- if (item.id == 1212) {
- item.tipshow = true;
- }
- }
- if (response.problemCount > 0) {
- if (item.id == 1209) {
- item.tipshow = true;
- }
- }
- if (response.applicationForm > 0) {
- if (item.id == 1221) {
- 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 !== null && response.hjzxCount !== undefined) {
- if (index.id == 1208) {
- if (response.hjzxCount < 100) {
- index.tipnum = response.hjzxCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.wechatWarningCount !== null && response.wechatWarningCount !== undefined) {
- if (index.id == 59) {
- if (response.wechatWarningCount < 100) {
- index.tipnum = response.wechatWarningCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.problemCount !== null && response.problemCount !== undefined) {
- if (index.id == 1210) {
- if (response.problemCount < 100) {
- index.tipnum = response.problemCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.releaseCount !== null && response.releaseCount !== undefined) {
- if (index.id == 1216) {
- if (response.releaseCount < 100) {
- index.tipnum = response.releaseCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.inspectionCount !== null && response.inspectionCount !== undefined) {
- if (index.id == 147) {
- if (response.inspectionCount < 100) {
- index.tipnum = response.inspectionCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.solutionCount !== null && response.solutionCount !== undefined) {
- if (index.id == 23) {
- if (response.solutionCount < 100) {
- index.tipnum = response.solutionCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.changeCount !== null && response.changeCount !== undefined) {
- if (index.id == 1213) {
- if (response.changeCount < 100) {
- index.tipnum = response.changeCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.incidentCount !== null && response.incidentCount !== undefined) {
- if (index.id == 3) {
- if (response.incidentCount < 100) {
- index.tipnum = response.incidentCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.applicationForm !== null && response.applicationForm !== undefined) {
- if (index.id == 1231) {
- if (response.applicationForm < 100) {
- index.tipnum = response.applicationForm;
- } 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) {
- var allJurisdiction2 = $rootScope.user.menu;
- var onlyMenu2 = [];
- for (var i = 0; i < allJurisdiction2.length; i++) {
- if (allJurisdiction2[i].event == "1") {
- onlyMenu2.push(allJurisdiction2[i])
- }
- }
- // userMenus = convertParentToChildList($rootScope.user.menu);
- userMenus = convertParentToChildList(onlyMenu2);
- }
- }
- //}
- $rootScope.userMenus = userMenus;
- if ($rootScope.userMenus.length > 0) {
- $rootScope.getpending();
- // setInterval($rootScope.getpending(), 30000);
- }
- return userMenus;
- }
- setInterval(function () {
- if ($rootScope.userMenus.length > 0) {
- $rootScope.getpending()
- $rootScope.getMsgNum($rootScope.user.id)
- }
- }, 5000);
- getMenus();
- // console.log("$rootScope.nickname="+JSON.stringify($rootScope));
- $rootScope.logout = function () {
- // var userid =data.id;
- // console.log(' userid='+JSON.stringify( userid));
- //单点登录
- if (localStorage.getItem('isSSo') === '1') {
- sessionStorage.clear();
- localStorage.clear();
- location.href = 'http://' + location.hostname + ':8080/pc_logout.jsp'
- } else {
- $auth.signOut()
- .then(function (resp) {
- // $auth.deleteData('auth_headers')
- sessionStorage.clear();
- localStorage.clear();
- if ($rootScope.isFuwutai) {
- tlwsa.tlaClose();
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫中心断开连接'
- });
- }
- $state.go("login.signin");
- })
- .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";
- // //},
- }
- // 快速建单
- $rootScope.newOrder = function () {
- $state.go('app.newOrder');
- }
- // 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();
- });
- $rootScope.app.layout.isNavbarFixed = false;
- $rootScope.app.layout.isSidebarFixed = false;
- $rootScope.app.layout.isFooterFixed = false;
- $scope.login_signquick = function (Requesteruserinform) {
- $rootScope.statuscall = 1;
- $scope.loginForm = {
- username: Requesteruserinform.username,
- password: Requesteruserinform.password
- }
- $auth.submitLogin($scope.loginForm)
- .then(function (resp) {
- localStorage.setItem("jry_user", JSON.stringify(resp));
- $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
- // $rootScope.userMenus = JSON.parse(localStorage.getItem("jry_user")).menu;
- var allJurisdiction = JSON.parse(localStorage.getItem("jry_user")).menu;
- var onlyMenu = [];
- for (var i = 0; i < allJurisdiction.length; i++) {
- if (allJurisdiction[i].event == "1") {
- onlyMenu.push(allJurisdiction[i])
- }
- };
- $rootScope.userMenus = onlyMenu;
- getMenus();
- if (resp.error != 500) {
- // $state.go('app.dashboard');
- $rootScope.app.isLoginFixed = false;
- } else {
- resp.error = "";
- $scope.loginForm.password = "";
- SweetAlert.swal("用户名或者密码验证失败,请重试!", "error");
- }
- })
- .catch(function (resp) {
- $scope.loginForm.password = "";
- SweetAlert.swal("系统错误,请重试!", "登录错误", "error");
- });
- }
- var url = location.hash; //获取url中"?"符后的字串 var index=obj.lastIndexOf("\-");
- var theRequest = {};
- var index = url.substring(index + 1, url.length).lastIndexOf("\?");
- if (url.indexOf("?") != -1 && url.indexOf("fixed_list")) {
- var str = url.substr(index + 1);
- var strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
- }
- // return theRequest;
- $scope.login_signquick(theRequest)
- }
- // $scope.casUserId = window.location.search;
- // $scope.loginForm = {
- // username: theRequest[0].split("=")[1],
- // password: theRequest[1].split("=")[1]
- // }
- // $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();
- // }
- // };
- // 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();
- // }
- //websocket 信息中心
- console.log(atmosphere)
- var socket = atmosphere;
- var subSocket;
- // We are now ready to cut the request
- var request = {
- url: 'ws://192.168.199.150:8080/messagestation/cache',
- contentType: "application/json",
- shared: true, // 标签共享
- trackMessageLength: true, //校验数据完整性
- transport: 'websocket'
- };
- // subSocket = socket.subscribe(request);暂时注释,不知道干啥的
- request.onOpen = function (response) {
- console.log(response)
- subSocket.push(JSON.stringify({ login: $rootScope.user.id }));
- // alert("开始连接")
- };
- request.onMessage = function (response) {
- var message = response.responseBody;
- // alert("连接成功")
- console.log(message)
- try {
- var json = JSON.parse(message);
- console.log(json.noRead)
- $scope.noReadData = json.noRead
- } catch (e) {
- console.log('呵呵哒: ', message);
- return;
- }
- };
- request.onClose = function (response) {
- // alert("连接结束")
- }
- request.onError = function (response) {
- // alert('连接失败')
- };
- //信息中心模态框
- var loginUser = $rootScope.user;
- // if(loginUser){
- // // 未读消息数量
- // api_msg.msgDataList({idx: 0, sum: 1, messageStation: {readStatus: 0, userId: loginUser.id}}).then(function(data) {
- // if (data.status == 200) {
- // $scope.noReadData=data.totalNum
- // // $rootScope.option.all = $rootScope.all;
- // } else {
- // $scope.noReadData=0
- // }
- // })
- // }
- // $scope.noReadData=($rootScope.noReadData||0)
- // // $rootScope.all = 5;
- // setTimeout(function() {
- // console.log($scope.noReadData)
- // }, 500)
- $rootScope.wt_messages = function () {
- var modalInstance = $modal.open({
- templateUrl: '../../../assets/views/wt_messages.html',
- controller: function ($scope, $modalInstance) {
- $rootScope.msgData = {
- idx: 0,
- sum: 5,
- messageStation: {
- readStatus: 0,
- userId: $rootScope.user.id
- }
- }
- // 关闭
- $scope.closeModel = function () {
- modalInstance.close();
- }
- $scope.getMsgData = function () {
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- if (data) {
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $scope.wt_msgData = data
- $rootScope.noReadData = data.totalNum
- }
- })
- }
- $scope.getMsgData()
- $scope.message_type = 2;
- $scope.message_no = function (type) { //未读1
- $scope.wt_msgData = {};
- $scope.message_type = type;
- $rootScope.msgData.messageStation.readStatus = 0,
- // $rootScope.option.curr = 1;
- $rootScope.msgData.idx = 0;
- // console.log($rootScope.option.curr)
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $scope.msg_yesType = true;
- if (data.status == 200) {
- $scope.msg_yesType = false
- $scope.wt_msgData = data
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $rootScope.noReadData = data.totalNum;
- // $rootScope.option.all = $rootScope.all;
- } else {
- $scope.msg_yesType = true;
- }
- })
- }
- $scope.message_yes = function (type) { //已读0
- $scope.wt_msgData = {};
- $scope.message_type = type;
- $rootScope.msgData.messageStation.readStatus = 1,
- $rootScope.msgData.idx = 0;
- // $rootScope.option.curr = 1;
- // console.log($rootScope.option.curr)
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $scope.msg_noType = true;
- if (data.status == 200) {
- $scope.msg_noType = false
- $scope.wt_msgData = data
- $rootScope.msg = data.list;
- $rootScope.all = data.pageCount;
- // $rootScope.option.all = $rootScope.all;
- } else {
- $scope.msg_noType = true
- }
- })
- };
- $scope.sBtn = function () {
- // console.log($rootScope.msgData)
- // console.log($scope.wt_msgData)
- $rootScope.msgData.idx = $rootScope.msgData.idx - 1;
- console.log($rootScope.msgData)
- $scope.getMsgData()
- }
- $scope.xBtn = function () {
- // console.log($rootScope.msgData)
- // console.log($scope.wt_msgData)
- $rootScope.msgData.idx = $rootScope.msgData.idx + 1;
- console.log($rootScope.msgData)
- $scope.getMsgData()
- }
- $scope.redIn = function (data) {
- var start = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
- $scope.messageStation = {
- messageStation: {
- id: data.id,
- readStatus: 1,
- readTime: start
- }
- }
- api_msg.updateDataList($scope.messageStation).then(function (data) {
- console.log(data);
- if (data.status == 200) {
- $rootScope.msgData.messageStation.readStatus = 0,
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $rootScope.noReadData = data.totalNum;
- })
- }
- })
- };
- },
- size: 'lg',
- resolve: {
- }
- })
- }
- }
- ]);
- //消息中心分页组件
- app.controller('msgCtrl', ['$scope', '$rootScope', 'api_msg', 'Myservice', function ($scope, $rootScope, api_msg, Myservice) {
- $rootScope.option = {
- curr: 1, //当前页数
- all: $rootScope.all, //总页数
- count: 5, //最多显示的页数,默认为10
- //点击页数的回调函数,参数page为点击的页数
- click: function (page) {
- $rootScope.msgData.idx = page - 1;
- //这里可以写跳转到某个页面等...
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $rootScope.option.all = $rootScope.all;
- })
- }
- }
- }]);
- app.directive('myPagination', function () {
- return {
- restrict: 'EA',
- replace: true,
- rootScope: {
- option: '=pageOption'
- },
- controller: 'msgCtrl',
- template: '<ul class="pagination">' +
- '<li ng-click="pageClick(p)" ng-repeat="p in page" class="{{option.curr==p?\'active\':\'\'}}">' +
- '<a href="javascript:;">{{p}}</a>' +
- '</li>' +
- '</ul>',
- link: function ($rootScope) {
- //容错处理
- if (!$rootScope.option.curr || isNaN($rootScope.option.curr) || $rootScope.option.curr < 1) $rootScope.option.curr = 1;
- if (!$rootScope.option.all || isNaN($rootScope.option.all) || $rootScope.option.all < 1) $rootScope.option.all = 1;
- if ($rootScope.option.curr > $rootScope.option.all) $rootScope.option.curr = $rootScope.option.all;
- if (!$rootScope.option.count || isNaN($rootScope.option.count) || $rootScope.option.count < 1) $rootScope.option.count = 10;
- //得到显示页数的数组
- $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
- //绑定点击事件
- $rootScope.pageClick = function (page) {
- if (page == '«') {
- page = parseInt($rootScope.option.curr) - 1;
- } else if (page == '»') {
- page = parseInt($rootScope.option.curr) + 1;
- }
- if (page < 1) page = 1;
- else if (page > $rootScope.option.all) page = $rootScope.option.all;
- //点击相同的页数 不执行点击事件
- if (page == $rootScope.option.curr) return;
- if ($rootScope.option.click && typeof $rootScope.option.click === 'function') {
- $rootScope.option.click(page);
- $rootScope.option.curr = page;
- $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
- }
- };
- //返回页数范围(用来遍历)
- function getRange(curr, all, count) {
- //计算显示的页数
- // console.log(curr, all, count)
- curr = parseInt(curr);
- all = parseInt(all);
- count = parseInt(count);
- var from = curr - parseInt(count / 2);
- var to = curr + parseInt(count / 2) + (count % 2) - 1;
- //显示的页数容处理
- if (from <= 0) {
- from = 1;
- to = from + count - 1;
- if (to > all) {
- to = all;
- }
- }
- if (to > all) {
- to = all;
- from = to - count + 1;
- if (from <= 0) {
- from = 1;
- }
- }
- var range = [];
- for (var i = from; i <= to; i++) {
- range.push(i);
- }
- range.push('»');
- range.unshift('«');
- return range;
- }
- }
- }
- });
- app.service('Myservice', function () {
- return {
- };
- });
- // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
- // console.log(bh)
- // if(bh>=0&&bh<=53){
- // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
- // }else{
- // $('#sidebar').css('padding-bottom', 0 + 'px')
- // }
- window.onscroll = function () {
- if (window.pageYOffset >= 0 && window.pageYOffset <= 65) {
- $('#sidebar').css('padding-top', (65 - window.pageYOffset) + 'px')
- } else {
- $('#sidebar').css('padding-top', '0')
- }
- // console.log(window.pageYOffset)
- // console.log(window.innerHeight)
- // console.log(document.body.scrollHeight)
- // 底部padding
- // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
- // console.log(bh)
- // if(bh>=0&&bh<=53){
- // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
- // }else{
- // $('#sidebar').css('padding-bottom', 0 + 'px')
- // }
- }
|