mainCtrl.js 124 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387
  1. 'use strict';
  2. /**
  3. * Clip-Two Main Controller
  4. */
  5. 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',
  6. 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) {
  7. // 未读消息数量seimin
  8. $rootScope.getMsgNum = function (id) {
  9. api_msg.msgDataList({ idx: 0, sum: 1, messageStation: { readStatus: 0, userId: id } }).then(function (data) {
  10. if (data.status == 200) {
  11. $rootScope.noReadData = data.totalNum;
  12. }
  13. return $rootScope.noReadData
  14. })
  15. }
  16. // Loading bar transition
  17. // -----------------------------------
  18. // console.log("haha");
  19. $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
  20. console.log($rootScope.user)
  21. if ($rootScope.user) {
  22. $rootScope.getMsgNum($rootScope.user.id);
  23. }
  24. var $win = $($window);
  25. $rootScope.isMask = false;
  26. window.onbeforeunload = function () {
  27. $rootScope.statuscall = 0;
  28. $rootScope.statecall = 1;
  29. }
  30. // 所有列表自动刷新
  31. $rootScope.refreshTime = 30000;
  32. $interval(function () {
  33. $scope.jry_year = new Date().getFullYear();
  34. $scope.jry_month = new Date().getMonth() + 1;
  35. $scope.jry_data = new Date().getDate();
  36. $scope.jry_hours = new Date().getHours();
  37. $scope.jry_minute = new Date().getMinutes();
  38. $scope.jry_second = new Date().getSeconds();
  39. // console.log($scope.jry_month)
  40. }, 1000)
  41. // $win.on('beforeunload', function() { return $state.go("login.signin"); });
  42. // $auth.deleteData('auth_headers')
  43. // }
  44. $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
  45. if (isEmpty($auth.retrieveData('auth_headers'))) {
  46. // if (toState.name != "login.signin" && toState.name != "echart") {
  47. // event.preventDefault();
  48. // $rootScope.app.isLoginFixed = true;
  49. // // $scope.lodingstyle = 'nodata';
  50. // return $state.go("login.signin");
  51. // }
  52. }
  53. // if (toState.name == "app.system.user.user") {
  54. // var isgoto = false;
  55. // if ($rootScope.user && $rootScope.user.menu) {
  56. // angular.forEach($rootScope.user.menu, function(item) {
  57. // if (item.link == toState.name) {
  58. // isgoto = true;
  59. // } else {}
  60. // })
  61. // }
  62. // if (isgoto) {
  63. // } else {
  64. // $state.go("app.dashboard");
  65. // }
  66. // }
  67. // if (toState.name != "app.incident.editor" && toState.name != "echart") {
  68. // if ($rootScope.status == 2 || $rootScope.status == 4 || $rootScope.status == 9) {
  69. // $rootScope.setidle();
  70. // }
  71. // }
  72. cfpLoadingBar.start();
  73. $auth.validateUser();
  74. });
  75. $rootScope.imUsrMap = {};
  76. $rootScope.onlineUser = [];
  77. $rootScope.offlineUser = [];
  78. $rootScope.me = undefined;
  79. $rootScope.imscope = {
  80. sessions: []
  81. }
  82. // var ws = new WebSocket('ws://192.168.3.51:8088/events');
  83. // var register= {"msgtype":"login","adn":"1001"};
  84. // ws.onopen = function() { ws.send(JSON.stringify(register));}
  85. // ws.onmessage = function(evt) { console.log(evt.data) }
  86. var ddp = new DDP('ws://115.156.150.70:3000/websocket');
  87. $rootScope.getDirectMsgRoomId = function (mdId, toId) {
  88. //me.id,to.id
  89. var rid = [mdId, toId].sort().join('');
  90. return rid;
  91. };
  92. $rootScope.sendMessage = function (rid, msg, callback, error) {
  93. ddp.call('sendMessage', [{ 'rid': rid, 'msg': msg }]).then(callback, error);
  94. };
  95. var pushNotification = function (notification) {
  96. deskNotification.showNotification(notification.title, {
  97. body: notification.body,
  98. icon: notification.icon || '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  99. onClick: notification.callback || function onNotificationClicked() {
  100. // console.log('Notification clicked.');
  101. },
  102. autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)
  103. }, function onShow(error, hide) {
  104. if (error) {
  105. window.alert('Unable to show notification: ' + error.message);
  106. } else {
  107. // console.log('Notification Shown.');
  108. setTimeout(function hideNotification() {
  109. // console.log('Hiding notification....');
  110. hide(); //manually close the notification (you can skip this if you use the autoClose option)
  111. }, 5000);
  112. }
  113. });
  114. }
  115. // $rootScope.subscribeRoomMessage = function(rid){
  116. // ddp.subscribe('stream-room-messages',[rid, true]).then(function(){},function(reason){
  117. // console.log('subscribe stream-room-messages:%o', reason);
  118. // });
  119. // }
  120. $rootScope.filternotifyuser = [];
  121. $rootScope.$on('openroom', function (event, data, otheruser) {
  122. ddp.call('createDirectMessage', [otheruser]).then(function () { }, function (reason) {
  123. // console.log('createDirectMessage', reason);
  124. });
  125. ddp.subscribe('stream-room-messages', [data.rid, true]).then(function () { }, function (reason) {
  126. // console.log('subscribe stream-room-messages:%o', reason);
  127. });
  128. if ($rootScope.imUsrMap[data.from]['unread'].msgs) {
  129. $rootScope.imUsrMap[data.from]['unread'].msgs.clear;
  130. }
  131. $rootScope.filternotifyuser.push(data.from);
  132. });
  133. $rootScope.$on("clip-two.toggled", function (e, target, newState, sameGroup) {
  134. if (newState == false && target == 'off-sidebar') {
  135. $rootScope.$broadcast('chatcloseroom');
  136. //$rootScope.toggle("users");
  137. //$rootScope.filternotifyuser = [];
  138. //ddp.unsubscribe('stream-room-messages');
  139. }
  140. });
  141. $rootScope.$on("closeroom", function (event, data) {
  142. $rootScope.filternotifyuser = [];
  143. ddp.unsubscribe('stream-room-messages');
  144. });
  145. var initImUser = function (email, token) {
  146. var ddpconnect = ddp.connect();
  147. ddpconnect.then(function (data) {
  148. //console.log(data);
  149. if (data.session) {
  150. // ddp.call('createDirectMessage', [data.from, data.rid]).then(function() {}, function(reason) {
  151. // console.log('subscribe createDirectMessage');
  152. // });
  153. ddp.call('login', [{ user: { email: email }, password: token }]).then(function (data) {
  154. // console.log('login data: %o', data);
  155. if (data.id) {
  156. $rootScope.me = {
  157. id: data.id,
  158. token: data.token,
  159. expiry: data.tokenExpires
  160. };
  161. //获取在线用户
  162. ddp.subscribe('activeUsers');
  163. ddp.subscribe('stream-notify-user', [$rootScope.me.id + '/notification', true]).then(function (result) {
  164. //console.log(result);
  165. }, function (reason) {
  166. // console.log('stream-notify-user error:%s', reason);
  167. });
  168. // ddp.subscribe('stream-notify-user',[$rootScope.me.id+'/message',false]).then(function(result){
  169. // console.log(result);
  170. // },function(reason){
  171. // console.log('stream-notify-user error:', reason);
  172. // });
  173. ddp.subscribe('messages', [$rootScope.me.id + '/message', true]).then(function () { }, function (reason) {
  174. // console.log('subscribe messages error:%s', reason);
  175. });
  176. //'stream-notify-user',$rootScope.me.id+'/message'
  177. // ddp.call('sendmessage', []).then(function(msg){
  178. // })
  179. //console.log('Logged in!');
  180. // ddp.subscribe('messages', [{rid:data.id,start:new Date()}]).then(function(submsg){
  181. // console.log('subscribe messages-%s', submsg);
  182. // $rootScope.rocketchat_message = ddp.getCollection('rocketchat_message');
  183. // },function(reason){
  184. // console.log(reason);
  185. // })
  186. }
  187. }, function (reason) {
  188. // console.log(reason);
  189. });
  190. } else {
  191. }
  192. ddp.watch('users', function (changedDoc, message) {
  193. //console.log('users:%o',changedDoc);
  194. // if (message == 'method') {
  195. // console.log("1111111111111111111")
  196. // }
  197. if (message == 'added') {
  198. if (changedDoc.status && ($rootScope.me.id != changedDoc._id)) {
  199. if (changedDoc.status == 'away') {
  200. $rootScope.offlineUser.push(changedDoc);
  201. $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
  202. } else {
  203. $rootScope.onlineUser.push(changedDoc);
  204. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
  205. }
  206. } else {
  207. //self
  208. }
  209. } else if (message == 'changed') {
  210. if ($rootScope.me.id != changedDoc._id) {
  211. if (!$rootScope.imUsrMap[changedDoc._id]) {
  212. if (changedDoc.status == 'away') {
  213. $rootScope.offlineUser.push(changedDoc);
  214. $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
  215. } else {
  216. $rootScope.onlineUser.push(changedDoc);
  217. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
  218. }
  219. }
  220. if (changedDoc.status == 'away') {
  221. if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
  222. } else {
  223. $rootScope.offlineUser.push(changedDoc);
  224. $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  225. window._.map(window._.slice($rootScope.onlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
  226. $rootScope.imUsrMap[item._id].index = n;
  227. })
  228. // $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){
  229. // item.index = item.index - 1;
  230. // }))
  231. //.splice($rootScope.imUsrMap[changedDoc.id].index,1);
  232. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.offlineUser.length };
  233. }
  234. } else {
  235. if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
  236. $rootScope.onlineUser.push(changedDoc);
  237. $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  238. window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
  239. $rootScope.imUsrMap[item._id].index = n;
  240. })
  241. // $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){
  242. // item.index = item.index - 1;
  243. // }))
  244. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length };
  245. } else {
  246. }
  247. }
  248. }
  249. } else if (message == 'removed') {
  250. if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
  251. } else {
  252. $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  253. $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  254. window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
  255. $rootScope.imUsrMap[item._id].index = n;
  256. });
  257. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length, unread: { total: 0, msgs: [] } };
  258. }
  259. }
  260. });
  261. ddp.watch('stream-notify-user', function (changedDoc, message) {
  262. if (message == 'changed') {
  263. if (changedDoc.eventName) {
  264. if (changedDoc.eventName.indexOf('/') > -1) {
  265. var [mineId, action] = changedDoc.eventName.split('/');
  266. if (action == 'notification') {
  267. angular.forEach(changedDoc.args, function (item) {
  268. if ($rootScope.filternotifyuser.indexOf(item.payload.sender._id) > -1) {
  269. } else {
  270. // console.log("push notify message:%o", item);
  271. var r = angular.extend(item, { 'date': new Date() })
  272. $rootScope.imUsrMap[item.payload.sender._id]['unread'].msgs.push(r);
  273. $rootScope.imUsrMap[item.payload.sender._id]['unread'].total++;
  274. pushNotification({
  275. title: "您有新消息-来自" + item.payload.sender.username,
  276. body: r.text,
  277. callback: function () {
  278. window.focus();
  279. $rootScope.toggle('off-sidebar');
  280. }
  281. })
  282. //toaster.pop('info', "您有新消息-来自"+item.payload.sender.username, r.text);
  283. }
  284. })
  285. }
  286. }
  287. }
  288. } else {
  289. }
  290. //console.log('notify message %o, %o', changedDoc, message);
  291. });
  292. ddp.watch('stream-room-messages', function (changedDoc, message) {
  293. if (message == 'changed') {
  294. //angular.forEach(changedDoc.args,function(item){
  295. $rootScope.$broadcast(changedDoc.eventName + '-msgs', changedDoc.args);
  296. //};
  297. // if(changedDoc.eventName){
  298. // $rootScope.imUsrMap[eventName]=$rootScope.imUsrMap[eventName]||{};
  299. // $rootScope.imUsrMap[eventName]['msgs']=$rootScope.imUsrMap[eventName]['msgs']||[];
  300. // angular.forEach(changedDoc.args,function(item){
  301. // $rootScope.imUsrMap[eventName].msgs.push(item);
  302. // })
  303. // }
  304. } else {
  305. }
  306. // console.log('notify message %o, %o', changedDoc, message);
  307. });
  308. ddp.watch('rocketchat_message', function (changedDoc, message) {
  309. // console.log('recieve rocketchat_message: %o-%o', changedDoc, message);
  310. });
  311. });
  312. }
  313. window.onunload = function () {
  314. }
  315. $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
  316. //$auth.validateUser();
  317. //stop loading bar on stateChangeSuccess
  318. event.targetScope.$watch("$viewContentLoaded", function () {
  319. cfpLoadingBar.complete();
  320. });
  321. // scroll top the page on change state
  322. $document.scrollTo(0, 0);
  323. if (angular.element('.email-reader').length) {
  324. angular.element('.email-reader').animate({
  325. scrollTop: 0
  326. }, 0);
  327. }
  328. // Save the route title
  329. $rootScope.currTitle = $state.current.title;
  330. if (angular.isDefined($state.current.pdKey)) {
  331. $rootScope.pdKey = $state.current.pdKey;
  332. }
  333. // console.log($state.current.title);
  334. });
  335. // State not found
  336. $rootScope.$on('$stateNotFound', function (event, unfoundState, fromState, fromParams) {
  337. //$rootScope.loading = false;
  338. if (angular.isUndefined($rootScope.user.id)) {
  339. $rootScope.loading = false;
  340. }
  341. // console.log(unfoundState.to);
  342. // "lazy.state"
  343. // console.log(unfoundState.toParams);
  344. // {a:1, b:2}
  345. // console.log(unfoundState.options);
  346. // {inherit:false} + default options
  347. });
  348. $rootScope.isMousedown = false;
  349. $rootScope.changeRemoveClass = function (e) {
  350. $rootScope.isMousedown = true
  351. }
  352. $rootScope.returnRemoveClass = function (e) {
  353. $rootScope.isMousedown = false;
  354. }
  355. $rootScope.$on('auth:login-success', function (ev, data) {
  356. // $state.go('login.signin');
  357. initImUser(data.email, data.msgUuid);
  358. getMenus();
  359. //console.log(data);
  360. //$rootScope.user = data.user;
  361. //$rootScope.menus = data.menu;
  362. });
  363. //$rootScope.$watch('$auth.user')
  364. // $rootScope.$on('auth:validation-success', function(ev, user) {
  365. // // console.log(user);
  366. // initImUser(user.email, user.msgUuid);
  367. // if ($rootScope.userMenus.length == 0) {
  368. // getMenus();
  369. // }
  370. // //alert('Welcome ', user.email);
  371. // });
  372. // $rootScope.$on('auth:invalid', function(ev) {
  373. // $state.go('login.signin');
  374. // });
  375. // $rootScope.$on('auth:validation-error', function(ev) {
  376. // $state.go('login.signin');
  377. // //alert('Welcome ', user.email);
  378. // });
  379. // $rootScope.$on('auth:session-expired', function(ev) {
  380. // //alert('Welcome ', user.email);
  381. // $state.go('login.signin');
  382. // });
  383. // $rootScope.$on('auth:logout-success', function(ev) {
  384. // //alert('goodbye');
  385. // //delete $rootScope.user;
  386. // //delete $rootScope.menus;
  387. // $state.go('login.signin');
  388. // });
  389. // $rootScope.$on('auth:logout-error', function(ev) {
  390. // $state.go('login.signin');
  391. // });
  392. $rootScope.pageTitle = function () {
  393. // if($rootScope.currTitle){
  394. // return $rootScope.app.name + ' - ' + $filter('translate')($rootScope.currTitle) || $rootScope.app.description;
  395. // }else{
  396. // return $rootScope.app.name + ' - ' + $rootScope.app.description
  397. // }
  398. var perfix = "sidebar.nav.";
  399. var toTransKeypageTitle = perfix + $rootScope.currTitle;
  400. return $rootScope.app.name + ' - ' + ($filter('translate')(toTransKeypageTitle) || $rootScope.app.description);
  401. };
  402. // $auth.validateUser();
  403. // $auth.authenticate('local').then(function(resp){
  404. // }).catch(function(resp){
  405. // })
  406. // if(angular.isDefined($rootScope.nickname)){
  407. // api_login.sso($rootScope.nickname).then(function(response){
  408. // var user = Restangular.stripRestangular(response);
  409. // if (user) {
  410. // if(angular.isUndefined(user.id)){
  411. // }else{
  412. // $rootScope.user = user;
  413. // }
  414. // }
  415. // });
  416. // }else{
  417. // var user= $cookieStore.get("userObm");
  418. // if(user){
  419. // $rootScope.user = user;
  420. // $rootScope.menus = $cookieStore.get("menuObm");
  421. // }else{
  422. // if(angular.isDefined($rootScope.nickname)){
  423. // api_login.sso($rootScope.nickname).then(function(response){
  424. // var data = Restangular.stripRestangular(response);
  425. // if (data) {
  426. // if(data.user){
  427. // if(angular.isUndefined(data.user.id)){
  428. // }else{
  429. // $rootScope.user = data.user;
  430. // $rootScope.menus = data.menu;
  431. // $cookieStore.put("userObm", $rootScope.user);
  432. // $cookieStore.put("menuObm", $rootScope.menus);
  433. // $cookieStore.put("session", data.sessionId);
  434. // }
  435. // }
  436. // }
  437. // });
  438. // }else{
  439. // }
  440. // }
  441. //}
  442. $rootScope.getSession = function () {
  443. if ($auth.userIsAuthenticated()) {
  444. return $auth.retrieveData('auth_headers')
  445. /*return {
  446. 'access-token':$auth.retrieveData('auth_headers')['access-token'],
  447. 'expiry':$auth.retrieveData('auth_headers')['expiry']
  448. };*/
  449. } else {
  450. return undefined;
  451. }
  452. }
  453. $scope.includes = [];
  454. $rootScope.includesState = function (state) {
  455. //for test
  456. //return true;
  457. //return includes;
  458. if ($rootScope.user) {
  459. if ($rootScope.user.menu) {
  460. angular.forEach($rootScope.user.menu, function (item) {
  461. $scope.includes[item.link] = true;
  462. });
  463. }
  464. }
  465. return $scope.includes[state];
  466. }
  467. //大屏入口
  468. $rootScope.opendashbord = function () {
  469. $state.go('echart');
  470. }
  471. // $rootScope.authority=false;
  472. // console.log($rootScope.user)
  473. // if($rootScope.user.role){
  474. // for(var i ;i<$rootScope.user.role.length;i++){
  475. // if($rootScope.user.role[i].rolecode=='call center') {
  476. // $rootScope.authority=true;
  477. // }else{$rootScope.authority=false;}
  478. // }
  479. // }
  480. /* status[已签入:1/通话中:3/来电:2],state[示闲:1,示忙:2] */
  481. // if (window.location.href && window.location.href.hash == "#/echart") {
  482. // } else {
  483. // // }
  484. // // 东经呼叫中心开始
  485. // $rootScope.statuscall = 0; //话机状态
  486. // $rootScope.statecall = 1; //示忙示闲
  487. // $scope.login = false; //签入签出
  488. // $rootScope.callout = false; //呼入呼出
  489. // $scope.group = 2000;
  490. // $scope.phone = 1500;
  491. // $rootScope.start = function(phone, group) {
  492. // api_text.start(phone, $rootScope.user.id).then(function(data) {
  493. // var token = data.token;
  494. // $rootScope.takes = token;
  495. // api_text.logout($rootScope.takes, $rootScope.user.id).then(function(data) { if (data.errno == 0) {} });
  496. // api_text.login($scope.group, token, $rootScope.user.id).then(function(data) {
  497. // if (data.errno == 0) {
  498. // $rootScope.setidle();
  499. // $scope.login = true;
  500. // $rootScope.statuscall = 1;
  501. // $rootScope.callout = false;
  502. // // function hello() {
  503. // // var ws = new WebSocket('ws://192.168.3.49:28088/events');
  504. // // ws.onopen = function() { ws.send(JSON.stringify(register)); };
  505. // // };
  506. // // window.setTimeout("hello()", 1000);
  507. // // var ws = new WebSocket('ws://192.168.77.57:28088/events');
  508. // function reconnect() {
  509. // // var ws = new WebSocket('ws://192.168.3.49:28088/events');
  510. // var ws = new WebSocket('ws://115.156.150.70:28088/events');
  511. // var register = { "msgtype": "login", "adn": phone };
  512. // ws.onopen = function() {
  513. // heartCheck.start();
  514. // ws.send(JSON.stringify(register));
  515. // };
  516. // ws.onmessage = function(evt) {
  517. // heartCheck.reset();
  518. // if (evt.data == "HeartBeat") {
  519. // } else {
  520. // var mydata = JSON.parse(evt.data);
  521. // $scope.filterData = [];
  522. // if (mydata.evttype == "callincome" && mydata.uud != "misc:callback") {
  523. // $rootScope.$apply(function() {
  524. // $rootScope.statuscall = 2;
  525. // });
  526. // $rootScope.callout = false;
  527. // $rootScope.phone = mydata.ano;
  528. // var Notification = window.Notification;
  529. // Notification.requestPermission();
  530. // var n = new Notification("你有来电", {
  531. // body: "来电号码:" + mydata.ano,
  532. // icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  533. // // onclick: function onNotificationClicked() {
  534. // // console.log('Notification clicked.');
  535. // // }
  536. // });
  537. // } else if (mydata.evttype == "callincome" && mydata.uud == "misc:callback") {
  538. // $rootScope.callout = true;
  539. // } else if (mydata.evttype == "ringstop") {
  540. // // $rootScope.status=7;
  541. // // $rootScope.$apply(function() {
  542. // $rootScope.statuscall = 1;
  543. // // });
  544. // $rootScope.phone = ""
  545. // } else if (mydata.evttype == 'hookchanged' && $rootScope.callout) {
  546. // if (mydata.status && mydata.status == '1') {
  547. // $rootScope.$apply(function() {
  548. // $rootScope.statuscall = 1;
  549. // });
  550. // $rootScope.phone = "";
  551. // } else if (mydata.status && mydata.status != '1') {
  552. // $rootScope.$apply(function() {
  553. // $rootScope.statuscall = 3;
  554. // });
  555. // }
  556. // } else if (mydata.evttype == 'hookchanged' && !$rootScope.callout) {
  557. // if ($rootScope.phone != "") {
  558. // if (mydata.status && mydata.status == '1') { //挂机
  559. // $rootScope.$apply(function() {
  560. // $rootScope.statuscall = 1;
  561. // });
  562. // console.log("挂机");
  563. // console.log(mydata);
  564. // } else if (mydata.status && mydata.status != '1' && $rootScope.statecall != 2) { //摘机
  565. // $rootScope.statuscall = 3;
  566. // api_text.setbusy($rootScope.takes).then(function(data) {
  567. // if (data.errno == 0) {
  568. // $rootScope.statecall = 2;
  569. // $scope.busy = true;
  570. // }
  571. // })
  572. // console.log("摘机");
  573. // console.log(mydata);
  574. // api_text.getcdrid($rootScope.takes).then(function(response) {
  575. // if (response.cdrid) {
  576. // var cdrid = response.cdrid;
  577. // // var response={cdrid:'219023836'}
  578. // var filterData = { "idx": 0, "sum": 10, "requester": { "mphone": $rootScope.phone, "telephone": $rootScope.phone, "selectType": 1 } }
  579. // api_user_data.fetchDataList('requester', filterData).then(function(data) {
  580. // var myData = Restangular.stripRestangular(data);
  581. // // $rootScope.phone="";
  582. // if (myData.list.length == 0) {
  583. // var modalInstance = $modal.open({
  584. // templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  585. // controller: function($scope, $modalInstance, api_user_data) {
  586. // $scope.title = "新增报修人";
  587. // $scope.requester = {};
  588. // $scope.onChangeadd = function(searchData) {
  589. // $scope.searchKey = searchData.account;
  590. // // $scope.searchDataadd = searchData;
  591. // var requesdata = angular.copy(searchData)
  592. // // if (requesdata.mphone) {
  593. // // delete requesdata.mphone;
  594. // // }
  595. // if (requesdata.telephone) {
  596. // delete requesdata.telephone;
  597. // }
  598. // angular.extend($scope.requester, requesdata);
  599. // }
  600. // $scope.refreshUseradd = function(searchKey) { //请求人搜索
  601. // $scope.requester.account = searchKey;
  602. // $scope.searchData = searchKey;
  603. // serchdataadd(searchKey);
  604. // }
  605. // $scope.getMydata = function(x) {
  606. // var reqestdatap = JSON.parse(x[0])
  607. // // if ($scope.requester.mphone) {
  608. // // delete reqestdatap.mphone;
  609. // // }
  610. // if ($scope.requester.telephone) {
  611. // delete reqestdatap.telephone;
  612. // }
  613. // $scope.searchField = JSON.parse(x[0]).account;
  614. // angular.extend($scope.requester, reqestdatap);
  615. // }
  616. // $scope.getMydataone = function(x) {
  617. // $scope.searchField = x;
  618. // $scope.requester.account = x;
  619. // }
  620. // serchdataadd();
  621. // function serchdataadd(searchKey) {
  622. // if (searchKey) {
  623. // var filterData = {
  624. // 'requester': {
  625. // 'searchKey': searchKey,
  626. // },
  627. // idx: 0,
  628. // sum: 10
  629. // };
  630. // } else {
  631. // var filterData = {
  632. // idx: 0,
  633. // sum: 10
  634. // };
  635. // }
  636. // // serchdataadd(searchKey)
  637. // // if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  638. // // angular.extend(filterData.requester, { 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO })
  639. // // }
  640. // api_user_data.fetchDataList('requester', filterData).then(function(response) {
  641. // var myData = response;
  642. // $scope.myData = myData.list;
  643. // });
  644. // }
  645. // // if ((/^1[34578]\d{9}$/.test($rootScope.phone))) {
  646. // // $scope.requester = { 'mphone': $rootScope.phone };
  647. // // } else {
  648. // // $scope.requester = { 'telephone': $rootScope.phone };
  649. // // }
  650. // $scope.requester = { 'telephone': $rootScope.phone };
  651. // $scope.ok = function() {
  652. // $modalInstance.close($scope.requester);
  653. // };
  654. // $scope.cancel = function() {
  655. // $modalInstance.dismiss('cancel');
  656. // };
  657. // },
  658. // });
  659. // modalInstance.result.then(function(selectedItem) {
  660. // if (selectedItem) {
  661. // if (selectedItem.telephone && !selectedItem.mphone) {
  662. // selectedItem.telephone = angular.copy(selectedItem.mphone);
  663. // delete selectedItem.mphone;
  664. // }
  665. // var data = {
  666. // 'requester': selectedItem
  667. // };
  668. // api_user_data.addData('requester', data).then(function(response) {
  669. // if (response.status == 200) {
  670. // var data = { 'model': { 'requestershow': response.data, 'incident': { 'requester': response.data, 'area': response.areaDTO, 'place': response.placeDTO, 'houseNumber': response.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
  671. // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  672. // }
  673. // })
  674. // }
  675. // });
  676. // } else if (myData.list.length == 1) {
  677. // 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 } } } }
  678. // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  679. // } else {
  680. // var modalInstance = $modal.open({
  681. // templateUrl: 'assets/views/createincident.html',
  682. // controller: function($scope, $modalInstance, api_user_data) {
  683. // $scope.title = "请确定报修人";
  684. // $scope.requester = myData.list;
  685. // $scope.choice = function(requester) {
  686. // $modalInstance.dismiss('cancel');
  687. // var data = { 'model': { 'requestershow': requester, 'incident': { 'requester': requester, 'area': requester.areaDTO, 'place': requester.placeDTO, 'houseNumber': requester.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
  688. // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  689. // };
  690. // $scope.cancel = function() {
  691. // $modalInstance.dismiss('cancel');
  692. // };
  693. // },
  694. // size: "lg"
  695. // });
  696. // }
  697. // });
  698. // }
  699. // })
  700. // }
  701. // }
  702. // }
  703. // }
  704. // };
  705. // var heartCheck = {
  706. // timeout: 12000, //60ms
  707. // timeoutObj: null,
  708. // serverTimeoutObj: null,
  709. // reset: function() {
  710. // clearTimeout(this.timeoutObj);
  711. // clearTimeout(this.serverTimeoutObj);
  712. // this.start();
  713. // },
  714. // start: function() {
  715. // var self = this;
  716. // this.timeoutObj = setTimeout(function() {
  717. // ws.send("HeartBeat");
  718. // self.serverTimeoutObj = setTimeout(function() {
  719. // ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  720. // }, self.timeout)
  721. // }, this.timeout)
  722. // },
  723. // }
  724. // ws.onclose = function(evt) { reconnect(); }
  725. // ws.onerror = function(evt) { reconnect(); };
  726. // }
  727. // reconnect();
  728. // } else {
  729. // var Notification = window.Notification;
  730. // Notification.requestPermission();
  731. // var n = new Notification("签入失败!", {
  732. // body: data.errmsg,
  733. // icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  734. // // onclick: function onNotificationClicked() {
  735. // // console.log('Notification clicked.');
  736. // // }
  737. // });
  738. // }
  739. // })
  740. // })
  741. // }
  742. // // 东经呼叫中心结束
  743. //话机呼叫中心--开始
  744. $rootScope.getExtnDirect = function () {
  745. var jry_data_dictionary = {
  746. key: "hjzx_cornet",
  747. type: "list"
  748. }
  749. api_wechatfile.getDictionary(jry_data_dictionary).then(function (res) {
  750. var websocket_url = "ws://192.168.3.122:29003/ola_socket";
  751. var ola_queue = "10009"; //通话配置-队列配置-队列ID
  752. // var ola_extn = "1001"; //个人信息-座席分机号
  753. $rootScope.jry_extnNumberSelect = [];
  754. $rootScope.jry_extnNumberObj = {};
  755. $rootScope.jry_extnNumberSelect = res;
  756. $rootScope.jry_extnNumberObj.jry_extnNumber = $rootScope.jry_extnNumberSelect[0];
  757. function log(msg) {
  758. //IE has no console
  759. if ('console' in window) console.log(msg);
  760. }
  761. function websocket_connect() {
  762. ola.connect(websocket_url);
  763. ola.onConnect = onConnect;
  764. ola.onClose = onClose;
  765. ola.onMessage = onMessage;
  766. }
  767. $(document).ready(function () {
  768. // if(ola_extn!=""){
  769. if ($rootScope.jry_extnNumberObj.jry_extnNumber) {
  770. websocket_connect();
  771. }
  772. });
  773. /* callbacks */
  774. function onMessage(evt) {
  775. var phoneData = JSON.parse(evt.data);
  776. if (phoneData.event_type == "agent_state") {
  777. console.log(phoneData);
  778. if (phoneData.state == "busy") {
  779. $('#agent_state').append(" (" + phoneData.private_data + ")");
  780. // 来电
  781. if (phoneData.private_data == "ring") {
  782. console.log(phoneData);
  783. $rootScope.jry_state = "laidian";
  784. var Notification = window.Notification;
  785. Notification.requestPermission();
  786. var n = new Notification("你有来电", {
  787. body: "来电号码:" + phoneData.ani,
  788. icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  789. });
  790. // 摘机
  791. } else if (phoneData.private_data == "answered") {
  792. $rootScope.jry_state = "tonghuazhong";
  793. var jry_findPhone = "";
  794. if (phoneData.ani) {
  795. jry_findPhone = phoneData.ani
  796. } else if (phoneData.dnis && phoneData.other_answered) {
  797. jry_findPhone = phoneData.dnis
  798. }
  799. var filterData = {
  800. "idx": 0,
  801. "sum": 100,
  802. "requester": {
  803. "mphone": jry_findPhone,
  804. "telephone": jry_findPhone,
  805. "selectType": 1
  806. }
  807. }
  808. api_user_data.fetchDataList('requester', filterData).then(function (data) {
  809. var myData = Restangular.stripRestangular(data);
  810. // $rootScope.phone="";
  811. // 新增报修人
  812. if (myData.list.length == 0) {
  813. var modalInstance = $modal.open({
  814. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  815. controller: function ($scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  816. $scope.title = "新增报修人";
  817. $scope.requester = {};
  818. $scope.onChangeadd = function (searchData) {
  819. $scope.searchKey = searchData.account;
  820. // $scope.searchDataadd = searchData;
  821. var requesdata = angular.copy(searchData)
  822. // if (requesdata.mphone) {
  823. // delete requesdata.mphone;
  824. // }
  825. if (requesdata.telephone) {
  826. delete requesdata.telephone;
  827. }
  828. angular.extend($scope.requester, requesdata);
  829. }
  830. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  831. $scope.requester.account = searchKey;
  832. $scope.searchData = searchKey;
  833. serchdataadd(searchKey);
  834. }
  835. $scope.getMydata = function (x) {
  836. var reqestdatap = JSON.parse(x[0])
  837. // if ($scope.requester.mphone) {
  838. // delete reqestdatap.mphone;
  839. // }
  840. if ($scope.requester.telephone) {
  841. delete reqestdatap.telephone;
  842. }
  843. $scope.searchField = JSON.parse(x[0]).account;
  844. angular.extend($scope.requester, reqestdatap);
  845. }
  846. $scope.getMydataone = function (x) {
  847. $scope.searchField = x;
  848. $scope.requester.account = x;
  849. }
  850. serchdataadd();
  851. function serchdataadd(searchKey) {
  852. if (searchKey) {
  853. var filterData = {
  854. 'requester': {
  855. 'searchKey': searchKey,
  856. },
  857. idx: 0,
  858. sum: 10
  859. };
  860. } else {
  861. var filterData = {
  862. idx: 0,
  863. sum: 10
  864. };
  865. }
  866. api_user_data.fetchDataList('requester', filterData).then(function (response) {
  867. var myData = response;
  868. $scope.myData = myData.list;
  869. });
  870. }
  871. api_user_data.fetchDataList('area', {
  872. idx: 0,
  873. sum: 100
  874. }).then(function (response) {
  875. if (response.status == 200) {
  876. $scope.areas = response.list;
  877. }
  878. })
  879. api_wechatfile.getDictionary({
  880. "key": "requester_type",
  881. "type": "list"
  882. }).then(function (response) {
  883. // if (response.status == 200) {
  884. $scope.networktypes = response;
  885. // }
  886. })
  887. $scope.requesterAreaid = "";
  888. $scope.onChange = function (item) {
  889. $scope.requesterAreaid = item.id;
  890. $scope.requester.placeDTO = {};
  891. api_user_data.fetchDataList('place', {
  892. place: {
  893. areaId: item.id
  894. },
  895. idx: 0,
  896. sum: 1000
  897. }).then(function (response) {
  898. if (response.status == 200) {
  899. $scope.places = response.list;
  900. }
  901. })
  902. }
  903. //地点搜索
  904. $scope.refresh = function (searchVal) {
  905. var faildata = {};
  906. if ($scope.requesterAreaid) {
  907. faildata = {
  908. 'idx': 0,
  909. 'sum': 1000,
  910. 'place': {
  911. 'areaId': $scope.requesterAreaid,
  912. 'place': searchVal,
  913. 'selectType': 'pinyin_qs'
  914. }
  915. }
  916. } else {
  917. faildata = {
  918. 'idx': 0,
  919. 'sum': 1000,
  920. 'place': {
  921. 'place': searchVal,
  922. 'selectType': 'pinyin_qs'
  923. }
  924. }
  925. }
  926. api_user_data.fetchDataList('place', faildata).then(function (response) {
  927. $scope.places = response.list;
  928. delete $scope.requester.placeDTO;
  929. })
  930. }
  931. $scope.requester = {
  932. 'telephone': jry_findPhone
  933. };
  934. $scope.ok = function () {
  935. var reg1 = /^1[3456789][0-9]{9}$/; //手机号
  936. var reg2 = /^((0\d{2,3})-)*(\d{7,8})(-(\d{3,}))?$/; //座机号
  937. var flag1 = reg1.test($scope.requester.mphone);
  938. var flag2 = reg2.test($scope.requester.mphone);
  939. console.log($scope.requester)
  940. if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  941. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  942. } else if (angular.isUndefined($scope.requester.requesterType)) {
  943. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  944. } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
  945. SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
  946. }
  947. else {
  948. $modalInstance.close($scope.requester);
  949. }
  950. };
  951. $scope.cancel = function () {
  952. $modalInstance.dismiss('cancel');
  953. };
  954. },
  955. });
  956. modalInstance.result.then(function (selectedItem) {
  957. if (selectedItem) {
  958. if (selectedItem.telephone && !selectedItem.mphone) {
  959. selectedItem.telephone = angular.copy(selectedItem.mphone);
  960. delete selectedItem.mphone;
  961. }
  962. var data = {
  963. 'requester': selectedItem
  964. };
  965. api_user_data.addData('requester', data).then(function (response) {
  966. if (response.status == 200) {
  967. var data = {
  968. 'model': {
  969. 'requestershow': response.data,
  970. 'incident': {
  971. 'requester': response.data,
  972. 'area': response.data.areaDTO,
  973. 'place': response.data.placeDTO,
  974. 'houseNumber': response.data.houseNumber,
  975. // 'callID': cdrid,
  976. 'source': {
  977. 'id': 1547
  978. }
  979. }
  980. }
  981. }
  982. $state.go('app.incident.title', {
  983. 'model': JSON.stringify(data)
  984. });
  985. }
  986. })
  987. }
  988. });
  989. } else if (myData.list.length == 1) {
  990. var data = {
  991. 'model': {
  992. 'requestershow': myData.list[0],
  993. 'incident': {
  994. 'requester': myData.list[0],
  995. 'area': myData.list[0].areaDTO,
  996. 'place': myData.list[0].placeDTO,
  997. 'houseNumber': myData.list[0].houseNumber,
  998. // 'callID': cdrid,
  999. 'source': {
  1000. 'id': 1547
  1001. }
  1002. }
  1003. }
  1004. }
  1005. $state.go('app.incident.title', {
  1006. 'model': JSON.stringify(data)
  1007. });
  1008. } else {
  1009. var modalInstance = $modal.open({
  1010. templateUrl: 'assets/views/createincident.html',
  1011. controller: function ($scope, $modalInstance, api_user_data) {
  1012. $scope.title = "请确定报修人";
  1013. $scope.requester = myData.list;
  1014. $scope.choice = function (requester) {
  1015. $modalInstance.dismiss('cancel');
  1016. var data = {
  1017. 'model': {
  1018. 'requestershow': requester,
  1019. 'incident': {
  1020. 'requester': requester,
  1021. 'area': requester.areaDTO,
  1022. 'place': requester.placeDTO,
  1023. 'houseNumber': requester.houseNumber,
  1024. // 'callID': cdrid,
  1025. 'source': {
  1026. 'id': 1547
  1027. }
  1028. }
  1029. }
  1030. }
  1031. $state.go('app.incident.title', {
  1032. 'model': JSON.stringify(data)
  1033. });
  1034. };
  1035. $scope.cancel = function () {
  1036. $modalInstance.dismiss('cancel');
  1037. };
  1038. },
  1039. size: "lg"
  1040. });
  1041. }
  1042. });
  1043. }
  1044. // 挂机
  1045. } else if (phoneData.state == "login") {
  1046. go_ready()
  1047. } else if (phoneData.state == "logout") {
  1048. $rootScope.jry_state = "weiqianru";
  1049. } else if (phoneData.state == "ready") {
  1050. // 来电挂机
  1051. if (phoneData.old_state == "busy" && phoneData.private_data == "answered") {
  1052. go_break()
  1053. } else {
  1054. $rootScope.jry_state = "shixian";
  1055. }
  1056. }
  1057. // else if (data.old_state == "busy") {
  1058. // }
  1059. } else if (phoneData.event_type == "agent_caller_state") {
  1060. // special feature, never mind
  1061. if (phoneData.action == "in") {
  1062. } else {
  1063. }
  1064. } else if (phoneData.event_type == "command/reply") {
  1065. if (phoneData.phoneData && phoneData.phoneData.state) {
  1066. }
  1067. }
  1068. }
  1069. function onConnect() {
  1070. console.log("websocket connected!");
  1071. // ola._extn = ola_extn;
  1072. // ola.subscribe('ola.queue.' + ola_queue + '.' + ola_extn);
  1073. // ola.subscribe('ola.caller.' + ola_extn);
  1074. // ola.get_agent_state(ola_extn);
  1075. ola._extn = $rootScope.jry_extnNumberObj.jry_extnNumber.name;
  1076. ola.subscribe('ola.queue.' + ola_queue + '.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
  1077. ola.subscribe('ola.caller.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
  1078. ola.get_agent_state($rootScope.jry_extnNumberObj.jry_extnNumber.name);
  1079. };
  1080. function onClose() {
  1081. }
  1082. function login() {
  1083. // ola.login(ola_queue, ola_extn, {type: "onhook"});
  1084. console.log($rootScope.jry_extnNumberObj.jry_extnNumber);
  1085. ola.login(ola_queue, $rootScope.jry_extnNumberObj.jry_extnNumber.name, { type: "onhook" });
  1086. }
  1087. function logout() {
  1088. ola.logout();
  1089. }
  1090. function go_ready() {
  1091. ola.go_ready();
  1092. }
  1093. function go_break() {
  1094. ola.go_break($('#break_reason').val());
  1095. $rootScope.jry_state = "shimang";
  1096. }
  1097. function answer() {
  1098. ola.answer();
  1099. }
  1100. function dial(dst) {
  1101. ola.dial(dst);
  1102. }
  1103. $rootScope.dial = function (dst) {
  1104. ola.dial(dst);
  1105. }
  1106. function conference(dst) {
  1107. ola.conference(dst);
  1108. }
  1109. function conference_uuid(channel_uuid) {
  1110. ola.conference_uuid(channel_uuid);
  1111. }
  1112. function hangup() {
  1113. ola.hangup();
  1114. }
  1115. function take_call(uuid) {
  1116. // ola.take_call(ola_extn, uuid);
  1117. ola.take_call($rootScope.jry_extnNumberObj.jry_extnNumber.name, uuid);
  1118. }
  1119. // 签入
  1120. $rootScope.jry_qianru = function () {
  1121. login();
  1122. }
  1123. // 示闲
  1124. $rootScope.jry_shixian = function () {
  1125. go_ready()
  1126. }
  1127. // 示忙
  1128. $rootScope.jry_shimang = function () {
  1129. go_break()
  1130. }
  1131. // 签出
  1132. $rootScope.jry_qianchu = function () {
  1133. logout()
  1134. }
  1135. $rootScope.jry_bohao = function (res) {
  1136. if ($rootScope.jry_state == "weiqianru") {
  1137. // SweetAlert.swal({
  1138. // title: "拨打失败",
  1139. // text: "请先签入!",
  1140. // type: "error",
  1141. // confirmButtonColor: "#DD6B55"
  1142. // });
  1143. } else if ($rootScope.jry_state == "shimang") {
  1144. // SweetAlert.swal({
  1145. // title: "拨打失败",
  1146. // text: "请先示闲!",
  1147. // type: "error",
  1148. // confirmButtonColor: "#DD6B55"
  1149. // });
  1150. } else {
  1151. dial(res);
  1152. }
  1153. }
  1154. })
  1155. }
  1156. $rootScope.jry_state = "weiqianru";
  1157. $rootScope.getExtnDirect();
  1158. //话机呼叫中心--结束
  1159. // 未接来电
  1160. $scope.jry_getUnanswered = function () {
  1161. var jry_data = {
  1162. idx: 0,
  1163. sum: 999,
  1164. "callRecord": {
  1165. "todayTime": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 00:00:00",
  1166. "todayTimeEnd": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 23:59:59",
  1167. }
  1168. }
  1169. api_bpm_data.fetchDataList("callRecord", jry_data).then(function (data) {
  1170. // fo0h
  1171. for (var i = 0; i < data.list.length; i++) {
  1172. 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()
  1173. }
  1174. $rootScope.jry_unansweredData = data.list;
  1175. });
  1176. }
  1177. // $scope.jry_getUnanswered();
  1178. // 来电号码回拨
  1179. $scope.jry_callBack = function (data) {
  1180. var callBackData = {
  1181. "callRecord": {
  1182. "id": data.id,
  1183. "isAnswered": "1"
  1184. }
  1185. };
  1186. api_bpm_data.updData("callRecord", callBackData).then(function (res) {
  1187. if (res) {
  1188. $scope.jry_getUnanswered();
  1189. dial(data.callerIdNumber)
  1190. }
  1191. });
  1192. if (data.department.id && data.requester) {
  1193. 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 } }
  1194. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  1195. } else if (data.department.id) {
  1196. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
  1197. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  1198. } else {
  1199. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
  1200. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  1201. };
  1202. // ws.send("{\"type\":\"1\",\"phone\":\""+data.phone+"\"}");
  1203. }
  1204. //来电号码生成事件
  1205. $scope.jry_callToIncident = function (data) {
  1206. if (data.department.id && data.requester) {
  1207. 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 } }
  1208. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  1209. } else if (data.department.id) {
  1210. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
  1211. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  1212. } else {
  1213. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
  1214. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  1215. }
  1216. }
  1217. $scope.onChangeadd = function (searchData) {
  1218. $scope.searchKey = searchData.account;
  1219. // $scope.searchDataadd = searchData;
  1220. var requesdata = angular.copy(searchData)
  1221. $scope.requester = requesdata;
  1222. }
  1223. $scope.refreshUseradd = function (searchKey) { //主题搜索
  1224. $scope.searchData = searchKey;
  1225. reashdata($scope.searchData);
  1226. }
  1227. $scope.getMydata = function (x) {
  1228. $scope.telephone = JSON.parse(x).phone;
  1229. $scope.searchField = $scope.telephone;
  1230. return $scope.searchField;
  1231. }
  1232. $scope.getMydataone = function (x) {
  1233. $scope.telephone = x;
  1234. $scope.searchField = $scope.telephone;
  1235. }
  1236. $scope.fildata = {
  1237. "idx": 0,
  1238. "sum": 10,
  1239. "flag": -1
  1240. }
  1241. function reashdata(item) {
  1242. if (item && item != "") {
  1243. angular.extend($scope.fildata, { 'user': { 'flag': -1, 'phone': item } })
  1244. } else {
  1245. delete $scope.fildata.user;
  1246. }
  1247. api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function (data) {
  1248. if (data.status == 200) {
  1249. $scope.myData = data.list;
  1250. }
  1251. })
  1252. // api_user_data.fetchDataList('user', $scope.fildata).then(function(response) {
  1253. // if (response) {
  1254. // if (response.status = 200) {
  1255. // var myData = response;
  1256. // $scope.myData = myData.list;
  1257. // }
  1258. // }
  1259. // })
  1260. }
  1261. if (window.location && window.location.hash == "#/echart") {
  1262. } else {
  1263. reashdata();
  1264. }
  1265. $rootScope.end = function () {
  1266. api_text.logout($rootScope.takes, $rootScope.user.id).then(function (data) {
  1267. if (data.errno == 0) {
  1268. api_text.exit($rootScope.takes).then(function (data) {
  1269. if (data.errno == 0) {
  1270. $rootScope.statuscall = 0;
  1271. $scope.login = false
  1272. // SweetAlert.swal({
  1273. // title: "登出成功",
  1274. // text: "呼叫中心登出成功!",
  1275. // type: "success"
  1276. // });
  1277. // }else{SweetAlert.swal({
  1278. // title: "登出失败",
  1279. // text: "呼叫中心登出失败!",
  1280. // type: "error"
  1281. // });
  1282. }
  1283. })
  1284. }
  1285. })
  1286. }
  1287. $rootScope.dialout = function (gid, teleno) {
  1288. var telephone = "";
  1289. if (teleno && teleno.length > 4) {
  1290. telephone = '9' + teleno;
  1291. } else {
  1292. // telephone = '*01' + teleno + '*';
  1293. telephone = teleno;
  1294. }
  1295. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  1296. if (data.errno == 0) {
  1297. // $rootScope.statuscall = 3;
  1298. $rootScope.callout = true;
  1299. // $rootScope.phone=teleno;
  1300. }
  1301. })
  1302. }
  1303. // $scope.busy=false;
  1304. $rootScope.setbusy = function () {
  1305. api_text.setbusy($rootScope.takes).then(function (data) {
  1306. if (data.errno == 0) {
  1307. $rootScope.statecall = 2;
  1308. $scope.busy = true;
  1309. }
  1310. })
  1311. }
  1312. $rootScope.setidle = function () {
  1313. api_text.setidle($rootScope.takes).then(function (data) {
  1314. if (data.errno == 0) {
  1315. $rootScope.statecall = 1;
  1316. $scope.busy = false;
  1317. }
  1318. })
  1319. }
  1320. $rootScope.inittrans = function (telephone) {
  1321. api_text.inittrans(telephone, $rootScope.takes).then(function (data) {
  1322. if (data.errno == 0) {
  1323. // $scope.status=9
  1324. }
  1325. })
  1326. }
  1327. $rootScope.comptrans = function () {
  1328. api_text.comptrans($rootScope.takes).then(function (data) {
  1329. if (data.errno == 0) {
  1330. $rootScope.statuscall = 1;
  1331. }
  1332. })
  1333. }
  1334. $rootScope.takeup = function () {
  1335. api_text.offhook($rootScope.takes).then(function (data) {
  1336. if (data.errno == 0) {
  1337. $rootScope.statuscall = 3;
  1338. }
  1339. })
  1340. }
  1341. $rootScope.takedown = function () {
  1342. api_text.onhook($rootScope.takes).then(function (data) {
  1343. if (data.errno == 0) {
  1344. $rootScope.statuscall = 1;
  1345. }
  1346. })
  1347. }
  1348. $rootScope.saveData = function (selectdata) {
  1349. var modalInstance = $modal.open({
  1350. templateUrl: 'assets/views/system/tpl/createknowledge.html',
  1351. controller: function ($scope, $modalInstance, api_bpm_data) {
  1352. $scope.worktimedata = {};
  1353. $scope.worktimedata = selectdata;
  1354. $scope.cancel = function () {
  1355. $modalInstance.dismiss('cancel');
  1356. };
  1357. $scope.savercode = function (worktimedata) {
  1358. var fildata = {
  1359. "scheduleclass": {
  1360. "id": selectdata.id,
  1361. "code": worktimedata.code,
  1362. "name": worktimedata.title,
  1363. "person": worktimedata.person,
  1364. "description": worktimedata.description,
  1365. "startTime": worktimedata.startTime,
  1366. "endTime": worktimedata.endTime,
  1367. "shiftTime": selectdata.shiftTime,
  1368. "succeedTime": selectdata.succeedTime,
  1369. "isTemplate": worktimedata.isTemplate
  1370. }
  1371. }
  1372. api_bpm_data.updData('scheduleclass', fildata).then(function (response) {
  1373. if (response) {
  1374. if (response.status == 200) {
  1375. SweetAlert.swal({
  1376. title: "修改成功!",
  1377. type: "success"
  1378. }, function () {
  1379. // $scope.refreshData('expand-right', defaultFilterData);
  1380. })
  1381. } else {
  1382. SweetAlert.swal({
  1383. title: "修改失败!",
  1384. type: "error"
  1385. })
  1386. }
  1387. }
  1388. })
  1389. $modalInstance.close();
  1390. }
  1391. }
  1392. });
  1393. }
  1394. $rootScope.changepassword = function (data1, size) {
  1395. var modalInstance = $modal.open({
  1396. templateUrl: 'assets/views/changepassword.html',
  1397. controller: function ($scope, $modalInstance, items, Restangular, SweetAlert) {
  1398. $scope.passwordnull = function (originalPwd, pwd, pwd_2) {
  1399. return originalPwd == undefined || pwd == undefined || pwd_2 == undefined || originalPwd == "" || pwd == "" || pwd_2 == "" || originalPwd == "null" || pwd == "null" || pwd_2 == "null";
  1400. }
  1401. $scope.savepassword = function (originalPwd, pwd, pwd_2) {
  1402. $modalInstance.dismiss('cancel');
  1403. // console.log('pwd=' + pwd + '+' + pwd_2);
  1404. // if(angular.isDefined(pwd)&&angular.isDefined(pwd_2)){
  1405. if (pwd == pwd_2) {
  1406. var data2 = {};
  1407. data2["originalPwd"] = originalPwd;
  1408. data2["userid"] = $rootScope.user.id;
  1409. data2["pwd"] = pwd;
  1410. api_login.uppwd(data2).then(function (response) {
  1411. var myData = Restangular.stripRestangular(response);
  1412. if (myData.status == 200) {
  1413. SweetAlert.swal({
  1414. title: "保存成功!",
  1415. type: "success",
  1416. confirmButtonColor: "#007AFF"
  1417. });
  1418. } else {
  1419. SweetAlert.swal({
  1420. title: "保存失败!",
  1421. text: "输入旧密码错误,请重新输入!",
  1422. type: "error"
  1423. });
  1424. }
  1425. })
  1426. } else {
  1427. SweetAlert.swal({
  1428. title: "两次输入的新密码不相同!",
  1429. text: "输入错误,请重新输入!",
  1430. type: "error"
  1431. });
  1432. }
  1433. // }else{
  1434. // SweetAlert.swal({
  1435. // title: "密码不能为空!",
  1436. // text: "请输入密码!",
  1437. // type: "error"
  1438. // });
  1439. // }
  1440. }
  1441. },
  1442. size: size,
  1443. resolve: {
  1444. items: function () {
  1445. return {
  1446. fetchItems: function (filterData, APIService) { }
  1447. };
  1448. },
  1449. }
  1450. });
  1451. }
  1452. // $rootScope.getnochildpending = function() {
  1453. // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
  1454. // angular.forEach($rootScope.userMenus, function(item) {
  1455. // item.tipnum = 1;
  1456. // })
  1457. // }
  1458. // }
  1459. // $rootScope.getchildpending = function(cantdata) {
  1460. // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
  1461. // angular.forEach($rootScope.userMenus, function(item) {
  1462. // item.tipnum = 1;
  1463. // angular.forEach(item, function(index) {
  1464. // index.tipnum = 18;
  1465. // })
  1466. // })
  1467. // }
  1468. // }
  1469. $rootScope.getpending = function () {
  1470. if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
  1471. if ($rootScope.user.group) {
  1472. var groupArr = [];
  1473. for (var i = 0; i < $rootScope.user.group.length; i++) {
  1474. groupArr.push($rootScope.user.group[i].id)
  1475. }
  1476. api_bpm_data.getCount({ "assignee": $rootScope.user.id, "candidateGroups": groupArr.join(), "idx": 0, "sum": 1000 }).then(function (response) {
  1477. angular.forEach($rootScope.userMenus, function (item, i) {
  1478. item.tipshow = false;
  1479. if (response) {
  1480. if (response.hjzxCount > 0 || response.wechatWarningCount > 0) {
  1481. if (item.id == 58) {
  1482. item.tipshow = true;
  1483. }
  1484. }
  1485. if (response.inspectionCount > 0) {
  1486. if (item.id == 27) {
  1487. item.tipshow = true;
  1488. }
  1489. }
  1490. if (response.incidentCount > 0) {
  1491. if (item.id == 2) {
  1492. item.tipshow = true;
  1493. }
  1494. }
  1495. if (response.releaseCount > 0) {
  1496. if (item.id == 1215) {
  1497. item.tipshow = true;
  1498. }
  1499. }
  1500. if (response.solutionCount > 0) {
  1501. if (item.id == 21) {
  1502. item.tipshow = true;
  1503. }
  1504. }
  1505. if (response.changeCount > 0) {
  1506. if (item.id == 1212) {
  1507. item.tipshow = true;
  1508. }
  1509. }
  1510. if (response.problemCount > 0) {
  1511. if (item.id == 1209) {
  1512. item.tipshow = true;
  1513. }
  1514. }
  1515. if (response.applicationForm > 0) {
  1516. if (item.id == 1221) {
  1517. item.tipshow = true;
  1518. }
  1519. }
  1520. if ((parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
  1521. if (item.id == 21) {
  1522. item.tipshow = true;
  1523. }
  1524. }
  1525. if (item.children) {
  1526. angular.forEach(item.children, function (index) {
  1527. if (response.hjzxCount !== null &&response.hjzxCount !== undefined) {
  1528. if (index.id == 1208) {
  1529. if (response.hjzxCount < 100) {
  1530. index.tipnum = response.hjzxCount;
  1531. } else {
  1532. index.tipnum = "99+";
  1533. }
  1534. }
  1535. }
  1536. if (response.wechatWarningCount !== null &&response.wechatWarningCount !== undefined) {
  1537. if (index.id == 59) {
  1538. if (response.wechatWarningCount < 100) {
  1539. index.tipnum = response.wechatWarningCount;
  1540. } else {
  1541. index.tipnum = "99+";
  1542. }
  1543. }
  1544. }
  1545. if (response.problemCount !== null &&response.problemCount !== undefined) {
  1546. if (index.id == 1210) {
  1547. if (response.problemCount < 100) {
  1548. index.tipnum = response.problemCount;
  1549. } else {
  1550. index.tipnum = "99+";
  1551. }
  1552. }
  1553. }
  1554. if (response.releaseCount !== null &&response.releaseCount !== undefined) {
  1555. if (index.id == 1216) {
  1556. if (response.releaseCount < 100) {
  1557. index.tipnum = response.releaseCount;
  1558. } else {
  1559. index.tipnum = "99+";
  1560. }
  1561. }
  1562. }
  1563. if (response.inspectionCount !== null &&response.inspectionCount !== undefined) {
  1564. if (index.id == 147) {
  1565. if (response.inspectionCount < 100) {
  1566. index.tipnum = response.inspectionCount;
  1567. } else {
  1568. index.tipnum = "99+";
  1569. }
  1570. }
  1571. }
  1572. if (response.solutionCount !== null &&response.solutionCount !== undefined) {
  1573. if (index.id == 23) {
  1574. if (response.solutionCount < 100) {
  1575. index.tipnum = response.solutionCount;
  1576. } else {
  1577. index.tipnum = "99+";
  1578. }
  1579. }
  1580. }
  1581. if (response.changeCount !== null &&response.changeCount !== undefined) {
  1582. if (index.id == 1213) {
  1583. if (response.changeCount < 100) {
  1584. index.tipnum = response.changeCount;
  1585. } else {
  1586. index.tipnum = "99+";
  1587. }
  1588. }
  1589. }
  1590. if (response.incidentCount !== null &&response.incidentCount !== undefined) {
  1591. if (index.id == 3) {
  1592. if (response.incidentCount < 100) {
  1593. index.tipnum = response.incidentCount;
  1594. } else {
  1595. index.tipnum = "99+";
  1596. }
  1597. }
  1598. }
  1599. if (response.applicationForm !== null &&response.applicationForm !== undefined) {
  1600. if (index.id == 1231) {
  1601. if (response.applicationForm < 100) {
  1602. index.tipnum = response.applicationForm;
  1603. } else {
  1604. index.tipnum = "99+";
  1605. }
  1606. }
  1607. }
  1608. if (response.toAuditCount && response.toReleaseCount && (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
  1609. if (index.id == 23) {
  1610. if (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount) < 100) {
  1611. index.tipnum = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
  1612. } else {
  1613. index.tipnum = "99+";
  1614. }
  1615. }
  1616. }
  1617. })
  1618. }
  1619. }
  1620. })
  1621. // return $rootScope.userMenus;
  1622. // $scope.recordpending = response.;
  1623. // $scope.dashboardcount.knowledgedata = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
  1624. })
  1625. } else {
  1626. // SweetAlert.swal("访问数据失败!", "该用户没有分配组", "error");
  1627. }
  1628. }
  1629. // console.log($rootScope.userMenus);
  1630. }
  1631. $rootScope.userMenus = [];
  1632. var getMenus = function () {
  1633. function convertListToTree(data, treeMap) {
  1634. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  1635. var root = null; //Initially set our loop to null
  1636. var parentNode = null;
  1637. //loop over data
  1638. for (var i = 0; i < data.length; i++) {
  1639. // data[i].id = Number(data[i].id);
  1640. var datum = data[i];
  1641. //each node will have children, so let's give it a "children" poperty
  1642. datum.children = [];
  1643. //add an entry for this node to the map so that any future children can
  1644. //lookup the parent
  1645. idToNodeMap[datum.id] = datum;
  1646. //Does this node have a parent?
  1647. if (typeof datum.parentid === "undefined" || datum.parentid == null) {
  1648. //Doesn't look like it, so this node is the root of the tree
  1649. root = datum;
  1650. treeMap[datum.id] = root;
  1651. } else {
  1652. //This node has a parent, so let's look it up using the id
  1653. parentNode = idToNodeMap[datum.parentid];
  1654. //We don't need this property, so let's delete it.
  1655. //delete datum.parentid;
  1656. //Let's add the current node as a child of the parent node.
  1657. parentNode.children.push(datum);
  1658. }
  1659. }
  1660. return root;
  1661. }
  1662. function convertParentToChildList(data) {
  1663. var treeMap = {};
  1664. var list = [];
  1665. convertListToTree(data, treeMap);
  1666. angular.forEach(treeMap, function (item) {
  1667. list.push(item);
  1668. });
  1669. list = window._.sortBy(list, function (o) {
  1670. return o.orders;
  1671. });
  1672. return list;
  1673. }
  1674. //if(userMenus.length==0){
  1675. var userMenus = [];
  1676. var idMapMenu = {};
  1677. if ($rootScope.user) {
  1678. if ($rootScope.user.menu) {
  1679. var allJurisdiction2 = $rootScope.user.menu;
  1680. var onlyMenu2 = [];
  1681. for (var i = 0; i < allJurisdiction2.length; i++) {
  1682. if (allJurisdiction2[i].event == "1") {
  1683. onlyMenu2.push(allJurisdiction2[i])
  1684. }
  1685. }
  1686. // userMenus = convertParentToChildList($rootScope.user.menu);
  1687. userMenus = convertParentToChildList(onlyMenu2);
  1688. }
  1689. }
  1690. //}
  1691. $rootScope.userMenus = userMenus;
  1692. if ($rootScope.userMenus.length > 0) {
  1693. $rootScope.getpending();
  1694. // setInterval($rootScope.getpending(), 30000);
  1695. }
  1696. return userMenus;
  1697. }
  1698. setInterval(function () {
  1699. if ($rootScope.userMenus.length > 0) {
  1700. $rootScope.getpending()
  1701. $rootScope.getMsgNum($rootScope.user.id)
  1702. }
  1703. }, 5000);
  1704. getMenus();
  1705. // console.log("$rootScope.nickname="+JSON.stringify($rootScope));
  1706. $rootScope.logout = function () {
  1707. // var userid =data.id;
  1708. // console.log(' userid='+JSON.stringify( userid));
  1709. //单点登录
  1710. if (localStorage.getItem('isSSo') === '1') {
  1711. sessionStorage.clear();
  1712. localStorage.clear();
  1713. location.href = 'http://' + location.hostname + ':8080/pc_logout.jsp'
  1714. } else {
  1715. $auth.signOut()
  1716. .then(function (resp) {
  1717. // $auth.deleteData('auth_headers')
  1718. sessionStorage.clear();
  1719. localStorage.clear();
  1720. $state.go("login.signin");
  1721. })
  1722. .catch(function (resp) { });
  1723. }
  1724. //$cookieStore.remove("userObm");
  1725. //$cookieStore.remove("menuObm");
  1726. //$cookieStore.remove("session");
  1727. //$rootScope.user = undefined;
  1728. //$rootScope.menus = undefined;
  1729. //$rootScope.nickname = undefined;
  1730. //window.location = "http://www.itsm.com:8080/itsm/dev/logout.jsp";
  1731. // //logout: function(noServerLogout){
  1732. // window.sessionStorage.clear();
  1733. // window.location = "https://www.yunwei.com:8443/cas/loginout";
  1734. // //},
  1735. }
  1736. // 快速建单
  1737. $rootScope.newOrder = function () {
  1738. $state.go('app.newOrder');
  1739. }
  1740. // save settings to local storage
  1741. if (angular.isDefined($localStorage.layout)) {
  1742. $scope.app.layout = $localStorage.layout;
  1743. } else {
  1744. $localStorage.layout = $scope.app.layout;
  1745. }
  1746. $scope.$watch('app.layout', function () {
  1747. // save to local storage
  1748. $localStorage.layout = $scope.app.layout;
  1749. }, true);
  1750. //global function to scroll page up
  1751. $scope.toTheTop = function () {
  1752. $document.scrollTopAnimated(0, 600);
  1753. };
  1754. // angular translate
  1755. // ----------------------
  1756. $scope.language = {
  1757. // Handles language dropdown
  1758. listIsOpen: false,
  1759. // list of available languages
  1760. available: {
  1761. 'en': 'English',
  1762. 'it_IT': 'Italiano',
  1763. 'de_DE': 'Deutsch',
  1764. 'zh_cn': 'Chinese'
  1765. },
  1766. // display always the current ui language
  1767. init: function () {
  1768. var proposedLanguage = $translate.proposedLanguage() || $translate.use();
  1769. var preferredLanguage = $translate.preferredLanguage();
  1770. // we know we have set a preferred one in app.config
  1771. $scope.language.selected = $scope.language.available[(proposedLanguage || preferredLanguage)];
  1772. },
  1773. set: function (localeId, ev) {
  1774. $translate.use(localeId);
  1775. $scope.language.selected = $scope.language.available[localeId];
  1776. $scope.language.listIsOpen = !$scope.language.listIsOpen;
  1777. }
  1778. };
  1779. $scope.language.init();
  1780. // Function that find the exact height and width of the viewport in a cross-browser way
  1781. var viewport = function () {
  1782. var e = window,
  1783. a = 'inner';
  1784. if (!('innerWidth' in window)) {
  1785. a = 'client';
  1786. e = document.documentElement || document.body;
  1787. }
  1788. return {
  1789. width: e[a + 'Width'],
  1790. height: e[a + 'Height']
  1791. };
  1792. };
  1793. // function that adds information in a scope of the height and width of the page
  1794. $scope.getWindowDimensions = function () {
  1795. return {
  1796. 'h': viewport().height,
  1797. 'w': viewport().width
  1798. };
  1799. };
  1800. // Detect when window is resized and set some variables
  1801. $scope.$watch($scope.getWindowDimensions, function (newValue, oldValue) {
  1802. $scope.windowHeight = newValue.h;
  1803. $scope.windowWidth = newValue.w;
  1804. if (newValue.w >= 992) {
  1805. $scope.isLargeDevice = true;
  1806. } else {
  1807. $scope.isLargeDevice = false;
  1808. }
  1809. if (newValue.w < 992) {
  1810. $scope.isSmallDevice = true;
  1811. } else {
  1812. $scope.isSmallDevice = false;
  1813. }
  1814. if (newValue.w <= 768) {
  1815. $scope.isMobileDevice = true;
  1816. } else {
  1817. $scope.isMobileDevice = false;
  1818. }
  1819. }, true);
  1820. // Apply on resize
  1821. $win.on('resize', function () {
  1822. $scope.$apply();
  1823. });
  1824. $rootScope.app.layout.isNavbarFixed = false;
  1825. $rootScope.app.layout.isSidebarFixed = false;
  1826. $rootScope.app.layout.isFooterFixed = false;
  1827. $scope.login_signquick = function (Requesteruserinform) {
  1828. $rootScope.statuscall = 1;
  1829. $scope.loginForm = {
  1830. username: Requesteruserinform.username,
  1831. password: Requesteruserinform.password
  1832. }
  1833. $auth.submitLogin($scope.loginForm)
  1834. .then(function (resp) {
  1835. localStorage.setItem("jry_user", JSON.stringify(resp));
  1836. $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
  1837. // $rootScope.userMenus = JSON.parse(localStorage.getItem("jry_user")).menu;
  1838. var allJurisdiction = JSON.parse(localStorage.getItem("jry_user")).menu;
  1839. var onlyMenu = [];
  1840. for (var i = 0; i < allJurisdiction.length; i++) {
  1841. if (allJurisdiction[i].event == "1") {
  1842. onlyMenu.push(allJurisdiction[i])
  1843. }
  1844. };
  1845. $rootScope.userMenus = onlyMenu;
  1846. getMenus();
  1847. if (resp.error != 500) {
  1848. // $state.go('app.dashboard');
  1849. $rootScope.app.isLoginFixed = false;
  1850. } else {
  1851. resp.error = "";
  1852. $scope.loginForm.password = "";
  1853. SweetAlert.swal("用户名或者密码验证失败,请重试!", "error");
  1854. }
  1855. })
  1856. .catch(function (resp) {
  1857. $scope.loginForm.password = "";
  1858. SweetAlert.swal("系统错误,请重试!", "登录错误", "error");
  1859. });
  1860. }
  1861. var url = location.hash; //获取url中"?"符后的字串 var index=obj.lastIndexOf("\-");
  1862. var theRequest = {};
  1863. var index = url.substring(index + 1, url.length).lastIndexOf("\?");
  1864. if (url.indexOf("?") != -1 && url.indexOf("fixed_list")) {
  1865. var str = url.substr(index + 1);
  1866. var strs = str.split("&");
  1867. for (var i = 0; i < strs.length; i++) {
  1868. theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
  1869. }
  1870. // return theRequest;
  1871. $scope.login_signquick(theRequest)
  1872. }
  1873. // $scope.casUserId = window.location.search;
  1874. // $scope.loginForm = {
  1875. // username: theRequest[0].split("=")[1],
  1876. // password: theRequest[1].split("=")[1]
  1877. // }
  1878. // $scope.lodingstyle = 'nodata';
  1879. var userAgent = window.navigator.userAgent.toLowerCase();
  1880. var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
  1881. var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
  1882. var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
  1883. var isSafari = userAgent.indexOf("Safari") > -1; //判断是否Safari浏览器
  1884. var isChrome = userAgent.indexOf("chrome") > -1; //判断是否Safari浏览器
  1885. if (isOpera) {
  1886. $scope.checkchrome = '当前所用浏览器是Opera浏览器,';
  1887. // return alert("访问失败,当前所用浏览器是Opera浏览器,请用Chrome浏览器访问!");
  1888. }
  1889. if (isIE) {
  1890. $scope.checkchrome = '当前所用浏览器是IE浏览器,';
  1891. // return alert("访问失败,当前所用浏览器是IE浏览器,请用Chrome浏览器访问!");
  1892. }
  1893. if (isFF) {
  1894. $scope.checkchrome = '当前所用浏览器是火狐浏览器,';
  1895. // return alert("访问失败,当前所用浏览器是火狐浏览器,请用Chrome浏览器访问!");
  1896. }
  1897. if (isSafari) {
  1898. $scope.checkchrome = '当前所用浏览器是Safari浏览器,';
  1899. // return alert("访问失败,当前所用浏览器是Safari浏览器,请用Chrome浏览器访问!");
  1900. }
  1901. if (isChrome) {
  1902. // login_sign();
  1903. $rootScope.app.isChrome = false;
  1904. // return alert("访问失败,当前所用浏览器是Chrome浏览器");
  1905. } else {
  1906. $rootScope.app.isChrome = true;
  1907. $scope.checkchrome = '';
  1908. // return alert("访问失败,请用Chrome浏览器访问!");
  1909. }
  1910. // }
  1911. // $scope.handleloginEnter = function(e) {
  1912. // if (e.keyCode == 13) {
  1913. // $scope.handleLoginClick();
  1914. // }
  1915. // };
  1916. // if (document.getElementById("isWatch").value == "true") {
  1917. // $scope.isHanderuser = true;
  1918. // } else {
  1919. // if (!JSON.parse(sessionStorage.getItem('header'))) {
  1920. // $scope.isHanderuser = false;
  1921. // $scope.login_sign();
  1922. // }
  1923. // }
  1924. // $scope.viewType = "password";
  1925. // $scope.isPassword = true;
  1926. // $scope.toggleView = function() {
  1927. // $scope.isPassword = !$scope.isPassword;
  1928. // $scope.viewType = $scope.isPassword ? "password" : "text";
  1929. // }
  1930. // $scope.handleSignOutBtnClick = function() {
  1931. // $auth.signOut()
  1932. // .then(function(resp) {
  1933. // // handle success response
  1934. // })
  1935. // .catch(function(resp) {
  1936. // // handle error response
  1937. // });
  1938. // };
  1939. // }
  1940. // }
  1941. // if (!isEmpty($auth.retrieveData('auth_headers'))) {
  1942. // } else {
  1943. // $scope.loginstart();
  1944. // }
  1945. //websocket 信息中心
  1946. console.log(atmosphere)
  1947. var socket = atmosphere;
  1948. var subSocket;
  1949. // We are now ready to cut the request
  1950. var request = {
  1951. url: 'ws://192.168.199.150:8080/messagestation/cache',
  1952. contentType: "application/json",
  1953. shared: true, // 标签共享
  1954. trackMessageLength: true, //校验数据完整性
  1955. transport: 'websocket'
  1956. };
  1957. subSocket = socket.subscribe(request);
  1958. request.onOpen = function (response) {
  1959. console.log(response)
  1960. subSocket.push(JSON.stringify({ login: $rootScope.user.id }));
  1961. // alert("开始连接")
  1962. };
  1963. request.onMessage = function (response) {
  1964. var message = response.responseBody;
  1965. // alert("连接成功")
  1966. console.log(message)
  1967. try {
  1968. var json = JSON.parse(message);
  1969. console.log(json.noRead)
  1970. $scope.noReadData = json.noRead
  1971. } catch (e) {
  1972. console.log('呵呵哒: ', message);
  1973. return;
  1974. }
  1975. };
  1976. request.onClose = function (response) {
  1977. // alert("连接结束")
  1978. }
  1979. request.onError = function (response) {
  1980. // alert('连接失败')
  1981. };
  1982. //信息中心模态框
  1983. var loginUser = $rootScope.user;
  1984. // if(loginUser){
  1985. // // 未读消息数量
  1986. // api_msg.msgDataList({idx: 0, sum: 1, messageStation: {readStatus: 0, userId: loginUser.id}}).then(function(data) {
  1987. // if (data.status == 200) {
  1988. // $scope.noReadData=data.totalNum
  1989. // // $rootScope.option.all = $rootScope.all;
  1990. // } else {
  1991. // $scope.noReadData=0
  1992. // }
  1993. // })
  1994. // }
  1995. // $scope.noReadData=($rootScope.noReadData||0)
  1996. // // $rootScope.all = 5;
  1997. // setTimeout(function() {
  1998. // console.log($scope.noReadData)
  1999. // }, 500)
  2000. $rootScope.wt_messages = function () {
  2001. var modalInstance = $modal.open({
  2002. templateUrl: '../../../assets/views/wt_messages.html',
  2003. controller: function ($scope, $modalInstance) {
  2004. $rootScope.msgData = {
  2005. idx: 0,
  2006. sum: 5,
  2007. messageStation: {
  2008. readStatus: 0,
  2009. userId: $rootScope.user.id
  2010. }
  2011. }
  2012. // 关闭
  2013. $scope.closeModel = function(){
  2014. modalInstance.close();
  2015. }
  2016. $scope.getMsgData = function () {
  2017. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2018. if (data) {
  2019. $rootScope.msg = data.list
  2020. $rootScope.all = data.pageCount;
  2021. $scope.wt_msgData = data
  2022. $rootScope.noReadData = data.totalNum
  2023. }
  2024. })
  2025. }
  2026. $scope.getMsgData()
  2027. $scope.message_type = 2;
  2028. $scope.message_no = function (type) { //未读1
  2029. $scope.wt_msgData = {};
  2030. $scope.message_type = type;
  2031. $rootScope.msgData.messageStation.readStatus = 0,
  2032. // $rootScope.option.curr = 1;
  2033. $rootScope.msgData.idx = 0;
  2034. // console.log($rootScope.option.curr)
  2035. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2036. $scope.msg_yesType = true;
  2037. if (data.status == 200) {
  2038. $scope.msg_yesType = false
  2039. $scope.wt_msgData = data
  2040. $rootScope.msg = data.list
  2041. $rootScope.all = data.pageCount;
  2042. $rootScope.noReadData = data.totalNum;
  2043. // $rootScope.option.all = $rootScope.all;
  2044. } else {
  2045. $scope.msg_yesType = true;
  2046. }
  2047. })
  2048. }
  2049. $scope.message_yes = function (type) { //已读0
  2050. $scope.wt_msgData = {};
  2051. $scope.message_type = type;
  2052. $rootScope.msgData.messageStation.readStatus = 1,
  2053. $rootScope.msgData.idx = 0;
  2054. // $rootScope.option.curr = 1;
  2055. // console.log($rootScope.option.curr)
  2056. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2057. $scope.msg_noType = true;
  2058. if (data.status == 200) {
  2059. $scope.msg_noType = false
  2060. $scope.wt_msgData = data
  2061. $rootScope.msg = data.list;
  2062. $rootScope.all = data.pageCount;
  2063. // $rootScope.option.all = $rootScope.all;
  2064. } else {
  2065. $scope.msg_noType = true
  2066. }
  2067. })
  2068. };
  2069. $scope.sBtn = function () {
  2070. // console.log($rootScope.msgData)
  2071. // console.log($scope.wt_msgData)
  2072. $rootScope.msgData.idx = $rootScope.msgData.idx - 1;
  2073. console.log($rootScope.msgData)
  2074. $scope.getMsgData()
  2075. }
  2076. $scope.xBtn = function () {
  2077. // console.log($rootScope.msgData)
  2078. // console.log($scope.wt_msgData)
  2079. $rootScope.msgData.idx = $rootScope.msgData.idx + 1;
  2080. console.log($rootScope.msgData)
  2081. $scope.getMsgData()
  2082. }
  2083. $scope.redIn = function (data) {
  2084. var start = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
  2085. $scope.messageStation = {
  2086. messageStation: {
  2087. id: data.id,
  2088. readStatus: 1,
  2089. readTime: start
  2090. }
  2091. }
  2092. api_msg.updateDataList($scope.messageStation).then(function (data) {
  2093. console.log(data);
  2094. if (data.status == 200) {
  2095. $rootScope.msgData.messageStation.readStatus = 0,
  2096. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2097. $rootScope.msg = data.list
  2098. $rootScope.all = data.pageCount;
  2099. $rootScope.noReadData = data.totalNum;
  2100. })
  2101. }
  2102. })
  2103. };
  2104. },
  2105. size: 'lg',
  2106. resolve: {
  2107. }
  2108. })
  2109. }
  2110. }
  2111. ]);
  2112. //消息中心分页组件
  2113. app.controller('msgCtrl', ['$scope', '$rootScope', 'api_msg', 'Myservice', function ($scope, $rootScope, api_msg, Myservice) {
  2114. $rootScope.option = {
  2115. curr: 1, //当前页数
  2116. all: $rootScope.all, //总页数
  2117. count: 5, //最多显示的页数,默认为10
  2118. //点击页数的回调函数,参数page为点击的页数
  2119. click: function (page) {
  2120. $rootScope.msgData.idx = page - 1;
  2121. //这里可以写跳转到某个页面等...
  2122. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2123. $rootScope.msg = data.list
  2124. $rootScope.all = data.pageCount;
  2125. $rootScope.option.all = $rootScope.all;
  2126. })
  2127. }
  2128. }
  2129. }]);
  2130. app.directive('myPagination', function () {
  2131. return {
  2132. restrict: 'EA',
  2133. replace: true,
  2134. rootScope: {
  2135. option: '=pageOption'
  2136. },
  2137. controller: 'msgCtrl',
  2138. template: '<ul class="pagination">' +
  2139. '<li ng-click="pageClick(p)" ng-repeat="p in page" class="{{option.curr==p?\'active\':\'\'}}">' +
  2140. '<a href="javascript:;">{{p}}</a>' +
  2141. '</li>' +
  2142. '</ul>',
  2143. link: function ($rootScope) {
  2144. //容错处理
  2145. if (!$rootScope.option.curr || isNaN($rootScope.option.curr) || $rootScope.option.curr < 1) $rootScope.option.curr = 1;
  2146. if (!$rootScope.option.all || isNaN($rootScope.option.all) || $rootScope.option.all < 1) $rootScope.option.all = 1;
  2147. if ($rootScope.option.curr > $rootScope.option.all) $rootScope.option.curr = $rootScope.option.all;
  2148. if (!$rootScope.option.count || isNaN($rootScope.option.count) || $rootScope.option.count < 1) $rootScope.option.count = 10;
  2149. //得到显示页数的数组
  2150. $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
  2151. //绑定点击事件
  2152. $rootScope.pageClick = function (page) {
  2153. if (page == '«') {
  2154. page = parseInt($rootScope.option.curr) - 1;
  2155. } else if (page == '»') {
  2156. page = parseInt($rootScope.option.curr) + 1;
  2157. }
  2158. if (page < 1) page = 1;
  2159. else if (page > $rootScope.option.all) page = $rootScope.option.all;
  2160. //点击相同的页数 不执行点击事件
  2161. if (page == $rootScope.option.curr) return;
  2162. if ($rootScope.option.click && typeof $rootScope.option.click === 'function') {
  2163. $rootScope.option.click(page);
  2164. $rootScope.option.curr = page;
  2165. $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
  2166. }
  2167. };
  2168. //返回页数范围(用来遍历)
  2169. function getRange(curr, all, count) {
  2170. //计算显示的页数
  2171. // console.log(curr, all, count)
  2172. curr = parseInt(curr);
  2173. all = parseInt(all);
  2174. count = parseInt(count);
  2175. var from = curr - parseInt(count / 2);
  2176. var to = curr + parseInt(count / 2) + (count % 2) - 1;
  2177. //显示的页数容处理
  2178. if (from <= 0) {
  2179. from = 1;
  2180. to = from + count - 1;
  2181. if (to > all) {
  2182. to = all;
  2183. }
  2184. }
  2185. if (to > all) {
  2186. to = all;
  2187. from = to - count + 1;
  2188. if (from <= 0) {
  2189. from = 1;
  2190. }
  2191. }
  2192. var range = [];
  2193. for (var i = from; i <= to; i++) {
  2194. range.push(i);
  2195. }
  2196. range.push('»');
  2197. range.unshift('«');
  2198. return range;
  2199. }
  2200. }
  2201. }
  2202. });
  2203. app.service('Myservice', function () {
  2204. return {
  2205. };
  2206. });
  2207. // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
  2208. // console.log(bh)
  2209. // if(bh>=0&&bh<=53){
  2210. // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
  2211. // }else{
  2212. // $('#sidebar').css('padding-bottom', 0 + 'px')
  2213. // }
  2214. window.onscroll = function () {
  2215. if (window.pageYOffset >= 0 && window.pageYOffset <= 65) {
  2216. $('#sidebar').css('padding-top', (65 - window.pageYOffset) + 'px')
  2217. } else {
  2218. $('#sidebar').css('padding-top', '0')
  2219. }
  2220. // console.log(window.pageYOffset)
  2221. // console.log(window.innerHeight)
  2222. // console.log(document.body.scrollHeight)
  2223. // 底部padding
  2224. // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
  2225. // console.log(bh)
  2226. // if(bh>=0&&bh<=53){
  2227. // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
  2228. // }else{
  2229. // $('#sidebar').css('padding-bottom', 0 + 'px')
  2230. // }
  2231. }