mainCtrl.js 123 KB

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