12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978 |
- 'use strict';
- /**
- * Clip-Two Main Controller
- */
- app.controller('AppCtrl', ['$rootScope', '$scope', '$state', '$translate', '$localStorage', '$cookieStore', '$window', '$modal', '$document', '$timeout', '$filter', '$auth', 'cfpLoadingBar', 'DDP', 'deskNotification', 'Restangular', 'api_login', 'api_text', 'api_user_data', 'api_wechatfile', 'api_bpm_data', 'api_msg', 'Myservice', '$interval', 'jry_api_bpm','fileReader','api_custom','api_category','api_simple','WebsocketPhoneService','api_newreport', 'api_flow',
- 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,fileReader,api_custom,api_category,api_simple,WebsocketPhoneService,api_newreport,api_flow) {
- // 未读消息数量seimin
- $rootScope.getMsgNum = function (id) {
- api_msg.msgDataList({ idx: 0, sum: 1, messageStation: { readStatus: 0, userId: id } }).then(function (data) {
- if (data.status == 200) {
- $rootScope.noReadData = data.totalNum;
- }
- return $rootScope.noReadData
- })
- }
- // Loading bar transition
- // -----------------------------------
- // console.log("haha");
- // 附件地址拼接-全局
- $rootScope.attachmentAddressSplicing = function(relativeFilePath){
- return location.origin + '/file' + relativeFilePath;
- }
- $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
- $rootScope.isRealtimeBroadcast = ($rootScope.user && $rootScope.user.menu)?$rootScope.user.menu.some(v => v.link == 'realtimeBroadcast'):false;
- $rootScope.isFuwutai = JSON.parse(localStorage.getItem("isFuwutai")) ? true : false;
- console.log($rootScope.user)
- //判断项目归属 start
- //因项目众多,前端为了加以区分,所以用域名加以判断,后期有更好的方式可以自行修改
- $rootScope.judgeHjzx = function(isMask = false, isStart = false){
- if(!$rootScope.user){
- return;
- }
- $rootScope.isZncd = false;
- $rootScope.isHk = false;
- $rootScope.isXy = false;
- $rootScope.isXyBox = false;
- var branchId;
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- branchId = $rootScope.user.duty.branch;
- }else if($rootScope.user.branch){
- branchId = $rootScope.user.branch.id;
- }
- if(isMask){
- $rootScope.isMask = true;
- }
- api_simple.fetchDataList("hospitalConfig", {"idx":0,"sum":100,"hospitalConfig":{"hosId":branchId}}).then(function(result){
- if(isMask){
- $rootScope.isMask = false;
- }
- if(result.status = 200){
- var hospitalConfig = result.list || [];
- var ccTypeDTO = hospitalConfig.find(function(v){return v.key == 'ccType'});
- // 暂无 1
- // 东进呼叫中心 2
- // 申欧录音盒子 3
- $rootScope.isXy = ccTypeDTO && ccTypeDTO.value == 2;
- $rootScope.isXyBox = ccTypeDTO && ccTypeDTO.value == 3;
- if($rootScope.isZncd){
- localStorage.setItem('version_qd','isZncd');
- }else if($rootScope.isHk){
- localStorage.setItem('version_qd','isHk');
- }else if($rootScope.isXy){
- localStorage.setItem('version_qd','isXy');
- }else if($rootScope.isXyBox){
- $rootScope.phoneNumList = hospitalConfig.filter(function(v){return v.key.includes('phone_num_port') && v.value}).map(function(v){return {value: v.value, checked: false}});
- $rootScope.phoneNumListBind.forEach((item) => {
- let obj = $rootScope.phoneNumList.find((item1) => item1.value === item);
- if (obj) {
- obj.checked = true;
- }
- });
- $rootScope.phoneNumListSelected = $rootScope.phoneNumList.filter(v => v.checked).map(v => v.value);
- $rootScope.phoneNumListSelectedStr = $rootScope.phoneNumListSelected.length ? '您选择了'+ $rootScope.phoneNumListSelected.map(v => '‘'+ v +'’').join('') +'号码,可在下方选择后确认更新。' : '请选择分机';
- console.log($rootScope.phoneNumList, 'phoneNumList');
- console.log($rootScope.phoneNumListBind, 'phoneNumListBind');
- localStorage.setItem('version_qd','isXyBox');
- }else{
- localStorage.removeItem('version_qd');
- }
- // 1是老的呼叫中心
- // 2是财大2021年12月29日新增的呼叫中心
- // 3是华科新增的呼叫中心
- // 4是支助紫铜录音盒子
- console.log($rootScope.isHk,'hk')
- console.log($rootScope.isZncd,'zncd')
- console.log($rootScope.isXy,'xy')
- console.log($rootScope.isXyBox,'xyBox')
- if($rootScope.isZncd || $rootScope.isXy){
- $rootScope.seiminHj = 2;
- }else if($rootScope.isXyBox){
- $rootScope.seiminHj = 4;
- }else if($rootScope.isHk){
- $rootScope.seiminHj = 3;
- }else{
- // $rootScope.seiminHj = 1;
- }
- if (isStart && $rootScope.isFuwutai && ($rootScope.isXy || $rootScope.isXyBox)) {
- console.log($rootScope.seiminHj, 'seiminHj');
- $rootScope.getExtnDirect();//seiminHj----1
- }
- }
- })
- }
- // $rootScope.judgeHjzx();
- //判断项目归属 end
- var loginUser = $rootScope.user;
- if(loginUser){
- $scope.allFlag = false;//全部事件
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "shijianliebiao_all") {
- $scope.allFlag = true
- }
- }
- }
- if ($rootScope.user) {
- $rootScope.getMsgNum($rootScope.user.id);
- }
- var $win = $($window);
- $rootScope.isMask = false;
- window.onbeforeunload = function () {
- $rootScope.statuscall = 0;
- $rootScope.statecall = 1;
- }
- // 所有列表自动刷新
- $rootScope.refreshTime = 60000;
- $interval(function () {
- $scope.jry_year = new Date().getFullYear();
- $scope.jry_month = new Date().getMonth() + 1;
- $scope.jry_data = new Date().getDate();
- $scope.jry_hours = new Date().getHours();
- $scope.jry_minute = new Date().getMinutes();
- $scope.jry_second = new Date().getSeconds();
- // console.log($scope.jry_month)
- }, 1000)
- // $win.on('beforeunload', function() { return $state.go("login.signin"); });
- // $auth.deleteData('auth_headers')
- // }
- // 监听路由
- $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
- var loginUser = $rootScope.user;
- if(loginUser){
- $scope.allFlag = false;//全部事件
- for (var i = 0; i < loginUser.menu.length; i++) {
- if (loginUser.menu[i].link == "shijianliebiao_all") {
- $scope.allFlag = true
- }
- }
- }
- console.log(event, toState, toParams, fromState, fromParams)
- // 请求首页统计
- if(toState.name != 'login.signin'){
- $rootScope.getOrderCount();
- // 判断首页统计页面是否显示
- // if($rootScope.user.role.length){
- // $scope.isShowTj = $rootScope.user.role.some(function(v){
- // return v.rolecode === "incident-category-manager" || v.rolecode === "incident manager";
- // })
- // }else{
- // $scope.isShowTj = false;
- // }
- }
- if($rootScope.isZncd || $rootScope.isXy){
- // 中南财大
- if ((toState.name == 'app.incident.chart' || toState.name == 'app.incident.editor') &&
- fromState.name) {
- console.log($rootScope.jry_state);
- $scope.isShixian = false;
- if($rootScope.jry_state == 'shixian'){
- $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
- //进入页面强制示忙
- if (tlwsa) {
- // tlwsa.tlaForceacw($rootScope.phoneNumber);
- setTimeout(()=>{
- tlwsa.tlaAcw();
- },0)
- }
- }
- }
- if ((fromState.name == 'app.incident.chart' || fromState.name == 'app.incident.editor') &&
- toState.name != 'app.incident.chart' && toState.name != 'app.incident.editor'
- ) {
- console.log($rootScope.jry_state);
- // $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
- //进入页面强制示闲
- $scope.isShixian = true;
- // if (tlwsa) {
- // // tlwsa.tlaForcewca($rootScope.phoneNumber);
- // tlwsa.tlaWca();
- // }
- }
- }else if($rootScope.isHk){
- if (toState.name != "app.incident.editor" && toState.name != "echart") {
- if ($rootScope.status == 2 || $rootScope.status == 4 || $rootScope.status == 9) {
- $rootScope.setidle();
- }
- }
- if (toState.name != "app.incident.editor" && toState.name != "app.incident.title") {
- if ($scope.login && $rootScope.statecall == 2 && !$rootScope.busy) {
- $rootScope.setidle();
- }
- } else {
- if ($scope.login && !$rootScope.busy) {
- $rootScope.setbusy();
- }
- // $rootScope.isMask = true;
- }
- }
- if (isEmpty($auth.retrieveData('auth_headers'))) {
- // if (toState.name != "login.signin" && toState.name != "echart") {
- // event.preventDefault();
- // $rootScope.app.isLoginFixed = true;
- // // $scope.lodingstyle = 'nodata';
- // return $state.go("login.signin");
- // }
- }
- // if (toState.name == "app.system.user.user") {
- // var isgoto = false;
- // if ($rootScope.user && $rootScope.user.menu) {
- // angular.forEach($rootScope.user.menu, function(item) {
- // if (item.link == toState.name) {
- // isgoto = true;
- // } else {}
- // })
- // }
- // if (isgoto) {
- // } else {
- // $state.go("app.dashboard");
- // }
- // }
- // if (toState.name != "app.incident.editor" && toState.name != "echart") {
- // if ($rootScope.status == 2 || $rootScope.status == 4 || $rootScope.status == 9) {
- // $rootScope.setidle();
- // }
- // }
- cfpLoadingBar.start();
- $auth.validateUser();
- });
- $rootScope.imUsrMap = {};
- $rootScope.onlineUser = [];
- $rootScope.offlineUser = [];
- $rootScope.me = undefined;
- $rootScope.imscope = {
- sessions: []
- }
- // var ws = new WebSocket('ws://192.168.3.51:8088/events');
- // var register= {"msgtype":"login","adn":"1001"};
- // ws.onopen = function() { ws.send(JSON.stringify(register));}
- // ws.onmessage = function(evt) { console.log(evt.data) }
- var ddp = new DDP('ws://115.156.150.70:3000/websocket');
- $rootScope.getDirectMsgRoomId = function (mdId, toId) {
- //me.id,to.id
- var rid = [mdId, toId].sort().join('');
- return rid;
- };
- $rootScope.sendMessage = function (rid, msg, callback, error) {
- ddp.call('sendMessage', [{ 'rid': rid, 'msg': msg }]).then(callback, error);
- };
- var pushNotification = function (notification) {
- deskNotification.showNotification(notification.title, {
- body: notification.body,
- icon: notification.icon || '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- onClick: notification.callback || function onNotificationClicked() {
- // console.log('Notification clicked.');
- },
- autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)
- }, function onShow(error, hide) {
- if (error) {
- window.alert('Unable to show notification: ' + error.message);
- } else {
- // console.log('Notification Shown.');
- setTimeout(function hideNotification() {
- // console.log('Hiding notification....');
- hide(); //manually close the notification (you can skip this if you use the autoClose option)
- }, 5000);
- }
- });
- }
- // $rootScope.subscribeRoomMessage = function(rid){
- // ddp.subscribe('stream-room-messages',[rid, true]).then(function(){},function(reason){
- // console.log('subscribe stream-room-messages:%o', reason);
- // });
- // }
- $rootScope.filternotifyuser = [];
- $rootScope.$on('openroom', function (event, data, otheruser) {
- ddp.call('createDirectMessage', [otheruser]).then(function () { }, function (reason) {
- // console.log('createDirectMessage', reason);
- });
- ddp.subscribe('stream-room-messages', [data.rid, true]).then(function () { }, function (reason) {
- // console.log('subscribe stream-room-messages:%o', reason);
- });
- if ($rootScope.imUsrMap[data.from]['unread'].msgs) {
- $rootScope.imUsrMap[data.from]['unread'].msgs.clear;
- }
- $rootScope.filternotifyuser.push(data.from);
- });
- $rootScope.$on("clip-two.toggled", function (e, target, newState, sameGroup) {
- console.log(newState)
- if (newState == false && target == 'off-sidebar') {
- $rootScope.$broadcast('chatcloseroom');
- $rootScope.judgeHjzx();
- //$rootScope.toggle("users");
- //$rootScope.filternotifyuser = [];
- //ddp.unsubscribe('stream-room-messages');
- }
- });
- $rootScope.$on("closeroom", function (event, data) {
- $rootScope.filternotifyuser = [];
- ddp.unsubscribe('stream-room-messages');
- });
- var initImUser = function (email, token) {
- var ddpconnect = ddp.connect();
- ddpconnect.then(function (data) {
- //console.log(data);
- if (data.session) {
- // ddp.call('createDirectMessage', [data.from, data.rid]).then(function() {}, function(reason) {
- // console.log('subscribe createDirectMessage');
- // });
- ddp.call('login', [{ user: { email: email }, password: token }]).then(function (data) {
- // console.log('login data: %o', data);
- if (data.id) {
- $rootScope.me = {
- id: data.id,
- token: data.token,
- expiry: data.tokenExpires
- };
- //获取在线用户
- ddp.subscribe('activeUsers');
- ddp.subscribe('stream-notify-user', [$rootScope.me.id + '/notification', true]).then(function (result) {
- //console.log(result);
- }, function (reason) {
- // console.log('stream-notify-user error:%s', reason);
- });
- // ddp.subscribe('stream-notify-user',[$rootScope.me.id+'/message',false]).then(function(result){
- // console.log(result);
- // },function(reason){
- // console.log('stream-notify-user error:', reason);
- // });
- ddp.subscribe('messages', [$rootScope.me.id + '/message', true]).then(function () { }, function (reason) {
- // console.log('subscribe messages error:%s', reason);
- });
- //'stream-notify-user',$rootScope.me.id+'/message'
- // ddp.call('sendmessage', []).then(function(msg){
- // })
- //console.log('Logged in!');
- // ddp.subscribe('messages', [{rid:data.id,start:new Date()}]).then(function(submsg){
- // console.log('subscribe messages-%s', submsg);
- // $rootScope.rocketchat_message = ddp.getCollection('rocketchat_message');
- // },function(reason){
- // console.log(reason);
- // })
- }
- }, function (reason) {
- // console.log(reason);
- });
- } else {
- }
- ddp.watch('users', function (changedDoc, message) {
- //console.log('users:%o',changedDoc);
- // if (message == 'method') {
- // console.log("1111111111111111111")
- // }
- if (message == 'added') {
- if (changedDoc.status && ($rootScope.me.id != changedDoc._id)) {
- if (changedDoc.status == 'away') {
- $rootScope.offlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
- } else {
- $rootScope.onlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
- }
- } else {
- //self
- }
- } else if (message == 'changed') {
- if ($rootScope.me.id != changedDoc._id) {
- if (!$rootScope.imUsrMap[changedDoc._id]) {
- if (changedDoc.status == 'away') {
- $rootScope.offlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
- } else {
- $rootScope.onlineUser.push(changedDoc);
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
- }
- }
- if (changedDoc.status == 'away') {
- if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
- } else {
- $rootScope.offlineUser.push(changedDoc);
- $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- window._.map(window._.slice($rootScope.onlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
- $rootScope.imUsrMap[item._id].index = n;
- })
- // $rootScope.onlineUser = window._.take($rootScope.onlineUser,$rootScope.imUsrMap[changedDoc._id].index).concat(window._.map(window._.slice($rootScope.onlineUser,$rootScope.imUsrMap[changedDoc._id].index+1),function(item){
- // item.index = item.index - 1;
- // }))
- //.splice($rootScope.imUsrMap[changedDoc.id].index,1);
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.offlineUser.length };
- }
- } else {
- if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
- $rootScope.onlineUser.push(changedDoc);
- $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
- $rootScope.imUsrMap[item._id].index = n;
- })
- // $rootScope.offlineUser = window._.take($rootScope.offlineUser,$rootScope.imUsrMap[changedDoc._id].index).concat(window._.map(window._.slice($rootScope.offlineUser,$rootScope.imUsrMap[changedDoc._id].index+1),function(item){
- // item.index = item.index - 1;
- // }))
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length };
- } else {
- }
- }
- }
- } else if (message == 'removed') {
- if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
- } else {
- $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
- window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
- $rootScope.imUsrMap[item._id].index = n;
- });
- $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length, unread: { total: 0, msgs: [] } };
- }
- }
- });
- ddp.watch('stream-notify-user', function (changedDoc, message) {
- if (message == 'changed') {
- if (changedDoc.eventName) {
- if (changedDoc.eventName.indexOf('/') > -1) {
- // var [mineId, action] = changedDoc.eventName.split('/');
- var mineId = changedDoc.eventName.split('/');
- var action = mineId;
- if (action == 'notification') {
- angular.forEach(changedDoc.args, function (item) {
- if ($rootScope.filternotifyuser.indexOf(item.payload.sender._id) > -1) {
- } else {
- // console.log("push notify message:%o", item);
- var r = angular.extend(item, { 'date': new Date() })
- $rootScope.imUsrMap[item.payload.sender._id]['unread'].msgs.push(r);
- $rootScope.imUsrMap[item.payload.sender._id]['unread'].total++;
- pushNotification({
- title: "您有新消息-来自" + item.payload.sender.username,
- body: r.text,
- callback: function () {
- window.focus();
- $rootScope.toggle('off-sidebar');
- }
- })
- //toaster.pop('info', "您有新消息-来自"+item.payload.sender.username, r.text);
- }
- })
- }
- }
- }
- } else {
- }
- //console.log('notify message %o, %o', changedDoc, message);
- });
- ddp.watch('stream-room-messages', function (changedDoc, message) {
- if (message == 'changed') {
- //angular.forEach(changedDoc.args,function(item){
- $rootScope.$broadcast(changedDoc.eventName + '-msgs', changedDoc.args);
- //};
- // if(changedDoc.eventName){
- // $rootScope.imUsrMap[eventName]=$rootScope.imUsrMap[eventName]||{};
- // $rootScope.imUsrMap[eventName]['msgs']=$rootScope.imUsrMap[eventName]['msgs']||[];
- // angular.forEach(changedDoc.args,function(item){
- // $rootScope.imUsrMap[eventName].msgs.push(item);
- // })
- // }
- } else {
- }
- // console.log('notify message %o, %o', changedDoc, message);
- });
- ddp.watch('rocketchat_message', function (changedDoc, message) {
- // console.log('recieve rocketchat_message: %o-%o', changedDoc, message);
- });
- });
- }
- window.onunload = function () {
- }
- $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
- //$auth.validateUser();
- //stop loading bar on stateChangeSuccess
- event.targetScope.$watch("$viewContentLoaded", function () {
- cfpLoadingBar.complete();
- });
- // scroll top the page on change state
- $document.scrollTo(0, 0);
- if (angular.element('.email-reader').length) {
- angular.element('.email-reader').animate({
- scrollTop: 0
- }, 0);
- }
- // Save the route title
- $rootScope.currTitle = $state.current.title;
- if (angular.isDefined($state.current.pdKey)) {
- $rootScope.pdKey = $state.current.pdKey;
- }
- // console.log($state.current.title);
- });
- // State not found
- $rootScope.$on('$stateNotFound', function (event, unfoundState, fromState, fromParams) {
- //$rootScope.loading = false;
- if (angular.isUndefined($rootScope.user.id)) {
- $rootScope.loading = false;
- }
- // console.log(unfoundState.to);
- // "lazy.state"
- // console.log(unfoundState.toParams);
- // {a:1, b:2}
- // console.log(unfoundState.options);
- // {inherit:false} + default options
- });
- $rootScope.isMousedown = false;
- $rootScope.changeRemoveClass = function (e) {
- $rootScope.isMousedown = true
- }
- $rootScope.returnRemoveClass = function (e) {
- $rootScope.isMousedown = false;
- }
- $rootScope.$on('auth:login-success', function (ev, data) {
- // $state.go('login.signin');
- initImUser(data.email, data.msgUuid);
- getMenus();
- //console.log(data);
- //$rootScope.user = data.user;
- //$rootScope.menus = data.menu;
- });
- //$rootScope.$watch('$auth.user')
- // $rootScope.$on('auth:validation-success', function(ev, user) {
- // // console.log(user);
- // initImUser(user.email, user.msgUuid);
- // if ($rootScope.userMenus.length == 0) {
- // getMenus();
- // }
- // //alert('Welcome ', user.email);
- // });
- // $rootScope.$on('auth:invalid', function(ev) {
- // $state.go('login.signin');
- // });
- // $rootScope.$on('auth:validation-error', function(ev) {
- // $state.go('login.signin');
- // //alert('Welcome ', user.email);
- // });
- // $rootScope.$on('auth:session-expired', function(ev) {
- // //alert('Welcome ', user.email);
- // $state.go('login.signin');
- // });
- // $rootScope.$on('auth:logout-success', function(ev) {
- // //alert('goodbye');
- // //delete $rootScope.user;
- // //delete $rootScope.menus;
- // $state.go('login.signin');
- // });
- // $rootScope.$on('auth:logout-error', function(ev) {
- // $state.go('login.signin');
- // });
- $rootScope.pageTitle = function () {
- // if($rootScope.currTitle){
- // return $rootScope.app.name + ' - ' + $filter('translate')($rootScope.currTitle) || $rootScope.app.description;
- // }else{
- // return $rootScope.app.name + ' - ' + $rootScope.app.description
- // }
- var perfix = "sidebar.nav.";
- var toTransKeypageTitle = perfix + $rootScope.currTitle;
- // return $rootScope.app.name + ' - ' + ($filter('translate')(toTransKeypageTitle) || $rootScope.app.description);
- return $rootScope.app.name;
- };
- // $auth.validateUser();
- // $auth.authenticate('local').then(function(resp){
- // }).catch(function(resp){
- // })
- // if(angular.isDefined($rootScope.nickname)){
- // api_login.sso($rootScope.nickname).then(function(response){
- // var user = Restangular.stripRestangular(response);
- // if (user) {
- // if(angular.isUndefined(user.id)){
- // }else{
- // $rootScope.user = user;
- // }
- // }
- // });
- // }else{
- // var user= $cookieStore.get("userObm");
- // if(user){
- // $rootScope.user = user;
- // $rootScope.menus = $cookieStore.get("menuObm");
- // }else{
- // if(angular.isDefined($rootScope.nickname)){
- // api_login.sso($rootScope.nickname).then(function(response){
- // var data = Restangular.stripRestangular(response);
- // if (data) {
- // if(data.user){
- // if(angular.isUndefined(data.user.id)){
- // }else{
- // $rootScope.user = data.user;
- // $rootScope.menus = data.menu;
- // $cookieStore.put("userObm", $rootScope.user);
- // $cookieStore.put("menuObm", $rootScope.menus);
- // $cookieStore.put("session", data.sessionId);
- // }
- // }
- // }
- // });
- // }else{
- // }
- // }
- //}
- //选择坐席号
- $scope.changeWorkId = function () {
- event.stopPropagation();
- }
- $rootScope.getSession = function () {
- if ($auth.userIsAuthenticated()) {
- return $auth.retrieveData('auth_headers')
- /*return {
- 'access-token':$auth.retrieveData('auth_headers')['access-token'],
- 'expiry':$auth.retrieveData('auth_headers')['expiry']
- };*/
- } else {
- return undefined;
- }
- }
- $scope.includes = [];
- $rootScope.includesState = function (state) {
- //for test
- //return true;
- //return includes;
- if ($rootScope.user) {
- if ($rootScope.user.menu) {
- angular.forEach($rootScope.user.menu, function (item) {
- $scope.includes[item.link] = true;
- });
- }
- }
- return $scope.includes[state];
- }
- //大屏入口
- $rootScope.opendashbord = function () {
- $state.go('echart');
- }
- // $rootScope.authority=false;
- // console.log($rootScope.user)
- // if($rootScope.user.role){
- // for(var i ;i<$rootScope.user.role.length;i++){
- // if($rootScope.user.role[i].rolecode=='call center') {
- // $rootScope.authority=true;
- // }else{$rootScope.authority=false;}
- // }
- // }
- /* status[已签入:1/通话中:3/来电:2],state[示闲:1,示忙:2] */
- // if (window.location.href && window.location.href.hash == "#/echart") {
- // } else {
- // // }
- // // 东经呼叫中心开始
- // $rootScope.statuscall = 0; //话机状态
- // $rootScope.statecall = 1; //示忙示闲
- // $scope.login = false; //签入签出
- // $rootScope.callout = false; //呼入呼出
- // $scope.group = 2000;
- // $scope.phone = 1500;
- // $rootScope.start = function(phone, group) {
- // api_text.start(phone, $rootScope.user.id).then(function(data) {
- // var token = data.token;
- // $rootScope.takes = token;
- // api_text.logout($rootScope.takes, $rootScope.user.id).then(function(data) { if (data.errno == 0) {} });
- // api_text.login($scope.group, token, $rootScope.user.id).then(function(data) {
- // if (data.errno == 0) {
- // $rootScope.setidle();
- // $scope.login = true;
- // $rootScope.statuscall = 1;
- // $rootScope.callout = false;
- // // function hello() {
- // // var ws = new WebSocket('ws://192.168.3.49:28088/events');
- // // ws.onopen = function() { ws.send(JSON.stringify(register)); };
- // // };
- // // window.setTimeout("hello()", 1000);
- // // var ws = new WebSocket('ws://192.168.77.57:28088/events');
- // function reconnect() {
- // // var ws = new WebSocket('ws://192.168.3.49:28088/events');
- // var ws = new WebSocket('ws://115.156.150.70:28088/events');
- // var register = { "msgtype": "login", "adn": phone };
- // ws.onopen = function() {
- // heartCheck.start();
- // ws.send(JSON.stringify(register));
- // };
- // ws.onmessage = function(evt) {
- // heartCheck.reset();
- // if (evt.data == "HeartBeat") {
- // } else {
- // var mydata = JSON.parse(evt.data);
- // $scope.filterData = [];
- // if (mydata.evttype == "callincome" && mydata.uud != "misc:callback") {
- // $rootScope.$apply(function() {
- // $rootScope.statuscall = 2;
- // });
- // $rootScope.callout = false;
- // $rootScope.phone = mydata.ano;
- // var Notification = window.Notification;
- // Notification.requestPermission();
- // var n = new Notification("你有来电", {
- // body: "来电号码:" + mydata.ano,
- // icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- // // onclick: function onNotificationClicked() {
- // // console.log('Notification clicked.');
- // // }
- // });
- // } else if (mydata.evttype == "callincome" && mydata.uud == "misc:callback") {
- // $rootScope.callout = true;
- // } else if (mydata.evttype == "ringstop") {
- // // $rootScope.status=7;
- // // $rootScope.$apply(function() {
- // $rootScope.statuscall = 1;
- // // });
- // $rootScope.phone = ""
- // } else if (mydata.evttype == 'hookchanged' && $rootScope.callout) {
- // if (mydata.status && mydata.status == '1') {
- // $rootScope.$apply(function() {
- // $rootScope.statuscall = 1;
- // });
- // $rootScope.phone = "";
- // } else if (mydata.status && mydata.status != '1') {
- // $rootScope.$apply(function() {
- // $rootScope.statuscall = 3;
- // });
- // }
- // } else if (mydata.evttype == 'hookchanged' && !$rootScope.callout) {
- // if ($rootScope.phone != "") {
- // if (mydata.status && mydata.status == '1') { //挂机
- // $rootScope.$apply(function() {
- // $rootScope.statuscall = 1;
- // });
- // console.log("挂机");
- // console.log(mydata);
- // } else if (mydata.status && mydata.status != '1' && $rootScope.statecall != 2) { //摘机
- // $rootScope.statuscall = 3;
- // api_text.setbusy($rootScope.takes).then(function(data) {
- // if (data.errno == 0) {
- // $rootScope.statecall = 2;
- // $scope.busy = true;
- // }
- // })
- // console.log("摘机");
- // console.log(mydata);
- // api_text.getcdrid($rootScope.takes).then(function(response) {
- // if (response.cdrid) {
- // var cdrid = response.cdrid;
- // // var response={cdrid:'219023836'}
- // var filterData = { "idx": 0, "sum": 10, "requester": { "mphone": $rootScope.phone, "telephone": $rootScope.phone, "selectType": 1 } }
- // api_user_data.fetchDataList('requester', filterData).then(function(data) {
- // var myData = Restangular.stripRestangular(data);
- // // $rootScope.phone="";
- // if (myData.list.length == 0) {
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
- // controller: function($scope, $modalInstance, api_user_data) {
- // $scope.title = "新增报修人";
- // $scope.requester = {};
- // $scope.onChangeadd = function(searchData) {
- // $scope.searchKey = searchData.account;
- // // $scope.searchDataadd = searchData;
- // var requesdata = angular.copy(searchData)
- // // if (requesdata.mphone) {
- // // delete requesdata.mphone;
- // // }
- // if (requesdata.telephone) {
- // delete requesdata.telephone;
- // }
- // angular.extend($scope.requester, requesdata);
- // }
- // $scope.refreshUseradd = function(searchKey) { //请求人搜索
- // $scope.requester.account = searchKey;
- // $scope.searchData = searchKey;
- // serchdataadd(searchKey);
- // }
- // $scope.getMydata = function(x) {
- // var reqestdatap = JSON.parse(x[0])
- // // if ($scope.requester.mphone) {
- // // delete reqestdatap.mphone;
- // // }
- // if ($scope.requester.telephone) {
- // delete reqestdatap.telephone;
- // }
- // $scope.searchField = JSON.parse(x[0]).account;
- // angular.extend($scope.requester, reqestdatap);
- // }
- // $scope.getMydataone = function(x) {
- // $scope.searchField = x;
- // $scope.requester.account = x;
- // }
- // serchdataadd();
- // function serchdataadd(searchKey) {
- // if (searchKey) {
- // var filterData = {
- // 'requester': {
- // 'searchKey': searchKey,
- // },
- // idx: 0,
- // sum: 10
- // };
- // } else {
- // var filterData = {
- // idx: 0,
- // sum: 10
- // };
- // }
- // // serchdataadd(searchKey)
- // // if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
- // // angular.extend(filterData.requester, { 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO })
- // // }
- // api_user_data.fetchDataList('requester', filterData).then(function(response) {
- // var myData = response;
- // $scope.myData = myData.list;
- // });
- // }
- // // if ((/^1[34578]\d{9}$/.test($rootScope.phone))) {
- // // $scope.requester = { 'mphone': $rootScope.phone };
- // // } else {
- // // $scope.requester = { 'telephone': $rootScope.phone };
- // // }
- // $scope.requester = { 'telephone': $rootScope.phone };
- // $scope.ok = function() {
- // $modalInstance.close($scope.requester);
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // });
- // modalInstance.result.then(function(selectedItem) {
- // if (selectedItem) {
- // if (selectedItem.telephone && !selectedItem.mphone) {
- // selectedItem.telephone = angular.copy(selectedItem.mphone);
- // delete selectedItem.mphone;
- // }
- // var data = {
- // 'requester': selectedItem
- // };
- // api_user_data.addData('requester', data).then(function(response) {
- // if (response.status == 200) {
- // var data = { 'model': { 'requestershow': response.data, 'incident': { 'requester': response.data, 'area': response.areaDTO, 'place': response.placeDTO, 'houseNumber': response.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
- // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- // }
- // })
- // }
- // });
- // } else if (myData.list.length == 1) {
- // var data = { 'model': { 'requestershow': myData.list[0], 'incident': { 'requester': myData.list[0], 'area': myData.list[0].areaDTO, 'place': myData.list[0].placeDTO, 'houseNumber': myData.list[0].houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
- // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- // } else {
- // var modalInstance = $modal.open({
- // templateUrl: 'assets/views/createincident.html',
- // controller: function($scope, $modalInstance, api_user_data) {
- // $scope.title = "请确定报修人";
- // $scope.requester = myData.list;
- // $scope.choice = function(requester) {
- // $modalInstance.dismiss('cancel');
- // var data = { 'model': { 'requestershow': requester, 'incident': { 'requester': requester, 'area': requester.areaDTO, 'place': requester.placeDTO, 'houseNumber': requester.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
- // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- // };
- // $scope.cancel = function() {
- // $modalInstance.dismiss('cancel');
- // };
- // },
- // size: "lg"
- // });
- // }
- // });
- // }
- // })
- // }
- // }
- // }
- // }
- // };
- // var heartCheck = {
- // timeout: 12000, //60ms
- // timeoutObj: null,
- // serverTimeoutObj: null,
- // reset: function() {
- // clearTimeout(this.timeoutObj);
- // clearTimeout(this.serverTimeoutObj);
- // this.start();
- // },
- // start: function() {
- // var self = this;
- // this.timeoutObj = setTimeout(function() {
- // ws.send("HeartBeat");
- // self.serverTimeoutObj = setTimeout(function() {
- // ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
- // }, self.timeout)
- // }, this.timeout)
- // },
- // }
- // ws.onclose = function(evt) { reconnect(); }
- // ws.onerror = function(evt) { reconnect(); };
- // }
- // reconnect();
- // } else {
- // var Notification = window.Notification;
- // Notification.requestPermission();
- // var n = new Notification("签入失败!", {
- // body: data.errmsg,
- // icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- // // onclick: function onNotificationClicked() {
- // // console.log('Notification clicked.');
- // // }
- // });
- // }
- // })
- // })
- // }
- // // 东经呼叫中心结束
- // 华科呼叫中心 start
- /* status[已签入:1/通话中:3/来电:2],state[示闲:1,示忙:2] */
- $rootScope.statuscall = 0; //话机状态
- $rootScope.statecall = 1; //示忙示闲
- $scope.login = false; //签入签出
- $rootScope.callout = 0; //呼入:1,呼出:2
- $scope.group = 2000;
- $scope.phone = 1500;
- $rootScope.phoneChange = function(phone) {
- if (phone == 1500||phone == 1501||phone == 1502) {
- $scope.group = 2000;
- } else if(phone == 1511) {
- $scope.group = 2001;
- }else if(phone == 1507) {
- $scope.group = 2002;
- }
- }
- $rootScope.start = function(phone) {
- if (phone == 1500||phone == 1501||phone == 1502) {
- $scope.group = 2000;
- } else if(phone == 1511) {
- $scope.group = 2001;
- }else if(phone == 1507) {
- $scope.group = 2002;
- }
- api_text.start(phone, $rootScope.user.id).then(function(data) {
- var token = data.token;
- $rootScope.takes = token;
- api_text.logout($rootScope.takes, $rootScope.user.id).then(function(data) { if (data.errno == 0) {} });
- api_text.login($scope.group, token, $rootScope.user.id).then(function(data) {
- if (data.errno == 0) {
- localStorage.setItem('hk_phone',phone);
- $rootScope.setidle();
- $scope.login = true;
- $rootScope.statuscall = 1;
- $rootScope.callout = 0;
- // function hello() {
- // var ws = new WebSocket('ws://192.168.3.49:28088/events');
- // ws.onopen = function() { ws.send(JSON.stringify(register)); };
- // };
- // window.setTimeout("hello()", 1000);
- // var ws = new WebSocket('ws://192.168.77.57:28088/events');
- function reconnect() {
- // var ws = new WebSocket('ws://192.168.3.49:28088/events');
- var ws = new WebSocket('ws://192.168.77.57:8088/IXServer/messagestation/hjzx');
- var register = { "msgtype": "login", "adn": phone };
- ws.onopen = function() {
- heartCheck.start();
- ws.send(JSON.stringify(register));
- };
- ws.onmessage = function(evt) {
- heartCheck.reset();
- if (evt.data == "HeartBeat") {
- } else {
- var mydata = JSON.parse(evt.data);
- $scope.filterData = [];
- if (mydata.evttype == "callincome" && mydata.uud != "misc:callback") {
- $rootScope.$apply(function() {
- $rootScope.statuscall = 2;
- $rootScope.callout = 1;
- });
- $rootScope.phone = mydata.ano;
- var Notification = window.Notification;
- Notification.requestPermission();
- var n = new Notification("你有来电", {
- body: "来电号码:" + mydata.ano,
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- // onclick: function onNotificationClicked() {
- // console.log('Notification clicked.');
- // }
- });
- } else if (mydata.evttype == "callincome" && mydata.uud == "misc:callback") {
- $rootScope.callout = 2;
- } else if (mydata.evttype == "ringstop") {
- // $rootScope.status=7;
- // $rootScope.$apply(function() {
- $rootScope.statuscall = 1;
- // });
- $rootScope.phone = ""
- } else if (mydata.evttype == 'hookchanged' && $rootScope.callout == 2) {
- if (mydata.status && mydata.status == '1') {
- $rootScope.$apply(function() {
- $rootScope.statuscall = 1;
- });
- $rootScope.phone = "";
- } else if (mydata.status && mydata.status != '1') {
- $rootScope.$apply(function() {
- $rootScope.statuscall = 3;
- });
- }
- } else if (mydata.evttype == 'hookchanged' && $rootScope.callout == 1) {
- if ($rootScope.phone != "") {
- if (mydata.status && mydata.status == '1') { //挂机
- $rootScope.$apply(function() {
- $rootScope.statuscall = 1;
- $rootScope.callout = 0;
- });
- // console.log("挂机");
- if ($rootScope.statecall == 1 && !$rootScope.isSetidle) {
- $rootScope.setbusy();
- }
- } else if (mydata.status && mydata.status != '1' && $rootScope.statecall != 2 && $rootScope.callout == 1) { //摘机
- $rootScope.status = 6
- $rootScope.statuscall = 3;
- $rootScope.isSetidle = false;
- $rootScope.app.layout.isSidebarClosed = true;
- // console.log("摘机");
- // console.log(mydata);
- api_text.getcdrid($rootScope.takes).then(function(response) {
- if (response.cdrid) {
- var cdrid = response.cdrid;
- // var response={cdrid:'219023836'}
- var filterData = { "idx": 0, "sum": 10, "requester": { "mphone": $rootScope.phone, "telephone": $rootScope.phone, "selectType": 1 } }
- api_user_data.fetchDataList('requester', filterData).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- // $rootScope.phone="";
- if (myData.list.length == 0) {
- var modalInstance = $modal.open({
- backdrop: "static",
- templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
- controller: function($scope, $modalInstance, api_user_data, SweetAlert) {
- $scope.title = "新增报修人";
- $scope.requester = {};
- $scope.onChangeadd = function(searchData) {
- $scope.searchKey = searchData.account;
- // $scope.searchDataadd = searchData;
- var requesdata = angular.copy(searchData)
- // if (requesdata.mphone) {
- // delete requesdata.mphone;
- // }
- if (requesdata.telephone) {
- delete requesdata.telephone;
- }
- angular.extend($scope.requester, requesdata);
- }
- $scope.refreshUseradd = function(searchKey) { //请求人搜索
- $scope.requester.account = searchKey;
- $scope.searchData = searchKey;
- serchdataadd(searchKey);
- }
- $scope.getMydata = function(x) {
- var reqestdatap = JSON.parse(x[0])
- // if ($scope.requester.mphone) {
- // delete reqestdatap.mphone;
- // }
- if ($scope.requester.telephone) {
- delete reqestdatap.telephone;
- }
- $scope.searchField = JSON.parse(x[0]).account;
- angular.extend($scope.requester, reqestdatap);
- if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
- api_user_data.fetchDataList('place', { place: { areaId: $scope.requester.areaDTO.id }, idx: 0, sum: 1000 }).then(function(response) {
- if (response.status == 200) {
- $scope.places = response.list;
- }
- })
- }
- }
- $scope.getMydataone = function(x) {
- $scope.searchField = x;
- $scope.requester.account = x;
- }
- serchdataadd();
- function serchdataadd(searchKey) {
- if (searchKey) {
- var filterData = {
- 'requester': {
- 'searchKey': searchKey,
- },
- idx: 0,
- sum: 10
- };
- } else {
- var filterData = {
- idx: 0,
- sum: 10
- };
- }
- api_user_data.fetchDataList('requester', filterData).then(function(response) {
- var myData = response;
- $scope.myData = myData.list;
- });
- }
- api_user_data.fetchDataList('area', { idx: 0, sum: 100 }).then(function(response) {
- if (response.status == 200) {
- $scope.areas = response.list;
- }
- })
- // api_user_data.fetchDataList('place', { idx: 0, sum: 1000 }).then(function(response) {
- // if (response.status == 200) {
- // $scope.places = response.list;
- // }
- // }) //地点
- api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
- if (response.status == 200) {
- $scope.networktypes = response.list;
- }
- })
- $scope.requesterAreaid = "";
- $scope.onChange = function(item) {
- $scope.requesterAreaid = item.id;
- $scope.requester.place = {};
- api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
- if (response.status == 200) {
- $scope.places = response.list;
- }
- })
- }
- //地点搜索
- $scope.refresh = function(searchVal) {
- var faildata = {};
- if ($scope.requesterAreaid) {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': { 'areaId': $scope.requesterAreaid, 'place': searchVal, 'selectType': 'pinyin_qs' }
- }
- } else {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': { 'place': searchVal, 'selectType': 'pinyin_qs' }
- }
- }
- api_user_data.fetchDataList('place', faildata).then(function(response) {
- $scope.places = response.list;
- delete $scope.requester.place;
- })
- }
- $scope.requester = { 'telephone': $rootScope.phone };
- $scope.ok = function() {
- // $modalInstance.close($scope.requester);
- if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
- SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
- } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
- SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
- } else {
- $modalInstance.close($scope.requester);
- }
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- $rootScope.setidle();
- };
- },
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- if (selectedItem.telephone && !selectedItem.mphone) {
- selectedItem.telephone = angular.copy(selectedItem.mphone);
- delete selectedItem.mphone;
- }
- var data = {
- 'requester': selectedItem
- };
- api_user_data.addData('requester', data).then(function(response) {
- if (response.status == 200) {
- var data = {
- model: {
- requestershow: response.data,
- incident: {
- requester: response.data,
- area: response.data.place?response.data.place.area:undefined,
- place: response.data.place,
- houseNumber: response.data.houseNumber,
- contactsInformation: response.data.telephone,
- contacts:response.data.name,
- callID: cdrid,
- source: { id: 1 },
- },
- },
- };
- $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- }
- })
- }
- });
- } else if (myData.list.length == 1) {
- angular.extend(myData.list[0], { 'telephone': $rootScope.phone });
- var data = {
- model: {
- requestershow: myData.list[0],
- incident: {
- requester: myData.list[0],
- area: myData.list[0].place?myData.list[0].place.area:undefined,
- place: myData.list[0].place,
- contactsInformation: myData.list[0].telephone,
- houseNumber: myData.list[0].houseNumber,
- contacts:myData.list[0].name,
- callID: cdrid,
- source: { id: 1 },
- },
- },
- };
- $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/createincident.html',
- backdrop: "static",
- controller: function($scope, $modalInstance, api_user_data) {
- $scope.title = "请确定报修人";
- $scope.requester = myData.list;
- $scope.choice = function(requester) {
- $modalInstance.dismiss('cancel');
- angular.extend(requester, { 'telephone': $rootScope.phone });
- var data = {
- model: {
- requestershow: requester,
- incident: {
- requester: requester,
- area: requester.place?requester.place.area:undefined,
- place: requester.place,
- houseNumber: requester.houseNumber,
- contactsInformation: requester.telephone,
- contacts:requester.name,
- callID: cdrid,
- source: { id: 1 },
- },
- },
- };
- $state.go('app.incident.title', { 'model': JSON.stringify(data) });
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- $rootScope.setidle();
- };
- },
- size: "lg"
- });
- }
- });
- }
- })
- }
- }
- }
- }
- };
- var heartCheck = {
- timeout: 12000, //60ms
- timeoutObj: null,
- serverTimeoutObj: null,
- reset: function() {
- clearTimeout(this.timeoutObj);
- clearTimeout(this.serverTimeoutObj);
- this.start();
- },
- start: function() {
- var self = this;
- this.timeoutObj = setTimeout(function() {
- if ($scope.login) {
- ws.send("HeartBeat");
- self.serverTimeoutObj = setTimeout(function() {
- ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
- }, self.timeout)
- }
- }, this.timeout)
- },
- }
- ws.onclose = function(evt) { reconnect(); }
- ws.onerror = function(evt) { reconnect(); };
- }
- reconnect();
- } else {
- var Notification = window.Notification;
- Notification.requestPermission();
- var n = new Notification("签入失败!", {
- body: data.errmsg,
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- // onclick: function onNotificationClicked() {
- // console.log('Notification clicked.');
- // }
- });
- }
- })
- })
- }
- setInterval(function() {
- if ($scope.login && $rootScope.statuscall == 1 && $rootScope.statecall == 1) {
- $rootScope.setidle();
- } else if ($scope.login && $rootScope.statuscall != 3 && $rootScope.statecall == 2 && statuscall != 0) {
- $rootScope.setbusy
- }
- }, 3000);
- // 华科呼叫中心 end
- //话机呼叫中心--开始
- $rootScope.getExtnDirect = function () {
- $rootScope['getExtnDirect' + $rootScope.seiminHj]();
- }
- // --------------------------1------------------------------
- $rootScope.getExtnDirect1 = function () {
- var jry_data_dictionary = {
- key: "hjzx_cornet",
- type: "list"
- }
- api_wechatfile.getDictionary(jry_data_dictionary).then(function (res) {
- var websocket_url = "ws://192.168.3.122:29003/ola_socket";
- var ola_queue = "10009"; //通话配置-队列配置-队列ID
- // var ola_extn = "1001"; //个人信息-座席分机号
- $rootScope.jry_extnNumberSelect = [];
- $rootScope.jry_extnNumberObj = {};
- $rootScope.jry_extnNumberSelect = res;
- $rootScope.jry_extnNumberObj.jry_extnNumber = $rootScope.jry_extnNumberSelect[0];
- function log(msg) {
- //IE has no console
- if ('console' in window) console.log(msg);
- }
- function websocket_connect() {
- ola.connect(websocket_url);
- ola.onConnect = onConnect;
- ola.onClose = onClose;
- ola.onMessage = onMessage;
- }
- $(document).ready(function () {
- // if(ola_extn!=""){
- if ($rootScope.jry_extnNumberObj.jry_extnNumber) {
- websocket_connect();
- }
- });
- /* callbacks */
- function onMessage(evt) {
- var phoneData = JSON.parse(evt.data);
- if (phoneData.event_type == "agent_state") {
- console.log(phoneData);
- if (phoneData.state == "busy") {
- $('#agent_state').append(" (" + phoneData.private_data + ")");
- // 来电
- if (phoneData.private_data == "ring") {
- console.log(phoneData);
- $rootScope.jry_state = "laidian";
- var Notification = window.Notification;
- Notification.requestPermission();
- var n = new Notification("你有来电", {
- body: "来电号码:" + phoneData.ani,
- icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
- });
- // 摘机
- } else if (phoneData.private_data == "answered") {
- $rootScope.jry_state = "tonghuazhong";
- var jry_findPhone = "";
- if (phoneData.ani) {
- jry_findPhone = phoneData.ani
- } else if (phoneData.dnis && phoneData.other_answered) {
- jry_findPhone = phoneData.dnis
- }
- var filterData = {
- "idx": 0,
- "sum": 100,
- "requester": {
- "mphone": jry_findPhone,
- "telephone": jry_findPhone,
- "selectType": 1
- }
- }
- api_user_data.fetchDataList('requester', filterData).then(function (data) {
- var myData = Restangular.stripRestangular(data);
- // $rootScope.phone="";
- // 新增报修人
- if (myData.list.length == 0) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
- controller: function ($scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
- $scope.title = "新增报修人";
- $scope.requester = {};
- $scope.onChangeadd = function (searchData) {
- $scope.searchKey = searchData.account;
- // $scope.searchDataadd = searchData;
- var requesdata = angular.copy(searchData)
- // if (requesdata.mphone) {
- // delete requesdata.mphone;
- // }
- if (requesdata.telephone) {
- delete requesdata.telephone;
- }
- angular.extend($scope.requester, requesdata);
- }
- $scope.refreshUseradd = function (searchKey) { //请求人搜索
- $scope.requester.account = searchKey;
- $scope.searchData = searchKey;
- serchdataadd(searchKey);
- }
- $scope.getMydata = function (x) {
- var reqestdatap = JSON.parse(x[0])
- // if ($scope.requester.mphone) {
- // delete reqestdatap.mphone;
- // }
- if ($scope.requester.telephone) {
- delete reqestdatap.telephone;
- }
- $scope.searchField = JSON.parse(x[0]).account;
- angular.extend($scope.requester, reqestdatap);
- }
- $scope.getMydataone = function (x) {
- $scope.searchField = x;
- $scope.requester.account = x;
- }
- serchdataadd();
- function serchdataadd(searchKey) {
- if (searchKey) {
- var filterData = {
- 'requester': {
- 'searchKey': searchKey,
- },
- idx: 0,
- sum: 10
- };
- } else {
- var filterData = {
- idx: 0,
- sum: 10
- };
- }
- api_user_data.fetchDataList('requester', filterData).then(function (response) {
- var myData = response;
- $scope.myData = myData.list;
- });
- }
- api_user_data.fetchDataList('area', {
- idx: 0,
- sum: 100
- }).then(function (response) {
- if (response.status == 200) {
- $scope.areas = response.list;
- }
- })
- api_wechatfile.getDictionary({
- "key": "requester_type",
- "type": "list"
- }).then(function (response) {
- // if (response.status == 200) {
- $scope.networktypes = response;
- // }
- })
- $scope.requesterAreaid = "";
- $scope.onChange = function (item) {
- $scope.requesterAreaid = item.id;
- $scope.requester.place = {};
- api_user_data.fetchDataList('place', {
- place: {
- areaId: item.id
- },
- idx: 0,
- sum: 1000
- }).then(function (response) {
- if (response.status == 200) {
- $scope.places = response.list;
- }
- })
- }
- //地点搜索
- $scope.refresh = function (searchVal) {
- var faildata = {};
- if ($scope.requesterAreaid) {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': {
- 'areaId': $scope.requesterAreaid,
- 'place': searchVal,
- 'selectType': 'pinyin_qs'
- }
- }
- } else {
- faildata = {
- 'idx': 0,
- 'sum': 1000,
- 'place': {
- 'place': searchVal,
- 'selectType': 'pinyin_qs'
- }
- }
- }
- api_user_data.fetchDataList('place', faildata).then(function (response) {
- $scope.places = response.list;
- delete $scope.requester.place;
- })
- }
- $scope.requester = {
- 'telephone': jry_findPhone
- };
- $scope.ok = function () {
- var reg1 = /^1[3456789][0-9]{9}$/; //手机号
- var reg2 = /^((0\d{2,3})-)*(\d{7,8})(-(\d{3,}))?$/; //座机号
- var flag1 = reg1.test($scope.requester.mphone);
- var flag2 = reg2.test($scope.requester.mphone);
- console.log($scope.requester)
- if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
- SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
- } else if (angular.isUndefined($scope.requester.requesterType)) {
- SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
- } else if (angular.isUndefined($scope.requester.mphone) || $scope.requester.mphone == null || $scope.requester.mphone == "") {
- SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
- }
- else {
- $modalInstance.close($scope.requester);
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- });
- modalInstance.result.then(function (selectedItem) {
- if (selectedItem) {
- if (selectedItem.telephone && !selectedItem.mphone) {
- selectedItem.telephone = angular.copy(selectedItem.mphone);
- delete selectedItem.mphone;
- }
- var data = {
- 'requester': selectedItem
- };
- api_user_data.addData('requester', data).then(function (response) {
- if (response.status == 200) {
- var data = {
- 'model': {
- 'requestershow': response.data,
- 'incident': {
- 'requester': response.data,
- 'area': response.data.place?response.data.place.area:undefined,
- 'place': response.data.place,
- 'houseNumber': response.data.houseNumber,
- 'callID': cdrid,
- 'contacts':response.data.name,
- 'contactsInformation': response.data.telephone,
- 'source': {
- 'id': 1547
- }
- }
- }
- }
- $state.go('app.incident.title', {
- 'model': JSON.stringify(data)
- });
- }
- })
- }
- });
- } else if (myData.list.length == 1) {
- var data = {
- 'model': {
- 'requestershow': myData.list[0],
- 'incident': {
- 'requester': myData.list[0],
- 'area': myData.list[0].place?myData.list[0].place.area:undefined,
- 'place': myData.list[0].place,
- 'houseNumber': myData.list[0].houseNumber,
- 'callID': cdrid,
- 'contacts':myData.list[0].name,
- 'contactsInformation': myData.list[0].telephone,
- 'source': {
- 'id': 1547
- }
- }
- }
- }
- $state.go('app.incident.title', {
- 'model': JSON.stringify(data)
- });
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/createincident.html',
- controller: function ($scope, $modalInstance, api_user_data) {
- $scope.title = "请确定报修人";
- $scope.requester = myData.list;
- $scope.choice = function (requester) {
- $modalInstance.dismiss('cancel');
- var data = {
- 'model': {
- 'requestershow': requester,
- 'incident': {
- 'requester': requester,
- 'area': requester.place?requester.place.area:undefined,
- 'place': requester.place,
- 'houseNumber': requester.houseNumber,
- 'callID': cdrid,
- 'contacts':requester.name,
- 'contactsInformation': requester.telephone,
- 'source': {
- 'id': 1547
- }
- }
- }
- }
- $state.go('app.incident.title', {
- 'model': JSON.stringify(data)
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- },
- size: "lg"
- });
- }
- });
- }
- // 挂机
- } else if (phoneData.state == "login") {
- go_ready()
- } else if (phoneData.state == "logout") {
- $rootScope.jry_state = "weiqianru";
- } else if (phoneData.state == "ready") {
- // 来电挂机
- if (phoneData.old_state == "busy" && phoneData.private_data == "answered") {
- go_break()
- } else {
- $rootScope.jry_state = "shixian";
- }
- }
- // else if (data.old_state == "busy") {
- // }
- } else if (phoneData.event_type == "agent_caller_state") {
- // special feature, never mind
- if (phoneData.action == "in") {
- } else {
- }
- } else if (phoneData.event_type == "command/reply") {
- if (phoneData.phoneData && phoneData.phoneData.state) {
- }
- }
- }
- function onConnect() {
- console.log("websocket connected!");
- // ola._extn = ola_extn;
- // ola.subscribe('ola.queue.' + ola_queue + '.' + ola_extn);
- // ola.subscribe('ola.caller.' + ola_extn);
- // ola.get_agent_state(ola_extn);
- ola._extn = $rootScope.jry_extnNumberObj.jry_extnNumber.name;
- ola.subscribe('ola.queue.' + ola_queue + '.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
- ola.subscribe('ola.caller.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
- ola.get_agent_state($rootScope.jry_extnNumberObj.jry_extnNumber.name);
- };
- function onClose() {
- }
- function login() {
- // ola.login(ola_queue, ola_extn, {type: "onhook"});
- console.log($rootScope.jry_extnNumberObj.jry_extnNumber);
- ola.login(ola_queue, $rootScope.jry_extnNumberObj.jry_extnNumber.name, { type: "onhook" });
- }
- function logout() {
- ola.logout();
- }
- function go_ready() {
- ola.go_ready();
- }
- function go_break() {
- ola.go_break($('#break_reason').val());
- $rootScope.jry_state = "shimang";
- }
- function answer() {
- ola.answer();
- }
- function dial(dst) {
- ola.dial(dst);
- }
- $rootScope.dial = function (dst) {
- ola.dial(dst);
- }
- function conference(dst) {
- ola.conference(dst);
- }
- function conference_uuid(channel_uuid) {
- ola.conference_uuid(channel_uuid);
- }
- function hangup() {
- ola.hangup();
- }
- function take_call(uuid) {
- // ola.take_call(ola_extn, uuid);
- ola.take_call($rootScope.jry_extnNumberObj.jry_extnNumber.name, uuid);
- }
- // 签入
- $rootScope.jry_qianru = function () {
- login();
- }
- // 示闲
- $rootScope.jry_shixian = function () {
- go_ready()
- }
- // 示忙
- $rootScope.jry_shimang = function () {
- go_break()
- }
- // 签出
- $rootScope.jry_qianchu = function () {
- logout()
- }
- $rootScope.jry_bohao = function (res) {
- if ($rootScope.jry_state == "weiqianru") {
- // SweetAlert.swal({
- // title: "拨打失败",
- // text: "请先签入!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- } else if ($rootScope.jry_state == "shimang") {
- // SweetAlert.swal({
- // title: "拨打失败",
- // text: "请先示闲!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- } else {
- dial(res);
- }
- }
- })
- }
- // ------------------------------2--------------------------
- $rootScope.getExtnDirect2 = function () {
- var jry_data_dictionary = {
- key: "hjzx_cornet",
- type: "list"
- }
- api_wechatfile.getDictionary(jry_data_dictionary).then(function (res) {
- sessionStorage.setItem('phones',JSON.stringify(res.map(v=>v.name)));
- var websocket_url = $rootScope.seiminCallIp;
- $rootScope.jry_extnNumberSelect = [];
- $rootScope.jry_extnNumberObj = {};
- $rootScope.jry_extnNumberSelect = angular.copy(res);
- $rootScope.jry_extnNumberObj.jry_extnNumber = {};
- var fenjiNumber = localStorage.getItem('fenjiNumber');
- if(fenjiNumber){
- $rootScope.jry_extnNumberSelect.forEach(ress=>{
- if(ress.name == fenjiNumber){
- $rootScope.jry_extnNumberObj.jry_extnNumber = ress;
- }
- })
- }
- // $rootScope.jry_extnNumberObj.jry_extnNumber = angular.copy(res[0]);//绑定分机对象
- // $rootScope.jry_extnNumberObj.tel1 = angular.copy(res[0]);//目的号码对象
- // $rootScope.jry_extnNumberObj.tel2 = angular.copy(res[0]);//转接坐席对象
- $rootScope.preState = '';//最近一次示忙还是示闲的状态
- //连接
- tlwsa.tlaOpen(websocket_url);
- // 强制示忙
- $scope.qShimang = function(state){
- if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
- //进入页面,强制示忙
- // tlwsa.tlaForceacw($rootScope.phoneNumber);
- setTimeout(()=>{
- tlwsa.tlaAcw();
- },0)
- }else{
- $scope.getState(state);
- }
- }
- // 获取状态
- $scope.getState = function (state) {
- // if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
- // if(state != 2&&state != 0){
- // //进入页面,强制示忙
- // // tlwsa.tlaForceacw($rootScope.phoneNumber);
- // setTimeout(()=>{
- // tlwsa.tlaAcw();
- // },3000)
- // }
- // }
- // var agcount = tlwsa.tlaGetagentcount();
- // var flag = true;
- // for (var i = 0; i < agcount; i++) {
- // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
- // flag = false;
- // var state = Number(tlwsa.tlaGetagentstate(i));
- // console.log(state);
- switch (state) {
- case 0:
- $rootScope.jry_state = 'weiqianru';
- break;
- case 1:
- $rootScope.jry_state = 'shixian';
- break;
- case 2:
- $rootScope.jry_state = 'shimang';
- break;
- case 3:
- $rootScope.jry_state = 'laidian';
- break;
- case 5:
- $rootScope.jry_state = 'tonghuazhong';
- break;
- case 6:
- $rootScope.jry_state = 'zhengzaiwaihu';
- break;
- case 7:
- $rootScope.jry_state = 'zhengzaizhuanyi';
- break;
- }
- // }
- // console.log('agnet No. ' + i + ' workid is ' + tlwsa.tlaGetagentwid(i) + ' state is ' + tlwsa.tlaGetagentstate(i) + ' ' + getStateInfo(tlwsa.tlaGetagentstate(i)))
- // }
- // if (flag) {
- // $rootScope.jry_state = 'weiqianru';
- // }
- }
- // 状态回调函数
- // TLWSA.onStatechange = onstatechange;
- // function onstatechange() {
- // console.log('事件:状态变化----------------------------------------------------');
- // $scope.getState();
- // }
- //连接呼叫中心回调函数
- TLWSA.onOpenreturn = onopenreturn;
- function onopenreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('呼叫中心连接成功-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫中心连接成功'
- });
- //如果设置过话机
- if (localStorage.getItem('phoneNumber')) {
- //强制签出,然后签入
- tlwsa.tlaKillworkid(localStorage.getItem('phoneNumber'));
- }
- } else {
- console.log('呼叫中心连接失败-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫中心连接失败'
- });
- }
- }
- //绑定分机回调函数
- TLWSA.onSetphonenumberreturn = onsetphonenumberreturn;
- function onsetphonenumberreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('绑定分机成功-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '绑定分机成功'
- });
- localStorage.setItem('phoneNumber', $rootScope.phoneNumber);
- localStorage.setItem('fenjiNumber', $rootScope.jry_extnNumberObj.jry_extnNumber.name);
- $scope.qShimang(1);
- } else {
- console.log('绑定分机失败-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '绑定分机失败'
- });
- }
- }
- //强制示忙回调函数
- // TLWSA.onAcw = onacw;
- // function onacw(err) {
- // err = Number(err);
- // if (!err) {
- // console.log('强制示忙成功-----seimin');
- // $scope.getState(2);
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示忙成功'
- // });
- // } else {
- // console.log('强制示忙失败-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示忙失败'
- // });
- // }
- // }
- // //强制示闲回调函数
- // TLWSA.onWca = onwca;
- // function onwca(err) {
- // console.log(err)
- // err = Number(err);
- // if (!err) {
- // console.log('强制示闲成功-----seimin');
- // $scope.getState(1);
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示闲成功'
- // });
- // } else {
- // console.log('强制示闲失败-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示闲失败'
- // });
- // }
- // }
- //与服务器网络连接中断回调函数
- TLWSA.onClosed = onclosed;
- function onclosed() {
- $scope.getState(0);
- console.log('与服务器网络连接中断-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '与服务器网络连接中断,2分钟后重连'
- });
- console.log('2分钟后自动重连-----seimin')
- $timeout(function () {
- //连接
- tlwsa.tlaOpen(websocket_url);
- }, 120000)
- }
- //签入回调函数
- TLWSA.onLoginreturn = onloginreturn;
- function onloginreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('签入成功-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签入成功'
- });
- setTimeout(function () {
- console.log($rootScope.jry_extnNumberObj.jry_extnNumber.name,1111)
- var fenjiNumber = $rootScope.jry_extnNumberObj.jry_extnNumber.name || localStorage.getItem('fenjiNumber');
- console.log('开始绑定分机【' + fenjiNumber + '】-----seimin');
- tlwsa.tlaSetphonenumber(fenjiNumber);
- }, 0)
- } else if (err == 9011) {
- console.log('签入失败,该分机已登录-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签入失败,该分机已登录'
- });
- } else {
- console.log('签入失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签入失败'
- });
- }
- // tlwsa.tlaSubscribestateinfo(2);
- }
- // 强制签出回调函数
- TLWSA.onKillreturn = onkillreturn;
- function onkillreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('强制签出成功-----seimin');
- $scope.getState(0);
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '强制签出成功'
- // });
- } else {
- console.log('强制签出失败,该分机不是签入状态-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '强制签出失败'
- // });
- }
- //如果设置过话机
- if (localStorage.getItem('phoneNumber')) {
- // 签入并绑定分机
- $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
- tlwsa.tlaLogin($rootScope.phoneNumber, 1, -1);
- }
- }
- // 签出回调函数
- TLWSA.onLogoffreturn = onlogoffreturn;
- function onlogoffreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('签出成功-----seimin');
- $scope.getState(0);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签出成功'
- });
- localStorage.removeItem('phoneNumber');
- localStorage.removeItem('fenjiNumber');
- $rootScope.jry_extnNumberObj.jry_extnNumber = {};
- } else {
- console.log('签出失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '签出失败'
- });
- }
- }
- //示忙回调函数
- TLWSA.onAcwreturn = onacwreturn;
- function onacwreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('示忙成功-----seimin');
- if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
- $scope.isShixian = false;
- }else{
- $scope.isShixian = true;
- }
- $scope.getState(2);
- $rootScope.preState = 2;
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '示忙成功'
- });
- } else {
- console.log('示忙失败-----seimin');
- // $.toaster({
- // priority: 'info',
- // title: '操作',
- // message: '示忙失败'
- // });
- }
- }
- //示闲回调函数
- TLWSA.onWcareturn = onwcareturn;
- function onwcareturn(err) {
- err = Number(err);
- if (!err) {
- console.log('示闲成功-----seimin');
- $scope.getState(1);
- $rootScope.preState = 1;
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '示闲成功'
- });
- } else {
- console.log('示闲失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '示闲失败'
- });
- }
- }
- //呼叫坐席回调函数
- TLWSA.onCallreturn = oncallreturn;
- function oncallreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('呼叫成功,请摘机-----seimin');
- $scope.getState(6);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫成功,请摘机'
- });
- } else {
- console.log('呼叫失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫失败'
- });
- }
- }
- //呼叫坐席被接听回调函数
- TLWSA.onCallresult = oncallresult;
- function oncallresult(jso) {
- console.log(jso);
- var err = Number(jso.err);
- if (!err) {
- console.log('呼叫被接听成功-----seimin');
- $scope.getState(5);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫被接听成功'
- });
- } else {
- console.log('呼叫被接听失败-----seimin');
- $scope.qShimang(1);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫被接听失败'
- });
- }
- }
- //挂断回调函数
- TLWSA.onCallend = oncallend;
- function oncallend(jso) {
- console.log(jso);//lmm
- if (jso) {
- console.log('挂断成功-----seimin');
- console.log('最近一次话机状态',$rootScope.preState);
- $scope.qShimang($rootScope.preState);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '挂断成功'
- });
- } else {
- console.log('挂断失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '挂断失败'
- });
- }
- }
- //呼入回调函数
- TLWSA.onCallin = oncallin;
- function oncallin(jso) {
- console.log(jso);//lmm
- $rootScope.callInPhoneNumber = jso.caller;//来电的电话
- $rootScope.sockid = jso.crs;//来电的话机id
- if (jso) {
- console.log('呼入坐席成功,请摘机-----seimin');
- $scope.getState(3);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入坐席成功,请摘机'
- });
- console.log('来电了!电话号码是【' + $rootScope.callInPhoneNumber + '】');
- } else {
- console.log('呼入坐席失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入坐席失败'
- });
- }
- }
- // 测试代码start
- // seachBxDept();
- // 测试代码end
- // 查报修科室
- function seachBxDept(){
- var postData = { "idx": 0, "sum": 10, "department": { phone: $rootScope.callInPhoneNumber } };//hjzxPhone
- api_user_data.fetchDataList('department', postData).then(function (result) {
- if (result.status == 200) {
- console.log(result.list);
- var requesters = result.list;
- if (requesters.length === 0) {
- //未匹配到报修科室
- $rootScope.newOrder({
- incident: {
- sockid: $rootScope.sockid,
- incomingPhone: $rootScope.callInPhoneNumber,
- source: {id:1547,name:'电话'}
- },
- },'incomingCall')
- // $state.go('app.incident.chart', {
- // model: JSON.stringify({
- // model: {
- // incident: {
- // requester: {
- // phone: $rootScope.callInPhoneNumber,//hjzxPhone
- // },
- // sockid: $rootScope.sockid
- // }
- // }
- // })
- // });
- } else if (requesters.length === 1) {
- //匹配到一个报修科室
- $rootScope.newOrder({
- incident: {
- department: requesters[0],
- phone: requesters[0].phone,
- sockid: $rootScope.sockid,
- incomingPhone: $rootScope.callInPhoneNumber,
- source: {id:1547,name:'电话'}
- },
- },'incomingCall')
- // $state.go('app.incident.chart', {
- // model: JSON.stringify({
- // model: {
- // incident: {
- // requester: requesters[0],
- // contactsInformation: requesters[0].mphone,
- // sockid: $rootScope.sockid
- // },
- // }
- // })
- // });
- } else {
- //匹配到多个报修科室
- $modal.open({
- templateUrl: 'assets/views/incident/tpl/tel.html',
- controller: function ($scope, $modalInstance, $timeout, SweetAlert) {
- $scope.list = requesters;
- $scope.selected = {
- selectedItem: 0
- };
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- $scope.changeBxr = function (id) {
- $scope.selected.selectedItem = id;
- }
- $scope.save = function () {
- var item = $scope.list.find(v => v.id == $scope.selected.selectedItem);
- if (item) {
- $scope.cancel();
- $rootScope.newOrder({
- incident: {
- department: item,
- phone: item.phone,
- sockid: $rootScope.sockid,
- incomingPhone: $rootScope.callInPhoneNumber,
- source: {id:1547,name:'电话'}
- },
- },'incomingCall')
- // $state.go('app.incident.chart', {
- // model: JSON.stringify({
- // model: {
- // incident: {
- // requester: item,
- // contactsInformation: item.mphone,
- // sockid: $rootScope.sockid
- // },
- // }
- // })
- // });
- } else {
- SweetAlert.swal({
- title: "请选择报修科室!",
- type: "error"
- })
- }
- }
- }
- });
- }
- }
- })
- }
- //呼入摘机应答回调函数
- TLWSA.onAnswer = onanswer;
- function onanswer(err) {
- err = Number(err);
- if (!err) {
- console.log('呼入摘机应答成功-----seimin');
- $scope.getState(5);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入摘机应答成功'
- });
- //根据电话号码反查报修人,如果是坐席号码,则不用
- // console.log(sessionStorage.getItem('phones'));
- // var phones = JSON.parse(sessionStorage.getItem('phones'));
- // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
- // if(isHuajihao){
- // return;
- // }
- // 查报修科室
- seachBxDept();
- // var postData = { "idx": 0, "sum": 10, "requester": { hjzxPhone: $rootScope.callInPhoneNumber } };
- // api_user_data.fetchDataList('requester', postData).then(function (result) {
- // if (result.status == 200) {
- // console.log(result.list);
- // var requesters = result.list;
- // if (requesters.length === 0) {
- // //未匹配到报修人,则弹窗添加报修人yeye
- // $state.go('app.incident.chart', {
- // model: JSON.stringify({
- // model: {
- // incident: {
- // requester: {
- // hjzxPhone: $rootScope.callInPhoneNumber
- // },
- // sockid: $rootScope.sockid
- // }
- // }
- // })
- // });
- // } else if (requesters.length === 1) {
- // //匹配到一个报修人
- // $state.go('app.incident.chart', {
- // model: JSON.stringify({
- // model: {
- // incident: {
- // requester: requesters[0],
- // contactsInformation: requesters[0].mphone,
- // sockid: $rootScope.sockid
- // },
- // }
- // })
- // });
- // } else {
- // //匹配到多个报修人
- // $modal.open({
- // templateUrl: 'assets/views/incident/tpl/tel.html',
- // controller: function ($scope, $modalInstance, $timeout, SweetAlert) {
- // $scope.list = requesters;
- // $scope.selectedItem = 0;
- // $scope.cancel = function () {
- // $modalInstance.dismiss('cancel');
- // };
- // $scope.changeBxr = function (id) {
- // $scope.selectedItem = id;
- // }
- // $scope.save = function () {
- // var item = $scope.list.find(v => v.id == $scope.selectedItem);
- // if (item) {
- // $scope.cancel();
- // $state.go('app.incident.chart', {
- // model: JSON.stringify({
- // model: {
- // incident: {
- // requester: item,
- // contactsInformation: item.mphone,
- // sockid: $rootScope.sockid
- // },
- // }
- // })
- // });
- // } else {
- // SweetAlert.swal({
- // title: "请选择报修人!",
- // type: "error"
- // })
- // }
- // }
- // }
- // });
- // }
- // }
- // })
- } else {
- console.log('呼入摘机应答失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入摘机应答失败'
- });
- }
- }
- //呼入未摘机应答回调函数
- TLWSA.onMisscall = onmisscall;
- function onmisscall(err) {
- err = Number(err);
- if (!err) {
- console.log('呼入未摘机应答成功-----seimin');
- $scope.getState(1);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入未摘机应答成功'
- });
- } else {
- console.log('呼入未摘机应答失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼入未摘机应答失败'
- });
- }
- }
- //转接开始回调函数
- TLWSA.onTransferreturn = ontransferreturn;//调用转移方法之后,返回该事件 如果错误码为0,仅仅表示开始转移,不代表转移目标已经接听或已经拒绝
- function ontransferreturn(err) {
- err = Number(err);
- if (!err) {
- console.log('转接坐席开始成功-----seimin');
- $scope.getState(7);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席开始成功'
- });
- } else {
- console.log('转接坐席开始失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席开始失败'
- });
- }
- }
- //转接结果回调函数
- TLWSA.onTransferresult = ontransferresult;
- function ontransferresult(err) {
- err = Number(err);
- if (!err) {
- console.log('转接坐席结果成功-----seimin');
- $scope.getState(1);
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席结果成功'
- });
- } else {
- console.log('转接坐席结果失败-----seimin');
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '转接坐席结果失败'
- });
- }
- }
- // 签入
- $rootScope.jry_qianru = function () {
- console.log($rootScope.jry_extnNumberObj.jry_extnNumber)
- if(Object.keys($rootScope.jry_extnNumberObj.jry_extnNumber).length === 0){
- $.toaster({
- priority: 'info',
- title: '警告',
- message: '绑定分机不能为空'
- });
- return;
- }
- // 签入并绑定分机
- // $rootScope.jry_extnNumberObj.jry_extnNumber.name 分机号
- // $rootScope.user.id 坐席号(用户id)
- tlwsa.tlaLogin($rootScope.user.id, 1, -1);
- $rootScope.phoneNumber = $rootScope.user.id;
- }
- // 示闲
- $rootScope.jry_shixian = function () {
- tlwsa.tlaWca();
- }
- // 示忙
- $rootScope.jry_shimang = function () {
- tlwsa.tlaAcw();
- }
- // 签出
- $rootScope.jry_qianchu = function () {
- tlwsa.tlaLogoff();
- }
- // 呼叫坐席
- // $scope.tlaCallagc = function () {
- // tlwsa.tlaCallagc($rootScope.jry_extnNumberObj.tel1)
- // }
- // 呼叫外线
- $scope.tlaCallout = function () {
- // 选择目的号码
- var reg1 = /^[0][1-9]{2,3}-[0-9]{5,10}$/;
- var reg2 = /^(0|9|90|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
- if(!reg1.test($rootScope.jry_extnNumberObj.tel1)&&!reg2.test($rootScope.jry_extnNumberObj.tel1)){
- $.toaster({
- priority: 'info',
- title: '警告',
- message: '请输入正确的手机号或座机号'
- });
- return;
- }
- // tlwsa.tlaCallout($rootScope.jry_extnNumberObj.tel1,$rootScope.jry_extnNumberObj.jry_extnNumber.name,0)
- tlwsa.tlaCallout($rootScope.jry_extnNumberObj.tel1, '3558177',1);//襄阳主叫号码写死
- }
- // // 转移坐席
- // $scope.tlaTransfertoagc = function () {
- // tlwsa.tlaTransfertoagc($rootScope.jry_extnNumberObj.tel2)
- // }
- // 转移外线
- $scope.tlaTransferout = function () {
- // 选择转接号码
- var reg1 = /^[0][1-9]{2,3}-[0-9]{5,10}$/;
- var reg2 = /^(0|9|90|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
- if(!reg1.test($rootScope.jry_extnNumberObj.tel2)&&!reg2.test($rootScope.jry_extnNumberObj.tel2)){
- $.toaster({
- priority: 'info',
- title: '警告',
- message: '请输入正确的手机号或座机号'
- });
- return;
- }
- // tlwsa.tlaTransferout($rootScope.jry_extnNumberObj.tel2,$rootScope.jry_extnNumberObj.jry_extnNumber.name,0)
- tlwsa.tlaTransferout($rootScope.jry_extnNumberObj.tel2, '3558177',1);//襄阳主叫号码写死
- }
- })
- }
- // ------------------------------3--------------------------
- $rootScope.getExtnDirect3 = function(){
- console.log($rootScope.user)
- var user = $rootScope.user;
- initImUser(user.email, user.msgUuid);
- // $rootScope.start(JSON.parse(localStorage.userdata).commonExtension.name);
- api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function(data) {
- $scope.runNumber = data;
- $scope.phone = $scope.runNumber[0].name;
- $rootScope.phoneChange($scope.phone);
- })
- if ($rootScope.userMenus.length == 0) {
- getMenus();
- }
- if(localStorage.getItem('hk_phone')){
- $rootScope.start(localStorage.getItem('hk_phone'));
- }
- }
- // ------------------------------4盒子--------------------------start
- $rootScope.phoneNumListBind = []; //已绑定分机列表
- $rootScope.phoneNumListSelected = []; //选中的分机列表
- $rootScope.phoneNumList = []; //所有分机列表
- $rootScope.newOrderShow = false; //展示/隐藏新建工单弹框
- $rootScope.newOrderShowOpen = false; //展示/隐藏新建工单弹框(辅助项)
- $rootScope.applyDept; //申请科室
- $rootScope.applyDeptMiddle; //申请科室(中间传递)
- $rootScope.getExtnDirect4 = function () {
- console.log(WebsocketPhoneService);
- $rootScope.getPhoneNum();
- }
- $rootScope.getPhoneNum = function(flag = true) {
- if (!flag) {
- //切换院区的时候清除掉缓存中的号码
- localStorage.removeItem("box_phones");
- }
- $rootScope.phoneNumListBind = localStorage.getItem("box_phones")
- ? localStorage.getItem("box_phones").split("_")
- : [];
- $rootScope.phoneNumListSelected = localStorage.getItem("box_phones")
- ? localStorage.getItem("box_phones").split("_")
- : [];
- if ($rootScope.phoneNumListBind.length) {
- $rootScope.getWebsocketPhone();
- }
- }
- // 查报修科室
- function seachBoxBxDept(callInPhoneNumber, callID){
- var postData = { "idx": 0, "sum": 10, "department": { phone: callInPhoneNumber } };//hjzxPhone
- api_user_data.fetchDataList('department', postData).then(function (result) {
- if (result.status == 200) {
- console.log(result.list);
- var requesters = result.list;
- if (requesters.length === 0) {
- //未匹配到报修科室
- $rootScope.newOrder({
- incident: {
- sockid: callID,
- incomingPhone: callInPhoneNumber,
- source: {id:1547,name:'电话'}
- },
- },'incomingCall')
- } else if (requesters.length === 1) {
- //匹配到一个报修科室
- $rootScope.newOrder({
- incident: {
- department: requesters[0],
- phone: requesters[0].phone,
- sockid: callID,
- incomingPhone: callInPhoneNumber,
- source: {id:1547,name:'电话'}
- },
- },'incomingCall')
- } else {
- //匹配到多个报修科室
- $modal.open({
- templateUrl: 'assets/views/incident/tpl/tel.html',
- controller: function ($scope, $modalInstance, $timeout, SweetAlert) {
- $scope.list = requesters;
- $scope.selected = {
- selectedItem: 0
- };
- $scope.cancel = function () {
- $rootScope.newOrderShowOpen = false;
- $modalInstance.dismiss('cancel');
- };
- $scope.changeBxr = function (id) {
- $scope.selected.selectedItem = id;
- }
- $scope.save = function () {
- var item = $scope.list.find(v => v.id == $scope.selected.selectedItem);
- if (item) {
- $scope.cancel();
- $rootScope.newOrder({
- incident: {
- department: item,
- phone: item.phone,
- sockid: callID,
- incomingPhone: callInPhoneNumber,
- source: {id:1547,name:'电话'}
- },
- },'incomingCall')
- } else {
- SweetAlert.swal({
- title: "请选择报修科室!",
- type: "error"
- })
- }
- }
- }
- });
- }
- }
- })
- }
- // 连接websocket---phone
- // 待完成
- $rootScope.getWebsocketPhone = function() {
- $rootScope.isMask = true;
- // {"userCount":"LiaoMingMing|3369_3366"}
- let userCount = $rootScope.user.account + "|" + $rootScope.phoneNumListSelected.join("_");
- WebsocketPhoneService.connectWs($rootScope.seiminCallBoxIp, { userCount }).subscribe((data) => {
- // data = { status: 201, phone: '013581394341' };//ceshi
- var callID = data.callId;
- console.log(data);
- $rootScope.isMask = false;
- if (data.status == 200 && data.phone) {
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '连接成功'
- });
- localStorage.setItem("box_phones", data.phone);
- $rootScope.phoneNumListBind = data.phone.split("_");
- $rootScope.phoneNumListBind.forEach((item) => {
- let obj = $rootScope.phoneNumList.find((item1) => item1.value === item);
- if (obj) {
- obj.checked = true;
- }
- });
- } else if (data.status == 201 && data.phone) {
- if (!$rootScope.newOrderShow && !$rootScope.newOrderShowOpen) {
- seachBoxBxDept(data.phone, callID);
- }
- } else if (data.status == 201 && data.phone === "") {
- //没绑定科室
- if (!$rootScope.newOrderShow && !$rootScope.newOrderShowOpen) {
- $rootScope.newOrder({
- incident: {
- sockid: callID,
- incomingPhone: data.phone,
- source: {id:1547,name:'电话'}
- },
- },'incomingCall')
- }
- }
- });
- }
- // 选择分机
- $rootScope.changePhones = function(value) {
- $rootScope.phoneNumListSelected = $rootScope.phoneNumList.filter(v => v.checked).map(v => v.value);
- $rootScope.phoneNumListSelectedStr = $rootScope.phoneNumListSelected.length ? '您选择了'+ $rootScope.phoneNumListSelected.map(v => '‘'+ v +'’').join('') +'号码,可在下方选择后确认更新。' : '请选择分机';
- console.log($rootScope.phoneNumListSelected);
- }
- //获取所有分机号码列表
- $rootScope.getPhoneNumList = function() {
- this.phoneNumLoading = true;
- let postData = {
- idx: 0,
- sum: 100,
- hospitalConfig: { hosId: this.checkedHos },
- };
- this.mainService
- .getFetchDataList("simple/data", "hospitalConfig", postData)
- .subscribe((result) => {
- this.phoneNumLoading = false;
- this.phoneNumList = result.list.filter(
- (item) => item.key.includes("phone_num_port") && item.value
- );
- this.phoneNumList.map((item) => {
- return { ...item, checked: false };
- });
- this.phoneNumListBind.forEach((item) => {
- let obj = this.phoneNumList.find((item1) => item1.value === item);
- if (obj) {
- obj.checked = true;
- }
- });
- });
- }
- //确定绑定
- $rootScope.bindingOk = function() {
- if ($rootScope.phoneNumListSelected.length > 0) {
- WebsocketPhoneService.closeWs(true);
- $rootScope.getWebsocketPhone();
- } else {
- localStorage.removeItem("box_phones");
- $rootScope.phoneNumListBind = [];
- $rootScope.phoneNumList.forEach((item) => {
- item.checked = false;
- });
- WebsocketPhoneService.closeWs(true);
- }
- }
- // ------------------------------4盒子--------------------------end
- $rootScope.jry_state = 'weiqianru';
- window.addEventListener('load', function () {
- $rootScope.judgeHjzx(false, true);
- })
- //话机呼叫中心--结束
- // 未接来电
- $scope.jry_getUnanswered = function () {
- var jry_data = {
- idx: 0,
- sum: 999,
- "callRecord": {
- "todayTime": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 00:00:00",
- "todayTimeEnd": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 23:59:59",
- }
- }
- api_bpm_data.fetchDataList("callRecord", jry_data).then(function (data) {
- // fo0h
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].createdTime = new Date(data.list[i].createdTime).getFullYear() + "-" + (new Date(data.list[i].createdTime).getMonth() + 1) + "-" + new Date(data.list[i].createdTime).getDate() + " " + new Date(data.list[i].createdTime).getHours() + ":" + new Date(data.list[i].createdTime).getMinutes() + ":" + new Date(data.list[i].createdTime).getSeconds()
- }
- $rootScope.jry_unansweredData = data.list;
- });
- }
- // $scope.jry_getUnanswered();
- // 来电号码回拨
- $scope.jry_callBack = function (data) {
- var callBackData = {
- "callRecord": {
- "id": data.id,
- "isAnswered": "1"
- }
- };
- api_bpm_data.updData("callRecord", callBackData).then(function (res) {
- if (res) {
- $scope.jry_getUnanswered();
- dial(data.callerIdNumber)
- }
- });
- if (data.department.id && data.requester) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'requester': data.requester, 'contacts': data.requester.name, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else if (data.department.id) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- };
- // ws.send("{\"type\":\"1\",\"phone\":\""+data.phone+"\"}");
- }
- //来电号码生成事件
- $scope.jry_callToIncident = function (data) {
- if (data.department.id && data.requester) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'requester': data.requester, 'contacts': data.requester.name, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else if (data.department.id) {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- } else {
- var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
- $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
- }
- }
- $scope.onChangeadd = function (searchData) {
- $scope.searchKey = searchData.account;
- // $scope.searchDataadd = searchData;
- var requesdata = angular.copy(searchData)
- $scope.requester = requesdata;
- }
- $scope.refreshUseradd = function (searchKey) { //主题搜索
- $scope.searchData = searchKey;
- reashdata($scope.searchData);
- }
- $scope.getMydata = function (x) {
- $scope.telephone = JSON.parse(x).phone;
- $scope.searchField = $scope.telephone;
- return $scope.searchField;
- }
- $scope.getMydataone = function (x) {
- $scope.telephone = x;
- $scope.searchField = $scope.telephone;
- }
- $scope.fildata = {
- "idx": 0,
- "sum": 10,
- "flag": -1
- }
- function reashdata(item) {
- if (item && item != "") {
- angular.extend($scope.fildata, { 'user': { 'flag': -1, 'phone': item } })
- } else {
- delete $scope.fildata.user;
- }
- api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function (data) {
- if (data.status == 200) {
- $scope.myData = data.list;
- }
- })
- // api_user_data.fetchDataList('user', $scope.fildata).then(function(response) {
- // if (response) {
- // if (response.status = 200) {
- // var myData = response;
- // $scope.myData = myData.list;
- // }
- // }
- // })
- }
- if (window.location && window.location.hash == "#/echart") {
- } else {
- $rootScope.user && reashdata();
- }
- $rootScope.end = function () {
- api_text.logout($rootScope.takes, $rootScope.user.id).then(function (data) {
- if (data.errno == 0) {
- localStorage.removeItem('hk_phone');
- api_text.exit($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 0;
- $scope.login = false;
- // SweetAlert.swal({
- // title: "登出成功",
- // text: "呼叫中心登出成功!",
- // type: "success"
- // });
- // }else{SweetAlert.swal({
- // title: "登出失败",
- // text: "呼叫中心登出失败!",
- // type: "error"
- // });
- }
- })
- }
- })
- }
- $rootScope.dialout = function (gid, teleno) {
- var telephone = "";
- if (teleno && teleno.length > 4) {
- telephone = '9' + teleno;
- } else {
- // telephone = '*01' + teleno + '*';
- telephone = teleno;
- }
- api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
- if (data.errno == 0) {
- // $rootScope.statuscall = 3;
- $rootScope.callout = true;
- // $rootScope.phone=teleno;
- }
- })
- }
- // $scope.busy=false;
- $rootScope.setbusy = function () {
- api_text.setbusy($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statecall = 2;
- $scope.busy = true;
- }
- })
- }
- $rootScope.setidle = function () {
- api_text.setidle($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statecall = 1;
- $scope.busy = false;
- }
- })
- }
- $rootScope.inittrans = function (telephone) {
- api_text.inittrans(telephone, $rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- // $scope.status=9
- }
- })
- }
- $rootScope.comptrans = function () {
- api_text.comptrans($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 1;
- }
- })
- }
- $rootScope.takeup = function () {
- api_text.offhook($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 3;
- }
- })
- }
- $rootScope.takedown = function () {
- api_text.onhook($rootScope.takes).then(function (data) {
- if (data.errno == 0) {
- $rootScope.statuscall = 1;
- }
- })
- }
- $rootScope.saveData = function (selectdata) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/system/tpl/createknowledge.html',
- controller: function ($scope, $modalInstance, api_bpm_data) {
- $scope.worktimedata = {};
- $scope.worktimedata = selectdata;
- $scope.cancel = function () {
- $modalInstance.dismiss('cancel');
- };
- $scope.savercode = function (worktimedata) {
- var fildata = {
- "scheduleclass": {
- "id": selectdata.id,
- "code": worktimedata.code,
- "name": worktimedata.title,
- "person": worktimedata.person,
- "description": worktimedata.description,
- "startTime": worktimedata.startTime,
- "endTime": worktimedata.endTime,
- "shiftTime": selectdata.shiftTime,
- "succeedTime": selectdata.succeedTime,
- "isTemplate": worktimedata.isTemplate
- }
- }
- api_bpm_data.updData('scheduleclass', fildata).then(function (response) {
- if (response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "修改成功!",
- type: "success"
- }, function () {
- // $scope.refreshData('expand-right', defaultFilterData);
- })
- } else {
- SweetAlert.swal({
- title: "修改失败!",
- type: "error"
- })
- }
- }
- })
- $modalInstance.close();
- }
- }
- });
- }
- $rootScope.changepassword = function (data1, size) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/changepassword.html',
- controller: function ($scope, $modalInstance, items, Restangular, SweetAlert) {
- $scope.passwordnull = function (originalPwd, pwd, pwd_2) {
- return originalPwd == undefined || pwd == undefined || pwd_2 == undefined || originalPwd == "" || pwd == "" || pwd_2 == "" || originalPwd == "null" || pwd == "null" || pwd_2 == "null";
- }
- $scope.savepassword = function (originalPwd, pwd, pwd_2) {
- $modalInstance.dismiss('cancel');
- // console.log('pwd=' + pwd + '+' + pwd_2);
- // if(angular.isDefined(pwd)&&angular.isDefined(pwd_2)){
- if (pwd == pwd_2) {
- var data2 = {};
- data2["originalPwd"] = originalPwd;
- data2["userid"] = $rootScope.user.id;
- data2["pwd"] = pwd;
- api_login.uppwd(data2).then(function (response) {
- var myData = Restangular.stripRestangular(response);
- if (myData.status == 200) {
- SweetAlert.swal({
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- });
- } else {
- SweetAlert.swal({
- title: "保存失败!",
- text: "输入旧密码错误,请重新输入!",
- type: "error"
- });
- }
- })
- } else {
- SweetAlert.swal({
- title: "两次输入的新密码不相同!",
- text: "输入错误,请重新输入!",
- type: "error"
- });
- }
- // }else{
- // SweetAlert.swal({
- // title: "密码不能为空!",
- // text: "请输入密码!",
- // type: "error"
- // });
- // }
- }
- },
- size: size,
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) { }
- };
- },
- }
- });
- }
- // 修改院区科室
- $rootScope.intervalTime = sessionStorage.getItem('intervalTime')?JSON.parse(sessionStorage.getItem('intervalTime')):{
- flag: false,
- rotationInterval: 10,
- rotationIntervals: [3, 5, 10, 15, 20, 25, 30, 35, 40, 45],
- logTimeConst: 60,
- logTimeConsts: [30, 60, 90, 120, 150, 180, 210, 240, 270, 300],
- }
- $rootScope.changeHospitalDept = function (flag = false) {
- $rootScope.intervalTime.flag = flag;
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/changeHospitalDept.html',
- controller: function ($scope, $modalInstance, items, Restangular, SweetAlert) {
- console.log($rootScope.user.duty)
- $scope.f = {
- uuid:''
- };
- $scope.dataList = {};
- // $scope.dataList = [];
- // $scope.hospitalAndDutyDept = {};
- // $scope.dutyDeptList = [];
- // $scope.branchObj = {};
- // $scope.f = {
- // hospitalDepartment:$rootScope.user.duty?$rootScope.user.duty:''
- // };
- // // 获取所属的院区科室
- // var dutyDepts = [];//责任科室
- // var branchs = [];//院区
- // $rootScope.user.role.forEach(v=>{
- // dutyDepts = dutyDepts.concat(v.dutyDepts);
- // branchs = branchs.concat(v.branchs);
- // })
- // // 责任科室除重
- // var obj = {};
- // dutyDepts = dutyDepts.reduce(function(item, next) {
- // obj[next.id] ? '' : obj[next.id] = true && item.push(next);
- // return item;
- // }, []);
- // $scope.dutyDeptList = dutyDepts;
- // // 院区除重
- // var obj1 = {};
- // branchs = branchs.reduce(function(item, next) {
- // obj1[next.id] ? '' : obj1[next.id] = true && item.push(next);
- // return item;
- // }, []);
- // // $scope.branchs = branchs;
- // // 院区数据处理
- // $scope.branchObj = angular.copy(branchs).find(v=>v.children.length>0);
- // $scope.branchObj.children.sort((a,b)=>a.id-b.id);
- // // 处理责任科室数据
- // $scope.hospitalAndDutyDept = {};
- // $scope.dutyDeptList.forEach(v=>{
- // if($scope.hospitalAndDutyDept[v.branch]){
- // $scope.hospitalAndDutyDept[v.branch].push(v);
- // }else{
- // $scope.hospitalAndDutyDept[v.branch] = [v];
- // }
- // })
- // console.log(dutyDepts,branchs)
- // ----------------------------------------------
- // api_category.branchDutyList({ "userId": $rootScope.user.id }).then(function(response) {
- // if(response.status == 200){
- // $scope.dataList = response.data;
- // $scope.branchObj = response.data.find(v=>!v.parent);
- // $scope.otherBranchs = response.data.filter(v=>v.parent);
- // if($rootScope.user.duty){
- // $scope.f.uuid = $rootScope.user.duty.uuid;
- // }else if($rootScope.user.branch){
- // $scope.f.uuid = $rootScope.user.branch.uuid;
- // }
- // }else{
- // SweetAlert.swal({
- // title: "系统错误!",
- // text: "请刷新重试!",
- // type: "error"
- // });
- // }
- // })
- // ------------------------------------------------------------------------------
- $scope.hospitalAndDutyDept = {};
- $scope.dutyDeptList = [];
- $scope.branchObj = {};
- api_category.branchDutyList({ "userId": $rootScope.user.id }).then(function(response1) {
- if(response1.status == 200){
- $scope.dataList = angular.copy(response1.data);
- if(!$scope.dataList.branchs){
- $scope.dataList.branchs = [];
- }
- if(!$scope.dataList.dutys){
- $scope.dataList.dutys = [];
- }
- var roleObj = response1.data;
- api_user_data.fetchDataList('branch', { "idx": 0, "sum": 1000 }).then(function(res) {
- if (res.status == 200) {
- api_user_data.fetchDataList('dutyDepartment', { "idx": 0, "sum": 1000 }).then(function(response) {
- if (response.status == 200) {
- // 院区数据处理
- $scope.branchObj = angular.copy(res.list).find(v=>v.children.length>0);
- $scope.branchObj.children.sort((a,b)=>a.id-b.id);
- // 清空
- response.list.forEach(v=>{
- v.flag = false
- });
- $scope.dutyDeptList = response.list;
- $scope.branchObj.flag = false;
- $scope.branchObj.children.forEach(v=>{
- v.flag = false;
- })
- // 回显数据接口数据
- if(roleObj){
- roleObj.dutys.forEach(v=>{
- $scope.dutyDeptList.forEach(vv=>{
- if(v.id == vv.id){
- vv.flag = true;
- }
- })
- })
- roleObj.branchs.forEach(v=>{
- if(v.id == $scope.branchObj.id){
- $scope.branchObj.flag = true;
- }
- $scope.branchObj.children.forEach(vv=>{
- if(v.id == vv.id){
- vv.flag = true;
- }
- })
- })
- }
- // 回显当前所属院区或责任科室
- if($rootScope.user.duty){
- $scope.f.uuid = $rootScope.user.duty.uuid;
- }else if($rootScope.user.branch){
- $scope.f.uuid = $rootScope.user.branch.uuid;
- }
- // 处理责任科室数据
- $scope.hospitalAndDutyDept = {};
- $scope.dutyDeptList.forEach(v=>{
- if($scope.hospitalAndDutyDept[v.branch]){
- $scope.hospitalAndDutyDept[v.branch].push(v);
- }else{
- $scope.hospitalAndDutyDept[v.branch] = [v];
- }
- })
- console.log($scope.branchObj,$scope.hospitalAndDutyDept)
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- }else{
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- })
- // -----------------------------------
- $scope.saveDept = function () {
- if(! $scope.f.uuid){
- SweetAlert.swal({
- title: "保存失败!",
- text: "请选择院区科室!",
- type: "error"
- });
- return;
- }
- $modalInstance.dismiss('cancel');
- var data2 = {};
- var branchObj = $scope.dataList.branchs.find(v=>v.uuid == $scope.f.uuid);//查找院区的uuid
- if(branchObj){
- data2.branchId = branchObj.id;
- }else{
- var dutyObj = $scope.dataList.dutys.find(v=>v.uuid == $scope.f.uuid);//查询责任科室的uuid
- if(dutyObj){
- data2.dutyId = dutyObj.id;
- }
- }
- // 当前所属院区或责任科室
- if($rootScope.user.duty){
- if(data2.dutyId && data2.dutyId == $rootScope.user.duty.id){
- sessionStorage.setItem('intervalTime', JSON.stringify($rootScope.intervalTime))
- return;
- }
- }else if($rootScope.user.branch){
- if(data2.branchId && data2.branchId == $rootScope.user.branch.id){
- sessionStorage.setItem('intervalTime', JSON.stringify($rootScope.intervalTime))
- return;
- }
- }
- $rootScope.isMask = true;
- api_login.changeBranch(data2).then(function (response) {
- $rootScope.isMask = false;
- var myData = Restangular.stripRestangular(response);
- if (myData.status == 200) {
- var jry_user = JSON.parse(localStorage.getItem('jry_user'));
- myData.user.user.menu = jry_user.menu;
- // jry_user.user = myData.user;
- // console.log(jry_user,myData.user)
- localStorage.setItem('jry_user',JSON.stringify(myData.user.user));
- sessionStorage.setItem('intervalTime', JSON.stringify($rootScope.intervalTime));
- localStorage.removeItem('phones');
- localStorage.removeItem('box_phones');
- SweetAlert.swal({
- title: "切换成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- },function(){
- location.reload(true);
- });
- } else {
- SweetAlert.swal({
- title: "切换失败!",
- type: "error"
- });
- }
- }).catch(function(err){
- $rootScope.isMask = false;
- SweetAlert.swal({
- title: "切换失败!",
- type: "error"
- });
- })
- }
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- resolve: {
- items: function () {
- return {
- fetchItems: function (filterData, APIService) { }
- };
- },
- }
- });
- }
- // $rootScope.getnochildpending = function() {
- // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
- // angular.forEach($rootScope.userMenus, function(item) {
- // item.tipnum = 1;
- // })
- // }
- // }
- // $rootScope.getchildpending = function(cantdata) {
- // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
- // angular.forEach($rootScope.userMenus, function(item) {
- // item.tipnum = 1;
- // angular.forEach(item, function(index) {
- // index.tipnum = 18;
- // })
- // })
- // }
- // }
- $rootScope.getpending = function () {
- if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
- if ($rootScope.user.group) {
- var groupArr = [];
- for (var i = 0; i < $rootScope.user.group.length; i++) {
- groupArr.push($rootScope.user.group[i].id)
- }
- api_bpm_data.getCount({ "assignee": $rootScope.user.id, "candidateGroups": groupArr.join(), "idx": 0, "sum": 1000 }).then(function (response) {
- angular.forEach($rootScope.userMenus, function (item, i) {
- item.tipshow = false;
- if (response) {
- if (response.hjzxCount > 0 || response.wechatWarningCount > 0) {
- if (item.id == 58) {
- item.tipshow = true;
- }
- }
- if (response.inspectionCount > 0) {
- if (item.id == 27) {
- item.tipshow = true;
- }
- }
- if (response.incidentCount > 0) {
- if (item.id == 2) {
- item.tipshow = true;
- }
- }
- if (response.releaseCount > 0) {
- if (item.id == 1215) {
- item.tipshow = true;
- }
- }
- if (response.solutionCount > 0) {
- if (item.id == 21) {
- item.tipshow = true;
- }
- }
- if (response.changeCount > 0) {
- if (item.id == 1212) {
- item.tipshow = true;
- }
- }
- if (response.problemCount > 0) {
- if (item.id == 1209) {
- item.tipshow = true;
- }
- }
- if (response.applicationForm > 0) {
- if (item.id == 1221) {
- item.tipshow = true;
- }
- }
- if ((parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
- if (item.id == 21) {
- item.tipshow = true;
- }
- }
- if (item.children) {
- angular.forEach(item.children, function (index) {
- if (response.hjzxCount !== null && response.hjzxCount !== undefined) {
- if (index.id == 1208) {
- if (response.hjzxCount < 100) {
- index.tipnum = response.hjzxCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.wechatWarningCount !== null && response.wechatWarningCount !== undefined) {
- if (index.id == 59) {
- if (response.wechatWarningCount < 100) {
- index.tipnum = response.wechatWarningCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.problemCount !== null && response.problemCount !== undefined) {
- if (index.id == 1210) {
- if (response.problemCount < 100) {
- index.tipnum = response.problemCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.releaseCount !== null && response.releaseCount !== undefined) {
- if (index.id == 1216) {
- if (response.releaseCount < 100) {
- index.tipnum = response.releaseCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.inspectionCount !== null && response.inspectionCount !== undefined) {
- if (index.id == 147) {
- if (response.inspectionCount < 100) {
- index.tipnum = response.inspectionCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.solutionCount !== null && response.solutionCount !== undefined) {
- if (index.id == 23) {
- if (response.solutionCount < 100) {
- index.tipnum = response.solutionCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.changeCount !== null && response.changeCount !== undefined) {
- if (index.id == 1213) {
- if (response.changeCount < 100) {
- index.tipnum = response.changeCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.incidentCount !== null && response.incidentCount !== undefined) {
- if (index.id == 3) {
- if (response.incidentCount < 100) {
- index.tipnum = response.incidentCount;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.applicationForm !== null && response.applicationForm !== undefined) {
- if (index.id == 1231) {
- if (response.applicationForm < 100) {
- index.tipnum = response.applicationForm;
- } else {
- index.tipnum = "99+";
- }
- }
- }
- if (response.toAuditCount && response.toReleaseCount && (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
- if (index.id == 23) {
- if (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount) < 100) {
- index.tipnum = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
- } else {
- index.tipnum = "99+";
- }
- }
- }
- })
- }
- }
- })
- // return $rootScope.userMenus;
- // $scope.recordpending = response.;
- // $scope.dashboardcount.knowledgedata = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
- })
- } else {
- // SweetAlert.swal("访问数据失败!", "该用户没有分配组", "error");
- }
- }
- // console.log($rootScope.userMenus);
- }
- $rootScope.userMenus = [];
- var getMenus = function () {
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- var parentNode = null;
- //loop over data
- for (var i = 0; i < data.length; i++) {
- // data[i].id = Number(data[i].id);
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- if (typeof datum.parentid === "undefined" || datum.parentid == null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parentid];
- //We don't need this property, so let's delete it.
- //delete datum.parentid;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function (item) {
- list.push(item);
- });
- list = window._.sortBy(list, function (o) {
- return o.orders;
- });
- return list;
- }
- //if(userMenus.length==0){
- var userMenus = [];
- var idMapMenu = {};
- if ($rootScope.user) {
- if ($rootScope.user.menu) {
- var allJurisdiction2 = $rootScope.user.menu;
- var onlyMenu2 = [];
- for (var i = 0; i < allJurisdiction2.length; i++) {
- if (allJurisdiction2[i].event == "1") {
- onlyMenu2.push(allJurisdiction2[i])
- }
- }
- // userMenus = convertParentToChildList($rootScope.user.menu);
- userMenus = convertParentToChildList(onlyMenu2);
- }
- }
- //}
- $rootScope.userMenus = userMenus;
- if ($rootScope.userMenus.length > 0) {
- $rootScope.getpending();
- // setInterval($rootScope.getpending(), 30000);
- }
- return userMenus;
- }
- setInterval(function () {
- if ($rootScope.userMenus.length > 0) {
- $rootScope.getpending()
- $rootScope.getMsgNum($rootScope.user.id)
- }
- }, 10000);
- getMenus();
- // console.log("$rootScope.nickname="+JSON.stringify($rootScope));
- $rootScope.logout = function () {
- // var userid =data.id;
- // console.log(' userid='+JSON.stringify( userid));
- //单点登录
- if (localStorage.getItem('isSSo') === '1') {
- sessionStorage.clear();
- localStorage.clear();
- location.href = 'http://' + location.hostname + ':8080/pc_logout.jsp'
- } else {
- $auth.signOut()
- .then(function (resp) {
- // $auth.deleteData('auth_headers')
- sessionStorage.clear();
- localStorage.clear();
- console.log($rootScope.isHk,'hk');
- console.log($rootScope.isZncd,'zncd');
- console.log($rootScope.isXy,'xy');
- console.log($rootScope.isXyBox,'isXyBox');
- if($rootScope.isZncd || $rootScope.isXy){
- if ($rootScope.isFuwutai) {
- tlwsa.tlaClose();
- $.toaster({
- priority: 'info',
- title: '操作',
- message: '呼叫中心断开连接'
- });
- }
- }else if($rootScope.isXyBox){
- if ($rootScope.isFuwutai) {
- WebsocketPhoneService.closeWs(true);
- }
- }
- $state.go("login.signin");
- })
- .catch(function (resp) { });
- }
- //$cookieStore.remove("userObm");
- //$cookieStore.remove("menuObm");
- //$cookieStore.remove("session");
- //$rootScope.user = undefined;
- //$rootScope.menus = undefined;
- //$rootScope.nickname = undefined;
- //window.location = "http://www.itsm.com:8080/itsm/dev/logout.jsp";
- // //logout: function(noServerLogout){
- // window.sessionStorage.clear();
- // window.location = "https://www.yunwei.com:8443/cas/loginout";
- // //},
- }
- // 首页统计跳转
- $scope.goTo = function(url,data){
- $state.go(url,data);
- }
- //获取首页建单统计信息
- $rootScope.getOrderCount = function(){
- // api_bpm_data.getManagerIndexInfo({}).then(function(result) {
- // $scope.managerIndexInfo = result.data;
- // });
- var postData = {}
- // 根据权限查询
- if($rootScope.user.duty){
- // 当前的所属责任科室
- postData.dutyId = $rootScope.user.duty.id;
- }else if($rootScope.user.branch){
- // 当前的所属院区
- postData.branchId = $rootScope.user.branch.id;
- }
- api_newreport.fetchDataListIndex('dutyOrderCount', postData).then(function(data) {
- if (data.status == 200) {
- $scope.managerIndexInfo = {
- createOrders: data.today,
- waitOrders: data.receiving,
- doingOrders: data.doing,
- doneOrders: data.complete,
- }
- }
- })
- }
- // $rootScope.getOrderCount();
- // 快速建单
- $rootScope.newOrder = function (model1, type = '') {
- $rootScope.newOrderShowOpen = true;
- //进入弹窗,强制示忙
- if (localStorage.getItem('fenjiNumber')) {
- setTimeout(()=>{
- tlwsa.tlaAcw();
- },0)
- }
- $modal.open({
- backdrop: false,
- templateUrl:
- "assets/views/newOrderSeimin.html",
- controller: function (
- $scope,
- $parse,
- fileReader,
- FileUploader,
- $modalInstance,
- SweetAlert,
- api_user_data,
- api_bpm_domain,
- up_down_file,
- $rootScope,
- modelData
- ) {
- // -------------------start----------------------
- $scope.modelData = modelData;
- // 当前所属院区处理
- console.log(modelData);
- // if(modelData){
- // var curentHospital = undefined;
- // api_bpm_data.fetchData('department', modelData.incident.department.id).then(res=>{
- // if(res.status == 200){
- // console.log(res.data);
- // curentHospital = {id:1,hosName:'同济医院-主院区'}
- // }
- // })
- // }else{
- // var curentHospital = $rootScope.user.duty?{id:$rootScope.user.duty.branch,hosName:$rootScope.user.duty.branchName}:$rootScope.user.branch;
- // }
- if(modelData){
- var curentHospital = {};
- }else{
- var curentHospital = $rootScope.user.duty?{id:$rootScope.user.duty.branch,hosName:$rootScope.user.duty.branchName}:$rootScope.user.branch;
- }
- // 是否连续建单
- $scope.isBuildOrderAgagin = false;
- //事件列表数据存储
- $scope.incidentModel = {
- department: "", //报修科室
- requester: "", //报修人
- contacts: "", //联系人
- contactsInformation: "", //联系电话
- branch: curentHospital, //院区
- area: "", //区域
- place: "", //地点
- address: "", //详细地址
- priority: "", //优先级
- description: "", //故障描述
- source: {id:1547,name:'电话'}, //事件来源
- yyTime: null, //预约报修时间
- assign: 1, //派单人或组
- user: "", //处理人
- group: "", //处理组
- };
- console.log(modelData)
- if(modelData){
- //报修生成事件,数据回显
- //来电生成事件,数据回显
- $scope.categorySelect = modelData.incident.category;
- $scope.jry_modelLeft = modelData.incident.category?modelData.incident.category.mutiCategory:'';
- console.log($scope.jry_deptData)
- $scope.incidentModel = {
- department: modelData.incident.department, //报修科室
- requester: "", //报修人
- contacts: modelData.incident.contacts, //联系人
- contactsInformation: modelData.incident.contactsInformation, //联系电话
- branch: curentHospital, //院区
- area: type === 'incomingCall' ? (modelData.incident.department ? modelData.incident.department.area : "") : modelData.incident.area, //区域
- place: type === 'incomingCall' ? (modelData.incident.department ? modelData.incident.department.place : "") : modelData.incident.place, //地点
- address: type === 'incomingCall' ? (modelData.incident.department ? modelData.incident.department.address : "") : modelData.incident.houseNumber, //详细地址
- priority: modelData.incident.priority, //优先级
- description: modelData.incident.description, //故障描述
- source: modelData.incident.source, //事件来源
- yyTime: null, //预约报修时间
- assign: 1, //派单人或组
- user: "", //处理人
- group: "", //处理组
- callID: modelData.incident.sockid || undefined, //callID
- incomingPhone: modelData.incident.incomingPhone || undefined, //来电电话
- };
- }
- $scope.minYYtime = new Date();
- // 建单并派单
- $scope.buildAndAssign = function(){
- if(!$scope.categorySelectId){
- SweetAlert.swal({
- title: "提示",
- text: "请选择故障现象!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.selectedDuty){
- SweetAlert.swal({
- title: "提示",
- text: "故障现象【"+ $scope.categorySelect.category +"】没有设置责任科室!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.department){
- SweetAlert.swal({
- title: "提示",
- text: "请选择报修科室!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.contactsInformation){
- SweetAlert.swal({
- title: "提示",
- text: "请填写联系电话!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.priority){
- SweetAlert.swal({
- title: "提示",
- text: "请选择优先级!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.description){
- SweetAlert.swal({
- title: "提示",
- text: "请选择故障描述!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if($scope.incidentModel.assign == 0){
- SweetAlert.swal({
- title: "提示",
- text: "请选择派单给人或组!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if($scope.incidentModel.assign == 1 && !$scope.incidentModel.user){
- SweetAlert.swal({
- title: "提示",
- text: "请选择处理人!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if($scope.incidentModel.assign == 2 && !$scope.incidentModel.group){
- SweetAlert.swal({
- title: "提示",
- text: "请选择处理组!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- $rootScope.isMask = true;
- var repair_main = JSON.parse(sessionStorage.getItem('repair_main'));
- // var postData = {
- // "loginUser": $rootScope.user,
- // "incident": {
- // "deleteFlag": 0,
- // "duty":$scope.selectedDuty?$scope.selectedDuty:undefined,
- // "department": $scope.incidentModel.department||undefined,
- // "contactsInformation": $scope.incidentModel.contactsInformation,
- // "contacts": $scope.incidentModel.contacts,
- // "branch": $scope.incidentModel.branch?$scope.incidentModel.branch.id:undefined,
- // "area": $scope.incidentModel.area||undefined,
- // "place": $scope.incidentModel.place||undefined,
- // "houseNumber": $scope.incidentModel.address,
- // "category": $scope.categorySelect||undefined,
- // "priority": $scope.incidentModel.priority||undefined,
- // "source": $scope.incidentModel.source||undefined,
- // "title": $scope.categorySelect.category,
- // "description": $scope.incidentModel.description,
- // "yyTime": $scope.incidentModel.yyTime ? moment($scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
- // "repairType": repair_main?repair_main.valueconfig:undefined,
- // "requester":$scope.incidentModel.requester||undefined,
- // "acceptUser": $rootScope.user||undefined,
- // "callID": $scope.incidentModel.callID||undefined,
- // "incomingPhone": $scope.incidentModel.incomingPhone||undefined,
- // },
- // "start_code": "assignment",
- // "initUser": $rootScope.user.id
- // };
- var postData = {
- "incident": {
- "deleteFlag": 0,
- "duty":$scope.selectedDuty?$scope.selectedDuty:undefined,
- "department": $scope.incidentModel.department||undefined,
- "contactsInformation": $scope.incidentModel.contactsInformation,
- "contacts": $scope.incidentModel.contacts,
- "branch": $scope.incidentModel.branch?$scope.incidentModel.branch.id:undefined,
- "area": $scope.incidentModel.area||undefined,
- "place": $scope.incidentModel.place||undefined,
- "houseNumber": $scope.incidentModel.address,
- "category": $scope.categorySelect||undefined,
- "priority": $scope.incidentModel.priority||undefined,
- "source": $scope.incidentModel.source||undefined,
- "title": $scope.categorySelect.category,
- "description": $scope.incidentModel.description,
- "yyTime": $scope.incidentModel.yyTime ? moment($scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
- "repairType": repair_main?repair_main.valueconfig:undefined,
- "requester":$scope.incidentModel.requester||undefined,
- "acceptUser": $rootScope.user||undefined,
- "callID": $scope.incidentModel.callID||undefined,
- "incomingPhone": $scope.incidentModel.incomingPhone||undefined,
- }
- };
- // if(modelData){
- // // 微信报修转事件
- // postData.flow = modelData.flow;
- // }
- if($scope.incidentModel.assign == 1){
- postData.incident.assignee = $scope.incidentModel.user.id;
- }else if($scope.incidentModel.assign == 2){
- postData.incident.candidateGroups = $scope.incidentModel.group.id;
- }
- api_bpm_domain.workernumber('sj').then(res1=>{
- postData.incident.incidentsign = res1.data;
- api_flow.accept("accept", postData).then(function (response) {
- if ($scope.uploader != null) {
- // 有图片
- $scope.uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.uploadAttachment(response.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name });
- };
- $scope.uploader.uploadAll();
- }
- $rootScope.isMask = false;
- SweetAlert.swal(
- {
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF",
- },
- function (isConfirm) {
- if(isConfirm){
- // 是否连续建单
- if($scope.isBuildOrderAgagin){
- $scope.categorySelect = "";
- $scope.categorySelectId = 0;
- $scope.incidentModel.assign = 1;
- $scope.incidentModel.user = "";
- $scope.incidentModel.group = "";
- }else{
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- $modalInstance.dismiss("cancel");
- }
- $rootScope.newOrderShowOpen = false;
- if($state.current.name === 'app.incident.list'){
- $state.reload();
- }else{
- $state.go("app.incident.list");
- }
- }
- }
- );
- });
- })
- }
- // 暂存
- $scope.temporaryStorage = function(){
- $rootScope.isMask = true;
- var repair_main = JSON.parse(sessionStorage.getItem('repair_main'));
- var postData = {
- "incident": {
- "deleteFlag": 0,
- "duty":$scope.selectedDuty?$scope.selectedDuty:undefined,
- "department": $scope.incidentModel.department||undefined,
- "contactsInformation": $scope.incidentModel.contactsInformation,
- "contacts": $scope.incidentModel.contacts,
- "branch": $scope.incidentModel.branch?$scope.incidentModel.branch.id:undefined,
- "area": $scope.incidentModel.area||undefined,
- "place": $scope.incidentModel.place||undefined,
- "houseNumber": $scope.incidentModel.address,
- "category": $scope.categorySelect||undefined,
- "priority": $scope.incidentModel.priority||undefined,
- "source": $scope.incidentModel.source||undefined,
- "title": $scope.categorySelect.category,
- "description": $scope.incidentModel.description,
- "yyTime": $scope.incidentModel.yyTime ? moment($scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
- "repairType": repair_main?repair_main.valueconfig:undefined,
- "requester":$scope.incidentModel.requester||undefined,
- "acceptUser": $rootScope.user||undefined,
- "callID": $scope.incidentModel.callID||undefined,
- "incomingPhone": $scope.incidentModel.incomingPhone||undefined,
- }
- };
- // if(modelData){
- // // 微信报修转事件
- // postData.flow = modelData.flow;
- // }
- if($scope.incidentModel.assign == 1){
- postData.incident.assignee = $scope.incidentModel ? $scope.incidentModel.user.id : undefined;
- }else if($scope.incidentModel.assign == 2){
- postData.incident.candidateGroups = $scope.incidentModel ? $scope.incidentModel.group.id : undefined;
- }
- api_bpm_domain.workernumber('sj').then(res1=>{
- postData.incident.incidentsign = res1.data;
- api_flow.accept("storage", postData).then(function (response) {
- if ($scope.uploader != null) {
- // 有图片
- $scope.uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.uploadAttachment(response.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name });
- };
- $scope.uploader.uploadAll();
- }
- $rootScope.isMask = false;
- SweetAlert.swal(
- {
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF",
- },
- function (isConfirm) {
- if(isConfirm){
- // 是否连续建单
- if($scope.isBuildOrderAgagin){
- $scope.categorySelect = "";
- $scope.categorySelectId = 0;
- $scope.incidentModel.assign = 1;
- $scope.incidentModel.user = "";
- $scope.incidentModel.group = "";
- }else{
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- $modalInstance.dismiss("cancel");
- }
- $rootScope.newOrderShowOpen = false;
- if($state.current.name === 'app.incident.list'){
- $state.reload();
- }else{
- $state.go("app.incident.list");
- }
- }
- }
- );
- });
- })
- }
- // 展开/收起
- $scope.showId = "";
- $scope.ifshow = false;
- $scope.showAll = function (id) {
- $scope.attachments = [];
- if ($scope.showId == id) {
- $scope.ifshow = !$scope.ifshow;
- } else {
- $scope.ifshow = true;
- }
- $scope.showId = id;
- // 获取附件
- api_wechatfile
- .listAttachments("knowledge", $scope.showId)
- .then(function (data) {
- $scope.attachments = data.data;
- $scope.download = function (token, filename) {
- var downUrl = up_down_file
- .downloadAttachment("common/common/downloadAttachment", token)
- .getRequestedUrl();
- var a = document.createElement("a");
- a.href = downUrl;
- a.target = "_blank";
- a.download = filename;
- document.body.appendChild(a);
- a.click();
- };
- });
- };
- // 回显处理人或组
- $scope.showUserOrGroup = function(){
- if($scope.incidentModel.department && $scope.categorySelect && $scope.selectedDuty && $scope.incidentModel.branch){
- var postData = {
- idx: 0,
- sum: 10,
- incidentAssignManager: {
- deptId:$scope.incidentModel.department.id,
- categoryId:$scope.categorySelect.id,
- branch:$scope.incidentModel.branch.id,
- dutyId: $scope.selectedDuty.id
- },
- };
- api_user_data.fetchDataList("incidentAssignManager", postData).then(function(result){
- if(result.status == 200){
- var deptBinduserConfig = result.list?result.list[0]:null;//获取第一条配置
- if(deptBinduserConfig){
- // 如果有科室绑定人员的配置
- if(deptBinduserConfig.userOrGroupType == 1){
- // 派单给人
- $scope.incidentModel.assign = 1;
- $scope.incidentModel.user = $scope.jry_userData.find(v=>v.id == deptBinduserConfig.handleUser);
- }else if(deptBinduserConfig.userOrGroupType == 2){
- // 派单给组
- $scope.incidentModel.assign = 2;
- $scope.incidentModel.group = $scope.jry_groupData.find(v=>v.id == deptBinduserConfig.group);
- }
- }else{
- // 没有查询到科室绑定人员的配置,则根据院区,普通科室,责任科室查询
- var postData = {
- idx: 0,
- sum: 10,
- incidentAssignManager: {
- deptId:$scope.incidentModel.department.id,
- branch:$scope.incidentModel.branch.id,
- dutyId: $scope.selectedDuty.id
- },
- };
- api_user_data.fetchDataList("incidentAssignManager", postData).then(function(result){
- if(result.status == 200){
- //获取配置
- var deptBinduserConfig = result.list || [];
- // 过滤掉有故障现象的配置
- deptBinduserConfig = deptBinduserConfig.filter(v => !v.categoryId);
- // 获取第一条配置
- deptBinduserConfig = deptBinduserConfig[0] || null;
- if(deptBinduserConfig){
- // 如果有科室绑定人员的配置
- if(deptBinduserConfig.userOrGroupType == 1){
- // 派单给人
- $scope.incidentModel.assign = 1;
- $scope.incidentModel.user = $scope.jry_userData.find(v=>v.id == deptBinduserConfig.handleUser);
- }else if(deptBinduserConfig.userOrGroupType == 2){
- // 派单给组
- $scope.incidentModel.assign = 2;
- $scope.incidentModel.group = $scope.jry_groupData.find(v=>v.id == deptBinduserConfig.group);
- }
- }else{
- if($scope.categorySelect){
- // 选择了故障现象
- assignCommon($scope.categorySelect);
- }
- }
- }
- })
- }
- }
- })
- }else if($scope.categorySelect){
- // 选择了故障现象
- assignCommon($scope.categorySelect);
- }
- }
- // 直接解决
- $scope.build = function(){
- if(!$scope.categorySelectId){
- SweetAlert.swal({
- title: "提示",
- text: "请选择故障现象!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.selectedDuty){
- SweetAlert.swal({
- title: "提示",
- text: "故障现象【"+ $scope.categorySelect.category +"】没有设置责任科室!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.department){
- SweetAlert.swal({
- title: "提示",
- text: "请选择报修科室!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.contactsInformation){
- SweetAlert.swal({
- title: "提示",
- text: "请填写联系电话!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.priority){
- SweetAlert.swal({
- title: "提示",
- text: "请选择优先级!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.description){
- SweetAlert.swal({
- title: "提示",
- text: "请选择故障描述!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- $modal.open({
- templateUrl: "assets/views/newOrderDirectly.html",
- controller: function ($scope,scope,$state, $modalInstance, SweetAlert,api_bpm) {
- $scope.categorySelect = scope.categorySelect;
- console.log($scope.categorySelect)
- $scope.incidentModel = {
- handlerMsg:'',//处理方案
- closecode:'',//关闭代码
- };
- // 关闭代码
- $scope.closecodeArray = [];
- $scope.jry_closecodeSearch = function () {
- api_wechatfile
- .getDictionary({ type: "list", key: "incident_closecode" })
- .then(function (data) {
- $scope.closecodeArray = data;
- });
- };
- $scope.jry_closecodeSearch();
- // 确定
- $scope.ok = function () {
- if($scope.categorySelect.hasSimple != 1 && !$scope.incidentModel.handlerMsg){
- SweetAlert.swal({
- title: "提示",
- text: "请填写处理方案!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- if(!$scope.incidentModel.closecode.id){
- SweetAlert.swal({
- title: "提示",
- text: "请选择关闭代码!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- });
- return;
- }
- // -------新建事件,积分机制,直接处理--------
- var integralMechanism = sessionStorage.getItem('integralMechanism');
- if(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2)){
- $modal.open({
- templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
- controller: function ($scope, $modalInstance, incidentData,categorySelect, currentUserId, Alert, api_wechatfile,scope,api_bpm_data) {
- console.log(incidentData,currentUserId,categorySelect);
- $scope.complexityConfirm = {complexity:null,updateReason:''};
- $scope.complexityFn = function(category){
- if(category.complexity){
- return category.complexity.value;
- }else if(category.parent){
- return $scope.complexityFn(category.parent);
- }else{
- return $scope.list[0]?$scope.list[0].value:1;
- }
- }
- $scope.list = [];
- api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
- $scope.list = res;
- if(categorySelect && categorySelect.id){
- api_bpm_data.fetchData("incidentCategory",categorySelect.id).then(function(result){
- if(result.status == 200){
- $scope.complexity = $scope.complexityFn(result.data);
- $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
- }
- })
- }
- })
- $scope.onChangeComplexity = function(item){
- }
- $scope.ok = function () {
- if (!$scope.complexityConfirm.complexity){
- Alert.swal({
- title: "操作失败",
- text: "请选择工时!",
- type: "error"
- });
- return;
- }
- if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
- Alert.swal({
- title: "操作失败",
- text: "请填写升级原因!",
- type: "error"
- });
- return;
- }
- $modalInstance.close('success');
- handlerStart();
- scope.complexity = $scope.complexity;
- scope.complexityConfirm = $scope.complexityConfirm;
- // 暂存--后面直接处理后调用积分接口
- }
- $scope.cancel = function () {
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- $modalInstance.dismiss('cancel');
- }
- },
- size: 'sm',
- resolve: {
- scope: function () {
- return $scope;
- },
- api_bpm: function () {
- return api_bpm;
- },
- incidentData: function () {
- return scope.incidentModel;
- },
- categorySelect: function () {
- return scope.categorySelect;
- },
- currentUserId: function () {
- return $rootScope.user.id;
- },
- Alert: function () {
- return SweetAlert;
- },
- api_user_data: function () {
- return api_user_data;
- },
- api_wechatfile: function () {
- return api_wechatfile;
- }
- }
- });
- }else{
- handlerStart();
- }
- // -------新建事件,积分机制,直接处理--------
- };
- // 直接处理,新建事件
- function handlerStart(){
- $rootScope.isMask = true;
- console.log(scope.incidentModel,$scope.incidentModel);
- var repair_main = JSON.parse(sessionStorage.getItem('repair_main'));
- // var postData = {
- // "loginUser": $rootScope.user||undefined,
- // "incident": {
- // "deleteFlag": 0,
- // "duty":scope.selectedDuty?scope.selectedDuty:undefined,
- // "requester":$scope.incidentModel.requester||undefined,
- // "alarmType": false,
- // "department": scope.incidentModel.department||undefined,
- // "contactsInformation": scope.incidentModel.contactsInformation,
- // "contacts": scope.incidentModel.contacts,
- // "branch": scope.incidentModel.branch?scope.incidentModel.branch.id:undefined,
- // "area": scope.incidentModel.area||undefined,
- // "place": scope.incidentModel.place||undefined,
- // "houseNumber": scope.incidentModel.address,
- // "category": scope.categorySelect||undefined,
- // "priority": scope.incidentModel.priority||undefined,
- // "source": scope.incidentModel.source||undefined,
- // "title": scope.categorySelect.category,
- // "description": scope.incidentModel.description,
- // "directProcess": 1,
- // "handleDescription": $scope.incidentModel.handlerMsg,
- // "handlingPersonnelUser":{id:$rootScope.user.id},
- // "yyTime": scope.incidentModel.yyTime ? moment(scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
- // "closecode": $scope.incidentModel.closecode||undefined,
- // "repairType": repair_main?repair_main.valueconfig:undefined,
- // "acceptUser": $rootScope.user||undefined,
- // "callID": scope.incidentModel.callID||undefined,
- // "incomingPhone": scope.incidentModel.incomingPhone||undefined,
- // },
- // "start_code": "close",
- // "handler_code": "resolve",
- // "initUser": $rootScope.user.id,
- // "isSolution": false
- // };
- var postData = {
- "incident": {
- "deleteFlag": 0,
- "duty":scope.selectedDuty?scope.selectedDuty:undefined,
- "requester":$scope.incidentModel.requester||undefined,
- "alarmType": false,
- "department": scope.incidentModel.department||undefined,
- "contactsInformation": scope.incidentModel.contactsInformation,
- "contacts": scope.incidentModel.contacts,
- "branch": scope.incidentModel.branch?scope.incidentModel.branch.id:undefined,
- "area": scope.incidentModel.area||undefined,
- "place": scope.incidentModel.place||undefined,
- "houseNumber": scope.incidentModel.address,
- "category": scope.categorySelect||undefined,
- "priority": scope.incidentModel.priority||undefined,
- "source": scope.incidentModel.source||undefined,
- "title": scope.categorySelect.category,
- "description": scope.incidentModel.description,
- "directProcess": 1,
- "handleDescription": $scope.incidentModel.handlerMsg,
- "handlingPersonnelUser":{id:$rootScope.user.id},
- "yyTime": scope.incidentModel.yyTime ? moment(scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
- "closecode": $scope.incidentModel.closecode||undefined,
- "repairType": repair_main?repair_main.valueconfig:undefined,
- "acceptUser": $rootScope.user||undefined,
- "callID": scope.incidentModel.callID||undefined,
- "incomingPhone": scope.incidentModel.incomingPhone||undefined,
- },
- };
- // if(scope.modelData){
- // // 微信报修转事件
- // postData.flow = scope.modelData.flow;
- // }
- api_bpm_domain.workernumber('sj').then(res1=>{
- postData.incident.incidentsign = res1.data;
- api_flow.accept("accept", postData).then(function (resData) {
- if (scope.uploader != null) {
- // 有图片
- scope.uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, $rootScope.getSession());
- item.url = api_bpm_domain.uploadAttachment(resData.id).getRequestedUrl();
- item.formData.push({ 'fileName': item.file.name });
- };
- scope.uploader.uploadAll();
- }
- var integralMechanism = sessionStorage.getItem('integralMechanism');
- if(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2)){
- api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
- var auditState = res.find(v=>v.value == 0);
- var postData = {
- incidentIntegral: {
- incidentId:resData.bussId,
- auditState:auditState,
- handlerUser:$rootScope.user.id,
- handlerUserName:$rootScope.user.name,
- sourceScore:$scope.complexity,
- currentScore:$scope.complexityConfirm.complexity.value,
- updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
- }
- }
- console.log(postData)
- api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
- console.log(response)
- $rootScope.isMask = false;
- if (response.status == 200) {
- SweetAlert.swal(
- {
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF",
- },
- function (isConfirm) {
- if(isConfirm){
- $modalInstance.dismiss("cancel");
- // 是否连续建单
- if(scope.isBuildOrderAgagin){
- scope.categorySelect = "";
- scope.categorySelectId = 0;
- scope.incidentModel.assign = 1;
- scope.incidentModel.user = "";
- scope.incidentModel.group = "";
- }else{
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- scope.cancel();
- }
- $rootScope.newOrderShowOpen = false;
- if($state.current.name === 'app.incident.list'){
- $state.reload();
- }else{
- $state.go("app.incident.list");
- }
- }
- }
- );
- } else {
- Alert.swal({
- title: "操作失败",
- text: "操作失败, 请稍后再试!",
- type: "error"
- });
- }
- });
- })
- }else{
- SweetAlert.swal(
- {
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF",
- },
- function (isConfirm) {
- if(isConfirm){
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- scope.cancel();
- $modalInstance.dismiss("cancel");
- $rootScope.newOrderShowOpen = false;
- if($state.current.name === 'app.incident.list'){
- $state.reload();
- }else{
- $state.go("app.incident.list");
- }
- }
- }
- );
- }
- // -------------------------------------------
- $rootScope.isMask = false;
- SweetAlert.swal(
- {
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF",
- },
- function (isConfirm) {
- if(isConfirm){
- $modalInstance.dismiss("cancel");
- // 是否连续建单
- if(scope.isBuildOrderAgagin){
- scope.categorySelect = "";
- scope.categorySelectId = 0;
- scope.incidentModel.assign = 1;
- scope.incidentModel.user = "";
- scope.incidentModel.group = "";
- }else{
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- scope.cancel();
- }
- $rootScope.newOrderShowOpen = false;
- if($state.current.name === 'app.incident.list'){
- $state.reload();
- }else{
- $state.go("app.incident.list");
- }
- }
- }
- );
- });
- })
- }
- // 取消
- $scope.cancel = function () {
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- $modalInstance.dismiss("cancel");
- };
- },
- size:'lg',
- resolve: {
- SweetAlert: function () {
- return SweetAlert;
- },
- scope: function(){
- return $scope;
- }
- },
- });
- }
- // 处理顶部责任科室数据
- $scope.handlerDuty = function(){
- if(!$scope.categorySelect){
- return;
- }
- if($scope.categorySelect.branchType == 1){
- // 分院区
- if($scope.incidentModel.branch){
- var dutyConfig = $scope.categorySelect.branchUserGroups.find(v=>v.branchId == $scope.incidentModel.branch.id);
- if(dutyConfig && dutyConfig.dutyId && dutyConfig.dutyName){
- $scope.selectedDuty = {id:dutyConfig.dutyId,dept:dutyConfig.dutyName};
- }else{
- $scope.selectedDuty = null;
- }
- }else{
- $scope.selectedDuty = null;
- }
- }else{
- // 不分院区
- $scope.selectedDuty = $scope.categorySelect.dutyDepartment;
- }
- }
- // 优先级
- $scope.priorityArray = [];
- $scope.jry_prioritySearch = function () {
- api_wechatfile
- .getDictionary({ type: "list", key: "incident_priority" })
- .then(function (data) {
- $scope.priorityArray = data;
- });
- };
- $scope.jry_prioritySearch();
- // 事件来源
- $scope.sourceArray = [];
- $scope.jry_sourceSearch = function () {
- api_wechatfile
- .getDictionary({ type: "list", key: "incident_source" })
- .then(function (data) {
- $scope.sourceArray = data;
- if($scope.incidentModel.source){
- if(!$scope.incidentModel.source.name && $scope.incidentModel.source.id){
- $scope.incidentModel.source = data.find(v=>v.id == $scope.incidentModel.source.id)
- }
- }
- });
- };
- $scope.jry_sourceSearch();
- // 报修科室模糊搜索
- $scope.jry_deptSearch = function (key = "",branchId) {
- console.log(branchId)
- if(!branchId){
- $scope.jry_deptData = [];
- return;
- }
- var deptData = {
- idx: 0,
- sum: 20,
- department: {
- branch:branchId,
- dept:key,
- selectType: "pinyin_qs",
- searchType: "quickStart",
- },
- };
- api_user_data.fetchDataList("department", deptData).then(function (data) {
- $scope.jry_deptData = data.list;
- if($scope.incidentModel.department){
- if(!$scope.incidentModel.department.dept && $scope.incidentModel.department.id){
- // $scope.incidentModel.department = data.list.find(v=>v.id == $scope.incidentModel.department.id)
- api_bpm_data.fetchData('department', $scope.incidentModel.department.id).then(res=>{
- if(res.status == 200){
- $scope.incidentModel.department = res.data;
- }else{
- $scope.incidentModel.department = '';
- }
- })
- }
- }
- });
- };
- // $scope.jry_deptSearch();
- // 报修人模糊搜索
- $scope.jry_requesterSearch = function (key = "") {
- var postData = {
- idx: 0,
- sum: 10,
- requester: {
- searchKey: key,
- },
- };
- api_user_data.fetchDataList("requester", postData).then(function (data) {
- $scope.jry_requesterData = data.list;
- });
- };
- $scope.jry_requesterSearch();
- $scope.$watch("incidentModel.requester", function (newVal,oldVal) {
- if(newVal){
- $scope.incidentModel.contacts = newVal.name;
- SweetAlert.swal({
- title: "提示",
- text: "是否覆盖联系电话?",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认覆盖",
- cancelButtonText: "取消操作",
- closeOnConfirm: true,
- closeOnCancel: true
- }, function (isConfirm) {
- if (isConfirm) {
- $scope.incidentModel.contactsInformation = newVal.mphone;
- }
- });
- }
- });
- // 处理人模糊搜索
- $scope.jry_userSearch = function (key = "") {
- var userData = {
- idx: 0,
- sum: 1000,
- user: {
- roledata: {rolecode: "first-line support"},
- selectDetails:'1',
- simple:true,
- name: key,
- selectType: "pinyin_qs",
- engineer: 1,
- },
- };
- api_user_data.fetchDataList("user", userData).then(function (data) {
- $scope.jry_userData = data.list;
- if($scope.incidentModel.user){
- if(!$scope.incidentModel.user.userTaskCount){
- $scope.incidentModel.user = data.list.find(v=>v.id == $scope.incidentModel.user.id);
- }
- }
- });
- };
- $scope.jry_userSearch();
- // 处理组模糊搜索
- $scope.jry_groupSearch = function (key = "") {
- var groupData = {
- idx: 0,
- sum: 1000,
- group: {
- selectType: "nouser"
- },
- };
- api_user_data.fetchDataList("group", groupData).then(function (data) {
- $scope.jry_groupData = data.list;
- });
- };
- $scope.jry_groupSearch();
- // 院区模糊搜索
- $scope.jry_branchSearch = function (key = "") {
- var postData = {
- idx: 0,
- sum: 1000
- };
- api_user_data.fetchDataList("branch", postData).then(function (data) {
- $scope.jry_branchData = data.list;
- if(modelData && modelData.incident && modelData.incident.department){
- api_bpm_data.fetchData('department', modelData.incident.department.id).then(res=>{
- if(res.status == 200){
- $scope.incidentModel.branch = $scope.jry_branchData.find(v=>v.id == res.data.branch);
- }
- })
- }
- });
- };
- $scope.jry_branchSearch();
- // 区域模糊搜索
- $scope.jry_areaSearch = function (key='',branchId) {
- if(!branchId){
- $scope.jry_areaData = [];
- return;
- }
- var areaData = {
- idx: 0,
- sum: 30,
- area: {
- branch:branchId,
- area:key,
- selectType:'pinyin_qs'
- },
- };
- api_user_data.fetchDataList("area", areaData).then(function (data) {
- $scope.jry_areaData = data.list;
- });
- };
- // 地点模糊搜索
- $scope.jry_placeSearch = function (key='',areaId) {
- if(!areaId){
- $scope.jry_placeData = [];
- return;
- }
- var placeData = {
- idx: 0,
- sum: 30,
- place: {
- place: key,
- areaId: areaId,
- selectType:'pinyin_qs'
- },
- };
- api_user_data.fetchDataList("place", placeData).then(function (data) {
- $scope.jry_placeData = data.list;
- });
- };
- $scope.changeBranch = function(){
- $scope.incidentModel.area = '';
- $scope.incidentModel.place = '';
- $scope.incidentModel.department = '';
- $scope.jry_placeData = [];
- }
- $scope.changeArea = function(){
- $scope.incidentModel.place = '';
- }
- $scope.$watch("incidentModel.branch", function (newVal,oldVal) {
- $scope.showUserOrGroup();
- newVal && $scope.jry_areaSearch('',newVal.id);
- newVal && $scope.jry_deptSearch('',newVal.id);
- $scope.handlerDuty();
- });
- $scope.$watch("incidentModel.area", function (newVal,oldVal) {
- newVal && $scope.jry_placeSearch('',newVal.id);
- console.log(modelData, $scope.oldDept,$scope.incidentModel)
- });
- $scope.$watch("categorySelect", function (newVal,oldVal) {
- if(newVal&&newVal.priority){
- // 回显优先级
- $scope.incidentModel.priority = newVal.priority;
- }
- // 选择了院区,科室,故障现象,责任科室
- $scope.showUserOrGroup();
- // 回显人员
- if($scope.incidentModel.user){
- if(!$scope.incidentModel.user.userTaskCount){
- $scope.incidentModel.user = $scope.jry_userData.find(v=>v.id == $scope.incidentModel.user.id);
- }
- }
- });
- // 派人或派组
- function assignCommon(sj){
- console.log(sj);
- if(!sj){return;}
- if (sj.branchType == 0) {
- if (sj.userOrGroupType === 1) {
- //派人
- $scope.incidentModel.assign = 1;
- $scope.incidentModel.user = sj.handleUser ? $scope.jry_userData.find(v=>v.id == sj.handleUser.id) : "";
- } else if (sj.userOrGroupType === 2) {
- //派组
- $scope.incidentModel.assign = 2;
- $scope.incidentModel.group = sj.group ? sj.group : "";
- } else {
- $scope.incidentModel.assign = 0;
- $scope.incidentModel.user = "";
- $scope.incidentModel.group = "";
- }
- } else if (sj.branchType == 1) {
- // 分院区
- // 选择了院区
- if ($scope.incidentModel.branch) {
- let branchId = $scope.incidentModel.branch.id;
- let branchUserGroup =
- sj.branchUserGroups.find(v => v.branchId == branchId) || {};
- if (branchUserGroup.branchUserOrGroupType == 1) {
- //派人
- $scope.incidentModel.assign = 1;
- console.log($scope.jry_userData)
- $scope.incidentModel.user = branchUserGroup.userId
- ? $scope.jry_userData.find(v=>v.id == branchUserGroup.userId)
- : "";
- } else if (branchUserGroup.branchUserOrGroupType === 2) {
- //派组
- $scope.incidentModel.assign = 2;
- $scope.incidentModel.group = branchUserGroup.groupId
- ? {id:branchUserGroup.groupId,groupName:branchUserGroup.groupName}
- : "";
- } else {
- $scope.incidentModel.assign = 1;
- $scope.incidentModel.user = "";
- $scope.incidentModel.group = "";
- }
- } else {
- $scope.incidentModel.assign = 1;
- $scope.incidentModel.user = "";
- $scope.incidentModel.group = "";
- }
- }
- }
- // 取消故障描述弹窗
- $scope.isShowAlertMask = false;
- $scope.copyItem = null;
- $scope.cancelAlertMask = function(){
- $scope.isShowAlertMask = false;
- }
- // 覆盖
- $scope.overlayAlertMask = function(){
- $scope.incidentModel.description = $scope.copyItem.mutiCategory;
- $scope.isShowAlertMask = false;
- }
- // 前覆盖
- $scope.overlayLeftAlertMask = function(){
- $scope.incidentModel.description = $scope.copyItem.mutiCategory + $scope.incidentModel.description;
- $scope.isShowAlertMask = false;
- }
- // 后覆盖
- $scope.overlayRightAlertMask = function(){
- $scope.incidentModel.description = $scope.incidentModel.description + $scope.copyItem.mutiCategory;
- $scope.isShowAlertMask = false;
- }
- // 故障现象选中
- $scope.categorySelectId = 0;
- $scope.categorySelect = "";
- $scope.selectedDuty = null;//选择故障现象后的责任科室
- $scope.changeCategorySelect = function(item){
- $scope.copyItem = angular.copy(item);
- $scope.copyItem.mutiCategory = $scope.copyItem.mutiCategory.replace(/<[^<>]+>/g,'');
- if($scope.incidentModel.description){
- $scope.isShowAlertMask = true;
- // SweetAlert.swal({
- // title: "提示",
- // text: "是否覆盖故障描述?",
- // type: "warning",
- // showCancelButton: true,
- // confirmButtonColor: "#DD6B55",
- // confirmButtonText: "确认覆盖",
- // cancelButtonText: "取消操作",
- // closeOnConfirm: true,
- // closeOnCancel: true
- // }, function (isConfirm) {
- // if (isConfirm) {
- // $scope.incidentModel.description = $scope.copyItem.mutiCategory;
- // }
- // });
- }else{
- $scope.incidentModel.description = $scope.copyItem.mutiCategory;
- }
- $scope.categorySelect = $scope.copyItem;
- $scope.categorySelectId = $scope.copyItem.id;
- // 处理责任科室数据
- $scope.handlerDuty();
- if($scope.selectTab == 2){
- $scope.jry_solution($scope.categorySelect.id);
- }
- }
- // 故障现象查询
- $scope.c_timer = null;
- $scope.c_keyword = '';
- $scope.jry_categorySearch = function (key = '') {
- $scope.c_keyword = key;
- clearTimeout($scope.c_timer);
- $scope.c_timer = setTimeout(()=>{
- var categoryData = {
- idx: 0,
- sum: 9999,
- incidentcategory: {
- category: key,
- selectType:'pinyin_qs',
- hierarchyQuery:'three'
- },
- };
- if($rootScope.user.duty){
- categoryData.incidentcategory.dutyDepartment = $rootScope.user.duty;
- }else if($rootScope.user.branch){
- // categoryData.incidentcategory.branch = $rootScope.user.branch.id;
- }
- $scope.loading_c = true;
- api_user_data.fetchDataList("incidentcategory", categoryData).then(function (data) {
- if($scope.c_keyword == key){
- $scope.loading_c = false;
- data.list.forEach(v=>{
- if(v.mutiCategory){
- v.mutiCategory = v.mutiCategory.replace($scope.jry_modelLeft,'<span class="colorRed">'+$scope.jry_modelLeft+'</span>');
- }
- })
- $scope.jry_categoryData = data.list;
- if(modelData){
- if( modelData.incident.category && !modelData.incident.category.complexity){
- $scope.categorySelect = data.list.find(v=>v.id == modelData.incident.category.id);
- if($scope.categorySelect){
- $scope.categorySelectId = $scope.categorySelect.id;
- }
- }
- }
- }
- });
- },500)
- };
- $scope.jry_categorySearch($scope.jry_modelLeft);
- // 右侧tab选中
- $scope.selectTab = 1;
- $scope.changeTab = function(id){
- $scope.selectTab = id;
- if(id == 1){
- $scope.jry_incident($scope.incidentModel.department?$scope.incidentModel.department.id:undefined);
- }else if(id == 2){
- $scope.jry_solution($scope.categorySelect?$scope.categorySelect.id:undefined);
- }
- }
- // 近期报修
- $scope.jry_incident = function (deptId) {
- $scope.loading_i = true;
- var placeData = {
- idx: 0,
- sum: 6,
- incident: {
- department: {id:deptId},
- },
- };
- api_user_data.fetchDataList("incident", placeData).then(function (data) {
- $scope.loading_i = false;
- data.list.forEach(v=>{
- v.acceptDate = moment(v.acceptDate).format('MM-DD HH:mm')
- })
- $scope.jry_incidentData = data.list;
- });
- };
- $scope.$watch("incidentModel.department", function (newVal,oldVal) {
- $scope.showUserOrGroup();
- newVal && $scope.jry_incident(newVal.id);
- console.log(newVal);
- if(newVal){
- api_bpm_data.fetchData('department', $scope.incidentModel.department.id).then(res=>{
- if(res.status == 200){
- // $scope.incidentModel.department = res.data;
- if(res.data && res.data.place){
- $scope.incidentModel.place = res.data.place;
- $scope.incidentModel.area = res.data.place.area;
- }else{
- $scope.incidentModel.place = '';
- $scope.incidentModel.area = '';
- }
- $scope.incidentModel.address = res.data.address || '';
- // 如果回显的有联系电话,联系电话不用科室带出
- !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (res.data&&res.data.phone)?res.data.phone.split(',')[0]:'');
- }else{
- $scope.incidentModel.place = '';
- $scope.incidentModel.area = '';
- $scope.incidentModel.address = '';
- // 如果回显的有联系电话,联系电话不用科室带出
- !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (newVal&&newVal.phone)?newVal.phone:'');
- }
- })
- }else{
- $scope.incidentModel.place = '';
- $scope.incidentModel.area = '';
- $scope.incidentModel.address = '';
- // 如果回显的有联系电话,联系电话不用科室带出
- !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (newVal&&newVal.phone)?newVal.phone:'');
- }
- // if(newVal && newVal.place){
- // $scope.incidentModel.place = newVal.place;
- // $scope.incidentModel.area = newVal.place.area;
- // }else{
- // $scope.incidentModel.place = '';
- // $scope.incidentModel.area = '';
- // }
- // // 如果回显的有联系电话,联系电话不用科室带出
- // !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (newVal&&newVal.phone)?newVal.phone:'');
- });
- // 知识库
- $scope.jry_solution = function (id,key='') {
- $scope.loading_i = true;
- var placeData = {
- idx: 0,
- sum: 1000,
- solution: {
- threeSearch:key,
- status: {id: 72},
- selectType: "keySearch",
- },
- };
- if(id){
- placeData.solution.category = {id:id};
- }
- api_user_data.fetchDataList("solution", placeData).then(function (data) {
- $scope.loading_i = false;
- $scope.jry_solutionData = data.list;
- });
- };
- // getFileFromBase64($scope.imgshows[0],'tt')
- // 图片上传
- $scope.imgshows = [];
- $scope.uploadimgs = [];
- var model = $parse("upload_img");
- var modelSetter = model.assign;
- var uploader = ($scope.uploader = new FileUploader({
- url: "/uploader",
- }));
- // uploader.filters.push({
- // name: "customFilter",
- // fn: function (item /*{File|FileLikeObject}*/, options) {
- // return this.queue.length < 10;
- // },
- // });
- $scope.getDetail = function(imgs){
- function getImageFileFromUrl(url, imageName, callback) {
- // imageName一定要带上后缀
- var blob = null
- var xhr = new XMLHttpRequest()
- xhr.open('GET', url)
- xhr.setRequestHeader('Accept', 'image/jpeg')
- xhr.responseType = 'blob'
- xhr.onload = () => {
- if (xhr.status === 200) {
- blob = xhr.response
- let imgFile = new File([blob], imageName, {type: 'image/jpeg'})
- console.log(imgFile)
- callback.call(this, imgFile)
- }
- }
- xhr.send()
- }
- imgs.forEach((v,i)=>{
- v.previewUrl = $rootScope.attachmentAddressSplicing(v.relativeFilePath);
- getImageFileFromUrl(v.previewUrl,v.name,function(file){
- var dummy = new FileUploader.FileItem(uploader, file);
- uploader.queue.push(dummy);
- getFile(file, $scope);
- })
- })
- //获得预览图地址并且把file对象放入上传合集内
- function getFile(imgupload, $scope) {
- if (!imgupload) {
- return;
- }
- fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
- console.log(result)
- $scope.imgshows.push(result);
- var file = imgupload;
- $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
- console.log($scope.imgshows, $scope.uploadimgs);
- if ($scope.imgshows.length < 3) {
- $("#upupgogo").show();
- } else {
- $("#upupgogo").hide();
- }
- });
- }
- }
- // 是否回显报修端图片
- // if(modelData){
- // if (modelData.flow) {
- // api_wechatfile
- // .listAttachment("wechatRequesterIncident", modelData.flow)
- // .then(function (res) {
- // $scope.getDetail(res.data)
- // });
- // }
- // }
- // 添加
- $scope.change = function (event) {
- var element = $(".upinp");
- modelSetter($scope, element[0].files[0]);
- //附件预览
- $scope.imgupload = event.files[0];
- getFile($scope.imgupload, $scope);
- //获得预览图地址并且把file对象放入上传合集内
- function getFile(imgupload, $scope) {
- if (!imgupload) {
- return;
- }
- fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
- console.log(result)
- $scope.imgshows.push(result);
- var file = document.querySelector("#upupgogo input[type=file]").files[0];
- $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
- console.log($scope.imgshows, $scope.uploadimgs);
- if ($scope.imgshows.length < 3) {
- $("#upupgogo").show();
- } else {
- $("#upupgogo").hide();
- }
- });
- }
- };
- // 删除
- $scope.uploadimg_del = function (index, imgs) {
- console.log(index, imgs);
- $scope.imgshows.splice(index, 1);
- $scope.uploadimgs.splice(index, 1);
- $scope.uploader.queue.splice(index, 1);
- if ($scope.imgshows.length < 3) {
- $("#upupgogo").show();
- } else {
- $("#upupgogo").hide();
- }
- };
- // 预览
- $scope.preview = function (url, idx) {
- var name = $scope.uploadimgs[idx].name;
- $modal.open({
- backdrop: false,
- templateUrl: "assets/views/customform/tpl/ui-showimage.html",
- controller: function ($scope, scope, $modalInstance) {
- //创建一个标签用来加载图片
- const image = document.createElement("img");
- image.src = url
- //待图片加载完成读取图片的真实宽高。
- image.addEventListener("load", function(e) {
- $scope.imgWidth = e.target.width + 'px';
- $scope.imgHeight = e.target.height + 'px';
- })
- $scope.title = name;
- $scope.imageurl = url;
- $scope.cancel = function () {
- $modalInstance.dismiss("cancel");
- };
- },
- resolve: {
- scope: function () {
- return $scope;
- },
- },
- });
- };
- if (uploader) {
- uploader.onWhenAddingFileFailed = function (
- item /*{File|FileLikeObject}*/,
- filter,
- options
- ) {
- console.info("onWhenAddingFileFailed", item, filter, options);
- };
- uploader.onAfterAddingFile = function (fileItem) {
- console.info("onAfterAddingFile", fileItem);
- };
- uploader.onAfterAddingAll = function (addedFileItems) {
- console.info("onAfterAddingAll", addedFileItems);
- };
- uploader.onBeforeUploadItem = function (item) {
- console.info("onBeforeUploadItem", item);
- };
- uploader.onProgressItem = function (fileItem, progress) {
- console.info("onProgressItem", fileItem, progress);
- };
- uploader.onProgressAll = function (progress) {
- console.info("onProgressAll", progress);
- };
- uploader.onSuccessItem = function (
- fileItem,
- response,
- status,
- headers
- ) {
- console.info("onSuccessItem", fileItem, response, status, headers);
- };
- uploader.onErrorItem = function (
- fileItem,
- response,
- status,
- headers
- ) {
- console.info("onErrorItem", fileItem, response, status, headers);
- };
- uploader.onCancelItem = function (
- fileItem,
- response,
- status,
- headers
- ) {
- console.info("onCancelItem", fileItem, response, status, headers);
- };
- uploader.onCompleteItem = function (
- fileItem,
- response,
- status,
- headers
- ) {
- console.info("onCompleteItem", fileItem, response, status, headers);
- };
- uploader.onCompleteAll = function () {
- console.info("onCompleteAll");
- };
- }
- // 取消
- $scope.cancel = function () {
- if (localStorage.getItem('fenjiNumber')) {
- $rootScope.jry_shixian();
- }
- $rootScope.newOrderShowOpen = false;
- $modalInstance.dismiss("cancel");
- };
- // -------------------end----------------------
- },
- resolve: {
- modelData:function(){
- return model1;
- }
- },
- });
- }
- // 事件实时播报
- $rootScope.realtimeBroadcast = function(){
- location.href = location.origin+'/#/bigScreen/realtimeBroadcast';
- // window.open(location.origin+'/#/bigScreen/realtimeBroadcast');
- }
- // save settings to local storage
- if (angular.isDefined($localStorage.layout)) {
- $scope.app.layout = $localStorage.layout;
- } else {
- $localStorage.layout = $scope.app.layout;
- }
- $scope.$watch('app.layout', function () {
- // save to local storage
- $localStorage.layout = $scope.app.layout;
- }, true);
- //global function to scroll page up
- $scope.toTheTop = function () {
- $document.scrollTopAnimated(0, 600);
- };
- // angular translate
- // ----------------------
- $scope.language = {
- // Handles language dropdown
- listIsOpen: false,
- // list of available languages
- available: {
- 'en': 'English',
- 'it_IT': 'Italiano',
- 'de_DE': 'Deutsch',
- 'zh_cn': 'Chinese'
- },
- // display always the current ui language
- init: function () {
- var proposedLanguage = $translate.proposedLanguage() || $translate.use();
- var preferredLanguage = $translate.preferredLanguage();
- // we know we have set a preferred one in app.config
- $scope.language.selected = $scope.language.available[(proposedLanguage || preferredLanguage)];
- },
- set: function (localeId, ev) {
- $translate.use(localeId);
- $scope.language.selected = $scope.language.available[localeId];
- $scope.language.listIsOpen = !$scope.language.listIsOpen;
- }
- };
- $scope.language.init();
- // Function that find the exact height and width of the viewport in a cross-browser way
- var viewport = function () {
- var e = window,
- a = 'inner';
- if (!('innerWidth' in window)) {
- a = 'client';
- e = document.documentElement || document.body;
- }
- return {
- width: e[a + 'Width'],
- height: e[a + 'Height']
- };
- };
- // function that adds information in a scope of the height and width of the page
- $scope.getWindowDimensions = function () {
- return {
- 'h': viewport().height,
- 'w': viewport().width
- };
- };
- // Detect when window is resized and set some variables
- $scope.$watch($scope.getWindowDimensions, function (newValue, oldValue) {
- $scope.windowHeight = newValue.h;
- $scope.windowWidth = newValue.w;
- if (newValue.w >= 992) {
- $scope.isLargeDevice = true;
- } else {
- $scope.isLargeDevice = false;
- }
- if (newValue.w < 992) {
- $scope.isSmallDevice = true;
- } else {
- $scope.isSmallDevice = false;
- }
- if (newValue.w <= 768) {
- $scope.isMobileDevice = true;
- } else {
- $scope.isMobileDevice = false;
- }
- }, true);
- // Apply on resize
- $win.on('resize', function () {
- $scope.$apply();
- });
- $rootScope.app.layout.isNavbarFixed = false;
- $rootScope.app.layout.isSidebarFixed = false;
- $rootScope.app.layout.isFooterFixed = false;
- $scope.login_signquick = function (Requesteruserinform) {
- $rootScope.statuscall = 1;
- $scope.loginForm = {
- username: Requesteruserinform.username,
- password: Requesteruserinform.password
- }
- $auth.submitLogin($scope.loginForm)
- .then(function (resp) {
- localStorage.setItem("jry_user", JSON.stringify(resp));
- $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
- $rootScope.isRealtimeBroadcast = ($rootScope.user && $rootScope.user.menu)?$rootScope.user.menu.some(v => v.link == 'realtimeBroadcast'):false;
- // $rootScope.userMenus = JSON.parse(localStorage.getItem("jry_user")).menu;
- var allJurisdiction = JSON.parse(localStorage.getItem("jry_user")).menu;
- var onlyMenu = [];
- for (var i = 0; i < allJurisdiction.length; i++) {
- if (allJurisdiction[i].event == "1") {
- onlyMenu.push(allJurisdiction[i])
- }
- };
- $rootScope.userMenus = onlyMenu;
- getMenus();
- if (resp.error != 500) {
- // $state.go('app.dashboard');
- $rootScope.app.isLoginFixed = false;
- } else {
- resp.error = "";
- $scope.loginForm.password = "";
- SweetAlert.swal("用户名或者密码验证失败,请重试!", "error");
- }
- })
- .catch(function (resp) {
- $scope.loginForm.password = "";
- SweetAlert.swal("系统错误,请重试!", "登录错误", "error");
- });
- }
- var url = location.hash; //获取url中"?"符后的字串 var index=obj.lastIndexOf("\-");
- var theRequest = {};
- var index = url.substring(index + 1, url.length).lastIndexOf("\?");
- if (url.indexOf("?") != -1 && url.indexOf("fixed_list")) {
- var str = url.substr(index + 1);
- var strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
- }
- // return theRequest;
- $scope.login_signquick(theRequest)
- }
- // $scope.casUserId = window.location.search;
- // $scope.loginForm = {
- // username: theRequest[0].split("=")[1],
- // password: theRequest[1].split("=")[1]
- // }
- // $scope.lodingstyle = 'nodata';
- var userAgent = window.navigator.userAgent.toLowerCase();
- var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
- var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
- var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
- var isSafari = userAgent.indexOf("Safari") > -1; //判断是否Safari浏览器
- var isChrome = userAgent.indexOf("chrome") > -1; //判断是否Safari浏览器
- if (isOpera) {
- $scope.checkchrome = '当前所用浏览器是Opera浏览器,';
- // return alert("访问失败,当前所用浏览器是Opera浏览器,请用Chrome浏览器访问!");
- }
- if (isIE) {
- $scope.checkchrome = '当前所用浏览器是IE浏览器,';
- // return alert("访问失败,当前所用浏览器是IE浏览器,请用Chrome浏览器访问!");
- }
- if (isFF) {
- $scope.checkchrome = '当前所用浏览器是火狐浏览器,';
- // return alert("访问失败,当前所用浏览器是火狐浏览器,请用Chrome浏览器访问!");
- }
- if (isSafari) {
- $scope.checkchrome = '当前所用浏览器是Safari浏览器,';
- // return alert("访问失败,当前所用浏览器是Safari浏览器,请用Chrome浏览器访问!");
- }
- if (isChrome) {
- // login_sign();
- $rootScope.app.isChrome = false;
- // return alert("访问失败,当前所用浏览器是Chrome浏览器");
- } else {
- $rootScope.app.isChrome = true;
- $scope.checkchrome = '';
- // return alert("访问失败,请用Chrome浏览器访问!");
- }
- // }
- // $scope.handleloginEnter = function(e) {
- // if (e.keyCode == 13) {
- // $scope.handleLoginClick();
- // }
- // };
- // if (document.getElementById("isWatch").value == "true") {
- // $scope.isHanderuser = true;
- // } else {
- // if (!JSON.parse(sessionStorage.getItem('header'))) {
- // $scope.isHanderuser = false;
- // $scope.login_sign();
- // }
- // }
- // $scope.viewType = "password";
- // $scope.isPassword = true;
- // $scope.toggleView = function() {
- // $scope.isPassword = !$scope.isPassword;
- // $scope.viewType = $scope.isPassword ? "password" : "text";
- // }
- // $scope.handleSignOutBtnClick = function() {
- // $auth.signOut()
- // .then(function(resp) {
- // // handle success response
- // })
- // .catch(function(resp) {
- // // handle error response
- // });
- // };
- // }
- // }
- // if (!isEmpty($auth.retrieveData('auth_headers'))) {
- // } else {
- // $scope.loginstart();
- // }
- //websocket 信息中心
- console.log(atmosphere)
- var socket = atmosphere;
- var subSocket;
- // We are now ready to cut the request
- var request = {
- url: 'ws://192.168.199.150:8080/messagestation/cache',
- contentType: "application/json",
- shared: true, // 标签共享
- trackMessageLength: true, //校验数据完整性
- transport: 'websocket'
- };
- // subSocket = socket.subscribe(request);暂时注释,不知道干啥的
- request.onOpen = function (response) {
- console.log(response)
- subSocket.push(JSON.stringify({ login: $rootScope.user.id }));
- // alert("开始连接")
- };
- request.onMessage = function (response) {
- var message = response.responseBody;
- // alert("连接成功")
- console.log(message)
- try {
- var json = JSON.parse(message);
- console.log(json.noRead)
- $scope.noReadData = json.noRead
- } catch (e) {
- console.log('呵呵哒: ', message);
- return;
- }
- };
- request.onClose = function (response) {
- // alert("连接结束")
- }
- request.onError = function (response) {
- // alert('连接失败')
- };
- //信息中心模态框
- var loginUser = $rootScope.user;
- // if(loginUser){
- // // 未读消息数量
- // api_msg.msgDataList({idx: 0, sum: 1, messageStation: {readStatus: 0, userId: loginUser.id}}).then(function(data) {
- // if (data.status == 200) {
- // $scope.noReadData=data.totalNum
- // // $rootScope.option.all = $rootScope.all;
- // } else {
- // $scope.noReadData=0
- // }
- // })
- // }
- // $scope.noReadData=($rootScope.noReadData||0)
- // // $rootScope.all = 5;
- // setTimeout(function() {
- // console.log($scope.noReadData)
- // }, 500)
- $rootScope.wt_messages = function () {
- var modalInstance = $modal.open({
- templateUrl: '../../../assets/views/wt_messages.html',
- controller: function ($scope, $modalInstance, SweetAlert) {
- $rootScope.msgData = {
- idx: 0,
- sum: 5,
- messageStation: {
- readStatus: 0,
- userId: $rootScope.user.id
- }
- }
- // 关闭
- $scope.closeModel = function () {
- modalInstance.close();
- }
- $scope.getMsgData = function () {
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- if (data) {
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $scope.wt_msgData = data
- $rootScope.noReadData = data.totalNum
- }
- })
- }
- $scope.getMsgData()
- $scope.message_type = 2;
- $scope.message_no = function (type) { //未读1
- $scope.wt_msgData = {};
- $scope.message_type = type;
- $rootScope.msgData.messageStation.readStatus = 0,
- // $rootScope.option.curr = 1;
- $rootScope.msgData.idx = 0;
- // console.log($rootScope.option.curr)
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $scope.msg_yesType = true;
- if (data.status == 200) {
- $scope.msg_yesType = false
- $scope.wt_msgData = data
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $rootScope.noReadData = data.totalNum;
- // $rootScope.option.all = $rootScope.all;
- } else {
- $scope.msg_yesType = true;
- }
- })
- }
- $scope.message_yes = function (type) { //已读0
- $scope.wt_msgData = {};
- $scope.message_type = type;
- $rootScope.msgData.messageStation.readStatus = 1,
- $rootScope.msgData.idx = 0;
- // $rootScope.option.curr = 1;
- // console.log($rootScope.option.curr)
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $scope.msg_noType = true;
- if (data.status == 200) {
- $scope.msg_noType = false
- $scope.wt_msgData = data
- $rootScope.msg = data.list;
- $rootScope.all = data.pageCount;
- // $rootScope.option.all = $rootScope.all;
- } else {
- $scope.msg_noType = true
- }
- })
- };
- $scope.sBtn = function () {
- // console.log($rootScope.msgData)
- // console.log($scope.wt_msgData)
- $rootScope.msgData.idx = $rootScope.msgData.idx - 1;
- console.log($rootScope.msgData)
- $scope.getMsgData()
- }
- $scope.xBtn = function () {
- // console.log($rootScope.msgData)
- // console.log($scope.wt_msgData)
- $rootScope.msgData.idx = $rootScope.msgData.idx + 1;
- console.log($rootScope.msgData)
- $scope.getMsgData()
- }
- $scope.redIn = function (data) {
- var start = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
- $scope.messageStation = {
- messageStation: {
- id: data.id,
- readStatus: 1,
- readTime: start
- }
- }
- api_msg.updateDataList($scope.messageStation).then(function (data) {
- console.log(data);
- if (data.status == 200) {
- $rootScope.msgData.messageStation.readStatus = 0,
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $rootScope.noReadData = data.totalNum;
- })
- }
- })
- };
- // 一键已读
- $scope.redAllIn = function () {
- SweetAlert.swal({
- title: "是否确认?",
- type: "warning",
- showCancelButton: true,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- closeOnConfirm: true,
- closeOnCancel: true
- }, function (isConfirm) {
- if (isConfirm) {
- $rootScope.isMask = true;
- api_msg.oneClickRead({userId: $rootScope.user.id}).then(function (data) {
- $rootScope.isMask = false;
- if (data.status == 200) {
- $rootScope.msgData.messageStation.readStatus = 0,
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $scope.wt_msgData = data
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $rootScope.noReadData = data.totalNum;
- })
- }
- })
- } else {}
- });
- };
- },
- size: 'lg',
- resolve: {
- }
- })
- }
- }
- ]);
- // 录音盒子
- app.service('WebsocketPhoneService', function () {
- return {
- lockReconnect: false, //避免ws重复连接
- ws: null, //定义websocket
- url: "", //ws连接地址
- urlParams: null, //ws连接传参
- isHandler: false, //是否手动
- subject: null,
- reconnectTimer: null,//重连的计时器
- // 连接websocket
- connectWs(url, data) {
- this.url = url;
- this.urlParams = data;
- this.subject = new rxjs.Subject();
- let request = {
- webSocketUrl: url,
- trackMessageLength: true, //校验数据完整性
- transport: "websocket",
- handleOnlineOffline: false,
- suspend: false,
- maxReconnectOnClose: 0,
- };
- request.onOpen = (response) => {
- console.log("ws连接成功" + new Date().toLocaleString());
- this.heartCheck.reset().start(this);
- console.log(response);
- this.ws.push(JSON.stringify(data));
- };
- request.onMessage = (response) => {
- this.heartCheck.reset().start(this);
- let message = response.responseBody;
- try {
- console.log("收到消息" + message);
- if (message !== "pong") {
- this.subject.next(JSON.parse(message));
- }
- } catch (e) {
- console.log("This doesn't look like a valid JSON: ", message);
- return;
- }
- };
- request.onClose = (response) => {
- console.log("ws连接关闭" + new Date().toLocaleString(), this.isHandler);
- this.ws = null;
- console.log(response)
- if (!this.isHandler && response.status === 408) {
- this.reconnect(this.url, this.urlParams);
- }
- };
- request.onError = (response) => {
- console.log("ws连接错误", this.isHandler);
- this.ws = null;
- if (response.status === 0) {
- this.reconnect(this.url, this.urlParams);
- }
- };
- this.ws = atmosphere.subscribe(request);
- return this.subject.asObservable();
- },
- //断线重连
- reconnect(url, data) {
- if (this.lockReconnect) return;
- this.lockReconnect = true;
- this.reconnectTimer = setTimeout(() => {
- //没连接上会一直重连,设置延迟避免请求过多
- this.connectWs(url, data);
- this.lockReconnect = false;
- }, 15000);
- },
- heartCheck: {
- timeout: 30000, //发一次心跳的间隔时间
- timeoutObj: null,
- serverTimeoutObj: null,
- reset: function () {
- clearTimeout(this.timeoutObj);
- clearTimeout(this.serverTimeoutObj);
- return this;
- },
- start: function (_this) {
- this.timeoutObj = setTimeout(() => {
- //这里发送一个心跳,后端收到后,返回一个心跳消息,
- //onmessage拿到返回的心跳就说明连接正常
- if (_this.ws) {
- _this.ws.push("ping");
- }
- this.serverTimeoutObj = setTimeout(() => {
- //如果超过一定时间还没重置,说明后端主动断开了
- _this.closeWs(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
- }, this.timeout);
- }, this.timeout);
- },
- },
- // 断开websocket
- closeWs(flag = false) {
- this.isHandler = flag;
- if (flag) {
- clearTimeout(this.reconnectTimer);
- }
- if (this.ws) {
- this.ws.close();
- }
- }
- };
- });
- //消息中心分页组件
- app.controller('msgCtrl', ['$scope', '$rootScope', 'api_msg', 'Myservice', function ($scope, $rootScope, api_msg, Myservice) {
- $rootScope.option = {
- curr: 1, //当前页数
- all: $rootScope.all, //总页数
- count: 5, //最多显示的页数,默认为10
- //点击页数的回调函数,参数page为点击的页数
- click: function (page) {
- $rootScope.msgData.idx = page - 1;
- //这里可以写跳转到某个页面等...
- api_msg.msgDataList($rootScope.msgData).then(function (data) {
- $rootScope.msg = data.list
- $rootScope.all = data.pageCount;
- $rootScope.option.all = $rootScope.all;
- })
- }
- }
- }]);
- app.directive('myPagination', function () {
- return {
- restrict: 'EA',
- replace: true,
- rootScope: {
- option: '=pageOption'
- },
- controller: 'msgCtrl',
- template: '<ul class="pagination">' +
- '<li ng-click="pageClick(p)" ng-repeat="p in page" class="{{option.curr==p?\'active\':\'\'}}">' +
- '<a href="javascript:;">{{p}}</a>' +
- '</li>' +
- '</ul>',
- link: function ($rootScope) {
- //容错处理
- if (!$rootScope.option.curr || isNaN($rootScope.option.curr) || $rootScope.option.curr < 1) $rootScope.option.curr = 1;
- if (!$rootScope.option.all || isNaN($rootScope.option.all) || $rootScope.option.all < 1) $rootScope.option.all = 1;
- if ($rootScope.option.curr > $rootScope.option.all) $rootScope.option.curr = $rootScope.option.all;
- if (!$rootScope.option.count || isNaN($rootScope.option.count) || $rootScope.option.count < 1) $rootScope.option.count = 10;
- //得到显示页数的数组
- $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
- //绑定点击事件
- $rootScope.pageClick = function (page) {
- if (page == '«') {
- page = parseInt($rootScope.option.curr) - 1;
- } else if (page == '»') {
- page = parseInt($rootScope.option.curr) + 1;
- }
- if (page < 1) page = 1;
- else if (page > $rootScope.option.all) page = $rootScope.option.all;
- //点击相同的页数 不执行点击事件
- if (page == $rootScope.option.curr) return;
- if ($rootScope.option.click && typeof $rootScope.option.click === 'function') {
- $rootScope.option.click(page);
- $rootScope.option.curr = page;
- $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
- }
- };
- //返回页数范围(用来遍历)
- function getRange(curr, all, count) {
- //计算显示的页数
- // console.log(curr, all, count)
- curr = parseInt(curr);
- all = parseInt(all);
- count = parseInt(count);
- var from = curr - parseInt(count / 2);
- var to = curr + parseInt(count / 2) + (count % 2) - 1;
- //显示的页数容处理
- if (from <= 0) {
- from = 1;
- to = from + count - 1;
- if (to > all) {
- to = all;
- }
- }
- if (to > all) {
- to = all;
- from = to - count + 1;
- if (from <= 0) {
- from = 1;
- }
- }
- var range = [];
- for (var i = from; i <= to; i++) {
- range.push(i);
- }
- range.push('»');
- range.unshift('«');
- return range;
- }
- }
- }
- });
- app.service('Myservice', function () {
- return {
- };
- });
- // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
- // console.log(bh)
- // if(bh>=0&&bh<=53){
- // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
- // }else{
- // $('#sidebar').css('padding-bottom', 0 + 'px')
- // }
- window.onscroll = function () {
- if (window.pageYOffset >= 0 && window.pageYOffset <= 65) {
- $('#sidebar').css('padding-top', (65 - window.pageYOffset) + 'px')
- } else {
- $('#sidebar').css('padding-top', '0')
- }
- // console.log(window.pageYOffset)
- // console.log(window.innerHeight)
- // console.log(document.body.scrollHeight)
- // 底部padding
- // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
- // console.log(bh)
- // if(bh>=0&&bh<=53){
- // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
- // }else{
- // $('#sidebar').css('padding-bottom', 0 + 'px')
- // }
- }
|