mainCtrl.js 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383
  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 && response.hjzxCount > 0) {
  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 && response.wechatWarningCount > 0) {
  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 && response.problemCount > 0) {
  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 && response.releaseCount > 0) {
  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 && response.inspectionCount > 0) {
  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 && response.solutionCount > 0) {
  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 && response.changeCount > 0) {
  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 && response.incidentCount > 0) {
  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 && response.applicationForm > 0) {
  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. $scope.getMsgData = function () {
  2013. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2014. if (data) {
  2015. $rootScope.msg = data.list
  2016. $rootScope.all = data.pageCount;
  2017. $scope.wt_msgData = data
  2018. $rootScope.noReadData = data.totalNum
  2019. }
  2020. })
  2021. }
  2022. $scope.getMsgData()
  2023. $scope.message_type = 2;
  2024. $scope.message_no = function (type) { //未读1
  2025. $scope.wt_msgData = {};
  2026. $scope.message_type = type;
  2027. $rootScope.msgData.messageStation.readStatus = 0,
  2028. // $rootScope.option.curr = 1;
  2029. $rootScope.msgData.idx = 0;
  2030. // console.log($rootScope.option.curr)
  2031. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2032. $scope.msg_yesType = true;
  2033. if (data.status == 200) {
  2034. $scope.msg_yesType = false
  2035. $scope.wt_msgData = data
  2036. $rootScope.msg = data.list
  2037. $rootScope.all = data.pageCount;
  2038. $rootScope.noReadData = data.totalNum;
  2039. // $rootScope.option.all = $rootScope.all;
  2040. } else {
  2041. $scope.msg_yesType = true;
  2042. }
  2043. })
  2044. }
  2045. $scope.message_yes = function (type) { //已读0
  2046. $scope.wt_msgData = {};
  2047. $scope.message_type = type;
  2048. $rootScope.msgData.messageStation.readStatus = 1,
  2049. $rootScope.msgData.idx = 0;
  2050. // $rootScope.option.curr = 1;
  2051. // console.log($rootScope.option.curr)
  2052. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2053. $scope.msg_noType = true;
  2054. if (data.status == 200) {
  2055. $scope.msg_noType = false
  2056. $scope.wt_msgData = data
  2057. $rootScope.msg = data.list;
  2058. $rootScope.all = data.pageCount;
  2059. // $rootScope.option.all = $rootScope.all;
  2060. } else {
  2061. $scope.msg_noType = true
  2062. }
  2063. })
  2064. };
  2065. $scope.sBtn = function () {
  2066. // console.log($rootScope.msgData)
  2067. // console.log($scope.wt_msgData)
  2068. $rootScope.msgData.idx = $rootScope.msgData.idx - 1;
  2069. console.log($rootScope.msgData)
  2070. $scope.getMsgData()
  2071. }
  2072. $scope.xBtn = function () {
  2073. // console.log($rootScope.msgData)
  2074. // console.log($scope.wt_msgData)
  2075. $rootScope.msgData.idx = $rootScope.msgData.idx + 1;
  2076. console.log($rootScope.msgData)
  2077. $scope.getMsgData()
  2078. }
  2079. $scope.redIn = function (data) {
  2080. var start = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
  2081. $scope.messageStation = {
  2082. messageStation: {
  2083. id: data.id,
  2084. readStatus: 1,
  2085. readTime: start
  2086. }
  2087. }
  2088. api_msg.updateDataList($scope.messageStation).then(function (data) {
  2089. console.log(data);
  2090. if (data.status == 200) {
  2091. $rootScope.msgData.messageStation.readStatus = 0,
  2092. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2093. $rootScope.msg = data.list
  2094. $rootScope.all = data.pageCount;
  2095. $rootScope.noReadData = data.totalNum;
  2096. })
  2097. }
  2098. })
  2099. };
  2100. },
  2101. size: 'lg',
  2102. resolve: {
  2103. }
  2104. })
  2105. }
  2106. }
  2107. ]);
  2108. //消息中心分页组件
  2109. app.controller('msgCtrl', ['$scope', '$rootScope', 'api_msg', 'Myservice', function ($scope, $rootScope, api_msg, Myservice) {
  2110. $rootScope.option = {
  2111. curr: 1, //当前页数
  2112. all: $rootScope.all, //总页数
  2113. count: 5, //最多显示的页数,默认为10
  2114. //点击页数的回调函数,参数page为点击的页数
  2115. click: function (page) {
  2116. $rootScope.msgData.idx = page - 1;
  2117. //这里可以写跳转到某个页面等...
  2118. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  2119. $rootScope.msg = data.list
  2120. $rootScope.all = data.pageCount;
  2121. $rootScope.option.all = $rootScope.all;
  2122. })
  2123. }
  2124. }
  2125. }]);
  2126. app.directive('myPagination', function () {
  2127. return {
  2128. restrict: 'EA',
  2129. replace: true,
  2130. rootScope: {
  2131. option: '=pageOption'
  2132. },
  2133. controller: 'msgCtrl',
  2134. template: '<ul class="pagination">' +
  2135. '<li ng-click="pageClick(p)" ng-repeat="p in page" class="{{option.curr==p?\'active\':\'\'}}">' +
  2136. '<a href="javascript:;">{{p}}</a>' +
  2137. '</li>' +
  2138. '</ul>',
  2139. link: function ($rootScope) {
  2140. //容错处理
  2141. if (!$rootScope.option.curr || isNaN($rootScope.option.curr) || $rootScope.option.curr < 1) $rootScope.option.curr = 1;
  2142. if (!$rootScope.option.all || isNaN($rootScope.option.all) || $rootScope.option.all < 1) $rootScope.option.all = 1;
  2143. if ($rootScope.option.curr > $rootScope.option.all) $rootScope.option.curr = $rootScope.option.all;
  2144. if (!$rootScope.option.count || isNaN($rootScope.option.count) || $rootScope.option.count < 1) $rootScope.option.count = 10;
  2145. //得到显示页数的数组
  2146. $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
  2147. //绑定点击事件
  2148. $rootScope.pageClick = function (page) {
  2149. if (page == '«') {
  2150. page = parseInt($rootScope.option.curr) - 1;
  2151. } else if (page == '»') {
  2152. page = parseInt($rootScope.option.curr) + 1;
  2153. }
  2154. if (page < 1) page = 1;
  2155. else if (page > $rootScope.option.all) page = $rootScope.option.all;
  2156. //点击相同的页数 不执行点击事件
  2157. if (page == $rootScope.option.curr) return;
  2158. if ($rootScope.option.click && typeof $rootScope.option.click === 'function') {
  2159. $rootScope.option.click(page);
  2160. $rootScope.option.curr = page;
  2161. $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
  2162. }
  2163. };
  2164. //返回页数范围(用来遍历)
  2165. function getRange(curr, all, count) {
  2166. //计算显示的页数
  2167. // console.log(curr, all, count)
  2168. curr = parseInt(curr);
  2169. all = parseInt(all);
  2170. count = parseInt(count);
  2171. var from = curr - parseInt(count / 2);
  2172. var to = curr + parseInt(count / 2) + (count % 2) - 1;
  2173. //显示的页数容处理
  2174. if (from <= 0) {
  2175. from = 1;
  2176. to = from + count - 1;
  2177. if (to > all) {
  2178. to = all;
  2179. }
  2180. }
  2181. if (to > all) {
  2182. to = all;
  2183. from = to - count + 1;
  2184. if (from <= 0) {
  2185. from = 1;
  2186. }
  2187. }
  2188. var range = [];
  2189. for (var i = from; i <= to; i++) {
  2190. range.push(i);
  2191. }
  2192. range.push('»');
  2193. range.unshift('«');
  2194. return range;
  2195. }
  2196. }
  2197. }
  2198. });
  2199. app.service('Myservice', function () {
  2200. return {
  2201. };
  2202. });
  2203. // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
  2204. // console.log(bh)
  2205. // if(bh>=0&&bh<=53){
  2206. // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
  2207. // }else{
  2208. // $('#sidebar').css('padding-bottom', 0 + 'px')
  2209. // }
  2210. window.onscroll = function () {
  2211. if (window.pageYOffset >= 0 && window.pageYOffset <= 65) {
  2212. $('#sidebar').css('padding-top', (65 - window.pageYOffset) + 'px')
  2213. } else {
  2214. $('#sidebar').css('padding-top', '0')
  2215. }
  2216. // console.log(window.pageYOffset)
  2217. // console.log(window.innerHeight)
  2218. // console.log(document.body.scrollHeight)
  2219. // 底部padding
  2220. // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
  2221. // console.log(bh)
  2222. // if(bh>=0&&bh<=53){
  2223. // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
  2224. // }else{
  2225. // $('#sidebar').css('padding-bottom', 0 + 'px')
  2226. // }
  2227. }