mainCtrl.js 276 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269
  1. 'use strict';
  2. /**
  3. * Clip-Two Main Controller
  4. */
  5. app.controller('AppCtrl', ['$rootScope', '$scope', '$state', '$translate', '$localStorage', '$cookieStore', '$window', '$modal', '$document', '$timeout', '$filter', '$auth', 'cfpLoadingBar', 'DDP', 'deskNotification', 'Restangular', 'api_login', 'api_text', 'api_user_data', 'api_wechatfile', 'api_bpm_data', 'api_msg', 'Myservice', '$interval', 'jry_api_bpm','fileReader','api_custom','api_category','api_simple','WebsocketPhoneService','api_newreport', 'api_flow',
  6. function ($rootScope, $scope, $state, $translate, $localStorage, $cookieStore, $window, $modal, $document, $timeout, $filter, $auth, cfpLoadingBar, DDP, deskNotification, Restangular, api_login, api_text, api_user_data, api_wechatfile, api_bpm_data, api_msg, Myservice, $interval, jry_api_bpm,fileReader,api_custom,api_category,api_simple,WebsocketPhoneService,api_newreport,api_flow) {
  7. // 未读消息数量seimin
  8. $rootScope.getMsgNum = function (id) {
  9. api_msg.msgDataList({ idx: 0, sum: 1, messageStation: { readStatus: 0, userId: id } }).then(function (data) {
  10. if (data.status == 200) {
  11. $rootScope.noReadData = data.totalNum;
  12. }
  13. return $rootScope.noReadData
  14. })
  15. }
  16. // Loading bar transition
  17. // -----------------------------------
  18. // console.log("haha");
  19. // 附件地址拼接-全局
  20. $rootScope.attachmentAddressSplicing = function(relativeFilePath){
  21. return location.origin + '/file' + relativeFilePath;
  22. }
  23. $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
  24. $rootScope.isRealtimeBroadcast = ($rootScope.user && $rootScope.user.menu)?$rootScope.user.menu.some(v => v.link == 'realtimeBroadcast'):false;
  25. $rootScope.isFuwutai = JSON.parse(localStorage.getItem("isFuwutai")) ? true : false;
  26. console.log($rootScope.user)
  27. //判断项目归属 start
  28. //因项目众多,前端为了加以区分,所以用域名加以判断,后期有更好的方式可以自行修改
  29. $rootScope.judgeHjzx = function(isMask = false, isStart = false){
  30. if(!$rootScope.user){
  31. return;
  32. }
  33. $rootScope.isZncd = false;
  34. $rootScope.isHk = false;
  35. $rootScope.isXy = false;
  36. $rootScope.isXyBox = false;
  37. var branchId;
  38. // 当前所属院区或责任科室
  39. if($rootScope.user.duty){
  40. branchId = $rootScope.user.duty.branch;
  41. }else if($rootScope.user.branch){
  42. branchId = $rootScope.user.branch.id;
  43. }
  44. if(isMask){
  45. $rootScope.isMask = true;
  46. }
  47. api_simple.fetchDataList("hospitalConfig", {"idx":0,"sum":100,"hospitalConfig":{"hosId":branchId}}).then(function(result){
  48. if(isMask){
  49. $rootScope.isMask = false;
  50. }
  51. if(result.status = 200){
  52. var hospitalConfig = result.list || [];
  53. var ccTypeDTO = hospitalConfig.find(function(v){return v.key == 'ccType'});
  54. // 暂无 1
  55. // 东进呼叫中心 2
  56. // 申欧录音盒子 3
  57. $rootScope.isXy = ccTypeDTO && ccTypeDTO.value == 2;
  58. $rootScope.isXyBox = ccTypeDTO && ccTypeDTO.value == 3;
  59. if($rootScope.isZncd){
  60. localStorage.setItem('version_qd','isZncd');
  61. }else if($rootScope.isHk){
  62. localStorage.setItem('version_qd','isHk');
  63. }else if($rootScope.isXy){
  64. localStorage.setItem('version_qd','isXy');
  65. }else if($rootScope.isXyBox){
  66. $rootScope.phoneNumList = hospitalConfig.filter(function(v){return v.key.includes('phone_num_port') && v.value}).map(function(v){return {value: v.value, checked: false}});
  67. $rootScope.phoneNumListBind.forEach((item) => {
  68. let obj = $rootScope.phoneNumList.find((item1) => item1.value === item);
  69. if (obj) {
  70. obj.checked = true;
  71. }
  72. });
  73. $rootScope.phoneNumListSelected = $rootScope.phoneNumList.filter(v => v.checked).map(v => v.value);
  74. $rootScope.phoneNumListSelectedStr = $rootScope.phoneNumListSelected.length ? '您选择了'+ $rootScope.phoneNumListSelected.map(v => '‘'+ v +'’').join('') +'号码,可在下方选择后确认更新。' : '请选择分机';
  75. console.log($rootScope.phoneNumList, 'phoneNumList');
  76. console.log($rootScope.phoneNumListBind, 'phoneNumListBind');
  77. localStorage.setItem('version_qd','isXyBox');
  78. }else{
  79. localStorage.removeItem('version_qd');
  80. }
  81. // 1是老的呼叫中心
  82. // 2是财大2021年12月29日新增的呼叫中心
  83. // 3是华科新增的呼叫中心
  84. // 4是支助紫铜录音盒子
  85. console.log($rootScope.isHk,'hk')
  86. console.log($rootScope.isZncd,'zncd')
  87. console.log($rootScope.isXy,'xy')
  88. console.log($rootScope.isXyBox,'xyBox')
  89. if($rootScope.isZncd || $rootScope.isXy){
  90. $rootScope.seiminHj = 2;
  91. }else if($rootScope.isXyBox){
  92. $rootScope.seiminHj = 4;
  93. }else if($rootScope.isHk){
  94. $rootScope.seiminHj = 3;
  95. }else{
  96. // $rootScope.seiminHj = 1;
  97. }
  98. if (isStart && $rootScope.isFuwutai && ($rootScope.isXy || $rootScope.isXyBox)) {
  99. console.log($rootScope.seiminHj, 'seiminHj');
  100. $rootScope.getExtnDirect();//seiminHj----1
  101. }
  102. }
  103. })
  104. }
  105. // $rootScope.judgeHjzx();
  106. //判断项目归属 end
  107. var loginUser = $rootScope.user;
  108. if(loginUser){
  109. $scope.allFlag = false;//全部事件
  110. for (var i = 0; i < loginUser.menu.length; i++) {
  111. if (loginUser.menu[i].link == "shijianliebiao_all") {
  112. $scope.allFlag = true
  113. }
  114. }
  115. }
  116. if ($rootScope.user) {
  117. $rootScope.getMsgNum($rootScope.user.id);
  118. }
  119. var $win = $($window);
  120. $rootScope.isMask = false;
  121. window.onbeforeunload = function () {
  122. $rootScope.statuscall = 0;
  123. $rootScope.statecall = 1;
  124. }
  125. // 所有列表自动刷新
  126. $rootScope.refreshTime = 60000;
  127. $interval(function () {
  128. $scope.jry_year = new Date().getFullYear();
  129. $scope.jry_month = new Date().getMonth() + 1;
  130. $scope.jry_data = new Date().getDate();
  131. $scope.jry_hours = new Date().getHours();
  132. $scope.jry_minute = new Date().getMinutes();
  133. $scope.jry_second = new Date().getSeconds();
  134. // console.log($scope.jry_month)
  135. }, 1000)
  136. // $win.on('beforeunload', function() { return $state.go("login.signin"); });
  137. // $auth.deleteData('auth_headers')
  138. // }
  139. // 监听路由
  140. $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
  141. var loginUser = $rootScope.user;
  142. if(loginUser){
  143. $scope.allFlag = false;//全部事件
  144. for (var i = 0; i < loginUser.menu.length; i++) {
  145. if (loginUser.menu[i].link == "shijianliebiao_all") {
  146. $scope.allFlag = true
  147. }
  148. }
  149. }
  150. console.log(event, toState, toParams, fromState, fromParams)
  151. // 请求首页统计
  152. if(toState.name != 'login.signin'){
  153. $rootScope.getOrderCount();
  154. // 判断首页统计页面是否显示
  155. // if($rootScope.user.role.length){
  156. // $scope.isShowTj = $rootScope.user.role.some(function(v){
  157. // return v.rolecode === "incident-category-manager" || v.rolecode === "incident manager";
  158. // })
  159. // }else{
  160. // $scope.isShowTj = false;
  161. // }
  162. }
  163. if($rootScope.isZncd || $rootScope.isXy){
  164. // 中南财大
  165. if ((toState.name == 'app.incident.chart' || toState.name == 'app.incident.editor') &&
  166. fromState.name) {
  167. console.log($rootScope.jry_state);
  168. $scope.isShixian = false;
  169. if($rootScope.jry_state == 'shixian'){
  170. $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
  171. //进入页面强制示忙
  172. if (tlwsa) {
  173. // tlwsa.tlaForceacw($rootScope.phoneNumber);
  174. setTimeout(()=>{
  175. tlwsa.tlaAcw();
  176. },0)
  177. }
  178. }
  179. }
  180. if ((fromState.name == 'app.incident.chart' || fromState.name == 'app.incident.editor') &&
  181. toState.name != 'app.incident.chart' && toState.name != 'app.incident.editor'
  182. ) {
  183. console.log($rootScope.jry_state);
  184. // $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
  185. //进入页面强制示闲
  186. $scope.isShixian = true;
  187. // if (tlwsa) {
  188. // // tlwsa.tlaForcewca($rootScope.phoneNumber);
  189. // tlwsa.tlaWca();
  190. // }
  191. }
  192. }else if($rootScope.isHk){
  193. if (toState.name != "app.incident.editor" && toState.name != "echart") {
  194. if ($rootScope.status == 2 || $rootScope.status == 4 || $rootScope.status == 9) {
  195. $rootScope.setidle();
  196. }
  197. }
  198. if (toState.name != "app.incident.editor" && toState.name != "app.incident.title") {
  199. if ($scope.login && $rootScope.statecall == 2 && !$rootScope.busy) {
  200. $rootScope.setidle();
  201. }
  202. } else {
  203. if ($scope.login && !$rootScope.busy) {
  204. $rootScope.setbusy();
  205. }
  206. // $rootScope.isMask = true;
  207. }
  208. }
  209. if (isEmpty($auth.retrieveData('auth_headers'))) {
  210. // if (toState.name != "login.signin" && toState.name != "echart") {
  211. // event.preventDefault();
  212. // $rootScope.app.isLoginFixed = true;
  213. // // $scope.lodingstyle = 'nodata';
  214. // return $state.go("login.signin");
  215. // }
  216. }
  217. // if (toState.name == "app.system.user.user") {
  218. // var isgoto = false;
  219. // if ($rootScope.user && $rootScope.user.menu) {
  220. // angular.forEach($rootScope.user.menu, function(item) {
  221. // if (item.link == toState.name) {
  222. // isgoto = true;
  223. // } else {}
  224. // })
  225. // }
  226. // if (isgoto) {
  227. // } else {
  228. // $state.go("app.dashboard");
  229. // }
  230. // }
  231. // if (toState.name != "app.incident.editor" && toState.name != "echart") {
  232. // if ($rootScope.status == 2 || $rootScope.status == 4 || $rootScope.status == 9) {
  233. // $rootScope.setidle();
  234. // }
  235. // }
  236. cfpLoadingBar.start();
  237. $auth.validateUser();
  238. });
  239. $rootScope.imUsrMap = {};
  240. $rootScope.onlineUser = [];
  241. $rootScope.offlineUser = [];
  242. $rootScope.me = undefined;
  243. $rootScope.imscope = {
  244. sessions: []
  245. }
  246. // var ws = new WebSocket('ws://192.168.3.51:8088/events');
  247. // var register= {"msgtype":"login","adn":"1001"};
  248. // ws.onopen = function() { ws.send(JSON.stringify(register));}
  249. // ws.onmessage = function(evt) { console.log(evt.data) }
  250. var ddp = new DDP('ws://115.156.150.70:3000/websocket');
  251. $rootScope.getDirectMsgRoomId = function (mdId, toId) {
  252. //me.id,to.id
  253. var rid = [mdId, toId].sort().join('');
  254. return rid;
  255. };
  256. $rootScope.sendMessage = function (rid, msg, callback, error) {
  257. ddp.call('sendMessage', [{ 'rid': rid, 'msg': msg }]).then(callback, error);
  258. };
  259. var pushNotification = function (notification) {
  260. deskNotification.showNotification(notification.title, {
  261. body: notification.body,
  262. icon: notification.icon || '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  263. onClick: notification.callback || function onNotificationClicked() {
  264. // console.log('Notification clicked.');
  265. },
  266. autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)
  267. }, function onShow(error, hide) {
  268. if (error) {
  269. window.alert('Unable to show notification: ' + error.message);
  270. } else {
  271. // console.log('Notification Shown.');
  272. setTimeout(function hideNotification() {
  273. // console.log('Hiding notification....');
  274. hide(); //manually close the notification (you can skip this if you use the autoClose option)
  275. }, 5000);
  276. }
  277. });
  278. }
  279. // $rootScope.subscribeRoomMessage = function(rid){
  280. // ddp.subscribe('stream-room-messages',[rid, true]).then(function(){},function(reason){
  281. // console.log('subscribe stream-room-messages:%o', reason);
  282. // });
  283. // }
  284. $rootScope.filternotifyuser = [];
  285. $rootScope.$on('openroom', function (event, data, otheruser) {
  286. ddp.call('createDirectMessage', [otheruser]).then(function () { }, function (reason) {
  287. // console.log('createDirectMessage', reason);
  288. });
  289. ddp.subscribe('stream-room-messages', [data.rid, true]).then(function () { }, function (reason) {
  290. // console.log('subscribe stream-room-messages:%o', reason);
  291. });
  292. if ($rootScope.imUsrMap[data.from]['unread'].msgs) {
  293. $rootScope.imUsrMap[data.from]['unread'].msgs.clear;
  294. }
  295. $rootScope.filternotifyuser.push(data.from);
  296. });
  297. $rootScope.$on("clip-two.toggled", function (e, target, newState, sameGroup) {
  298. console.log(newState)
  299. if (newState == false && target == 'off-sidebar') {
  300. $rootScope.$broadcast('chatcloseroom');
  301. $rootScope.judgeHjzx();
  302. //$rootScope.toggle("users");
  303. //$rootScope.filternotifyuser = [];
  304. //ddp.unsubscribe('stream-room-messages');
  305. }
  306. });
  307. $rootScope.$on("closeroom", function (event, data) {
  308. $rootScope.filternotifyuser = [];
  309. ddp.unsubscribe('stream-room-messages');
  310. });
  311. var initImUser = function (email, token) {
  312. var ddpconnect = ddp.connect();
  313. ddpconnect.then(function (data) {
  314. //console.log(data);
  315. if (data.session) {
  316. // ddp.call('createDirectMessage', [data.from, data.rid]).then(function() {}, function(reason) {
  317. // console.log('subscribe createDirectMessage');
  318. // });
  319. ddp.call('login', [{ user: { email: email }, password: token }]).then(function (data) {
  320. // console.log('login data: %o', data);
  321. if (data.id) {
  322. $rootScope.me = {
  323. id: data.id,
  324. token: data.token,
  325. expiry: data.tokenExpires
  326. };
  327. //获取在线用户
  328. ddp.subscribe('activeUsers');
  329. ddp.subscribe('stream-notify-user', [$rootScope.me.id + '/notification', true]).then(function (result) {
  330. //console.log(result);
  331. }, function (reason) {
  332. // console.log('stream-notify-user error:%s', reason);
  333. });
  334. // ddp.subscribe('stream-notify-user',[$rootScope.me.id+'/message',false]).then(function(result){
  335. // console.log(result);
  336. // },function(reason){
  337. // console.log('stream-notify-user error:', reason);
  338. // });
  339. ddp.subscribe('messages', [$rootScope.me.id + '/message', true]).then(function () { }, function (reason) {
  340. // console.log('subscribe messages error:%s', reason);
  341. });
  342. //'stream-notify-user',$rootScope.me.id+'/message'
  343. // ddp.call('sendmessage', []).then(function(msg){
  344. // })
  345. //console.log('Logged in!');
  346. // ddp.subscribe('messages', [{rid:data.id,start:new Date()}]).then(function(submsg){
  347. // console.log('subscribe messages-%s', submsg);
  348. // $rootScope.rocketchat_message = ddp.getCollection('rocketchat_message');
  349. // },function(reason){
  350. // console.log(reason);
  351. // })
  352. }
  353. }, function (reason) {
  354. // console.log(reason);
  355. });
  356. } else {
  357. }
  358. ddp.watch('users', function (changedDoc, message) {
  359. //console.log('users:%o',changedDoc);
  360. // if (message == 'method') {
  361. // console.log("1111111111111111111")
  362. // }
  363. if (message == 'added') {
  364. if (changedDoc.status && ($rootScope.me.id != changedDoc._id)) {
  365. if (changedDoc.status == 'away') {
  366. $rootScope.offlineUser.push(changedDoc);
  367. $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
  368. } else {
  369. $rootScope.onlineUser.push(changedDoc);
  370. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
  371. }
  372. } else {
  373. //self
  374. }
  375. } else if (message == 'changed') {
  376. if ($rootScope.me.id != changedDoc._id) {
  377. if (!$rootScope.imUsrMap[changedDoc._id]) {
  378. if (changedDoc.status == 'away') {
  379. $rootScope.offlineUser.push(changedDoc);
  380. $rootScope.imUsrMap[changedDoc._id] = { state: 'away', username: changedDoc.username, index: $rootScope.offlineUser.length - 1, unread: { total: 0, msgs: [] } };
  381. } else {
  382. $rootScope.onlineUser.push(changedDoc);
  383. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length - 1, unread: { total: 0, msgs: [] } };
  384. }
  385. }
  386. if (changedDoc.status == 'away') {
  387. if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
  388. } else {
  389. $rootScope.offlineUser.push(changedDoc);
  390. $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  391. window._.map(window._.slice($rootScope.onlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
  392. $rootScope.imUsrMap[item._id].index = n;
  393. })
  394. // $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){
  395. // item.index = item.index - 1;
  396. // }))
  397. //.splice($rootScope.imUsrMap[changedDoc.id].index,1);
  398. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.offlineUser.length };
  399. }
  400. } else {
  401. if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
  402. $rootScope.onlineUser.push(changedDoc);
  403. $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  404. window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
  405. $rootScope.imUsrMap[item._id].index = n;
  406. })
  407. // $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){
  408. // item.index = item.index - 1;
  409. // }))
  410. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length };
  411. } else {
  412. }
  413. }
  414. }
  415. } else if (message == 'removed') {
  416. if ($rootScope.imUsrMap[changedDoc._id].state == 'away') {
  417. } else {
  418. $rootScope.onlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  419. $rootScope.offlineUser.splice($rootScope.imUsrMap[changedDoc._id].index, 1);
  420. window._.map(window._.slice($rootScope.offlineUser, $rootScope.imUsrMap[changedDoc._id].index), function (item, n) {
  421. $rootScope.imUsrMap[item._id].index = n;
  422. });
  423. $rootScope.imUsrMap[changedDoc._id] = { state: changedDoc.status, username: changedDoc.username, index: $rootScope.onlineUser.length, unread: { total: 0, msgs: [] } };
  424. }
  425. }
  426. });
  427. ddp.watch('stream-notify-user', function (changedDoc, message) {
  428. if (message == 'changed') {
  429. if (changedDoc.eventName) {
  430. if (changedDoc.eventName.indexOf('/') > -1) {
  431. // var [mineId, action] = changedDoc.eventName.split('/');
  432. var mineId = changedDoc.eventName.split('/');
  433. var action = mineId;
  434. if (action == 'notification') {
  435. angular.forEach(changedDoc.args, function (item) {
  436. if ($rootScope.filternotifyuser.indexOf(item.payload.sender._id) > -1) {
  437. } else {
  438. // console.log("push notify message:%o", item);
  439. var r = angular.extend(item, { 'date': new Date() })
  440. $rootScope.imUsrMap[item.payload.sender._id]['unread'].msgs.push(r);
  441. $rootScope.imUsrMap[item.payload.sender._id]['unread'].total++;
  442. pushNotification({
  443. title: "您有新消息-来自" + item.payload.sender.username,
  444. body: r.text,
  445. callback: function () {
  446. window.focus();
  447. $rootScope.toggle('off-sidebar');
  448. }
  449. })
  450. //toaster.pop('info', "您有新消息-来自"+item.payload.sender.username, r.text);
  451. }
  452. })
  453. }
  454. }
  455. }
  456. } else {
  457. }
  458. //console.log('notify message %o, %o', changedDoc, message);
  459. });
  460. ddp.watch('stream-room-messages', function (changedDoc, message) {
  461. if (message == 'changed') {
  462. //angular.forEach(changedDoc.args,function(item){
  463. $rootScope.$broadcast(changedDoc.eventName + '-msgs', changedDoc.args);
  464. //};
  465. // if(changedDoc.eventName){
  466. // $rootScope.imUsrMap[eventName]=$rootScope.imUsrMap[eventName]||{};
  467. // $rootScope.imUsrMap[eventName]['msgs']=$rootScope.imUsrMap[eventName]['msgs']||[];
  468. // angular.forEach(changedDoc.args,function(item){
  469. // $rootScope.imUsrMap[eventName].msgs.push(item);
  470. // })
  471. // }
  472. } else {
  473. }
  474. // console.log('notify message %o, %o', changedDoc, message);
  475. });
  476. ddp.watch('rocketchat_message', function (changedDoc, message) {
  477. // console.log('recieve rocketchat_message: %o-%o', changedDoc, message);
  478. });
  479. });
  480. }
  481. window.onunload = function () {
  482. }
  483. $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
  484. //$auth.validateUser();
  485. //stop loading bar on stateChangeSuccess
  486. event.targetScope.$watch("$viewContentLoaded", function () {
  487. cfpLoadingBar.complete();
  488. });
  489. // scroll top the page on change state
  490. $document.scrollTo(0, 0);
  491. if (angular.element('.email-reader').length) {
  492. angular.element('.email-reader').animate({
  493. scrollTop: 0
  494. }, 0);
  495. }
  496. // Save the route title
  497. $rootScope.currTitle = $state.current.title;
  498. if (angular.isDefined($state.current.pdKey)) {
  499. $rootScope.pdKey = $state.current.pdKey;
  500. }
  501. // console.log($state.current.title);
  502. });
  503. // State not found
  504. $rootScope.$on('$stateNotFound', function (event, unfoundState, fromState, fromParams) {
  505. //$rootScope.loading = false;
  506. if (angular.isUndefined($rootScope.user.id)) {
  507. $rootScope.loading = false;
  508. }
  509. // console.log(unfoundState.to);
  510. // "lazy.state"
  511. // console.log(unfoundState.toParams);
  512. // {a:1, b:2}
  513. // console.log(unfoundState.options);
  514. // {inherit:false} + default options
  515. });
  516. $rootScope.isMousedown = false;
  517. $rootScope.changeRemoveClass = function (e) {
  518. $rootScope.isMousedown = true
  519. }
  520. $rootScope.returnRemoveClass = function (e) {
  521. $rootScope.isMousedown = false;
  522. }
  523. $rootScope.$on('auth:login-success', function (ev, data) {
  524. // $state.go('login.signin');
  525. initImUser(data.email, data.msgUuid);
  526. getMenus();
  527. //console.log(data);
  528. //$rootScope.user = data.user;
  529. //$rootScope.menus = data.menu;
  530. });
  531. //$rootScope.$watch('$auth.user')
  532. // $rootScope.$on('auth:validation-success', function(ev, user) {
  533. // // console.log(user);
  534. // initImUser(user.email, user.msgUuid);
  535. // if ($rootScope.userMenus.length == 0) {
  536. // getMenus();
  537. // }
  538. // //alert('Welcome ', user.email);
  539. // });
  540. // $rootScope.$on('auth:invalid', function(ev) {
  541. // $state.go('login.signin');
  542. // });
  543. // $rootScope.$on('auth:validation-error', function(ev) {
  544. // $state.go('login.signin');
  545. // //alert('Welcome ', user.email);
  546. // });
  547. // $rootScope.$on('auth:session-expired', function(ev) {
  548. // //alert('Welcome ', user.email);
  549. // $state.go('login.signin');
  550. // });
  551. // $rootScope.$on('auth:logout-success', function(ev) {
  552. // //alert('goodbye');
  553. // //delete $rootScope.user;
  554. // //delete $rootScope.menus;
  555. // $state.go('login.signin');
  556. // });
  557. // $rootScope.$on('auth:logout-error', function(ev) {
  558. // $state.go('login.signin');
  559. // });
  560. $rootScope.pageTitle = function () {
  561. // if($rootScope.currTitle){
  562. // return $rootScope.app.name + ' - ' + $filter('translate')($rootScope.currTitle) || $rootScope.app.description;
  563. // }else{
  564. // return $rootScope.app.name + ' - ' + $rootScope.app.description
  565. // }
  566. var perfix = "sidebar.nav.";
  567. var toTransKeypageTitle = perfix + $rootScope.currTitle;
  568. // return $rootScope.app.name + ' - ' + ($filter('translate')(toTransKeypageTitle) || $rootScope.app.description);
  569. return $rootScope.app.name;
  570. };
  571. // $auth.validateUser();
  572. // $auth.authenticate('local').then(function(resp){
  573. // }).catch(function(resp){
  574. // })
  575. // if(angular.isDefined($rootScope.nickname)){
  576. // api_login.sso($rootScope.nickname).then(function(response){
  577. // var user = Restangular.stripRestangular(response);
  578. // if (user) {
  579. // if(angular.isUndefined(user.id)){
  580. // }else{
  581. // $rootScope.user = user;
  582. // }
  583. // }
  584. // });
  585. // }else{
  586. // var user= $cookieStore.get("userObm");
  587. // if(user){
  588. // $rootScope.user = user;
  589. // $rootScope.menus = $cookieStore.get("menuObm");
  590. // }else{
  591. // if(angular.isDefined($rootScope.nickname)){
  592. // api_login.sso($rootScope.nickname).then(function(response){
  593. // var data = Restangular.stripRestangular(response);
  594. // if (data) {
  595. // if(data.user){
  596. // if(angular.isUndefined(data.user.id)){
  597. // }else{
  598. // $rootScope.user = data.user;
  599. // $rootScope.menus = data.menu;
  600. // $cookieStore.put("userObm", $rootScope.user);
  601. // $cookieStore.put("menuObm", $rootScope.menus);
  602. // $cookieStore.put("session", data.sessionId);
  603. // }
  604. // }
  605. // }
  606. // });
  607. // }else{
  608. // }
  609. // }
  610. //}
  611. //选择坐席号
  612. $scope.changeWorkId = function () {
  613. event.stopPropagation();
  614. }
  615. $rootScope.getSession = function () {
  616. if ($auth.userIsAuthenticated()) {
  617. return $auth.retrieveData('auth_headers')
  618. /*return {
  619. 'access-token':$auth.retrieveData('auth_headers')['access-token'],
  620. 'expiry':$auth.retrieveData('auth_headers')['expiry']
  621. };*/
  622. } else {
  623. return undefined;
  624. }
  625. }
  626. $scope.includes = [];
  627. $rootScope.includesState = function (state) {
  628. //for test
  629. //return true;
  630. //return includes;
  631. if ($rootScope.user) {
  632. if ($rootScope.user.menu) {
  633. angular.forEach($rootScope.user.menu, function (item) {
  634. $scope.includes[item.link] = true;
  635. });
  636. }
  637. }
  638. return $scope.includes[state];
  639. }
  640. //大屏入口
  641. $rootScope.opendashbord = function () {
  642. $state.go('echart');
  643. }
  644. // $rootScope.authority=false;
  645. // console.log($rootScope.user)
  646. // if($rootScope.user.role){
  647. // for(var i ;i<$rootScope.user.role.length;i++){
  648. // if($rootScope.user.role[i].rolecode=='call center') {
  649. // $rootScope.authority=true;
  650. // }else{$rootScope.authority=false;}
  651. // }
  652. // }
  653. /* status[已签入:1/通话中:3/来电:2],state[示闲:1,示忙:2] */
  654. // if (window.location.href && window.location.href.hash == "#/echart") {
  655. // } else {
  656. // // }
  657. // // 东经呼叫中心开始
  658. // $rootScope.statuscall = 0; //话机状态
  659. // $rootScope.statecall = 1; //示忙示闲
  660. // $scope.login = false; //签入签出
  661. // $rootScope.callout = false; //呼入呼出
  662. // $scope.group = 2000;
  663. // $scope.phone = 1500;
  664. // $rootScope.start = function(phone, group) {
  665. // api_text.start(phone, $rootScope.user.id).then(function(data) {
  666. // var token = data.token;
  667. // $rootScope.takes = token;
  668. // api_text.logout($rootScope.takes, $rootScope.user.id).then(function(data) { if (data.errno == 0) {} });
  669. // api_text.login($scope.group, token, $rootScope.user.id).then(function(data) {
  670. // if (data.errno == 0) {
  671. // $rootScope.setidle();
  672. // $scope.login = true;
  673. // $rootScope.statuscall = 1;
  674. // $rootScope.callout = false;
  675. // // function hello() {
  676. // // var ws = new WebSocket('ws://192.168.3.49:28088/events');
  677. // // ws.onopen = function() { ws.send(JSON.stringify(register)); };
  678. // // };
  679. // // window.setTimeout("hello()", 1000);
  680. // // var ws = new WebSocket('ws://192.168.77.57:28088/events');
  681. // function reconnect() {
  682. // // var ws = new WebSocket('ws://192.168.3.49:28088/events');
  683. // var ws = new WebSocket('ws://115.156.150.70:28088/events');
  684. // var register = { "msgtype": "login", "adn": phone };
  685. // ws.onopen = function() {
  686. // heartCheck.start();
  687. // ws.send(JSON.stringify(register));
  688. // };
  689. // ws.onmessage = function(evt) {
  690. // heartCheck.reset();
  691. // if (evt.data == "HeartBeat") {
  692. // } else {
  693. // var mydata = JSON.parse(evt.data);
  694. // $scope.filterData = [];
  695. // if (mydata.evttype == "callincome" && mydata.uud != "misc:callback") {
  696. // $rootScope.$apply(function() {
  697. // $rootScope.statuscall = 2;
  698. // });
  699. // $rootScope.callout = false;
  700. // $rootScope.phone = mydata.ano;
  701. // var Notification = window.Notification;
  702. // Notification.requestPermission();
  703. // var n = new Notification("你有来电", {
  704. // body: "来电号码:" + mydata.ano,
  705. // icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  706. // // onclick: function onNotificationClicked() {
  707. // // console.log('Notification clicked.');
  708. // // }
  709. // });
  710. // } else if (mydata.evttype == "callincome" && mydata.uud == "misc:callback") {
  711. // $rootScope.callout = true;
  712. // } else if (mydata.evttype == "ringstop") {
  713. // // $rootScope.status=7;
  714. // // $rootScope.$apply(function() {
  715. // $rootScope.statuscall = 1;
  716. // // });
  717. // $rootScope.phone = ""
  718. // } else if (mydata.evttype == 'hookchanged' && $rootScope.callout) {
  719. // if (mydata.status && mydata.status == '1') {
  720. // $rootScope.$apply(function() {
  721. // $rootScope.statuscall = 1;
  722. // });
  723. // $rootScope.phone = "";
  724. // } else if (mydata.status && mydata.status != '1') {
  725. // $rootScope.$apply(function() {
  726. // $rootScope.statuscall = 3;
  727. // });
  728. // }
  729. // } else if (mydata.evttype == 'hookchanged' && !$rootScope.callout) {
  730. // if ($rootScope.phone != "") {
  731. // if (mydata.status && mydata.status == '1') { //挂机
  732. // $rootScope.$apply(function() {
  733. // $rootScope.statuscall = 1;
  734. // });
  735. // console.log("挂机");
  736. // console.log(mydata);
  737. // } else if (mydata.status && mydata.status != '1' && $rootScope.statecall != 2) { //摘机
  738. // $rootScope.statuscall = 3;
  739. // api_text.setbusy($rootScope.takes).then(function(data) {
  740. // if (data.errno == 0) {
  741. // $rootScope.statecall = 2;
  742. // $scope.busy = true;
  743. // }
  744. // })
  745. // console.log("摘机");
  746. // console.log(mydata);
  747. // api_text.getcdrid($rootScope.takes).then(function(response) {
  748. // if (response.cdrid) {
  749. // var cdrid = response.cdrid;
  750. // // var response={cdrid:'219023836'}
  751. // var filterData = { "idx": 0, "sum": 10, "requester": { "phone": $rootScope.phone, "telephone": $rootScope.phone, "selectType": 1 } }
  752. // api_user_data.fetchDataList('requester', filterData).then(function(data) {
  753. // var myData = Restangular.stripRestangular(data);
  754. // // $rootScope.phone="";
  755. // if (myData.list.length == 0) {
  756. // var modalInstance = $modal.open({
  757. // templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  758. // controller: function($scope, $modalInstance, api_user_data) {
  759. // $scope.title = "新增报修人";
  760. // $scope.requester = {};
  761. // $scope.onChangeadd = function(searchData) {
  762. // $scope.searchKey = searchData.account;
  763. // // $scope.searchDataadd = searchData;
  764. // var requesdata = angular.copy(searchData)
  765. // // if (requesdata.phone) {
  766. // // delete requesdata.phone;
  767. // // }
  768. // if (requesdata.telephone) {
  769. // delete requesdata.telephone;
  770. // }
  771. // angular.extend($scope.requester, requesdata);
  772. // }
  773. // $scope.refreshUseradd = function(searchKey) { //请求人搜索
  774. // $scope.requester.account = searchKey;
  775. // $scope.searchData = searchKey;
  776. // serchdataadd(searchKey);
  777. // }
  778. // $scope.getMydata = function(x) {
  779. // var reqestdatap = JSON.parse(x[0])
  780. // // if ($scope.requester.phone) {
  781. // // delete reqestdatap.phone;
  782. // // }
  783. // if ($scope.requester.telephone) {
  784. // delete reqestdatap.telephone;
  785. // }
  786. // $scope.searchField = JSON.parse(x[0]).account;
  787. // angular.extend($scope.requester, reqestdatap);
  788. // }
  789. // $scope.getMydataone = function(x) {
  790. // $scope.searchField = x;
  791. // $scope.requester.account = x;
  792. // }
  793. // serchdataadd();
  794. // function serchdataadd(searchKey) {
  795. // if (searchKey) {
  796. // var filterData = {
  797. // 'requester': {
  798. // 'searchKey': searchKey,
  799. // },
  800. // idx: 0,
  801. // sum: 10
  802. // };
  803. // } else {
  804. // var filterData = {
  805. // idx: 0,
  806. // sum: 10
  807. // };
  808. // }
  809. // // serchdataadd(searchKey)
  810. // // if ($scope.model.requester && $scope.model.requester.requesterTypeDTO) {
  811. // // angular.extend(filterData.requester, { 'requesterTypeDTO': $scope.model.requester.requesterTypeDTO })
  812. // // }
  813. // api_user_data.fetchDataList('requester', filterData).then(function(response) {
  814. // var myData = response;
  815. // $scope.myData = myData.list;
  816. // });
  817. // }
  818. // // if ((/^1[34578]\d{9}$/.test($rootScope.phone))) {
  819. // // $scope.requester = { 'phone': $rootScope.phone };
  820. // // } else {
  821. // // $scope.requester = { 'telephone': $rootScope.phone };
  822. // // }
  823. // $scope.requester = { 'telephone': $rootScope.phone };
  824. // $scope.ok = function() {
  825. // $modalInstance.close($scope.requester);
  826. // };
  827. // $scope.cancel = function() {
  828. // $modalInstance.dismiss('cancel');
  829. // };
  830. // },
  831. // });
  832. // modalInstance.result.then(function(selectedItem) {
  833. // if (selectedItem) {
  834. // if (selectedItem.telephone && !selectedItem.phone) {
  835. // selectedItem.telephone = angular.copy(selectedItem.phone);
  836. // delete selectedItem.phone;
  837. // }
  838. // var data = {
  839. // 'requester': selectedItem
  840. // };
  841. // api_user_data.addData('requester', data).then(function(response) {
  842. // if (response.status == 200) {
  843. // var data = { 'model': { 'requestershow': response.data, 'incident': { 'requester': response.data, 'area': response.areaDTO, 'place': response.placeDTO, 'houseNumber': response.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
  844. // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  845. // }
  846. // })
  847. // }
  848. // });
  849. // } else if (myData.list.length == 1) {
  850. // 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 } } } }
  851. // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  852. // } else {
  853. // var modalInstance = $modal.open({
  854. // templateUrl: 'assets/views/createincident.html',
  855. // controller: function($scope, $modalInstance, api_user_data) {
  856. // $scope.title = "请确定报修人";
  857. // $scope.requester = myData.list;
  858. // $scope.choice = function(requester) {
  859. // $modalInstance.dismiss('cancel');
  860. // var data = { 'model': { 'requestershow': requester, 'incident': { 'requester': requester, 'area': requester.areaDTO, 'place': requester.placeDTO, 'houseNumber': requester.houseNumber, 'callID': cdrid, 'source': { 'id': 1 } } } }
  861. // $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  862. // };
  863. // $scope.cancel = function() {
  864. // $modalInstance.dismiss('cancel');
  865. // };
  866. // },
  867. // size: "lg"
  868. // });
  869. // }
  870. // });
  871. // }
  872. // })
  873. // }
  874. // }
  875. // }
  876. // }
  877. // };
  878. // var heartCheck = {
  879. // timeout: 12000, //60ms
  880. // timeoutObj: null,
  881. // serverTimeoutObj: null,
  882. // reset: function() {
  883. // clearTimeout(this.timeoutObj);
  884. // clearTimeout(this.serverTimeoutObj);
  885. // this.start();
  886. // },
  887. // start: function() {
  888. // var self = this;
  889. // this.timeoutObj = setTimeout(function() {
  890. // ws.send("HeartBeat");
  891. // self.serverTimeoutObj = setTimeout(function() {
  892. // ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  893. // }, self.timeout)
  894. // }, this.timeout)
  895. // },
  896. // }
  897. // ws.onclose = function(evt) { reconnect(); }
  898. // ws.onerror = function(evt) { reconnect(); };
  899. // }
  900. // reconnect();
  901. // } else {
  902. // var Notification = window.Notification;
  903. // Notification.requestPermission();
  904. // var n = new Notification("签入失败!", {
  905. // body: data.errmsg,
  906. // icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  907. // // onclick: function onNotificationClicked() {
  908. // // console.log('Notification clicked.');
  909. // // }
  910. // });
  911. // }
  912. // })
  913. // })
  914. // }
  915. // // 东经呼叫中心结束
  916. // 华科呼叫中心 start
  917. /* status[已签入:1/通话中:3/来电:2],state[示闲:1,示忙:2] */
  918. $rootScope.statuscall = 0; //话机状态
  919. $rootScope.statecall = 1; //示忙示闲
  920. $scope.login = false; //签入签出
  921. $rootScope.callout = 0; //呼入:1,呼出:2
  922. $scope.group = 2000;
  923. $scope.phone = 1500;
  924. $rootScope.phoneChange = function(phone) {
  925. if (phone == 1500||phone == 1501||phone == 1502) {
  926. $scope.group = 2000;
  927. } else if(phone == 1511) {
  928. $scope.group = 2001;
  929. }else if(phone == 1507) {
  930. $scope.group = 2002;
  931. }
  932. }
  933. $rootScope.start = function(phone) {
  934. if (phone == 1500||phone == 1501||phone == 1502) {
  935. $scope.group = 2000;
  936. } else if(phone == 1511) {
  937. $scope.group = 2001;
  938. }else if(phone == 1507) {
  939. $scope.group = 2002;
  940. }
  941. api_text.start(phone, $rootScope.user.id).then(function(data) {
  942. var token = data.token;
  943. $rootScope.takes = token;
  944. api_text.logout($rootScope.takes, $rootScope.user.id).then(function(data) { if (data.errno == 0) {} });
  945. api_text.login($scope.group, token, $rootScope.user.id).then(function(data) {
  946. if (data.errno == 0) {
  947. localStorage.setItem('hk_phone',phone);
  948. $rootScope.setidle();
  949. $scope.login = true;
  950. $rootScope.statuscall = 1;
  951. $rootScope.callout = 0;
  952. // function hello() {
  953. // var ws = new WebSocket('ws://192.168.3.49:28088/events');
  954. // ws.onopen = function() { ws.send(JSON.stringify(register)); };
  955. // };
  956. // window.setTimeout("hello()", 1000);
  957. // var ws = new WebSocket('ws://192.168.77.57:28088/events');
  958. function reconnect() {
  959. // var ws = new WebSocket('ws://192.168.3.49:28088/events');
  960. var ws = new WebSocket('ws://192.168.77.57:8088/IXServer/messagestation/hjzx');
  961. var register = { "msgtype": "login", "adn": phone };
  962. ws.onopen = function() {
  963. heartCheck.start();
  964. ws.send(JSON.stringify(register));
  965. };
  966. ws.onmessage = function(evt) {
  967. heartCheck.reset();
  968. if (evt.data == "HeartBeat") {
  969. } else {
  970. var mydata = JSON.parse(evt.data);
  971. $scope.filterData = [];
  972. if (mydata.evttype == "callincome" && mydata.uud != "misc:callback") {
  973. $rootScope.$apply(function() {
  974. $rootScope.statuscall = 2;
  975. $rootScope.callout = 1;
  976. });
  977. $rootScope.phone = mydata.ano;
  978. var Notification = window.Notification;
  979. Notification.requestPermission();
  980. var n = new Notification("你有来电", {
  981. body: "来电号码:" + mydata.ano,
  982. icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  983. // onclick: function onNotificationClicked() {
  984. // console.log('Notification clicked.');
  985. // }
  986. });
  987. } else if (mydata.evttype == "callincome" && mydata.uud == "misc:callback") {
  988. $rootScope.callout = 2;
  989. } else if (mydata.evttype == "ringstop") {
  990. // $rootScope.status=7;
  991. // $rootScope.$apply(function() {
  992. $rootScope.statuscall = 1;
  993. // });
  994. $rootScope.phone = ""
  995. } else if (mydata.evttype == 'hookchanged' && $rootScope.callout == 2) {
  996. if (mydata.status && mydata.status == '1') {
  997. $rootScope.$apply(function() {
  998. $rootScope.statuscall = 1;
  999. });
  1000. $rootScope.phone = "";
  1001. } else if (mydata.status && mydata.status != '1') {
  1002. $rootScope.$apply(function() {
  1003. $rootScope.statuscall = 3;
  1004. });
  1005. }
  1006. } else if (mydata.evttype == 'hookchanged' && $rootScope.callout == 1) {
  1007. if ($rootScope.phone != "") {
  1008. if (mydata.status && mydata.status == '1') { //挂机
  1009. $rootScope.$apply(function() {
  1010. $rootScope.statuscall = 1;
  1011. $rootScope.callout = 0;
  1012. });
  1013. // console.log("挂机");
  1014. if ($rootScope.statecall == 1 && !$rootScope.isSetidle) {
  1015. $rootScope.setbusy();
  1016. }
  1017. } else if (mydata.status && mydata.status != '1' && $rootScope.statecall != 2 && $rootScope.callout == 1) { //摘机
  1018. $rootScope.status = 6
  1019. $rootScope.statuscall = 3;
  1020. $rootScope.isSetidle = false;
  1021. $rootScope.app.layout.isSidebarClosed = true;
  1022. // console.log("摘机");
  1023. // console.log(mydata);
  1024. api_text.getcdrid($rootScope.takes).then(function(response) {
  1025. if (response.cdrid) {
  1026. var cdrid = response.cdrid;
  1027. // var response={cdrid:'219023836'}
  1028. var filterData = { "idx": 0, "sum": 10, "user": { "phone": $rootScope.phone, engineer: undefined, } }
  1029. api_user_data.fetchDataList('user', filterData).then(function(data) {
  1030. var myData = Restangular.stripRestangular(data);
  1031. // $rootScope.phone="";
  1032. if (myData.list.length == 0) {
  1033. var modalInstance = $modal.open({
  1034. backdrop: "static",
  1035. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  1036. controller: function($scope, $modalInstance, api_user_data, SweetAlert) {
  1037. $scope.title = "新增报修人";
  1038. $scope.requester = {};
  1039. $scope.onChangeadd = function(searchData) {
  1040. $scope.searchKey = searchData.account;
  1041. // $scope.searchDataadd = searchData;
  1042. var requesdata = angular.copy(searchData)
  1043. // if (requesdata.phone) {
  1044. // delete requesdata.phone;
  1045. // }
  1046. if (requesdata.telephone) {
  1047. delete requesdata.telephone;
  1048. }
  1049. angular.extend($scope.requester, requesdata);
  1050. }
  1051. $scope.refreshUseradd = function(searchKey) { //请求人搜索
  1052. $scope.requester.account = searchKey;
  1053. $scope.searchData = searchKey;
  1054. serchdataadd(searchKey);
  1055. }
  1056. $scope.getMydata = function(x) {
  1057. var reqestdatap = JSON.parse(x[0])
  1058. // if ($scope.requester.phone) {
  1059. // delete reqestdatap.phone;
  1060. // }
  1061. if ($scope.requester.telephone) {
  1062. delete reqestdatap.telephone;
  1063. }
  1064. $scope.searchField = JSON.parse(x[0]).account;
  1065. angular.extend($scope.requester, reqestdatap);
  1066. if ($scope.requester.areaDTO && $scope.requester.areaDTO.id && $scope.requester.areaDTO.id != "") {
  1067. api_user_data.fetchDataList('place', { place: { areaId: $scope.requester.areaDTO.id }, idx: 0, sum: 1000 }).then(function(response) {
  1068. if (response.status == 200) {
  1069. $scope.places = response.list;
  1070. }
  1071. })
  1072. }
  1073. }
  1074. $scope.getMydataone = function(x) {
  1075. $scope.searchField = x;
  1076. $scope.requester.account = x;
  1077. }
  1078. serchdataadd();
  1079. function serchdataadd(searchKey) {
  1080. if (searchKey) {
  1081. var filterData = {
  1082. 'user': {
  1083. 'name': searchKey,
  1084. selectType: "pinyin_all",
  1085. engineer: undefined,
  1086. },
  1087. idx: 0,
  1088. sum: 10
  1089. };
  1090. } else {
  1091. var filterData = {
  1092. idx: 0,
  1093. sum: 10,
  1094. user: {
  1095. engineer: undefined,
  1096. }
  1097. };
  1098. }
  1099. api_user_data.fetchDataList('user', filterData).then(function(response) {
  1100. var myData = response;
  1101. $scope.myData = myData.list;
  1102. });
  1103. }
  1104. api_user_data.fetchDataList('area', { idx: 0, sum: 100 }).then(function(response) {
  1105. if (response.status == 200) {
  1106. $scope.areas = response.list;
  1107. }
  1108. })
  1109. // api_user_data.fetchDataList('place', { idx: 0, sum: 1000 }).then(function(response) {
  1110. // if (response.status == 200) {
  1111. // $scope.places = response.list;
  1112. // }
  1113. // }) //地点
  1114. api_user_data.fetchDataList('requesterType', { idx: 0, sum: 100 }).then(function(response) {
  1115. if (response.status == 200) {
  1116. $scope.networktypes = response.list;
  1117. }
  1118. })
  1119. $scope.requesterAreaid = "";
  1120. $scope.onChange = function(item) {
  1121. $scope.requesterAreaid = item.id;
  1122. $scope.requester.place = {};
  1123. api_user_data.fetchDataList('place', { place: { areaId: item.id }, idx: 0, sum: 1000 }).then(function(response) {
  1124. if (response.status == 200) {
  1125. $scope.places = response.list;
  1126. }
  1127. })
  1128. }
  1129. //地点搜索
  1130. $scope.refresh = function(searchVal) {
  1131. var faildata = {};
  1132. if ($scope.requesterAreaid) {
  1133. faildata = {
  1134. 'idx': 0,
  1135. 'sum': 1000,
  1136. 'place': { 'areaId': $scope.requesterAreaid, 'place': searchVal, 'selectType': 'pinyin_qs' }
  1137. }
  1138. } else {
  1139. faildata = {
  1140. 'idx': 0,
  1141. 'sum': 1000,
  1142. 'place': { 'place': searchVal, 'selectType': 'pinyin_qs' }
  1143. }
  1144. }
  1145. api_user_data.fetchDataList('place', faildata).then(function(response) {
  1146. $scope.places = response.list;
  1147. delete $scope.requester.place;
  1148. })
  1149. }
  1150. $scope.requester = { 'telephone': $rootScope.phone };
  1151. $scope.ok = function() {
  1152. // $modalInstance.close($scope.requester);
  1153. if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  1154. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  1155. } else if (angular.isUndefined($scope.requester.phone) || $scope.requester.phone == null || $scope.requester.phone == "") {
  1156. SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
  1157. } else {
  1158. $modalInstance.close($scope.requester);
  1159. }
  1160. };
  1161. $scope.cancel = function() {
  1162. $modalInstance.dismiss('cancel');
  1163. $rootScope.setidle();
  1164. };
  1165. },
  1166. });
  1167. modalInstance.result.then(function(selectedItem) {
  1168. if (selectedItem) {
  1169. if (selectedItem.telephone && !selectedItem.phone) {
  1170. selectedItem.telephone = angular.copy(selectedItem.phone);
  1171. delete selectedItem.phone;
  1172. }
  1173. var data = {
  1174. 'requester': selectedItem
  1175. };
  1176. api_user_data.addData('requester', data).then(function(response) {
  1177. if (response.status == 200) {
  1178. var data = {
  1179. model: {
  1180. requestershow: response.data,
  1181. incident: {
  1182. requester: response.data,
  1183. area: response.data.place?response.data.place.area:undefined,
  1184. place: response.data.place,
  1185. houseNumber: response.data.houseNumber,
  1186. contactsInformation: response.data.telephone,
  1187. contacts:response.data.name,
  1188. callID: cdrid,
  1189. source: { id: 1 },
  1190. },
  1191. },
  1192. };
  1193. $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  1194. }
  1195. })
  1196. }
  1197. });
  1198. } else if (myData.list.length == 1) {
  1199. angular.extend(myData.list[0], { 'telephone': $rootScope.phone });
  1200. var data = {
  1201. model: {
  1202. requestershow: myData.list[0],
  1203. incident: {
  1204. requester: myData.list[0],
  1205. area: myData.list[0].place?myData.list[0].place.area:undefined,
  1206. place: myData.list[0].place,
  1207. contactsInformation: myData.list[0].telephone,
  1208. houseNumber: myData.list[0].houseNumber,
  1209. contacts:myData.list[0].name,
  1210. callID: cdrid,
  1211. source: { id: 1 },
  1212. },
  1213. },
  1214. };
  1215. $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  1216. } else {
  1217. var modalInstance = $modal.open({
  1218. templateUrl: 'assets/views/createincident.html',
  1219. backdrop: "static",
  1220. controller: function($scope, $modalInstance, api_user_data) {
  1221. $scope.title = "请确定报修人";
  1222. $scope.requester = myData.list;
  1223. $scope.choice = function(requester) {
  1224. $modalInstance.dismiss('cancel');
  1225. angular.extend(requester, { 'telephone': $rootScope.phone });
  1226. var data = {
  1227. model: {
  1228. requestershow: requester,
  1229. incident: {
  1230. requester: requester,
  1231. area: requester.place?requester.place.area:undefined,
  1232. place: requester.place,
  1233. houseNumber: requester.houseNumber,
  1234. contactsInformation: requester.telephone,
  1235. contacts:requester.name,
  1236. callID: cdrid,
  1237. source: { id: 1 },
  1238. },
  1239. },
  1240. };
  1241. $state.go('app.incident.title', { 'model': JSON.stringify(data) });
  1242. };
  1243. $scope.cancel = function() {
  1244. $modalInstance.dismiss('cancel');
  1245. $rootScope.setidle();
  1246. };
  1247. },
  1248. size: "lg"
  1249. });
  1250. }
  1251. });
  1252. }
  1253. })
  1254. }
  1255. }
  1256. }
  1257. }
  1258. };
  1259. var heartCheck = {
  1260. timeout: 12000, //60ms
  1261. timeoutObj: null,
  1262. serverTimeoutObj: null,
  1263. reset: function() {
  1264. clearTimeout(this.timeoutObj);
  1265. clearTimeout(this.serverTimeoutObj);    
  1266. this.start();
  1267. },
  1268. start: function() {
  1269. var self = this;
  1270. this.timeoutObj = setTimeout(function() {
  1271. if ($scope.login) {
  1272. ws.send("HeartBeat");
  1273. self.serverTimeoutObj = setTimeout(function() {
  1274. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  1275. }, self.timeout)
  1276. }
  1277. }, this.timeout)
  1278. },
  1279. }
  1280. ws.onclose = function(evt) { reconnect(); }
  1281. ws.onerror = function(evt) { reconnect(); };
  1282. }
  1283. reconnect();
  1284. } else {
  1285. var Notification = window.Notification;
  1286. Notification.requestPermission();
  1287. var n = new Notification("签入失败!", {
  1288. body: data.errmsg,
  1289. icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  1290. // onclick: function onNotificationClicked() {
  1291. // console.log('Notification clicked.');
  1292. // }
  1293. });
  1294. }
  1295. })
  1296. })
  1297. }
  1298. setInterval(function() {
  1299. if ($scope.login && $rootScope.statuscall == 1 && $rootScope.statecall == 1) {
  1300. $rootScope.setidle();
  1301. } else if ($scope.login && $rootScope.statuscall != 3 && $rootScope.statecall == 2 && statuscall != 0) {
  1302. $rootScope.setbusy
  1303. }
  1304. }, 3000);
  1305. // 华科呼叫中心 end
  1306. //话机呼叫中心--开始
  1307. $rootScope.getExtnDirect = function () {
  1308. $rootScope['getExtnDirect' + $rootScope.seiminHj]();
  1309. }
  1310. // --------------------------1------------------------------
  1311. $rootScope.getExtnDirect1 = function () {
  1312. var jry_data_dictionary = {
  1313. key: "hjzx_cornet",
  1314. type: "list"
  1315. }
  1316. api_wechatfile.getDictionary(jry_data_dictionary).then(function (res) {
  1317. var websocket_url = "ws://192.168.3.122:29003/ola_socket";
  1318. var ola_queue = "10009"; //通话配置-队列配置-队列ID
  1319. // var ola_extn = "1001"; //个人信息-座席分机号
  1320. $rootScope.jry_extnNumberSelect = [];
  1321. $rootScope.jry_extnNumberObj = {};
  1322. $rootScope.jry_extnNumberSelect = res;
  1323. $rootScope.jry_extnNumberObj.jry_extnNumber = $rootScope.jry_extnNumberSelect[0];
  1324. function log(msg) {
  1325. //IE has no console
  1326. if ('console' in window) console.log(msg);
  1327. }
  1328. function websocket_connect() {
  1329. ola.connect(websocket_url);
  1330. ola.onConnect = onConnect;
  1331. ola.onClose = onClose;
  1332. ola.onMessage = onMessage;
  1333. }
  1334. $(document).ready(function () {
  1335. // if(ola_extn!=""){
  1336. if ($rootScope.jry_extnNumberObj.jry_extnNumber) {
  1337. websocket_connect();
  1338. }
  1339. });
  1340. /* callbacks */
  1341. function onMessage(evt) {
  1342. var phoneData = JSON.parse(evt.data);
  1343. if (phoneData.event_type == "agent_state") {
  1344. console.log(phoneData);
  1345. if (phoneData.state == "busy") {
  1346. $('#agent_state').append(" (" + phoneData.private_data + ")");
  1347. // 来电
  1348. if (phoneData.private_data == "ring") {
  1349. console.log(phoneData);
  1350. $rootScope.jry_state = "laidian";
  1351. var Notification = window.Notification;
  1352. Notification.requestPermission();
  1353. var n = new Notification("你有来电", {
  1354. body: "来电号码:" + phoneData.ani,
  1355. icon: '../bower_components/HTML5-Desktop-Notifications/alert.ico',
  1356. });
  1357. // 摘机
  1358. } else if (phoneData.private_data == "answered") {
  1359. $rootScope.jry_state = "tonghuazhong";
  1360. var jry_findPhone = "";
  1361. if (phoneData.ani) {
  1362. jry_findPhone = phoneData.ani
  1363. } else if (phoneData.dnis && phoneData.other_answered) {
  1364. jry_findPhone = phoneData.dnis
  1365. }
  1366. var filterData = {
  1367. "idx": 0,
  1368. "sum": 100,
  1369. "user": {
  1370. "phone": jry_findPhone,
  1371. engineer: undefined,
  1372. }
  1373. }
  1374. api_user_data.fetchDataList('user', filterData).then(function (data) {
  1375. var myData = Restangular.stripRestangular(data);
  1376. // $rootScope.phone="";
  1377. // 新增报修人
  1378. if (myData.list.length == 0) {
  1379. var modalInstance = $modal.open({
  1380. templateUrl: 'assets/views/customform/tpl/modal-add-callrequester.html',
  1381. controller: function ($scope, $modalInstance, api_user_data, SweetAlert, api_wechatfile) {
  1382. $scope.title = "新增报修人";
  1383. $scope.requester = {};
  1384. $scope.onChangeadd = function (searchData) {
  1385. $scope.searchKey = searchData.account;
  1386. // $scope.searchDataadd = searchData;
  1387. var requesdata = angular.copy(searchData)
  1388. // if (requesdata.phone) {
  1389. // delete requesdata.phone;
  1390. // }
  1391. if (requesdata.telephone) {
  1392. delete requesdata.telephone;
  1393. }
  1394. angular.extend($scope.requester, requesdata);
  1395. }
  1396. $scope.refreshUseradd = function (searchKey) { //请求人搜索
  1397. $scope.requester.account = searchKey;
  1398. $scope.searchData = searchKey;
  1399. serchdataadd(searchKey);
  1400. }
  1401. $scope.getMydata = function (x) {
  1402. var reqestdatap = JSON.parse(x[0])
  1403. // if ($scope.requester.phone) {
  1404. // delete reqestdatap.phone;
  1405. // }
  1406. if ($scope.requester.telephone) {
  1407. delete reqestdatap.telephone;
  1408. }
  1409. $scope.searchField = JSON.parse(x[0]).account;
  1410. angular.extend($scope.requester, reqestdatap);
  1411. }
  1412. $scope.getMydataone = function (x) {
  1413. $scope.searchField = x;
  1414. $scope.requester.account = x;
  1415. }
  1416. serchdataadd();
  1417. function serchdataadd(searchKey) {
  1418. if (searchKey) {
  1419. var filterData = {
  1420. 'user': {
  1421. 'name': searchKey,
  1422. selectType: "pinyin_all",
  1423. engineer: undefined,
  1424. },
  1425. idx: 0,
  1426. sum: 10
  1427. };
  1428. } else {
  1429. var filterData = {
  1430. idx: 0,
  1431. sum: 10,
  1432. user: {engineer: undefined,}
  1433. };
  1434. }
  1435. api_user_data.fetchDataList('user', filterData).then(function (response) {
  1436. var myData = response;
  1437. $scope.myData = myData.list;
  1438. });
  1439. }
  1440. api_user_data.fetchDataList('area', {
  1441. idx: 0,
  1442. sum: 100
  1443. }).then(function (response) {
  1444. if (response.status == 200) {
  1445. $scope.areas = response.list;
  1446. }
  1447. })
  1448. api_wechatfile.getDictionary({
  1449. "key": "requester_type",
  1450. "type": "list"
  1451. }).then(function (response) {
  1452. // if (response.status == 200) {
  1453. $scope.networktypes = response;
  1454. // }
  1455. })
  1456. $scope.requesterAreaid = "";
  1457. $scope.onChange = function (item) {
  1458. $scope.requesterAreaid = item.id;
  1459. $scope.requester.place = {};
  1460. api_user_data.fetchDataList('place', {
  1461. place: {
  1462. areaId: item.id
  1463. },
  1464. idx: 0,
  1465. sum: 1000
  1466. }).then(function (response) {
  1467. if (response.status == 200) {
  1468. $scope.places = response.list;
  1469. }
  1470. })
  1471. }
  1472. //地点搜索
  1473. $scope.refresh = function (searchVal) {
  1474. var faildata = {};
  1475. if ($scope.requesterAreaid) {
  1476. faildata = {
  1477. 'idx': 0,
  1478. 'sum': 1000,
  1479. 'place': {
  1480. 'areaId': $scope.requesterAreaid,
  1481. 'place': searchVal,
  1482. 'selectType': 'pinyin_qs'
  1483. }
  1484. }
  1485. } else {
  1486. faildata = {
  1487. 'idx': 0,
  1488. 'sum': 1000,
  1489. 'place': {
  1490. 'place': searchVal,
  1491. 'selectType': 'pinyin_qs'
  1492. }
  1493. }
  1494. }
  1495. api_user_data.fetchDataList('place', faildata).then(function (response) {
  1496. $scope.places = response.list;
  1497. delete $scope.requester.place;
  1498. })
  1499. }
  1500. $scope.requester = {
  1501. 'telephone': jry_findPhone
  1502. };
  1503. $scope.ok = function () {
  1504. var reg1 = /^1[3456789][0-9]{9}$/; //手机号
  1505. var reg2 = /^((0\d{2,3})-)*(\d{7,8})(-(\d{3,}))?$/; //座机号
  1506. var flag1 = reg1.test($scope.requester.phone);
  1507. var flag2 = reg2.test($scope.requester.phone);
  1508. console.log($scope.requester)
  1509. if (angular.isUndefined($scope.requester.name) || $scope.requester.name == null || $scope.requester.name == "") {
  1510. SweetAlert.swal("报修人姓名未填!", "请填写报修人姓名", "error");
  1511. } else if (angular.isUndefined($scope.requester.requesterType)) {
  1512. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  1513. } else if (angular.isUndefined($scope.requester.phone) || $scope.requester.phone == null || $scope.requester.phone == "") {
  1514. SweetAlert.swal("报修人电话未填!", "请填写报修人电话", "error");
  1515. }
  1516. else {
  1517. $modalInstance.close($scope.requester);
  1518. }
  1519. };
  1520. $scope.cancel = function () {
  1521. $modalInstance.dismiss('cancel');
  1522. };
  1523. },
  1524. });
  1525. modalInstance.result.then(function (selectedItem) {
  1526. if (selectedItem) {
  1527. if (selectedItem.telephone && !selectedItem.phone) {
  1528. selectedItem.telephone = angular.copy(selectedItem.phone);
  1529. delete selectedItem.phone;
  1530. }
  1531. var data = {
  1532. 'requester': selectedItem
  1533. };
  1534. api_user_data.addData('requester', data).then(function (response) {
  1535. if (response.status == 200) {
  1536. var data = {
  1537. 'model': {
  1538. 'requestershow': response.data,
  1539. 'incident': {
  1540. 'requester': response.data,
  1541. 'area': response.data.place?response.data.place.area:undefined,
  1542. 'place': response.data.place,
  1543. 'houseNumber': response.data.houseNumber,
  1544. 'callID': cdrid,
  1545. 'contacts':response.data.name,
  1546. 'contactsInformation': response.data.telephone,
  1547. 'source': {
  1548. 'id': 1547
  1549. }
  1550. }
  1551. }
  1552. }
  1553. $state.go('app.incident.title', {
  1554. 'model': JSON.stringify(data)
  1555. });
  1556. }
  1557. })
  1558. }
  1559. });
  1560. } else if (myData.list.length == 1) {
  1561. var data = {
  1562. 'model': {
  1563. 'requestershow': myData.list[0],
  1564. 'incident': {
  1565. 'requester': myData.list[0],
  1566. 'area': myData.list[0].place?myData.list[0].place.area:undefined,
  1567. 'place': myData.list[0].place,
  1568. 'houseNumber': myData.list[0].houseNumber,
  1569. 'callID': cdrid,
  1570. 'contacts':myData.list[0].name,
  1571. 'contactsInformation': myData.list[0].telephone,
  1572. 'source': {
  1573. 'id': 1547
  1574. }
  1575. }
  1576. }
  1577. }
  1578. $state.go('app.incident.title', {
  1579. 'model': JSON.stringify(data)
  1580. });
  1581. } else {
  1582. var modalInstance = $modal.open({
  1583. templateUrl: 'assets/views/createincident.html',
  1584. controller: function ($scope, $modalInstance, api_user_data) {
  1585. $scope.title = "请确定报修人";
  1586. $scope.requester = myData.list;
  1587. $scope.choice = function (requester) {
  1588. $modalInstance.dismiss('cancel');
  1589. var data = {
  1590. 'model': {
  1591. 'requestershow': requester,
  1592. 'incident': {
  1593. 'requester': requester,
  1594. 'area': requester.place?requester.place.area:undefined,
  1595. 'place': requester.place,
  1596. 'houseNumber': requester.houseNumber,
  1597. 'callID': cdrid,
  1598. 'contacts':requester.name,
  1599. 'contactsInformation': requester.telephone,
  1600. 'source': {
  1601. 'id': 1547
  1602. }
  1603. }
  1604. }
  1605. }
  1606. $state.go('app.incident.title', {
  1607. 'model': JSON.stringify(data)
  1608. });
  1609. };
  1610. $scope.cancel = function () {
  1611. $modalInstance.dismiss('cancel');
  1612. };
  1613. },
  1614. size: "lg"
  1615. });
  1616. }
  1617. });
  1618. }
  1619. // 挂机
  1620. } else if (phoneData.state == "login") {
  1621. go_ready()
  1622. } else if (phoneData.state == "logout") {
  1623. $rootScope.jry_state = "weiqianru";
  1624. } else if (phoneData.state == "ready") {
  1625. // 来电挂机
  1626. if (phoneData.old_state == "busy" && phoneData.private_data == "answered") {
  1627. go_break()
  1628. } else {
  1629. $rootScope.jry_state = "shixian";
  1630. }
  1631. }
  1632. // else if (data.old_state == "busy") {
  1633. // }
  1634. } else if (phoneData.event_type == "agent_caller_state") {
  1635. // special feature, never mind
  1636. if (phoneData.action == "in") {
  1637. } else {
  1638. }
  1639. } else if (phoneData.event_type == "command/reply") {
  1640. if (phoneData.phoneData && phoneData.phoneData.state) {
  1641. }
  1642. }
  1643. }
  1644. function onConnect() {
  1645. console.log("websocket connected!");
  1646. // ola._extn = ola_extn;
  1647. // ola.subscribe('ola.queue.' + ola_queue + '.' + ola_extn);
  1648. // ola.subscribe('ola.caller.' + ola_extn);
  1649. // ola.get_agent_state(ola_extn);
  1650. ola._extn = $rootScope.jry_extnNumberObj.jry_extnNumber.name;
  1651. ola.subscribe('ola.queue.' + ola_queue + '.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
  1652. ola.subscribe('ola.caller.' + $rootScope.jry_extnNumberObj.jry_extnNumber.name);
  1653. ola.get_agent_state($rootScope.jry_extnNumberObj.jry_extnNumber.name);
  1654. };
  1655. function onClose() {
  1656. }
  1657. function login() {
  1658. // ola.login(ola_queue, ola_extn, {type: "onhook"});
  1659. console.log($rootScope.jry_extnNumberObj.jry_extnNumber);
  1660. ola.login(ola_queue, $rootScope.jry_extnNumberObj.jry_extnNumber.name, { type: "onhook" });
  1661. }
  1662. function logout() {
  1663. ola.logout();
  1664. }
  1665. function go_ready() {
  1666. ola.go_ready();
  1667. }
  1668. function go_break() {
  1669. ola.go_break($('#break_reason').val());
  1670. $rootScope.jry_state = "shimang";
  1671. }
  1672. function answer() {
  1673. ola.answer();
  1674. }
  1675. function dial(dst) {
  1676. ola.dial(dst);
  1677. }
  1678. $rootScope.dial = function (dst) {
  1679. ola.dial(dst);
  1680. }
  1681. function conference(dst) {
  1682. ola.conference(dst);
  1683. }
  1684. function conference_uuid(channel_uuid) {
  1685. ola.conference_uuid(channel_uuid);
  1686. }
  1687. function hangup() {
  1688. ola.hangup();
  1689. }
  1690. function take_call(uuid) {
  1691. // ola.take_call(ola_extn, uuid);
  1692. ola.take_call($rootScope.jry_extnNumberObj.jry_extnNumber.name, uuid);
  1693. }
  1694. // 签入
  1695. $rootScope.jry_qianru = function () {
  1696. login();
  1697. }
  1698. // 示闲
  1699. $rootScope.jry_shixian = function () {
  1700. go_ready()
  1701. }
  1702. // 示忙
  1703. $rootScope.jry_shimang = function () {
  1704. go_break()
  1705. }
  1706. // 签出
  1707. $rootScope.jry_qianchu = function () {
  1708. logout()
  1709. }
  1710. $rootScope.jry_bohao = function (res) {
  1711. if ($rootScope.jry_state == "weiqianru") {
  1712. // SweetAlert.swal({
  1713. // title: "拨打失败",
  1714. // text: "请先签入!",
  1715. // type: "error",
  1716. // confirmButtonColor: "#DD6B55"
  1717. // });
  1718. } else if ($rootScope.jry_state == "shimang") {
  1719. // SweetAlert.swal({
  1720. // title: "拨打失败",
  1721. // text: "请先示闲!",
  1722. // type: "error",
  1723. // confirmButtonColor: "#DD6B55"
  1724. // });
  1725. } else {
  1726. dial(res);
  1727. }
  1728. }
  1729. })
  1730. }
  1731. // ------------------------------2--------------------------
  1732. $rootScope.getExtnDirect2 = function () {
  1733. var jry_data_dictionary = {
  1734. key: "hjzx_cornet",
  1735. type: "list"
  1736. }
  1737. api_wechatfile.getDictionary(jry_data_dictionary).then(function (res) {
  1738. sessionStorage.setItem('phones',JSON.stringify(res.map(v=>v.name)));
  1739. var websocket_url = $rootScope.seiminCallIp;
  1740. $rootScope.jry_extnNumberSelect = [];
  1741. $rootScope.jry_extnNumberObj = {};
  1742. $rootScope.jry_extnNumberSelect = angular.copy(res);
  1743. $rootScope.jry_extnNumberObj.jry_extnNumber = {};
  1744. var fenjiNumber = localStorage.getItem('fenjiNumber');
  1745. if(fenjiNumber){
  1746. $rootScope.jry_extnNumberSelect.forEach(ress=>{
  1747. if(ress.name == fenjiNumber){
  1748. $rootScope.jry_extnNumberObj.jry_extnNumber = ress;
  1749. }
  1750. })
  1751. }
  1752. // $rootScope.jry_extnNumberObj.jry_extnNumber = angular.copy(res[0]);//绑定分机对象
  1753. // $rootScope.jry_extnNumberObj.tel1 = angular.copy(res[0]);//目的号码对象
  1754. // $rootScope.jry_extnNumberObj.tel2 = angular.copy(res[0]);//转接坐席对象
  1755. $rootScope.preState = '';//最近一次示忙还是示闲的状态
  1756. //连接
  1757. tlwsa.tlaOpen(websocket_url);
  1758. // 强制示忙
  1759. $scope.qShimang = function(state){
  1760. if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
  1761. //进入页面,强制示忙
  1762. // tlwsa.tlaForceacw($rootScope.phoneNumber);
  1763. setTimeout(()=>{
  1764. tlwsa.tlaAcw();
  1765. },0)
  1766. }else{
  1767. $scope.getState(state);
  1768. }
  1769. }
  1770. // 获取状态
  1771. $scope.getState = function (state) {
  1772. // if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
  1773. // if(state != 2&&state != 0){
  1774. // //进入页面,强制示忙
  1775. // // tlwsa.tlaForceacw($rootScope.phoneNumber);
  1776. // setTimeout(()=>{
  1777. // tlwsa.tlaAcw();
  1778. // },3000)
  1779. // }
  1780. // }
  1781. // var agcount = tlwsa.tlaGetagentcount();
  1782. // var flag = true;
  1783. // for (var i = 0; i < agcount; i++) {
  1784. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  1785. // flag = false;
  1786. // var state = Number(tlwsa.tlaGetagentstate(i));
  1787. // console.log(state);
  1788. switch (state) {
  1789. case 0:
  1790. $rootScope.jry_state = 'weiqianru';
  1791. break;
  1792. case 1:
  1793. $rootScope.jry_state = 'shixian';
  1794. break;
  1795. case 2:
  1796. $rootScope.jry_state = 'shimang';
  1797. break;
  1798. case 3:
  1799. $rootScope.jry_state = 'laidian';
  1800. break;
  1801. case 5:
  1802. $rootScope.jry_state = 'tonghuazhong';
  1803. break;
  1804. case 6:
  1805. $rootScope.jry_state = 'zhengzaiwaihu';
  1806. break;
  1807. case 7:
  1808. $rootScope.jry_state = 'zhengzaizhuanyi';
  1809. break;
  1810. }
  1811. // }
  1812. // console.log('agnet No. ' + i + ' workid is ' + tlwsa.tlaGetagentwid(i) + ' state is ' + tlwsa.tlaGetagentstate(i) + ' ' + getStateInfo(tlwsa.tlaGetagentstate(i)))
  1813. // }
  1814. // if (flag) {
  1815. // $rootScope.jry_state = 'weiqianru';
  1816. // }
  1817. }
  1818. // 状态回调函数
  1819. // TLWSA.onStatechange = onstatechange;
  1820. // function onstatechange() {
  1821. // console.log('事件:状态变化----------------------------------------------------');
  1822. // $scope.getState();
  1823. // }
  1824. //连接呼叫中心回调函数
  1825. TLWSA.onOpenreturn = onopenreturn;
  1826. function onopenreturn(err) {
  1827. err = Number(err);
  1828. if (!err) {
  1829. console.log('呼叫中心连接成功-----seimin');
  1830. $scope.getState(0);
  1831. $.toaster({
  1832. priority: 'info',
  1833. title: '操作',
  1834. message: '呼叫中心连接成功'
  1835. });
  1836. //如果设置过话机
  1837. if (localStorage.getItem('phoneNumber')) {
  1838. //强制签出,然后签入
  1839. tlwsa.tlaKillworkid(localStorage.getItem('phoneNumber'));
  1840. }
  1841. } else {
  1842. console.log('呼叫中心连接失败-----seimin');
  1843. $scope.getState(0);
  1844. $.toaster({
  1845. priority: 'info',
  1846. title: '操作',
  1847. message: '呼叫中心连接失败'
  1848. });
  1849. }
  1850. }
  1851. //绑定分机回调函数
  1852. TLWSA.onSetphonenumberreturn = onsetphonenumberreturn;
  1853. function onsetphonenumberreturn(err) {
  1854. err = Number(err);
  1855. if (!err) {
  1856. console.log('绑定分机成功-----seimin');
  1857. $.toaster({
  1858. priority: 'info',
  1859. title: '操作',
  1860. message: '绑定分机成功'
  1861. });
  1862. localStorage.setItem('phoneNumber', $rootScope.phoneNumber);
  1863. localStorage.setItem('fenjiNumber', $rootScope.jry_extnNumberObj.jry_extnNumber.name);
  1864. $scope.qShimang(1);
  1865. } else {
  1866. console.log('绑定分机失败-----seimin');
  1867. $scope.getState(0);
  1868. $.toaster({
  1869. priority: 'info',
  1870. title: '操作',
  1871. message: '绑定分机失败'
  1872. });
  1873. }
  1874. }
  1875. //强制示忙回调函数
  1876. // TLWSA.onAcw = onacw;
  1877. // function onacw(err) {
  1878. // err = Number(err);
  1879. // if (!err) {
  1880. // console.log('强制示忙成功-----seimin');
  1881. // $scope.getState(2);
  1882. // $.toaster({
  1883. // priority: 'info',
  1884. // title: '操作',
  1885. // message: '示忙成功'
  1886. // });
  1887. // } else {
  1888. // console.log('强制示忙失败-----seimin');
  1889. // $.toaster({
  1890. // priority: 'info',
  1891. // title: '操作',
  1892. // message: '示忙失败'
  1893. // });
  1894. // }
  1895. // }
  1896. // //强制示闲回调函数
  1897. // TLWSA.onWca = onwca;
  1898. // function onwca(err) {
  1899. // console.log(err)
  1900. // err = Number(err);
  1901. // if (!err) {
  1902. // console.log('强制示闲成功-----seimin');
  1903. // $scope.getState(1);
  1904. // $.toaster({
  1905. // priority: 'info',
  1906. // title: '操作',
  1907. // message: '示闲成功'
  1908. // });
  1909. // } else {
  1910. // console.log('强制示闲失败-----seimin');
  1911. // $.toaster({
  1912. // priority: 'info',
  1913. // title: '操作',
  1914. // message: '示闲失败'
  1915. // });
  1916. // }
  1917. // }
  1918. //与服务器网络连接中断回调函数
  1919. TLWSA.onClosed = onclosed;
  1920. function onclosed() {
  1921. $scope.getState(0);
  1922. console.log('与服务器网络连接中断-----seimin');
  1923. $.toaster({
  1924. priority: 'info',
  1925. title: '操作',
  1926. message: '与服务器网络连接中断,2分钟后重连'
  1927. });
  1928. console.log('2分钟后自动重连-----seimin')
  1929. $timeout(function () {
  1930. //连接
  1931. tlwsa.tlaOpen(websocket_url);
  1932. }, 120000)
  1933. }
  1934. //签入回调函数
  1935. TLWSA.onLoginreturn = onloginreturn;
  1936. function onloginreturn(err) {
  1937. err = Number(err);
  1938. if (!err) {
  1939. console.log('签入成功-----seimin');
  1940. $.toaster({
  1941. priority: 'info',
  1942. title: '操作',
  1943. message: '签入成功'
  1944. });
  1945. setTimeout(function () {
  1946. console.log($rootScope.jry_extnNumberObj.jry_extnNumber.name,1111)
  1947. var fenjiNumber = $rootScope.jry_extnNumberObj.jry_extnNumber.name || localStorage.getItem('fenjiNumber');
  1948. console.log('开始绑定分机【' + fenjiNumber + '】-----seimin');
  1949. tlwsa.tlaSetphonenumber(fenjiNumber);
  1950. }, 0)
  1951. } else if (err == 9011) {
  1952. console.log('签入失败,该分机已登录-----seimin');
  1953. $.toaster({
  1954. priority: 'info',
  1955. title: '操作',
  1956. message: '签入失败,该分机已登录'
  1957. });
  1958. } else {
  1959. console.log('签入失败-----seimin');
  1960. $.toaster({
  1961. priority: 'info',
  1962. title: '操作',
  1963. message: '签入失败'
  1964. });
  1965. }
  1966. // tlwsa.tlaSubscribestateinfo(2);
  1967. }
  1968. // 强制签出回调函数
  1969. TLWSA.onKillreturn = onkillreturn;
  1970. function onkillreturn(err) {
  1971. err = Number(err);
  1972. if (!err) {
  1973. console.log('强制签出成功-----seimin');
  1974. $scope.getState(0);
  1975. // $.toaster({
  1976. // priority: 'info',
  1977. // title: '操作',
  1978. // message: '强制签出成功'
  1979. // });
  1980. } else {
  1981. console.log('强制签出失败,该分机不是签入状态-----seimin');
  1982. // $.toaster({
  1983. // priority: 'info',
  1984. // title: '操作',
  1985. // message: '强制签出失败'
  1986. // });
  1987. }
  1988. //如果设置过话机
  1989. if (localStorage.getItem('phoneNumber')) {
  1990. // 签入并绑定分机
  1991. $rootScope.phoneNumber = localStorage.getItem('phoneNumber');
  1992. tlwsa.tlaLogin($rootScope.phoneNumber, 1, -1);
  1993. }
  1994. }
  1995. // 签出回调函数
  1996. TLWSA.onLogoffreturn = onlogoffreturn;
  1997. function onlogoffreturn(err) {
  1998. err = Number(err);
  1999. if (!err) {
  2000. console.log('签出成功-----seimin');
  2001. $scope.getState(0);
  2002. $.toaster({
  2003. priority: 'info',
  2004. title: '操作',
  2005. message: '签出成功'
  2006. });
  2007. localStorage.removeItem('phoneNumber');
  2008. localStorage.removeItem('fenjiNumber');
  2009. $rootScope.jry_extnNumberObj.jry_extnNumber = {};
  2010. } else {
  2011. console.log('签出失败-----seimin');
  2012. $.toaster({
  2013. priority: 'info',
  2014. title: '操作',
  2015. message: '签出失败'
  2016. });
  2017. }
  2018. }
  2019. //示忙回调函数
  2020. TLWSA.onAcwreturn = onacwreturn;
  2021. function onacwreturn(err) {
  2022. err = Number(err);
  2023. if (!err) {
  2024. console.log('示忙成功-----seimin');
  2025. if (location.href.includes('app/incident/editor') || location.href.includes('app/incident/chart')) {
  2026. $scope.isShixian = false;
  2027. }else{
  2028. $scope.isShixian = true;
  2029. }
  2030. $scope.getState(2);
  2031. $rootScope.preState = 2;
  2032. $.toaster({
  2033. priority: 'info',
  2034. title: '操作',
  2035. message: '示忙成功'
  2036. });
  2037. } else {
  2038. console.log('示忙失败-----seimin');
  2039. // $.toaster({
  2040. // priority: 'info',
  2041. // title: '操作',
  2042. // message: '示忙失败'
  2043. // });
  2044. }
  2045. }
  2046. //示闲回调函数
  2047. TLWSA.onWcareturn = onwcareturn;
  2048. function onwcareturn(err) {
  2049. err = Number(err);
  2050. if (!err) {
  2051. console.log('示闲成功-----seimin');
  2052. $scope.getState(1);
  2053. $rootScope.preState = 1;
  2054. $.toaster({
  2055. priority: 'info',
  2056. title: '操作',
  2057. message: '示闲成功'
  2058. });
  2059. } else {
  2060. console.log('示闲失败-----seimin');
  2061. $.toaster({
  2062. priority: 'info',
  2063. title: '操作',
  2064. message: '示闲失败'
  2065. });
  2066. }
  2067. }
  2068. //呼叫坐席回调函数
  2069. TLWSA.onCallreturn = oncallreturn;
  2070. function oncallreturn(err) {
  2071. err = Number(err);
  2072. if (!err) {
  2073. console.log('呼叫成功,请摘机-----seimin');
  2074. $scope.getState(6);
  2075. $.toaster({
  2076. priority: 'info',
  2077. title: '操作',
  2078. message: '呼叫成功,请摘机'
  2079. });
  2080. } else {
  2081. console.log('呼叫失败-----seimin');
  2082. $.toaster({
  2083. priority: 'info',
  2084. title: '操作',
  2085. message: '呼叫失败'
  2086. });
  2087. }
  2088. }
  2089. //呼叫坐席被接听回调函数
  2090. TLWSA.onCallresult = oncallresult;
  2091. function oncallresult(jso) {
  2092. console.log(jso);
  2093. var err = Number(jso.err);
  2094. if (!err) {
  2095. console.log('呼叫被接听成功-----seimin');
  2096. $scope.getState(5);
  2097. $.toaster({
  2098. priority: 'info',
  2099. title: '操作',
  2100. message: '呼叫被接听成功'
  2101. });
  2102. } else {
  2103. console.log('呼叫被接听失败-----seimin');
  2104. $scope.qShimang(1);
  2105. $.toaster({
  2106. priority: 'info',
  2107. title: '操作',
  2108. message: '呼叫被接听失败'
  2109. });
  2110. }
  2111. }
  2112. //挂断回调函数
  2113. TLWSA.onCallend = oncallend;
  2114. function oncallend(jso) {
  2115. console.log(jso);//lmm
  2116. if (jso) {
  2117. console.log('挂断成功-----seimin');
  2118. console.log('最近一次话机状态',$rootScope.preState);
  2119. $scope.qShimang($rootScope.preState);
  2120. $.toaster({
  2121. priority: 'info',
  2122. title: '操作',
  2123. message: '挂断成功'
  2124. });
  2125. } else {
  2126. console.log('挂断失败-----seimin');
  2127. $.toaster({
  2128. priority: 'info',
  2129. title: '操作',
  2130. message: '挂断失败'
  2131. });
  2132. }
  2133. }
  2134. //呼入回调函数
  2135. TLWSA.onCallin = oncallin;
  2136. function oncallin(jso) {
  2137. console.log(jso);//lmm
  2138. $rootScope.callInPhoneNumber = jso.caller;//来电的电话
  2139. $rootScope.sockid = jso.crs;//来电的话机id
  2140. if (jso) {
  2141. console.log('呼入坐席成功,请摘机-----seimin');
  2142. $scope.getState(3);
  2143. $.toaster({
  2144. priority: 'info',
  2145. title: '操作',
  2146. message: '呼入坐席成功,请摘机'
  2147. });
  2148. console.log('来电了!电话号码是【' + $rootScope.callInPhoneNumber + '】');
  2149. } else {
  2150. console.log('呼入坐席失败-----seimin');
  2151. $.toaster({
  2152. priority: 'info',
  2153. title: '操作',
  2154. message: '呼入坐席失败'
  2155. });
  2156. }
  2157. }
  2158. // 测试代码start
  2159. // seachBxDept();
  2160. // 测试代码end
  2161. // 查报修科室
  2162. function seachBxDept(){
  2163. var postData = { "idx": 0, "sum": 10, "department": { phone: $rootScope.callInPhoneNumber } };//hjzxPhone
  2164. api_user_data.fetchDataList('department', postData).then(function (result) {
  2165. if (result.status == 200) {
  2166. console.log(result.list);
  2167. var requesters = result.list;
  2168. if (requesters.length === 0) {
  2169. //未匹配到报修科室
  2170. $rootScope.newOrder({
  2171. incident: {
  2172. sockid: $rootScope.sockid,
  2173. incomingPhone: $rootScope.callInPhoneNumber,
  2174. source: {id:1547,name:'电话'}
  2175. },
  2176. },'incomingCall')
  2177. // $state.go('app.incident.chart', {
  2178. // model: JSON.stringify({
  2179. // model: {
  2180. // incident: {
  2181. // requester: {
  2182. // phone: $rootScope.callInPhoneNumber,//hjzxPhone
  2183. // },
  2184. // sockid: $rootScope.sockid
  2185. // }
  2186. // }
  2187. // })
  2188. // });
  2189. } else if (requesters.length === 1) {
  2190. //匹配到一个报修科室
  2191. $rootScope.newOrder({
  2192. incident: {
  2193. department: requesters[0],
  2194. phone: requesters[0].phone,
  2195. sockid: $rootScope.sockid,
  2196. incomingPhone: $rootScope.callInPhoneNumber,
  2197. source: {id:1547,name:'电话'}
  2198. },
  2199. },'incomingCall')
  2200. // $state.go('app.incident.chart', {
  2201. // model: JSON.stringify({
  2202. // model: {
  2203. // incident: {
  2204. // requester: requesters[0],
  2205. // contactsInformation: requesters[0].phone,
  2206. // sockid: $rootScope.sockid
  2207. // },
  2208. // }
  2209. // })
  2210. // });
  2211. } else {
  2212. //匹配到多个报修科室
  2213. $modal.open({
  2214. templateUrl: 'assets/views/incident/tpl/tel.html',
  2215. controller: function ($scope, $modalInstance, $timeout, SweetAlert) {
  2216. $scope.list = requesters;
  2217. $scope.selected = {
  2218. selectedItem: 0
  2219. };
  2220. $scope.cancel = function () {
  2221. $modalInstance.dismiss('cancel');
  2222. };
  2223. $scope.changeBxr = function (id) {
  2224. $scope.selected.selectedItem = id;
  2225. }
  2226. $scope.save = function () {
  2227. var item = $scope.list.find(v => v.id == $scope.selected.selectedItem);
  2228. if (item) {
  2229. $scope.cancel();
  2230. $rootScope.newOrder({
  2231. incident: {
  2232. department: item,
  2233. phone: item.phone,
  2234. sockid: $rootScope.sockid,
  2235. incomingPhone: $rootScope.callInPhoneNumber,
  2236. source: {id:1547,name:'电话'}
  2237. },
  2238. },'incomingCall')
  2239. // $state.go('app.incident.chart', {
  2240. // model: JSON.stringify({
  2241. // model: {
  2242. // incident: {
  2243. // requester: item,
  2244. // contactsInformation: item.phone,
  2245. // sockid: $rootScope.sockid
  2246. // },
  2247. // }
  2248. // })
  2249. // });
  2250. } else {
  2251. SweetAlert.swal({
  2252. title: "请选择报修科室!",
  2253. type: "error"
  2254. })
  2255. }
  2256. }
  2257. }
  2258. });
  2259. }
  2260. }
  2261. })
  2262. }
  2263. //呼入摘机应答回调函数
  2264. TLWSA.onAnswer = onanswer;
  2265. function onanswer(err) {
  2266. err = Number(err);
  2267. if (!err) {
  2268. console.log('呼入摘机应答成功-----seimin');
  2269. $scope.getState(5);
  2270. $.toaster({
  2271. priority: 'info',
  2272. title: '操作',
  2273. message: '呼入摘机应答成功'
  2274. });
  2275. //根据电话号码反查报修人,如果是坐席号码,则不用
  2276. // console.log(sessionStorage.getItem('phones'));
  2277. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  2278. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  2279. // if(isHuajihao){
  2280. // return;
  2281. // }
  2282. // 查报修科室
  2283. seachBxDept();
  2284. // var postData = { "idx": 0, "sum": 10, "requester": { hjzxPhone: $rootScope.callInPhoneNumber } };
  2285. // api_user_data.fetchDataList('requester', postData).then(function (result) {
  2286. // if (result.status == 200) {
  2287. // console.log(result.list);
  2288. // var requesters = result.list;
  2289. // if (requesters.length === 0) {
  2290. // //未匹配到报修人,则弹窗添加报修人yeye
  2291. // $state.go('app.incident.chart', {
  2292. // model: JSON.stringify({
  2293. // model: {
  2294. // incident: {
  2295. // requester: {
  2296. // hjzxPhone: $rootScope.callInPhoneNumber
  2297. // },
  2298. // sockid: $rootScope.sockid
  2299. // }
  2300. // }
  2301. // })
  2302. // });
  2303. // } else if (requesters.length === 1) {
  2304. // //匹配到一个报修人
  2305. // $state.go('app.incident.chart', {
  2306. // model: JSON.stringify({
  2307. // model: {
  2308. // incident: {
  2309. // requester: requesters[0],
  2310. // contactsInformation: requesters[0].phone,
  2311. // sockid: $rootScope.sockid
  2312. // },
  2313. // }
  2314. // })
  2315. // });
  2316. // } else {
  2317. // //匹配到多个报修人
  2318. // $modal.open({
  2319. // templateUrl: 'assets/views/incident/tpl/tel.html',
  2320. // controller: function ($scope, $modalInstance, $timeout, SweetAlert) {
  2321. // $scope.list = requesters;
  2322. // $scope.selectedItem = 0;
  2323. // $scope.cancel = function () {
  2324. // $modalInstance.dismiss('cancel');
  2325. // };
  2326. // $scope.changeBxr = function (id) {
  2327. // $scope.selectedItem = id;
  2328. // }
  2329. // $scope.save = function () {
  2330. // var item = $scope.list.find(v => v.id == $scope.selectedItem);
  2331. // if (item) {
  2332. // $scope.cancel();
  2333. // $state.go('app.incident.chart', {
  2334. // model: JSON.stringify({
  2335. // model: {
  2336. // incident: {
  2337. // requester: item,
  2338. // contactsInformation: item.phone,
  2339. // sockid: $rootScope.sockid
  2340. // },
  2341. // }
  2342. // })
  2343. // });
  2344. // } else {
  2345. // SweetAlert.swal({
  2346. // title: "请选择报修人!",
  2347. // type: "error"
  2348. // })
  2349. // }
  2350. // }
  2351. // }
  2352. // });
  2353. // }
  2354. // }
  2355. // })
  2356. } else {
  2357. console.log('呼入摘机应答失败-----seimin');
  2358. $.toaster({
  2359. priority: 'info',
  2360. title: '操作',
  2361. message: '呼入摘机应答失败'
  2362. });
  2363. }
  2364. }
  2365. //呼入未摘机应答回调函数
  2366. TLWSA.onMisscall = onmisscall;
  2367. function onmisscall(err) {
  2368. err = Number(err);
  2369. if (!err) {
  2370. console.log('呼入未摘机应答成功-----seimin');
  2371. $scope.getState(1);
  2372. $.toaster({
  2373. priority: 'info',
  2374. title: '操作',
  2375. message: '呼入未摘机应答成功'
  2376. });
  2377. } else {
  2378. console.log('呼入未摘机应答失败-----seimin');
  2379. $.toaster({
  2380. priority: 'info',
  2381. title: '操作',
  2382. message: '呼入未摘机应答失败'
  2383. });
  2384. }
  2385. }
  2386. //转接开始回调函数
  2387. TLWSA.onTransferreturn = ontransferreturn;//调用转移方法之后,返回该事件 如果错误码为0,仅仅表示开始转移,不代表转移目标已经接听或已经拒绝
  2388. function ontransferreturn(err) {
  2389. err = Number(err);
  2390. if (!err) {
  2391. console.log('转接坐席开始成功-----seimin');
  2392. $scope.getState(7);
  2393. $.toaster({
  2394. priority: 'info',
  2395. title: '操作',
  2396. message: '转接坐席开始成功'
  2397. });
  2398. } else {
  2399. console.log('转接坐席开始失败-----seimin');
  2400. $.toaster({
  2401. priority: 'info',
  2402. title: '操作',
  2403. message: '转接坐席开始失败'
  2404. });
  2405. }
  2406. }
  2407. //转接结果回调函数
  2408. TLWSA.onTransferresult = ontransferresult;
  2409. function ontransferresult(err) {
  2410. err = Number(err);
  2411. if (!err) {
  2412. console.log('转接坐席结果成功-----seimin');
  2413. $scope.getState(1);
  2414. $.toaster({
  2415. priority: 'info',
  2416. title: '操作',
  2417. message: '转接坐席结果成功'
  2418. });
  2419. } else {
  2420. console.log('转接坐席结果失败-----seimin');
  2421. $.toaster({
  2422. priority: 'info',
  2423. title: '操作',
  2424. message: '转接坐席结果失败'
  2425. });
  2426. }
  2427. }
  2428. // 签入
  2429. $rootScope.jry_qianru = function () {
  2430. console.log($rootScope.jry_extnNumberObj.jry_extnNumber)
  2431. if(Object.keys($rootScope.jry_extnNumberObj.jry_extnNumber).length === 0){
  2432. $.toaster({
  2433. priority: 'info',
  2434. title: '警告',
  2435. message: '绑定分机不能为空'
  2436. });
  2437. return;
  2438. }
  2439. // 签入并绑定分机
  2440. // $rootScope.jry_extnNumberObj.jry_extnNumber.name 分机号
  2441. // $rootScope.user.id 坐席号(用户id)
  2442. tlwsa.tlaLogin($rootScope.user.id, 1, -1);
  2443. $rootScope.phoneNumber = $rootScope.user.id;
  2444. }
  2445. // 示闲
  2446. $rootScope.jry_shixian = function () {
  2447. tlwsa.tlaWca();
  2448. }
  2449. // 示忙
  2450. $rootScope.jry_shimang = function () {
  2451. tlwsa.tlaAcw();
  2452. }
  2453. // 签出
  2454. $rootScope.jry_qianchu = function () {
  2455. tlwsa.tlaLogoff();
  2456. }
  2457. // 呼叫坐席
  2458. // $scope.tlaCallagc = function () {
  2459. // tlwsa.tlaCallagc($rootScope.jry_extnNumberObj.tel1)
  2460. // }
  2461. // 呼叫外线
  2462. $scope.tlaCallout = function () {
  2463. // 选择目的号码
  2464. var reg1 = /^[0][1-9]{2,3}-[0-9]{5,10}$/;
  2465. var reg2 = /^(0|9|90|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
  2466. if(!reg1.test($rootScope.jry_extnNumberObj.tel1)&&!reg2.test($rootScope.jry_extnNumberObj.tel1)){
  2467. $.toaster({
  2468. priority: 'info',
  2469. title: '警告',
  2470. message: '请输入正确的手机号或座机号'
  2471. });
  2472. return;
  2473. }
  2474. // tlwsa.tlaCallout($rootScope.jry_extnNumberObj.tel1,$rootScope.jry_extnNumberObj.jry_extnNumber.name,0)
  2475. tlwsa.tlaCallout($rootScope.jry_extnNumberObj.tel1, '3558177',1);//襄阳主叫号码写死
  2476. }
  2477. // // 转移坐席
  2478. // $scope.tlaTransfertoagc = function () {
  2479. // tlwsa.tlaTransfertoagc($rootScope.jry_extnNumberObj.tel2)
  2480. // }
  2481. // 转移外线
  2482. $scope.tlaTransferout = function () {
  2483. // 选择转接号码
  2484. var reg1 = /^[0][1-9]{2,3}-[0-9]{5,10}$/;
  2485. var reg2 = /^(0|9|90|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
  2486. if(!reg1.test($rootScope.jry_extnNumberObj.tel2)&&!reg2.test($rootScope.jry_extnNumberObj.tel2)){
  2487. $.toaster({
  2488. priority: 'info',
  2489. title: '警告',
  2490. message: '请输入正确的手机号或座机号'
  2491. });
  2492. return;
  2493. }
  2494. // tlwsa.tlaTransferout($rootScope.jry_extnNumberObj.tel2,$rootScope.jry_extnNumberObj.jry_extnNumber.name,0)
  2495. tlwsa.tlaTransferout($rootScope.jry_extnNumberObj.tel2, '3558177',1);//襄阳主叫号码写死
  2496. }
  2497. })
  2498. }
  2499. // ------------------------------3--------------------------
  2500. $rootScope.getExtnDirect3 = function(){
  2501. console.log($rootScope.user)
  2502. var user = $rootScope.user;
  2503. initImUser(user.email, user.msgUuid);
  2504. // $rootScope.start(JSON.parse(localStorage.userdata).commonExtension.name);
  2505. api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function(data) {
  2506. $scope.runNumber = data;
  2507. $scope.phone = $scope.runNumber[0].name;
  2508. $rootScope.phoneChange($scope.phone);
  2509. })
  2510. if ($rootScope.userMenus.length == 0) {
  2511. getMenus();
  2512. }
  2513. if(localStorage.getItem('hk_phone')){
  2514. $rootScope.start(localStorage.getItem('hk_phone'));
  2515. }
  2516. }
  2517. // ------------------------------4盒子--------------------------start
  2518. $rootScope.phoneNumListBind = []; //已绑定分机列表
  2519. $rootScope.phoneNumListSelected = []; //选中的分机列表
  2520. $rootScope.phoneNumList = []; //所有分机列表
  2521. $rootScope.newOrderShow = false; //展示/隐藏新建工单弹框
  2522. $rootScope.newOrderShowOpen = false; //展示/隐藏新建工单弹框(辅助项)
  2523. $rootScope.applyDept; //申请科室
  2524. $rootScope.applyDeptMiddle; //申请科室(中间传递)
  2525. $rootScope.getExtnDirect4 = function () {
  2526. console.log(WebsocketPhoneService);
  2527. $rootScope.getPhoneNum();
  2528. }
  2529. $rootScope.getPhoneNum = function(flag = true) {
  2530. if (!flag) {
  2531. //切换院区的时候清除掉缓存中的号码
  2532. localStorage.removeItem("box_phones");
  2533. }
  2534. $rootScope.phoneNumListBind = localStorage.getItem("box_phones")
  2535. ? localStorage.getItem("box_phones").split("_")
  2536. : [];
  2537. $rootScope.phoneNumListSelected = localStorage.getItem("box_phones")
  2538. ? localStorage.getItem("box_phones").split("_")
  2539. : [];
  2540. if ($rootScope.phoneNumListBind.length) {
  2541. $rootScope.getWebsocketPhone();
  2542. }
  2543. }
  2544. // 查报修科室
  2545. function seachBoxBxDept(callInPhoneNumber, callID){
  2546. var postData = { "idx": 0, "sum": 10, "department": { phone: callInPhoneNumber } };//hjzxPhone
  2547. api_user_data.fetchDataList('department', postData).then(function (result) {
  2548. if (result.status == 200) {
  2549. console.log(result.list);
  2550. var requesters = result.list;
  2551. if (requesters.length === 0) {
  2552. //未匹配到报修科室
  2553. $rootScope.newOrder({
  2554. incident: {
  2555. sockid: callID,
  2556. incomingPhone: callInPhoneNumber,
  2557. source: {id:1547,name:'电话'}
  2558. },
  2559. },'incomingCall')
  2560. } else if (requesters.length === 1) {
  2561. //匹配到一个报修科室
  2562. $rootScope.newOrder({
  2563. incident: {
  2564. department: requesters[0],
  2565. phone: requesters[0].phone,
  2566. sockid: callID,
  2567. incomingPhone: callInPhoneNumber,
  2568. source: {id:1547,name:'电话'}
  2569. },
  2570. },'incomingCall')
  2571. } else {
  2572. //匹配到多个报修科室
  2573. $modal.open({
  2574. templateUrl: 'assets/views/incident/tpl/tel.html',
  2575. controller: function ($scope, $modalInstance, $timeout, SweetAlert) {
  2576. $scope.list = requesters;
  2577. $scope.selected = {
  2578. selectedItem: 0
  2579. };
  2580. $scope.cancel = function () {
  2581. $rootScope.newOrderShowOpen = false;
  2582. $modalInstance.dismiss('cancel');
  2583. };
  2584. $scope.changeBxr = function (id) {
  2585. $scope.selected.selectedItem = id;
  2586. }
  2587. $scope.save = function () {
  2588. var item = $scope.list.find(v => v.id == $scope.selected.selectedItem);
  2589. if (item) {
  2590. $scope.cancel();
  2591. $rootScope.newOrder({
  2592. incident: {
  2593. department: item,
  2594. phone: item.phone,
  2595. sockid: callID,
  2596. incomingPhone: callInPhoneNumber,
  2597. source: {id:1547,name:'电话'}
  2598. },
  2599. },'incomingCall')
  2600. } else {
  2601. SweetAlert.swal({
  2602. title: "请选择报修科室!",
  2603. type: "error"
  2604. })
  2605. }
  2606. }
  2607. }
  2608. });
  2609. }
  2610. }
  2611. })
  2612. }
  2613. // 连接websocket---phone
  2614. // 待完成
  2615. $rootScope.getWebsocketPhone = function() {
  2616. $rootScope.isMask = true;
  2617. // {"userCount":"LiaoMingMing|3369_3366"}
  2618. let userCount = $rootScope.user.account + "|" + $rootScope.phoneNumListSelected.join("_");
  2619. WebsocketPhoneService.connectWs($rootScope.seiminCallBoxIp, { userCount }).subscribe((data) => {
  2620. // data = { status: 201, phone: '013581394341' };//ceshi
  2621. var callID = data.callId;
  2622. console.log(data);
  2623. $rootScope.isMask = false;
  2624. if (data.status == 200 && data.phone) {
  2625. $.toaster({
  2626. priority: 'info',
  2627. title: '操作',
  2628. message: '连接成功'
  2629. });
  2630. localStorage.setItem("box_phones", data.phone);
  2631. $rootScope.phoneNumListBind = data.phone.split("_");
  2632. $rootScope.phoneNumListBind.forEach((item) => {
  2633. let obj = $rootScope.phoneNumList.find((item1) => item1.value === item);
  2634. if (obj) {
  2635. obj.checked = true;
  2636. }
  2637. });
  2638. } else if (data.status == 201 && data.phone) {
  2639. if (!$rootScope.newOrderShow && !$rootScope.newOrderShowOpen) {
  2640. seachBoxBxDept(data.phone, callID);
  2641. }
  2642. } else if (data.status == 201 && data.phone === "") {
  2643. //没绑定科室
  2644. if (!$rootScope.newOrderShow && !$rootScope.newOrderShowOpen) {
  2645. $rootScope.newOrder({
  2646. incident: {
  2647. sockid: callID,
  2648. incomingPhone: data.phone,
  2649. source: {id:1547,name:'电话'}
  2650. },
  2651. },'incomingCall')
  2652. }
  2653. }
  2654. });
  2655. }
  2656. // 选择分机
  2657. $rootScope.changePhones = function(value) {
  2658. $rootScope.phoneNumListSelected = $rootScope.phoneNumList.filter(v => v.checked).map(v => v.value);
  2659. $rootScope.phoneNumListSelectedStr = $rootScope.phoneNumListSelected.length ? '您选择了'+ $rootScope.phoneNumListSelected.map(v => '‘'+ v +'’').join('') +'号码,可在下方选择后确认更新。' : '请选择分机';
  2660. console.log($rootScope.phoneNumListSelected);
  2661. }
  2662. //获取所有分机号码列表
  2663. $rootScope.getPhoneNumList = function() {
  2664. this.phoneNumLoading = true;
  2665. let postData = {
  2666. idx: 0,
  2667. sum: 100,
  2668. hospitalConfig: { hosId: this.checkedHos },
  2669. };
  2670. this.mainService
  2671. .getFetchDataList("simple/data", "hospitalConfig", postData)
  2672. .subscribe((result) => {
  2673. this.phoneNumLoading = false;
  2674. this.phoneNumList = result.list.filter(
  2675. (item) => item.key.includes("phone_num_port") && item.value
  2676. );
  2677. this.phoneNumList.map((item) => {
  2678. return { ...item, checked: false };
  2679. });
  2680. this.phoneNumListBind.forEach((item) => {
  2681. let obj = this.phoneNumList.find((item1) => item1.value === item);
  2682. if (obj) {
  2683. obj.checked = true;
  2684. }
  2685. });
  2686. });
  2687. }
  2688. //确定绑定
  2689. $rootScope.bindingOk = function() {
  2690. if ($rootScope.phoneNumListSelected.length > 0) {
  2691. WebsocketPhoneService.closeWs(true);
  2692. $rootScope.getWebsocketPhone();
  2693. } else {
  2694. localStorage.removeItem("box_phones");
  2695. $rootScope.phoneNumListBind = [];
  2696. $rootScope.phoneNumList.forEach((item) => {
  2697. item.checked = false;
  2698. });
  2699. WebsocketPhoneService.closeWs(true);
  2700. }
  2701. }
  2702. // ------------------------------4盒子--------------------------end
  2703. $rootScope.jry_state = 'weiqianru';
  2704. window.addEventListener('load', function () {
  2705. $rootScope.judgeHjzx(false, true);
  2706. })
  2707. //话机呼叫中心--结束
  2708. // 未接来电
  2709. $scope.jry_getUnanswered = function () {
  2710. var jry_data = {
  2711. idx: 0,
  2712. sum: 999,
  2713. "callRecord": {
  2714. "todayTime": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 00:00:00",
  2715. "todayTimeEnd": new Date().getFullYear() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getDate() + " 23:59:59",
  2716. }
  2717. }
  2718. api_bpm_data.fetchDataList("callRecord", jry_data).then(function (data) {
  2719. // fo0h
  2720. for (var i = 0; i < data.list.length; i++) {
  2721. 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()
  2722. }
  2723. $rootScope.jry_unansweredData = data.list;
  2724. });
  2725. }
  2726. // $scope.jry_getUnanswered();
  2727. // 来电号码回拨
  2728. $scope.jry_callBack = function (data) {
  2729. var callBackData = {
  2730. "callRecord": {
  2731. "id": data.id,
  2732. "isAnswered": "1"
  2733. }
  2734. };
  2735. api_bpm_data.updData("callRecord", callBackData).then(function (res) {
  2736. if (res) {
  2737. $scope.jry_getUnanswered();
  2738. dial(data.callerIdNumber)
  2739. }
  2740. });
  2741. if (data.department.id && data.requester) {
  2742. 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 } }
  2743. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  2744. } else if (data.department.id) {
  2745. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
  2746. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  2747. } else {
  2748. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
  2749. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  2750. };
  2751. // ws.send("{\"type\":\"1\",\"phone\":\""+data.phone+"\"}");
  2752. }
  2753. //来电号码生成事件
  2754. $scope.jry_callToIncident = function (data) {
  2755. if (data.department.id && data.requester) {
  2756. 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 } }
  2757. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  2758. } else if (data.department.id) {
  2759. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'dept': data.department, 'faultLocation': data.department.address, 'source': { 'id': 1 } }, 'openModel': true } }
  2760. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  2761. } else {
  2762. var toData = { 'model': { 'incident': { 'contactsInformation': data.callerIdNumber, 'source': { 'id': 1 } } } }
  2763. $state.go('app.incident.title', { 'model': JSON.stringify(toData) });
  2764. }
  2765. }
  2766. $scope.onChangeadd = function (searchData) {
  2767. $scope.searchKey = searchData.account;
  2768. // $scope.searchDataadd = searchData;
  2769. var requesdata = angular.copy(searchData)
  2770. $scope.requester = requesdata;
  2771. }
  2772. $scope.refreshUseradd = function (searchKey) { //主题搜索
  2773. $scope.searchData = searchKey;
  2774. reashdata($scope.searchData);
  2775. }
  2776. $scope.getMydata = function (x) {
  2777. $scope.telephone = JSON.parse(x).phone;
  2778. $scope.searchField = $scope.telephone;
  2779. return $scope.searchField;
  2780. }
  2781. $scope.getMydataone = function (x) {
  2782. $scope.telephone = x;
  2783. $scope.searchField = $scope.telephone;
  2784. }
  2785. $scope.fildata = {
  2786. "idx": 0,
  2787. "sum": 10,
  2788. "flag": -1
  2789. }
  2790. function reashdata(item) {
  2791. if (item && item != "") {
  2792. angular.extend($scope.fildata, { 'user': { 'flag': -1, 'phone': item } })
  2793. } else {
  2794. delete $scope.fildata.user;
  2795. }
  2796. api_wechatfile.getDictionary({ "type": "list", "key": "hjzx_cornet" }).then(function (data) {
  2797. if (data.status == 200) {
  2798. $scope.myData = data.list;
  2799. }
  2800. })
  2801. // api_user_data.fetchDataList('user', $scope.fildata).then(function(response) {
  2802. // if (response) {
  2803. // if (response.status = 200) {
  2804. // var myData = response;
  2805. // $scope.myData = myData.list;
  2806. // }
  2807. // }
  2808. // })
  2809. }
  2810. if (window.location && window.location.hash == "#/echart") {
  2811. } else {
  2812. $rootScope.user && reashdata();
  2813. }
  2814. $rootScope.end = function () {
  2815. api_text.logout($rootScope.takes, $rootScope.user.id).then(function (data) {
  2816. if (data.errno == 0) {
  2817. localStorage.removeItem('hk_phone');
  2818. api_text.exit($rootScope.takes).then(function (data) {
  2819. if (data.errno == 0) {
  2820. $rootScope.statuscall = 0;
  2821. $scope.login = false;
  2822. // SweetAlert.swal({
  2823. // title: "登出成功",
  2824. // text: "呼叫中心登出成功!",
  2825. // type: "success"
  2826. // });
  2827. // }else{SweetAlert.swal({
  2828. // title: "登出失败",
  2829. // text: "呼叫中心登出失败!",
  2830. // type: "error"
  2831. // });
  2832. }
  2833. })
  2834. }
  2835. })
  2836. }
  2837. $rootScope.dialout = function (gid, teleno) {
  2838. var telephone = "";
  2839. if (teleno && teleno.length > 4) {
  2840. telephone = '9' + teleno;
  2841. } else {
  2842. // telephone = '*01' + teleno + '*';
  2843. telephone = teleno;
  2844. }
  2845. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  2846. if (data.errno == 0) {
  2847. // $rootScope.statuscall = 3;
  2848. $rootScope.callout = true;
  2849. // $rootScope.phone=teleno;
  2850. }
  2851. })
  2852. }
  2853. // $scope.busy=false;
  2854. $rootScope.setbusy = function () {
  2855. api_text.setbusy($rootScope.takes).then(function (data) {
  2856. if (data.errno == 0) {
  2857. $rootScope.statecall = 2;
  2858. $scope.busy = true;
  2859. }
  2860. })
  2861. }
  2862. $rootScope.setidle = function () {
  2863. api_text.setidle($rootScope.takes).then(function (data) {
  2864. if (data.errno == 0) {
  2865. $rootScope.statecall = 1;
  2866. $scope.busy = false;
  2867. }
  2868. })
  2869. }
  2870. $rootScope.inittrans = function (telephone) {
  2871. api_text.inittrans(telephone, $rootScope.takes).then(function (data) {
  2872. if (data.errno == 0) {
  2873. // $scope.status=9
  2874. }
  2875. })
  2876. }
  2877. $rootScope.comptrans = function () {
  2878. api_text.comptrans($rootScope.takes).then(function (data) {
  2879. if (data.errno == 0) {
  2880. $rootScope.statuscall = 1;
  2881. }
  2882. })
  2883. }
  2884. $rootScope.takeup = function () {
  2885. api_text.offhook($rootScope.takes).then(function (data) {
  2886. if (data.errno == 0) {
  2887. $rootScope.statuscall = 3;
  2888. }
  2889. })
  2890. }
  2891. $rootScope.takedown = function () {
  2892. api_text.onhook($rootScope.takes).then(function (data) {
  2893. if (data.errno == 0) {
  2894. $rootScope.statuscall = 1;
  2895. }
  2896. })
  2897. }
  2898. $rootScope.saveData = function (selectdata) {
  2899. var modalInstance = $modal.open({
  2900. templateUrl: 'assets/views/system/tpl/createknowledge.html',
  2901. controller: function ($scope, $modalInstance, api_bpm_data) {
  2902. $scope.worktimedata = {};
  2903. $scope.worktimedata = selectdata;
  2904. $scope.cancel = function () {
  2905. $modalInstance.dismiss('cancel');
  2906. };
  2907. $scope.savercode = function (worktimedata) {
  2908. var fildata = {
  2909. "scheduleclass": {
  2910. "id": selectdata.id,
  2911. "code": worktimedata.code,
  2912. "name": worktimedata.title,
  2913. "person": worktimedata.person,
  2914. "description": worktimedata.description,
  2915. "startTime": worktimedata.startTime,
  2916. "endTime": worktimedata.endTime,
  2917. "shiftTime": selectdata.shiftTime,
  2918. "succeedTime": selectdata.succeedTime,
  2919. "isTemplate": worktimedata.isTemplate
  2920. }
  2921. }
  2922. api_bpm_data.updData('scheduleclass', fildata).then(function (response) {
  2923. if (response) {
  2924. if (response.status == 200) {
  2925. SweetAlert.swal({
  2926. title: "修改成功!",
  2927. type: "success"
  2928. }, function () {
  2929. // $scope.refreshData('expand-right', defaultFilterData);
  2930. })
  2931. } else {
  2932. SweetAlert.swal({
  2933. title: "修改失败!",
  2934. type: "error"
  2935. })
  2936. }
  2937. }
  2938. })
  2939. $modalInstance.close();
  2940. }
  2941. }
  2942. });
  2943. }
  2944. $rootScope.changepassword = function (data1, size) {
  2945. var modalInstance = $modal.open({
  2946. templateUrl: 'assets/views/changepassword.html',
  2947. controller: function ($scope, $modalInstance, items, Restangular, SweetAlert) {
  2948. $scope.passwordnull = function (originalPwd, pwd, pwd_2) {
  2949. return originalPwd == undefined || pwd == undefined || pwd_2 == undefined || originalPwd == "" || pwd == "" || pwd_2 == "" || originalPwd == "null" || pwd == "null" || pwd_2 == "null";
  2950. }
  2951. $scope.savepassword = function (originalPwd, pwd, pwd_2) {
  2952. $modalInstance.dismiss('cancel');
  2953. // console.log('pwd=' + pwd + '+' + pwd_2);
  2954. // if(angular.isDefined(pwd)&&angular.isDefined(pwd_2)){
  2955. if (pwd == pwd_2) {
  2956. var data2 = {};
  2957. data2["originalPwd"] = originalPwd;
  2958. data2["userid"] = $rootScope.user.id;
  2959. data2["pwd"] = pwd;
  2960. api_login.uppwd(data2).then(function (response) {
  2961. var myData = Restangular.stripRestangular(response);
  2962. if (myData.status == 200) {
  2963. SweetAlert.swal({
  2964. title: "保存成功!",
  2965. type: "success",
  2966. confirmButtonColor: "#007AFF"
  2967. });
  2968. } else {
  2969. SweetAlert.swal({
  2970. title: "保存失败!",
  2971. text: "输入旧密码错误,请重新输入!",
  2972. type: "error"
  2973. });
  2974. }
  2975. })
  2976. } else {
  2977. SweetAlert.swal({
  2978. title: "两次输入的新密码不相同!",
  2979. text: "输入错误,请重新输入!",
  2980. type: "error"
  2981. });
  2982. }
  2983. // }else{
  2984. // SweetAlert.swal({
  2985. // title: "密码不能为空!",
  2986. // text: "请输入密码!",
  2987. // type: "error"
  2988. // });
  2989. // }
  2990. }
  2991. },
  2992. size: size,
  2993. resolve: {
  2994. items: function () {
  2995. return {
  2996. fetchItems: function (filterData, APIService) { }
  2997. };
  2998. },
  2999. }
  3000. });
  3001. }
  3002. // 修改院区科室
  3003. $rootScope.intervalTime = sessionStorage.getItem('intervalTime')?JSON.parse(sessionStorage.getItem('intervalTime')):{
  3004. flag: false,
  3005. rotationInterval: 10,
  3006. rotationIntervals: [3, 5, 10, 15, 20, 25, 30, 35, 40, 45],
  3007. logTimeConst: 60,
  3008. logTimeConsts: [30, 60, 90, 120, 150, 180, 210, 240, 270, 300],
  3009. }
  3010. $rootScope.changeHospitalDept = function (flag = false) {
  3011. $rootScope.intervalTime.flag = flag;
  3012. var modalInstance = $modal.open({
  3013. templateUrl: 'assets/views/changeHospitalDept.html',
  3014. controller: function ($scope, $modalInstance, items, Restangular, SweetAlert) {
  3015. console.log($rootScope.user.duty)
  3016. $scope.f = {
  3017. uuid:''
  3018. };
  3019. $scope.dataList = {};
  3020. // $scope.dataList = [];
  3021. // $scope.hospitalAndDutyDept = {};
  3022. // $scope.dutyDeptList = [];
  3023. // $scope.branchObj = {};
  3024. // $scope.f = {
  3025. // hospitalDepartment:$rootScope.user.duty?$rootScope.user.duty:''
  3026. // };
  3027. // // 获取所属的院区科室
  3028. // var dutyDepts = [];//责任科室
  3029. // var branchs = [];//院区
  3030. // $rootScope.user.role.forEach(v=>{
  3031. // dutyDepts = dutyDepts.concat(v.dutyDepts);
  3032. // branchs = branchs.concat(v.branchs);
  3033. // })
  3034. // // 责任科室除重
  3035. // var obj = {};
  3036. // dutyDepts = dutyDepts.reduce(function(item, next) {
  3037. // obj[next.id] ? '' : obj[next.id] = true && item.push(next);
  3038. // return item;
  3039. // }, []);
  3040. // $scope.dutyDeptList = dutyDepts;
  3041. // // 院区除重
  3042. // var obj1 = {};
  3043. // branchs = branchs.reduce(function(item, next) {
  3044. // obj1[next.id] ? '' : obj1[next.id] = true && item.push(next);
  3045. // return item;
  3046. // }, []);
  3047. // // $scope.branchs = branchs;
  3048. // // 院区数据处理
  3049. // $scope.branchObj = angular.copy(branchs).find(v=>v.children.length>0);
  3050. // $scope.branchObj.children.sort((a,b)=>a.id-b.id);
  3051. // // 处理责任科室数据
  3052. // $scope.hospitalAndDutyDept = {};
  3053. // $scope.dutyDeptList.forEach(v=>{
  3054. // if($scope.hospitalAndDutyDept[v.branch]){
  3055. // $scope.hospitalAndDutyDept[v.branch].push(v);
  3056. // }else{
  3057. // $scope.hospitalAndDutyDept[v.branch] = [v];
  3058. // }
  3059. // })
  3060. // console.log(dutyDepts,branchs)
  3061. // ----------------------------------------------
  3062. // api_category.branchDutyList({ "userId": $rootScope.user.id }).then(function(response) {
  3063. // if(response.status == 200){
  3064. // $scope.dataList = response.data;
  3065. // $scope.branchObj = response.data.find(v=>!v.parent);
  3066. // $scope.otherBranchs = response.data.filter(v=>v.parent);
  3067. // if($rootScope.user.duty){
  3068. // $scope.f.uuid = $rootScope.user.duty.uuid;
  3069. // }else if($rootScope.user.branch){
  3070. // $scope.f.uuid = $rootScope.user.branch.uuid;
  3071. // }
  3072. // }else{
  3073. // SweetAlert.swal({
  3074. // title: "系统错误!",
  3075. // text: "请刷新重试!",
  3076. // type: "error"
  3077. // });
  3078. // }
  3079. // })
  3080. // ------------------------------------------------------------------------------
  3081. $scope.hospitalAndDutyDept = {};
  3082. $scope.dutyDeptList = [];
  3083. $scope.branchObj = {};
  3084. api_category.branchDutyList({ "userId": $rootScope.user.id }).then(function(response1) {
  3085. if(response1.status == 200){
  3086. $scope.dataList = angular.copy(response1.data);
  3087. if(!$scope.dataList.branchs){
  3088. $scope.dataList.branchs = [];
  3089. }
  3090. if(!$scope.dataList.dutys){
  3091. $scope.dataList.dutys = [];
  3092. }
  3093. var roleObj = response1.data;
  3094. api_user_data.fetchDataList('branch', { "idx": 0, "sum": 1000 }).then(function(res) {
  3095. if (res.status == 200) {
  3096. api_user_data.fetchDataList('dutyDepartment', { "idx": 0, "sum": 1000 }).then(function(response) {
  3097. if (response.status == 200) {
  3098. // 院区数据处理
  3099. $scope.branchObj = angular.copy(res.list).find(v=>v.children.length>0);
  3100. $scope.branchObj.children.sort((a,b)=>a.id-b.id);
  3101. // 清空
  3102. response.list.forEach(v=>{
  3103. v.flag = false
  3104. });
  3105. $scope.dutyDeptList = response.list;
  3106. $scope.branchObj.flag = false;
  3107. $scope.branchObj.children.forEach(v=>{
  3108. v.flag = false;
  3109. })
  3110. // 回显数据接口数据
  3111. if(roleObj){
  3112. roleObj.dutys.forEach(v=>{
  3113. $scope.dutyDeptList.forEach(vv=>{
  3114. if(v.id == vv.id){
  3115. vv.flag = true;
  3116. }
  3117. })
  3118. })
  3119. roleObj.branchs.forEach(v=>{
  3120. if(v.id == $scope.branchObj.id){
  3121. $scope.branchObj.flag = true;
  3122. }
  3123. $scope.branchObj.children.forEach(vv=>{
  3124. if(v.id == vv.id){
  3125. vv.flag = true;
  3126. }
  3127. })
  3128. })
  3129. }
  3130. // 回显当前所属院区或责任科室
  3131. if($rootScope.user.duty){
  3132. $scope.f.uuid = $rootScope.user.duty.uuid;
  3133. }else if($rootScope.user.branch){
  3134. $scope.f.uuid = $rootScope.user.branch.uuid;
  3135. }
  3136. // 处理责任科室数据
  3137. $scope.hospitalAndDutyDept = {};
  3138. $scope.dutyDeptList.forEach(v=>{
  3139. if($scope.hospitalAndDutyDept[v.branch]){
  3140. $scope.hospitalAndDutyDept[v.branch].push(v);
  3141. }else{
  3142. $scope.hospitalAndDutyDept[v.branch] = [v];
  3143. }
  3144. })
  3145. console.log($scope.branchObj,$scope.hospitalAndDutyDept)
  3146. } else {
  3147. SweetAlert.swal({
  3148. title: "系统错误!",
  3149. text: "请刷新重试!",
  3150. type: "error"
  3151. });
  3152. }
  3153. });
  3154. } else {
  3155. SweetAlert.swal({
  3156. title: "系统错误!",
  3157. text: "请刷新重试!",
  3158. type: "error"
  3159. });
  3160. }
  3161. });
  3162. }else{
  3163. SweetAlert.swal({
  3164. title: "系统错误!",
  3165. text: "请刷新重试!",
  3166. type: "error"
  3167. });
  3168. }
  3169. })
  3170. // -----------------------------------
  3171. $scope.saveDept = function () {
  3172. if(! $scope.f.uuid){
  3173. SweetAlert.swal({
  3174. title: "保存失败!",
  3175. text: "请选择院区科室!",
  3176. type: "error"
  3177. });
  3178. return;
  3179. }
  3180. $modalInstance.dismiss('cancel');
  3181. var data2 = {};
  3182. var branchObj = $scope.dataList.branchs.find(v=>v.uuid == $scope.f.uuid);//查找院区的uuid
  3183. if(branchObj){
  3184. data2.branchId = branchObj.id;
  3185. }else{
  3186. var dutyObj = $scope.dataList.dutys.find(v=>v.uuid == $scope.f.uuid);//查询责任科室的uuid
  3187. if(dutyObj){
  3188. data2.dutyId = dutyObj.id;
  3189. }
  3190. }
  3191. // 当前所属院区或责任科室
  3192. if($rootScope.user.duty){
  3193. if(data2.dutyId && data2.dutyId == $rootScope.user.duty.id){
  3194. sessionStorage.setItem('intervalTime', JSON.stringify($rootScope.intervalTime))
  3195. return;
  3196. }
  3197. }else if($rootScope.user.branch){
  3198. if(data2.branchId && data2.branchId == $rootScope.user.branch.id){
  3199. sessionStorage.setItem('intervalTime', JSON.stringify($rootScope.intervalTime))
  3200. return;
  3201. }
  3202. }
  3203. $rootScope.isMask = true;
  3204. api_login.changeBranch(data2).then(function (response) {
  3205. $rootScope.isMask = false;
  3206. var myData = Restangular.stripRestangular(response);
  3207. if (myData.status == 200) {
  3208. var jry_user = JSON.parse(localStorage.getItem('jry_user'));
  3209. myData.user.user.menu = jry_user.menu;
  3210. // jry_user.user = myData.user;
  3211. // console.log(jry_user,myData.user)
  3212. localStorage.setItem('jry_user',JSON.stringify(myData.user.user));
  3213. sessionStorage.setItem('intervalTime', JSON.stringify($rootScope.intervalTime));
  3214. localStorage.removeItem('phones');
  3215. localStorage.removeItem('box_phones');
  3216. SweetAlert.swal({
  3217. title: "切换成功!",
  3218. type: "success",
  3219. confirmButtonColor: "#007AFF"
  3220. },function(){
  3221. location.reload(true);
  3222. });
  3223. } else {
  3224. SweetAlert.swal({
  3225. title: "切换失败!",
  3226. type: "error"
  3227. });
  3228. }
  3229. }).catch(function(err){
  3230. $rootScope.isMask = false;
  3231. SweetAlert.swal({
  3232. title: "切换失败!",
  3233. type: "error"
  3234. });
  3235. })
  3236. }
  3237. $scope.cancel = function() {
  3238. $modalInstance.dismiss('cancel');
  3239. };
  3240. },
  3241. resolve: {
  3242. items: function () {
  3243. return {
  3244. fetchItems: function (filterData, APIService) { }
  3245. };
  3246. },
  3247. }
  3248. });
  3249. }
  3250. // $rootScope.getnochildpending = function() {
  3251. // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
  3252. // angular.forEach($rootScope.userMenus, function(item) {
  3253. // item.tipnum = 1;
  3254. // })
  3255. // }
  3256. // }
  3257. // $rootScope.getchildpending = function(cantdata) {
  3258. // if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
  3259. // angular.forEach($rootScope.userMenus, function(item) {
  3260. // item.tipnum = 1;
  3261. // angular.forEach(item, function(index) {
  3262. // index.tipnum = 18;
  3263. // })
  3264. // })
  3265. // }
  3266. // }
  3267. $rootScope.getpending = function () {
  3268. if(!$rootScope.user){return;}
  3269. if ($rootScope.userMenus && $rootScope.userMenus.length > 0) {
  3270. if ($rootScope.user.group) {
  3271. var groupArr = [];
  3272. for (var i = 0; i < $rootScope.user.group.length; i++) {
  3273. groupArr.push($rootScope.user.group[i].id)
  3274. }
  3275. var postData = {
  3276. "assignee": $rootScope.user.id,
  3277. "candidateGroups": groupArr.join(),
  3278. "idx": 0,
  3279. "sum": 1000
  3280. }
  3281. $scope.tabs = [
  3282. // {key: 'all', value: '全部事件', num: ''},
  3283. {key: 'todo', value: '待我接单', num: ''},
  3284. {key: 'doing', value: '待我处理', num: ''},
  3285. // {key: 'reassign', value: '重新指派', num: ''},
  3286. // {key: 'callback', value: '待我回访', num: ''},
  3287. {key: 'resolve', value: '由我解决', num: ''},
  3288. {key: 'owns', value: '与我关联', num: ''},
  3289. {key: 'storage', value: '暂存', num: ''},
  3290. ]
  3291. for (var i = 0; i < $rootScope.user.menu.length; i++) {
  3292. if ($rootScope.user.menu[i].link == "shijianliebiao_all") {
  3293. $scope.tabs.splice(0, 0 , {key: 'all', value: '全部事件', num: ''});
  3294. }
  3295. if ($rootScope.user.menu[i].link == "shijianliebiao_huifang") {
  3296. let index = $scope.tabs.findIndex(v => v.key == 'resolve');
  3297. $scope.tabs.splice(index, 0 , {key: 'callback', value: '待我回访', num: ''});
  3298. }
  3299. if ($rootScope.user.menu[i].link == "shijianliebiao_reassign") {
  3300. let index = $scope.tabs.findIndex(v => v.key == 'doing');
  3301. $scope.tabs.splice(index + 1, 0 , {key: 'reassign', value: '重新指派', num: ''});
  3302. }
  3303. }
  3304. postData.queryTask = $scope.tabs.map(v => v.key).toString()
  3305. api_bpm_data.getCount(postData).then(function (response) {
  3306. angular.forEach($rootScope.userMenus, function (item, i) {
  3307. item.tipshow = false;
  3308. if (response) {
  3309. if (response.hjzxCount > 0 || response.wechatWarningCount > 0) {
  3310. if (item.id == 58) {
  3311. item.tipshow = true;
  3312. }
  3313. }
  3314. if (response.inspectionCount > 0) {
  3315. if (item.id == 27) {
  3316. item.tipshow = true;
  3317. }
  3318. }
  3319. if (response.incidentCount > 0) {
  3320. if (item.id == 2) {
  3321. item.tipshow = true;
  3322. }
  3323. }
  3324. if (response.releaseCount > 0) {
  3325. if (item.id == 1215) {
  3326. item.tipshow = true;
  3327. }
  3328. }
  3329. if (response.solutionCount > 0) {
  3330. if (item.id == 21) {
  3331. item.tipshow = true;
  3332. }
  3333. }
  3334. if (response.changeCount > 0) {
  3335. if (item.id == 1212) {
  3336. item.tipshow = true;
  3337. }
  3338. }
  3339. if (response.problemCount > 0) {
  3340. if (item.id == 1209) {
  3341. item.tipshow = true;
  3342. }
  3343. }
  3344. if (response.applicationForm > 0) {
  3345. if (item.id == 1221) {
  3346. item.tipshow = true;
  3347. }
  3348. }
  3349. if ((parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
  3350. if (item.id == 21) {
  3351. item.tipshow = true;
  3352. }
  3353. }
  3354. if (item.children) {
  3355. angular.forEach(item.children, function (index) {
  3356. if (response.hjzxCount !== null && response.hjzxCount !== undefined) {
  3357. if (index.id == 1208) {
  3358. if (response.hjzxCount < 100) {
  3359. index.tipnum = response.hjzxCount;
  3360. } else {
  3361. index.tipnum = "99+";
  3362. }
  3363. }
  3364. }
  3365. if (response.wechatWarningCount !== null && response.wechatWarningCount !== undefined) {
  3366. if (index.id == 59) {
  3367. if (response.wechatWarningCount < 100) {
  3368. index.tipnum = response.wechatWarningCount;
  3369. } else {
  3370. index.tipnum = "99+";
  3371. }
  3372. }
  3373. }
  3374. if (response.problemCount !== null && response.problemCount !== undefined) {
  3375. if (index.id == 1210) {
  3376. if (response.problemCount < 100) {
  3377. index.tipnum = response.problemCount;
  3378. } else {
  3379. index.tipnum = "99+";
  3380. }
  3381. }
  3382. }
  3383. if (response.releaseCount !== null && response.releaseCount !== undefined) {
  3384. if (index.id == 1216) {
  3385. if (response.releaseCount < 100) {
  3386. index.tipnum = response.releaseCount;
  3387. } else {
  3388. index.tipnum = "99+";
  3389. }
  3390. }
  3391. }
  3392. if (response.inspectionCount !== null && response.inspectionCount !== undefined) {
  3393. if (index.id == 147) {
  3394. if (response.inspectionCount < 100) {
  3395. index.tipnum = response.inspectionCount;
  3396. } else {
  3397. index.tipnum = "99+";
  3398. }
  3399. }
  3400. }
  3401. if (response.solutionCount !== null && response.solutionCount !== undefined) {
  3402. if (index.id == 23) {
  3403. if (response.solutionCount < 100) {
  3404. index.tipnum = response.solutionCount;
  3405. } else {
  3406. index.tipnum = "99+";
  3407. }
  3408. }
  3409. }
  3410. if (response.changeCount !== null && response.changeCount !== undefined) {
  3411. if (index.id == 1213) {
  3412. if (response.changeCount < 100) {
  3413. index.tipnum = response.changeCount;
  3414. } else {
  3415. index.tipnum = "99+";
  3416. }
  3417. }
  3418. }
  3419. if (response.incidentCount !== null && response.incidentCount !== undefined) {
  3420. if (index.id == 3) {
  3421. if (response.incidentCount < 100) {
  3422. index.tipnum = response.incidentCount;
  3423. } else {
  3424. index.tipnum = "99+";
  3425. }
  3426. }
  3427. }
  3428. if (response.applicationForm !== null && response.applicationForm !== undefined) {
  3429. if (index.id == 1231) {
  3430. if (response.applicationForm < 100) {
  3431. index.tipnum = response.applicationForm;
  3432. } else {
  3433. index.tipnum = "99+";
  3434. }
  3435. }
  3436. }
  3437. if (response.toAuditCount && response.toReleaseCount && (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount)) > 0) {
  3438. if (index.id == 23) {
  3439. if (parseInt(response.toReleaseCount) + parseInt(response.toAuditCount) < 100) {
  3440. index.tipnum = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
  3441. } else {
  3442. index.tipnum = "99+";
  3443. }
  3444. }
  3445. }
  3446. })
  3447. }
  3448. }
  3449. })
  3450. // return $rootScope.userMenus;
  3451. // $scope.recordpending = response.;
  3452. // $scope.dashboardcount.knowledgedata = parseInt(response.toReleaseCount) + parseInt(response.toAuditCount);
  3453. })
  3454. } else {
  3455. // SweetAlert.swal("访问数据失败!", "该用户没有分配组", "error");
  3456. }
  3457. }
  3458. // console.log($rootScope.userMenus);
  3459. }
  3460. $rootScope.userMenus = [];
  3461. var getMenus = function () {
  3462. function convertListToTree(data, treeMap) {
  3463. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3464. var root = null; //Initially set our loop to null
  3465. var parentNode = null;
  3466. //loop over data
  3467. for (var i = 0; i < data.length; i++) {
  3468. // data[i].id = Number(data[i].id);
  3469. var datum = data[i];
  3470. //each node will have children, so let's give it a "children" poperty
  3471. datum.children = [];
  3472. //add an entry for this node to the map so that any future children can
  3473. //lookup the parent
  3474. idToNodeMap[datum.id] = datum;
  3475. //Does this node have a parent?
  3476. if (typeof datum.parentid === "undefined" || datum.parentid == null) {
  3477. //Doesn't look like it, so this node is the root of the tree
  3478. root = datum;
  3479. treeMap[datum.id] = root;
  3480. } else {
  3481. //This node has a parent, so let's look it up using the id
  3482. parentNode = idToNodeMap[datum.parentid];
  3483. //We don't need this property, so let's delete it.
  3484. //delete datum.parentid;
  3485. //Let's add the current node as a child of the parent node.
  3486. parentNode.children.push(datum);
  3487. }
  3488. }
  3489. return root;
  3490. }
  3491. function convertParentToChildList(data) {
  3492. var treeMap = {};
  3493. var list = [];
  3494. convertListToTree(data, treeMap);
  3495. angular.forEach(treeMap, function (item) {
  3496. list.push(item);
  3497. });
  3498. list = window._.sortBy(list, function (o) {
  3499. return o.orders;
  3500. });
  3501. return list;
  3502. }
  3503. //if(userMenus.length==0){
  3504. var userMenus = [];
  3505. var idMapMenu = {};
  3506. if ($rootScope.user) {
  3507. if ($rootScope.user.menu) {
  3508. var allJurisdiction2 = $rootScope.user.menu;
  3509. var onlyMenu2 = [];
  3510. for (var i = 0; i < allJurisdiction2.length; i++) {
  3511. if (allJurisdiction2[i].event == "1") {
  3512. onlyMenu2.push(allJurisdiction2[i])
  3513. }
  3514. }
  3515. // userMenus = convertParentToChildList($rootScope.user.menu);
  3516. userMenus = convertParentToChildList(onlyMenu2);
  3517. }
  3518. }
  3519. //}
  3520. $rootScope.userMenus = userMenus;
  3521. if ($rootScope.userMenus.length > 0) {
  3522. $rootScope.getpending();
  3523. // setInterval($rootScope.getpending(), 30000);
  3524. }
  3525. return userMenus;
  3526. }
  3527. setInterval(function () {
  3528. if ($rootScope.userMenus.length > 0) {
  3529. $rootScope.getpending()
  3530. $rootScope.getMsgNum($rootScope.user.id)
  3531. }
  3532. }, 10000);
  3533. getMenus();
  3534. // console.log("$rootScope.nickname="+JSON.stringify($rootScope));
  3535. $rootScope.logout = function () {
  3536. // var userid =data.id;
  3537. // console.log(' userid='+JSON.stringify( userid));
  3538. //单点登录
  3539. if (localStorage.getItem('isSSo') === '1') {
  3540. sessionStorage.clear();
  3541. localStorage.clear();
  3542. location.href = 'http://' + location.hostname + ':8080/pc_logout.jsp'
  3543. } else {
  3544. $auth.signOut()
  3545. .then(function (resp) {
  3546. // $auth.deleteData('auth_headers')
  3547. sessionStorage.clear();
  3548. localStorage.clear();
  3549. console.log($rootScope.isHk,'hk');
  3550. console.log($rootScope.isZncd,'zncd');
  3551. console.log($rootScope.isXy,'xy');
  3552. console.log($rootScope.isXyBox,'isXyBox');
  3553. if($rootScope.isZncd || $rootScope.isXy){
  3554. if ($rootScope.isFuwutai) {
  3555. tlwsa.tlaClose();
  3556. $.toaster({
  3557. priority: 'info',
  3558. title: '操作',
  3559. message: '呼叫中心断开连接'
  3560. });
  3561. }
  3562. }else if($rootScope.isXyBox){
  3563. if ($rootScope.isFuwutai) {
  3564. WebsocketPhoneService.closeWs(true);
  3565. }
  3566. }
  3567. $state.go("login.signin");
  3568. })
  3569. .catch(function (resp) { });
  3570. }
  3571. //$cookieStore.remove("userObm");
  3572. //$cookieStore.remove("menuObm");
  3573. //$cookieStore.remove("session");
  3574. //$rootScope.user = undefined;
  3575. //$rootScope.menus = undefined;
  3576. //$rootScope.nickname = undefined;
  3577. //window.location = "http://www.itsm.com:8080/itsm/dev/logout.jsp";
  3578. // //logout: function(noServerLogout){
  3579. // window.sessionStorage.clear();
  3580. // window.location = "https://www.yunwei.com:8443/cas/loginout";
  3581. // //},
  3582. }
  3583. // 首页统计跳转
  3584. $scope.goTo = function(url,data){
  3585. $state.go(url,data);
  3586. }
  3587. //获取首页建单统计信息
  3588. $rootScope.getOrderCount = function(){
  3589. // api_bpm_data.getManagerIndexInfo({}).then(function(result) {
  3590. // $scope.managerIndexInfo = result.data;
  3591. // });
  3592. var postData = {}
  3593. // 根据权限查询
  3594. if($rootScope.user.duty){
  3595. // 当前的所属责任科室
  3596. postData.dutyId = $rootScope.user.duty.id;
  3597. }else if($rootScope.user.branch){
  3598. // 当前的所属院区
  3599. postData.branchId = $rootScope.user.branch.id;
  3600. }
  3601. api_newreport.fetchDataListIndex('dutyOrderCount', postData).then(function(data) {
  3602. if (data.status == 200) {
  3603. $scope.managerIndexInfo = {
  3604. createOrders: data.today,
  3605. waitOrders: data.receiving,
  3606. doingOrders: data.doing,
  3607. doneOrders: data.complete,
  3608. }
  3609. }
  3610. })
  3611. }
  3612. // $rootScope.getOrderCount();
  3613. // 快速建单
  3614. $rootScope.newOrder = function (model1, type = '') {
  3615. $rootScope.newOrderShowOpen = true;
  3616. $rootScope.newOrderType = type;
  3617. //进入弹窗,强制示忙
  3618. if (localStorage.getItem('fenjiNumber')) {
  3619. setTimeout(()=>{
  3620. tlwsa.tlaAcw();
  3621. },0)
  3622. }
  3623. $modal.open({
  3624. backdrop: false,
  3625. templateUrl:
  3626. "assets/views/newOrderSeimin.html",
  3627. controller: function (
  3628. $scope,
  3629. $parse,
  3630. fileReader,
  3631. FileUploader,
  3632. $modalInstance,
  3633. SweetAlert,
  3634. api_user_data,
  3635. api_bpm_domain,
  3636. up_down_file,
  3637. $rootScope,
  3638. modelData
  3639. ) {
  3640. // -------------------start----------------------
  3641. $scope.modelData = modelData;
  3642. // 事件报修图片
  3643. $scope.requestImgs = [];
  3644. // 当前所属院区处理
  3645. console.log(modelData);
  3646. // if(modelData){
  3647. // var curentHospital = undefined;
  3648. // api_bpm_data.fetchData('department', modelData.incident.department.id).then(res=>{
  3649. // if(res.status == 200){
  3650. // console.log(res.data);
  3651. // curentHospital = {id:1,hosName:'同济医院-主院区'}
  3652. // }
  3653. // })
  3654. // }else{
  3655. // var curentHospital = $rootScope.user.duty?{id:$rootScope.user.duty.branch,hosName:$rootScope.user.duty.branchName}:$rootScope.user.branch;
  3656. // }
  3657. if(modelData && type !== 'incomingCall'){
  3658. var curentHospital = {id: modelData.branch, hosName: modelData.branchName};
  3659. }else{
  3660. var curentHospital = $rootScope.user.duty?{id:$rootScope.user.duty.branch,hosName:$rootScope.user.duty.branchName}:$rootScope.user.branch;
  3661. }
  3662. // 是否连续建单
  3663. $scope.isBuildOrderAgagin = false;
  3664. //工单列表数据存储
  3665. $scope.incidentModel = {
  3666. department: "", //报修科室
  3667. requester: "", //报修人
  3668. contacts: "", //联系人
  3669. contactsInformation: "", //联系电话
  3670. branch: curentHospital, //院区
  3671. area: "", //区域
  3672. place: "", //地点
  3673. address: "", //详细地址
  3674. priority: "", //优先级
  3675. description: "", //故障描述
  3676. source: {id:1547,name:'电话'}, //事件来源
  3677. yyTime: null, //预约报修时间
  3678. assign: 1, //派单人或组
  3679. user: "", //处理人
  3680. group: "", //处理组
  3681. };
  3682. console.log(modelData)
  3683. if(modelData){
  3684. //报修生成事件,数据回显
  3685. //来电生成事件,数据回显
  3686. //暂存生成事件,数据回显
  3687. // 报修图片
  3688. if (modelData.incident && modelData.incident.id) {
  3689. $rootScope.isMask = true;
  3690. api_wechatfile.listAttachment("wechatRequesterIncident", modelData.incident.id).then( (res) => {
  3691. $rootScope.isMask = false;
  3692. $scope.requestImgs = res.data || [];
  3693. });
  3694. }
  3695. $scope.categorySelect = modelData.incident.category;
  3696. $scope.jry_modelLeft = modelData.incident.category?modelData.incident.category.mutiCategory:'';
  3697. console.log($scope.jry_deptData)
  3698. $scope.incidentModel = {
  3699. id: modelData.incident.id || undefined, //事件id
  3700. department: modelData.incident.department, //报修科室
  3701. requester: modelData.incident.requester || undefined, //报修人
  3702. contacts: modelData.incident.contacts, //联系人
  3703. contactsInformation: type === 'incomingCall' ? modelData.incident.incomingPhone : modelData.incident.contactsInformation, //联系电话
  3704. branch: curentHospital, //院区
  3705. area: type === 'incomingCall' ? (modelData.incident.department ? (modelData.incident.department.place ? modelData.incident.department.place.area : "") : "") : (modelData.incident.place ? modelData.incident.place.area : ""), //区域
  3706. place: type === 'incomingCall' ? (modelData.incident.department ? (modelData.incident.department.place || "") : "") : (modelData.incident.place || ""), //地点
  3707. address: type === 'incomingCall' ? (modelData.incident.department ? modelData.incident.department.address : "") : modelData.incident.houseNumber, //详细地址
  3708. priority: modelData.incident.priority, //优先级
  3709. description: modelData.incident.description, //故障描述
  3710. source: modelData.incident.source, //事件来源
  3711. yyTime: null, //预约报修时间
  3712. assign: 1, //派单人或组
  3713. user: "", //处理人
  3714. group: "", //处理组
  3715. callID: type === 'incomingCall' ? (modelData.incident.sockid || undefined) : (modelData.incident.callID || undefined), //callID
  3716. incomingPhone: modelData.incident.incomingPhone || undefined, //来电电话
  3717. };
  3718. }
  3719. $scope.minYYtime = new Date();
  3720. // 预览图片
  3721. $scope.previewNew = function (type, url, idx) {
  3722. let title = $scope[type][idx].title;
  3723. $modal.open({
  3724. backdrop: false,
  3725. size: "sm",
  3726. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  3727. controller: function ($scope, $rootScope, scope, $modalInstance) {
  3728. $scope.title = title;
  3729. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  3730. $scope.cancel = function () {
  3731. $modalInstance.dismiss("cancel");
  3732. };
  3733. },
  3734. resolve: {
  3735. scope: function () {
  3736. return $scope;
  3737. },
  3738. },
  3739. });
  3740. };
  3741. // 编辑后保存
  3742. $scope.editSave = function(){
  3743. if(!$scope.categorySelectId){
  3744. SweetAlert.swal({
  3745. title: "提示",
  3746. text: "请选择故障现象!",
  3747. type: "error",
  3748. confirmButtonColor: "#DD6B55"
  3749. });
  3750. return;
  3751. }
  3752. if(!$scope.selectedDuty){
  3753. SweetAlert.swal({
  3754. title: "提示",
  3755. text: "故障现象【"+ $scope.categorySelect.category +"】没有设置责任科室!",
  3756. type: "error",
  3757. confirmButtonColor: "#DD6B55"
  3758. });
  3759. return;
  3760. }
  3761. if(!$scope.incidentModel.department){
  3762. SweetAlert.swal({
  3763. title: "提示",
  3764. text: "请选择报修科室!",
  3765. type: "error",
  3766. confirmButtonColor: "#DD6B55"
  3767. });
  3768. return;
  3769. }
  3770. if(!$scope.incidentModel.contactsInformation){
  3771. SweetAlert.swal({
  3772. title: "提示",
  3773. text: "请填写联系电话!",
  3774. type: "error",
  3775. confirmButtonColor: "#DD6B55"
  3776. });
  3777. return;
  3778. }
  3779. if(!$scope.incidentModel.priority){
  3780. SweetAlert.swal({
  3781. title: "提示",
  3782. text: "请选择优先级!",
  3783. type: "error",
  3784. confirmButtonColor: "#DD6B55"
  3785. });
  3786. return;
  3787. }
  3788. if(!$scope.incidentModel.description){
  3789. SweetAlert.swal({
  3790. title: "提示",
  3791. text: "请选择故障描述!",
  3792. type: "error",
  3793. confirmButtonColor: "#DD6B55"
  3794. });
  3795. return;
  3796. }
  3797. $rootScope.isMask = true;
  3798. var repair_main = JSON.parse(sessionStorage.getItem('repair_main'));
  3799. var postData = {
  3800. "incident": {
  3801. "id": $scope.incidentModel.id || undefined,
  3802. "deleteFlag": 0,
  3803. "duty":$scope.selectedDuty?$scope.selectedDuty:undefined,
  3804. "department": $scope.incidentModel.department||undefined,
  3805. "contactsInformation": $scope.incidentModel.contactsInformation,
  3806. "contacts": $scope.incidentModel.contacts,
  3807. "branch": $scope.incidentModel.branch?$scope.incidentModel.branch.id:undefined,
  3808. "area": $scope.incidentModel.area||undefined,
  3809. "place": $scope.incidentModel.place||undefined,
  3810. "houseNumber": $scope.incidentModel.address,
  3811. "category": $scope.categorySelect||undefined,
  3812. "priority": $scope.incidentModel.priority||undefined,
  3813. "source": $scope.incidentModel.source||undefined,
  3814. "title": $scope.categorySelect.category,
  3815. "description": $scope.incidentModel.description,
  3816. "yyTime": $scope.incidentModel.yyTime ? moment($scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
  3817. "repairType": repair_main?repair_main.valueconfig:undefined,
  3818. "requester":$scope.incidentModel.requester||undefined,
  3819. "acceptUser": $rootScope.user||undefined,
  3820. "callID": $scope.incidentModel.callID||undefined,
  3821. "incomingPhone": $scope.incidentModel.incomingPhone||undefined,
  3822. }
  3823. };
  3824. $scope.modelData && (postData.incident = Object.assign({}, $scope.modelData.incident, postData.incident));
  3825. api_flow.accept("edit", postData).then(function (response) {
  3826. // if ($scope.uploader != null) {
  3827. // // 有图片
  3828. // $scope.uploader.onBeforeUploadItem = function(item) {
  3829. // angular.extend(item.headers, $rootScope.getSession());
  3830. // item.url = api_bpm_domain.uploadAttachmentJryModel("wechatRequesterIncident", response.data.id).getRequestedUrl();
  3831. // item.formData.push({ 'fileName': item.file.name });
  3832. // };
  3833. // $scope.uploader.uploadAll();
  3834. // }
  3835. $rootScope.isMask = false;
  3836. SweetAlert.swal(
  3837. {
  3838. title: "保存成功!",
  3839. type: "success",
  3840. confirmButtonColor: "#007AFF",
  3841. },
  3842. function (isConfirm) {
  3843. if(isConfirm){
  3844. if (localStorage.getItem('fenjiNumber')) {
  3845. $rootScope.jry_shixian();
  3846. }
  3847. $modalInstance.dismiss("cancel");
  3848. $rootScope.newOrderShowOpen = false;
  3849. if($state.current.name === 'app.incident.list'){
  3850. $state.reload();
  3851. }else{
  3852. $state.go("app.incident.list");
  3853. }
  3854. }
  3855. }
  3856. );
  3857. });
  3858. }
  3859. // 建单并派单
  3860. $scope.buildAndAssign = function(){
  3861. if(!$scope.categorySelectId){
  3862. SweetAlert.swal({
  3863. title: "提示",
  3864. text: "请选择故障现象!",
  3865. type: "error",
  3866. confirmButtonColor: "#DD6B55"
  3867. });
  3868. return;
  3869. }
  3870. if(!$scope.selectedDuty){
  3871. SweetAlert.swal({
  3872. title: "提示",
  3873. text: "故障现象【"+ $scope.categorySelect.category +"】没有设置责任科室!",
  3874. type: "error",
  3875. confirmButtonColor: "#DD6B55"
  3876. });
  3877. return;
  3878. }
  3879. if(!$scope.incidentModel.department){
  3880. SweetAlert.swal({
  3881. title: "提示",
  3882. text: "请选择报修科室!",
  3883. type: "error",
  3884. confirmButtonColor: "#DD6B55"
  3885. });
  3886. return;
  3887. }
  3888. if(!$scope.incidentModel.contactsInformation){
  3889. SweetAlert.swal({
  3890. title: "提示",
  3891. text: "请填写联系电话!",
  3892. type: "error",
  3893. confirmButtonColor: "#DD6B55"
  3894. });
  3895. return;
  3896. }
  3897. if(!$scope.incidentModel.priority){
  3898. SweetAlert.swal({
  3899. title: "提示",
  3900. text: "请选择优先级!",
  3901. type: "error",
  3902. confirmButtonColor: "#DD6B55"
  3903. });
  3904. return;
  3905. }
  3906. if(!$scope.incidentModel.description){
  3907. SweetAlert.swal({
  3908. title: "提示",
  3909. text: "请选择故障描述!",
  3910. type: "error",
  3911. confirmButtonColor: "#DD6B55"
  3912. });
  3913. return;
  3914. }
  3915. if($scope.incidentModel.assign == 0){
  3916. SweetAlert.swal({
  3917. title: "提示",
  3918. text: "请选择派单给人或组!",
  3919. type: "error",
  3920. confirmButtonColor: "#DD6B55"
  3921. });
  3922. return;
  3923. }
  3924. if($scope.incidentModel.assign == 1 && !$scope.incidentModel.user){
  3925. SweetAlert.swal({
  3926. title: "提示",
  3927. text: "请选择处理人!",
  3928. type: "error",
  3929. confirmButtonColor: "#DD6B55"
  3930. });
  3931. return;
  3932. }
  3933. if($scope.incidentModel.assign == 2 && !$scope.incidentModel.group){
  3934. SweetAlert.swal({
  3935. title: "提示",
  3936. text: "请选择处理组!",
  3937. type: "error",
  3938. confirmButtonColor: "#DD6B55"
  3939. });
  3940. return;
  3941. }
  3942. $rootScope.isMask = true;
  3943. var repair_main = JSON.parse(sessionStorage.getItem('repair_main'));
  3944. // var postData = {
  3945. // "loginUser": $rootScope.user,
  3946. // "incident": {
  3947. // "deleteFlag": 0,
  3948. // "duty":$scope.selectedDuty?$scope.selectedDuty:undefined,
  3949. // "department": $scope.incidentModel.department||undefined,
  3950. // "contactsInformation": $scope.incidentModel.contactsInformation,
  3951. // "contacts": $scope.incidentModel.contacts,
  3952. // "branch": $scope.incidentModel.branch?$scope.incidentModel.branch.id:undefined,
  3953. // "area": $scope.incidentModel.area||undefined,
  3954. // "place": $scope.incidentModel.place||undefined,
  3955. // "houseNumber": $scope.incidentModel.address,
  3956. // "category": $scope.categorySelect||undefined,
  3957. // "priority": $scope.incidentModel.priority||undefined,
  3958. // "source": $scope.incidentModel.source||undefined,
  3959. // "title": $scope.categorySelect.category,
  3960. // "description": $scope.incidentModel.description,
  3961. // "yyTime": $scope.incidentModel.yyTime ? moment($scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
  3962. // "repairType": repair_main?repair_main.valueconfig:undefined,
  3963. // "requester":$scope.incidentModel.requester||undefined,
  3964. // "acceptUser": $rootScope.user||undefined,
  3965. // "callID": $scope.incidentModel.callID||undefined,
  3966. // "incomingPhone": $scope.incidentModel.incomingPhone||undefined,
  3967. // },
  3968. // "start_code": "assignment",
  3969. // "initUser": $rootScope.user.id
  3970. // };
  3971. var postData = {
  3972. "incident": {
  3973. "id": $scope.incidentModel.id || undefined,
  3974. "deleteFlag": 0,
  3975. "duty":$scope.selectedDuty?$scope.selectedDuty:undefined,
  3976. "department": $scope.incidentModel.department||undefined,
  3977. "contactsInformation": $scope.incidentModel.contactsInformation,
  3978. "contacts": $scope.incidentModel.contacts,
  3979. "branch": $scope.incidentModel.branch?$scope.incidentModel.branch.id:undefined,
  3980. "area": $scope.incidentModel.area||undefined,
  3981. "place": $scope.incidentModel.place||undefined,
  3982. "houseNumber": $scope.incidentModel.address,
  3983. "category": $scope.categorySelect||undefined,
  3984. "priority": $scope.incidentModel.priority||undefined,
  3985. "source": $scope.incidentModel.source||undefined,
  3986. "title": $scope.categorySelect.category,
  3987. "description": $scope.incidentModel.description,
  3988. "yyTime": $scope.incidentModel.yyTime ? moment($scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
  3989. "repairType": repair_main?repair_main.valueconfig:undefined,
  3990. "requester":$scope.incidentModel.requester||undefined,
  3991. "acceptUser": $rootScope.user||undefined,
  3992. "callID": $scope.incidentModel.callID||undefined,
  3993. "incomingPhone": $scope.incidentModel.incomingPhone||undefined,
  3994. }
  3995. };
  3996. $scope.modelData && (postData.incident = Object.assign({}, $scope.modelData.incident, postData.incident));
  3997. // if(modelData){
  3998. // // 微信报修转事件
  3999. // postData.flow = modelData.flow;
  4000. // }
  4001. if($scope.incidentModel.assign == 1){
  4002. postData.incident.assignee = $scope.incidentModel.user.id;
  4003. }else if($scope.incidentModel.assign == 2){
  4004. postData.incident.candidateGroups = $scope.incidentModel.group.id;
  4005. }
  4006. api_bpm_domain.workernumber('sj').then(res1=>{
  4007. postData.incident.incidentsign = res1.data;
  4008. api_flow.accept("accept", postData).then(function (response) {
  4009. if ($scope.uploader != null) {
  4010. // 有图片
  4011. $scope.uploader.onBeforeUploadItem = function(item) {
  4012. angular.extend(item.headers, $rootScope.getSession());
  4013. item.url = api_bpm_domain.uploadAttachmentJryModel("wechatRequesterIncident", response.data.id).getRequestedUrl();
  4014. item.formData.push({ 'fileName': item.file.name });
  4015. };
  4016. $scope.uploader.uploadAll();
  4017. }
  4018. $rootScope.isMask = false;
  4019. SweetAlert.swal(
  4020. {
  4021. title: "保存成功!",
  4022. type: "success",
  4023. confirmButtonColor: "#007AFF",
  4024. },
  4025. function (isConfirm) {
  4026. if(isConfirm){
  4027. // 是否连续建单
  4028. if($scope.isBuildOrderAgagin){
  4029. $scope.categorySelect = "";
  4030. $scope.categorySelectId = 0;
  4031. $scope.incidentModel.assign = 1;
  4032. $scope.incidentModel.user = "";
  4033. $scope.incidentModel.group = "";
  4034. }else{
  4035. if (localStorage.getItem('fenjiNumber')) {
  4036. $rootScope.jry_shixian();
  4037. }
  4038. $modalInstance.dismiss("cancel");
  4039. }
  4040. $rootScope.newOrderShowOpen = false;
  4041. if($state.current.name === 'app.incident.list'){
  4042. $state.reload();
  4043. }else{
  4044. $state.go("app.incident.list");
  4045. }
  4046. }
  4047. }
  4048. );
  4049. });
  4050. })
  4051. }
  4052. // 暂存
  4053. $scope.temporaryStorage = function(){
  4054. $rootScope.isMask = true;
  4055. var repair_main = JSON.parse(sessionStorage.getItem('repair_main'));
  4056. var postData = {
  4057. "incident": {
  4058. "id": $scope.incidentModel.id || undefined,
  4059. "deleteFlag": 0,
  4060. "duty":$scope.selectedDuty?$scope.selectedDuty:undefined,
  4061. "department": $scope.incidentModel.department||undefined,
  4062. "contactsInformation": $scope.incidentModel.contactsInformation,
  4063. "contacts": $scope.incidentModel.contacts,
  4064. "branch": $scope.incidentModel.branch?$scope.incidentModel.branch.id:undefined,
  4065. "area": $scope.incidentModel.area||undefined,
  4066. "place": $scope.incidentModel.place||undefined,
  4067. "houseNumber": $scope.incidentModel.address,
  4068. "category": $scope.categorySelect||undefined,
  4069. "priority": $scope.incidentModel.priority||undefined,
  4070. "source": $scope.incidentModel.source||undefined,
  4071. "title": $scope.categorySelect.category,
  4072. "description": $scope.incidentModel.description,
  4073. "yyTime": $scope.incidentModel.yyTime ? moment($scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
  4074. "repairType": repair_main?repair_main.valueconfig:undefined,
  4075. "requester":$scope.incidentModel.requester||undefined,
  4076. "acceptUser": $rootScope.user||undefined,
  4077. "callID": $scope.incidentModel.callID||undefined,
  4078. "incomingPhone": $scope.incidentModel.incomingPhone||undefined,
  4079. }
  4080. };
  4081. $scope.modelData && (postData.incident = Object.assign({}, $scope.modelData.incident, postData.incident));
  4082. // if(modelData){
  4083. // // 微信报修转事件
  4084. // postData.flow = modelData.flow;
  4085. // }
  4086. if($scope.incidentModel.assign == 1){
  4087. postData.incident.assignee = $scope.incidentModel ? $scope.incidentModel.user.id : undefined;
  4088. }else if($scope.incidentModel.assign == 2){
  4089. postData.incident.candidateGroups = $scope.incidentModel ? $scope.incidentModel.group.id : undefined;
  4090. }
  4091. api_bpm_domain.workernumber('sj').then(res1=>{
  4092. postData.incident.incidentsign = res1.data;
  4093. api_flow.accept("storage", postData).then(function (response) {
  4094. if ($scope.uploader != null) {
  4095. // 有图片
  4096. $scope.uploader.onBeforeUploadItem = function(item) {
  4097. angular.extend(item.headers, $rootScope.getSession());
  4098. item.url = api_bpm_domain.uploadAttachmentJryModel("wechatRequesterIncident", response.data.id).getRequestedUrl();
  4099. item.formData.push({ 'fileName': item.file.name });
  4100. };
  4101. $scope.uploader.uploadAll();
  4102. }
  4103. $rootScope.isMask = false;
  4104. SweetAlert.swal(
  4105. {
  4106. title: "保存成功!",
  4107. type: "success",
  4108. confirmButtonColor: "#007AFF",
  4109. },
  4110. function (isConfirm) {
  4111. if(isConfirm){
  4112. // 是否连续建单
  4113. if($scope.isBuildOrderAgagin){
  4114. $scope.categorySelect = "";
  4115. $scope.categorySelectId = 0;
  4116. $scope.incidentModel.assign = 1;
  4117. $scope.incidentModel.user = "";
  4118. $scope.incidentModel.group = "";
  4119. }else{
  4120. if (localStorage.getItem('fenjiNumber')) {
  4121. $rootScope.jry_shixian();
  4122. }
  4123. $modalInstance.dismiss("cancel");
  4124. }
  4125. $rootScope.newOrderShowOpen = false;
  4126. if($state.current.name === 'app.incident.list'){
  4127. $state.reload();
  4128. }else{
  4129. $state.go("app.incident.list");
  4130. }
  4131. }
  4132. }
  4133. );
  4134. });
  4135. })
  4136. }
  4137. // 展开/收起
  4138. $scope.showId = "";
  4139. $scope.ifshow = false;
  4140. $scope.showAll = function (id) {
  4141. $scope.attachments = [];
  4142. if ($scope.showId == id) {
  4143. $scope.ifshow = !$scope.ifshow;
  4144. } else {
  4145. $scope.ifshow = true;
  4146. }
  4147. $scope.showId = id;
  4148. // 获取附件
  4149. api_wechatfile
  4150. .listAttachments("knowledge", $scope.showId)
  4151. .then(function (data) {
  4152. $scope.attachments = data.data;
  4153. $scope.download = function (token, filename) {
  4154. var downUrl = up_down_file
  4155. .downloadAttachment("common/common/downloadAttachment", token)
  4156. .getRequestedUrl();
  4157. var a = document.createElement("a");
  4158. a.href = downUrl;
  4159. a.target = "_blank";
  4160. a.download = filename;
  4161. document.body.appendChild(a);
  4162. a.click();
  4163. };
  4164. });
  4165. };
  4166. // 切换派人或派组
  4167. $scope.assginChange = function(){
  4168. $scope.incidentModel.user = '';
  4169. $scope.incidentModel.group = '';
  4170. }
  4171. // 处理人/处理组加责任科室搜索
  4172. $scope.userAndGroupSearch = async function(){
  4173. // $scope.jry_userSearch();
  4174. // $scope.jry_groupSearch();
  4175. var userData = {
  4176. idx: 0,
  4177. sum: 1000,
  4178. user: {
  4179. duty: $scope.selectedDuty || undefined,
  4180. roledata: {rolecode: "first-line support"},
  4181. selectDetails:'1',
  4182. simple:true,
  4183. name: '',
  4184. selectType: "pinyin_qs",
  4185. engineer: 1,
  4186. },
  4187. };
  4188. var groupData = {
  4189. idx: 0,
  4190. sum: 1000,
  4191. group: {
  4192. duty: $scope.selectedDuty || undefined,
  4193. selectType: "nouser"
  4194. },
  4195. };
  4196. let userResult = await api_user_data.fetchDataList("user", userData);
  4197. let groupResult = await api_user_data.fetchDataList("group", groupData);
  4198. $scope.jry_userData = userResult.list;
  4199. if($scope.incidentModel.user){
  4200. if(!$scope.incidentModel.user.name){
  4201. $scope.incidentModel.user = userResult.list.find(v=>v.id == $scope.incidentModel.user.id);
  4202. }
  4203. }
  4204. $scope.jry_groupData = groupResult.list;
  4205. // if($scope.incidentModel.assign == 0){
  4206. // $scope.jry_userSearch();
  4207. // $scope.jry_groupSearch();
  4208. // }else if($scope.incidentModel.assign == 1){
  4209. // $scope.jry_userSearch();
  4210. // }else if($scope.incidentModel.assign == 2){
  4211. // $scope.jry_groupSearch();
  4212. // }
  4213. }
  4214. // 回显处理人或组
  4215. $scope.showUserOrGroup = function(){
  4216. if($scope.incidentModel.department && $scope.categorySelect && $scope.selectedDuty && $scope.incidentModel.branch){
  4217. var postData = {
  4218. idx: 0,
  4219. sum: 10,
  4220. incidentAssignManager: {
  4221. deptId:$scope.incidentModel.department.id,
  4222. categoryId:$scope.categorySelect.id,
  4223. branch:$scope.incidentModel.branch.id,
  4224. dutyId: $scope.selectedDuty.id
  4225. },
  4226. };
  4227. api_user_data.fetchDataList("incidentAssignManager", postData).then(async function(result){
  4228. if(result.status == 200){
  4229. var deptBinduserConfig = result.list?result.list[0]:null;//获取第一条配置
  4230. if(deptBinduserConfig){
  4231. await $scope.userAndGroupSearch();
  4232. // 如果有科室绑定人员的配置
  4233. if(deptBinduserConfig.userOrGroupType == 1){
  4234. // 派单给人
  4235. $scope.incidentModel.assign = 1;
  4236. $scope.incidentModel.user = $scope.jry_userData.find(v=>v.id == deptBinduserConfig.handleUser);
  4237. }else if(deptBinduserConfig.userOrGroupType == 2){
  4238. // 派单给组
  4239. $scope.incidentModel.assign = 2;
  4240. $scope.incidentModel.group = $scope.jry_groupData.find(v=>v.id == deptBinduserConfig.group);
  4241. }
  4242. }else{
  4243. // 没有查询到科室绑定人员的配置,则根据院区,普通科室,责任科室查询
  4244. var postData = {
  4245. idx: 0,
  4246. sum: 10,
  4247. incidentAssignManager: {
  4248. deptId:$scope.incidentModel.department.id,
  4249. branch:$scope.incidentModel.branch.id,
  4250. dutyId: $scope.selectedDuty.id
  4251. },
  4252. };
  4253. api_user_data.fetchDataList("incidentAssignManager", postData).then(async function(result){
  4254. if(result.status == 200){
  4255. //获取配置
  4256. var deptBinduserConfig = result.list || [];
  4257. // 过滤掉有故障现象的配置
  4258. deptBinduserConfig = deptBinduserConfig.filter(v => !v.categoryId);
  4259. // 获取第一条配置
  4260. deptBinduserConfig = deptBinduserConfig[0] || null;
  4261. if(deptBinduserConfig){
  4262. await $scope.userAndGroupSearch();
  4263. // 如果有科室绑定人员的配置
  4264. if(deptBinduserConfig.userOrGroupType == 1){
  4265. // 派单给人
  4266. $scope.incidentModel.assign = 1;
  4267. $scope.incidentModel.user = $scope.jry_userData.find(v=>v.id == deptBinduserConfig.handleUser);
  4268. }else if(deptBinduserConfig.userOrGroupType == 2){
  4269. // 派单给组
  4270. $scope.incidentModel.assign = 2;
  4271. $scope.incidentModel.group = $scope.jry_groupData.find(v=>v.id == deptBinduserConfig.group);
  4272. }
  4273. }else{
  4274. if($scope.categorySelect){
  4275. // 选择了故障现象
  4276. assignCommon($scope.categorySelect);
  4277. }
  4278. }
  4279. }
  4280. })
  4281. }
  4282. }
  4283. })
  4284. }else if($scope.categorySelect){
  4285. // 选择了故障现象
  4286. assignCommon($scope.categorySelect);
  4287. }
  4288. }
  4289. // 直接解决
  4290. $scope.build = function(){
  4291. if(!$scope.categorySelectId){
  4292. SweetAlert.swal({
  4293. title: "提示",
  4294. text: "请选择故障现象!",
  4295. type: "error",
  4296. confirmButtonColor: "#DD6B55"
  4297. });
  4298. return;
  4299. }
  4300. if(!$scope.selectedDuty){
  4301. SweetAlert.swal({
  4302. title: "提示",
  4303. text: "故障现象【"+ $scope.categorySelect.category +"】没有设置责任科室!",
  4304. type: "error",
  4305. confirmButtonColor: "#DD6B55"
  4306. });
  4307. return;
  4308. }
  4309. if(!$scope.incidentModel.department){
  4310. SweetAlert.swal({
  4311. title: "提示",
  4312. text: "请选择报修科室!",
  4313. type: "error",
  4314. confirmButtonColor: "#DD6B55"
  4315. });
  4316. return;
  4317. }
  4318. if(!$scope.incidentModel.contactsInformation){
  4319. SweetAlert.swal({
  4320. title: "提示",
  4321. text: "请填写联系电话!",
  4322. type: "error",
  4323. confirmButtonColor: "#DD6B55"
  4324. });
  4325. return;
  4326. }
  4327. if(!$scope.incidentModel.priority){
  4328. SweetAlert.swal({
  4329. title: "提示",
  4330. text: "请选择优先级!",
  4331. type: "error",
  4332. confirmButtonColor: "#DD6B55"
  4333. });
  4334. return;
  4335. }
  4336. if(!$scope.incidentModel.description){
  4337. SweetAlert.swal({
  4338. title: "提示",
  4339. text: "请选择故障描述!",
  4340. type: "error",
  4341. confirmButtonColor: "#DD6B55"
  4342. });
  4343. return;
  4344. }
  4345. $modal.open({
  4346. templateUrl: "assets/views/newOrderDirectly.html",
  4347. controller: function ($scope,scope,$state, $modalInstance, SweetAlert,api_bpm) {
  4348. $scope.categorySelect = scope.categorySelect;
  4349. console.log($scope.categorySelect)
  4350. $scope.incidentModel = {
  4351. handlerMsg:'',//处理方案
  4352. closecode:'',//处理结果
  4353. };
  4354. // 处理结果
  4355. $scope.closecodeArray = [];
  4356. $scope.jry_closecodeSearch = function () {
  4357. api_wechatfile
  4358. .getDictionary({ type: "list", key: "incident_closecode" })
  4359. .then(function (data) {
  4360. $scope.closecodeArray = data;
  4361. });
  4362. };
  4363. $scope.jry_closecodeSearch();
  4364. // 确定
  4365. $scope.ok = function () {
  4366. if($scope.categorySelect.hasSimple != 1 && !$scope.incidentModel.handlerMsg){
  4367. SweetAlert.swal({
  4368. title: "提示",
  4369. text: "请填写处理方案!",
  4370. type: "error",
  4371. confirmButtonColor: "#DD6B55"
  4372. });
  4373. return;
  4374. }
  4375. if(!$scope.incidentModel.closecode.id){
  4376. SweetAlert.swal({
  4377. title: "提示",
  4378. text: "请选择处理结果!",
  4379. type: "error",
  4380. confirmButtonColor: "#DD6B55"
  4381. });
  4382. return;
  4383. }
  4384. // -------新建事件,积分机制,直接处理--------
  4385. var integralMechanism = sessionStorage.getItem('integralMechanism');
  4386. if(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2)){
  4387. $modal.open({
  4388. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  4389. controller: function ($scope, $modalInstance, incidentData,categorySelect, currentUserId, Alert, api_wechatfile,scope,api_bpm_data) {
  4390. console.log(incidentData,currentUserId,categorySelect);
  4391. $scope.complexityConfirm = {complexity:null,updateReason:''};
  4392. $scope.complexityFn = function(category){
  4393. if(category.complexity){
  4394. return category.complexity.value;
  4395. }else if(category.parent){
  4396. return $scope.complexityFn(category.parent);
  4397. }else{
  4398. return $scope.list[0]?$scope.list[0].value:1;
  4399. }
  4400. }
  4401. $scope.list = [];
  4402. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  4403. $scope.list = res;
  4404. if(categorySelect && categorySelect.id){
  4405. api_bpm_data.fetchData("incidentCategory",categorySelect.id).then(function(result){
  4406. if(result.status == 200){
  4407. $scope.complexity = $scope.complexityFn(result.data);
  4408. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  4409. }
  4410. })
  4411. }
  4412. })
  4413. $scope.onChangeComplexity = function(item){
  4414. }
  4415. $scope.ok = function () {
  4416. if (!$scope.complexityConfirm.complexity){
  4417. Alert.swal({
  4418. title: "操作失败",
  4419. text: "请选择工时!",
  4420. type: "error"
  4421. });
  4422. return;
  4423. }
  4424. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  4425. Alert.swal({
  4426. title: "操作失败",
  4427. text: "请填写升级原因!",
  4428. type: "error"
  4429. });
  4430. return;
  4431. }
  4432. $modalInstance.close('success');
  4433. handlerStart();
  4434. scope.complexity = $scope.complexity;
  4435. scope.complexityConfirm = $scope.complexityConfirm;
  4436. // 暂存--后面直接处理后调用积分接口
  4437. }
  4438. $scope.cancel = function () {
  4439. if (localStorage.getItem('fenjiNumber')) {
  4440. $rootScope.jry_shixian();
  4441. }
  4442. $modalInstance.dismiss('cancel');
  4443. }
  4444. },
  4445. size: 'sm',
  4446. resolve: {
  4447. scope: function () {
  4448. return $scope;
  4449. },
  4450. api_bpm: function () {
  4451. return api_bpm;
  4452. },
  4453. incidentData: function () {
  4454. return scope.incidentModel;
  4455. },
  4456. categorySelect: function () {
  4457. return scope.categorySelect;
  4458. },
  4459. currentUserId: function () {
  4460. return $rootScope.user.id;
  4461. },
  4462. Alert: function () {
  4463. return SweetAlert;
  4464. },
  4465. api_user_data: function () {
  4466. return api_user_data;
  4467. },
  4468. api_wechatfile: function () {
  4469. return api_wechatfile;
  4470. }
  4471. }
  4472. });
  4473. }else{
  4474. handlerStart();
  4475. }
  4476. // -------新建事件,积分机制,直接处理--------
  4477. };
  4478. // 直接处理,新建事件
  4479. function handlerStart(){
  4480. $rootScope.isMask = true;
  4481. console.log(scope.incidentModel,$scope.incidentModel);
  4482. var repair_main = JSON.parse(sessionStorage.getItem('repair_main'));
  4483. // var postData = {
  4484. // "loginUser": $rootScope.user||undefined,
  4485. // "incident": {
  4486. // "deleteFlag": 0,
  4487. // "duty":scope.selectedDuty?scope.selectedDuty:undefined,
  4488. // "requester":$scope.incidentModel.requester||undefined,
  4489. // "alarmType": false,
  4490. // "department": scope.incidentModel.department||undefined,
  4491. // "contactsInformation": scope.incidentModel.contactsInformation,
  4492. // "contacts": scope.incidentModel.contacts,
  4493. // "branch": scope.incidentModel.branch?scope.incidentModel.branch.id:undefined,
  4494. // "area": scope.incidentModel.area||undefined,
  4495. // "place": scope.incidentModel.place||undefined,
  4496. // "houseNumber": scope.incidentModel.address,
  4497. // "category": scope.categorySelect||undefined,
  4498. // "priority": scope.incidentModel.priority||undefined,
  4499. // "source": scope.incidentModel.source||undefined,
  4500. // "title": scope.categorySelect.category,
  4501. // "description": scope.incidentModel.description,
  4502. // "directProcess": 1,
  4503. // "handleDescription": $scope.incidentModel.handlerMsg,
  4504. // "handlingPersonnelUser":{id:$rootScope.user.id},
  4505. // "yyTime": scope.incidentModel.yyTime ? moment(scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
  4506. // "closecode": $scope.incidentModel.closecode||undefined,
  4507. // "repairType": repair_main?repair_main.valueconfig:undefined,
  4508. // "acceptUser": $rootScope.user||undefined,
  4509. // "callID": scope.incidentModel.callID||undefined,
  4510. // "incomingPhone": scope.incidentModel.incomingPhone||undefined,
  4511. // },
  4512. // "start_code": "close",
  4513. // "handler_code": "resolve",
  4514. // "initUser": $rootScope.user.id,
  4515. // "isSolution": false
  4516. // };
  4517. var postData = {
  4518. "incident": {
  4519. "id": scope.incidentModel.id || undefined,
  4520. "deleteFlag": 0,
  4521. "duty":scope.selectedDuty?scope.selectedDuty:undefined,
  4522. "requester":scope.incidentModel.requester||undefined,
  4523. "alarmType": false,
  4524. "department": scope.incidentModel.department||undefined,
  4525. "contactsInformation": scope.incidentModel.contactsInformation,
  4526. "contacts": scope.incidentModel.contacts,
  4527. "branch": scope.incidentModel.branch?scope.incidentModel.branch.id:undefined,
  4528. "area": scope.incidentModel.area||undefined,
  4529. "place": scope.incidentModel.place||undefined,
  4530. "houseNumber": scope.incidentModel.address,
  4531. "category": scope.categorySelect||undefined,
  4532. "priority": scope.incidentModel.priority||undefined,
  4533. "source": scope.incidentModel.source||undefined,
  4534. "title": scope.categorySelect.category,
  4535. "description": scope.incidentModel.description,
  4536. "directProcess": 1,
  4537. "handleDescription": $scope.incidentModel.handlerMsg,
  4538. "handlingPersonnelUser":{id:$rootScope.user.id},
  4539. "yyTime": scope.incidentModel.yyTime ? moment(scope.incidentModel.yyTime).format('YYYY-MM-DD HH:mm:ss') : undefined,
  4540. "closecode": $scope.incidentModel.closecode||undefined,
  4541. "repairType": repair_main?repair_main.valueconfig:undefined,
  4542. "acceptUser": $rootScope.user||undefined,
  4543. "callID": scope.incidentModel.callID||undefined,
  4544. "incomingPhone": scope.incidentModel.incomingPhone||undefined,
  4545. },
  4546. };
  4547. scope.modelData && (postData.incident = Object.assign({}, scope.modelData.incident, postData.incident));
  4548. // if(scope.modelData){
  4549. // // 微信报修转事件
  4550. // postData.flow = scope.modelData.flow;
  4551. // }
  4552. api_bpm_domain.workernumber('sj').then(res1=>{
  4553. postData.incident.incidentsign = res1.data;
  4554. api_flow.accept("accept", postData).then(function (resData) {
  4555. if (scope.uploader != null) {
  4556. // 有图片
  4557. scope.uploader.onBeforeUploadItem = function(item) {
  4558. angular.extend(item.headers, $rootScope.getSession());
  4559. item.url = api_bpm_domain.uploadAttachmentJryModel("wechatRequesterIncident", resData.data.id).getRequestedUrl();
  4560. item.formData.push({ 'fileName': item.file.name });
  4561. };
  4562. scope.uploader.uploadAll();
  4563. }
  4564. var integralMechanism = sessionStorage.getItem('integralMechanism');
  4565. if(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2)){
  4566. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  4567. var auditState = res.find(v=>v.value == 0);
  4568. var postData = {
  4569. incidentIntegral: {
  4570. incidentId:resData.bussId,
  4571. auditState:auditState,
  4572. handlerUser:$rootScope.user.id,
  4573. handlerUserName:$rootScope.user.name,
  4574. sourceScore:$scope.complexity,
  4575. currentScore:$scope.complexityConfirm.complexity.value,
  4576. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  4577. }
  4578. }
  4579. console.log(postData)
  4580. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  4581. console.log(response)
  4582. $rootScope.isMask = false;
  4583. if (response.status == 200) {
  4584. SweetAlert.swal(
  4585. {
  4586. title: "保存成功!",
  4587. type: "success",
  4588. confirmButtonColor: "#007AFF",
  4589. },
  4590. function (isConfirm) {
  4591. if(isConfirm){
  4592. $modalInstance.dismiss("cancel");
  4593. // 是否连续建单
  4594. if(scope.isBuildOrderAgagin){
  4595. scope.categorySelect = "";
  4596. scope.categorySelectId = 0;
  4597. scope.incidentModel.assign = 1;
  4598. scope.incidentModel.user = "";
  4599. scope.incidentModel.group = "";
  4600. }else{
  4601. if (localStorage.getItem('fenjiNumber')) {
  4602. $rootScope.jry_shixian();
  4603. }
  4604. scope.cancel();
  4605. }
  4606. $rootScope.newOrderShowOpen = false;
  4607. if($state.current.name === 'app.incident.list'){
  4608. $state.reload();
  4609. }else{
  4610. $state.go("app.incident.list");
  4611. }
  4612. }
  4613. }
  4614. );
  4615. } else {
  4616. Alert.swal({
  4617. title: "操作失败",
  4618. text: "操作失败, 请稍后再试!",
  4619. type: "error"
  4620. });
  4621. }
  4622. });
  4623. })
  4624. }else{
  4625. SweetAlert.swal(
  4626. {
  4627. title: "提交成功!",
  4628. type: "success",
  4629. confirmButtonColor: "#007AFF",
  4630. },
  4631. function (isConfirm) {
  4632. if(isConfirm){
  4633. if (localStorage.getItem('fenjiNumber')) {
  4634. $rootScope.jry_shixian();
  4635. }
  4636. scope.cancel();
  4637. $modalInstance.dismiss("cancel");
  4638. $rootScope.newOrderShowOpen = false;
  4639. if($state.current.name === 'app.incident.list'){
  4640. $state.reload();
  4641. }else{
  4642. $state.go("app.incident.list");
  4643. }
  4644. }
  4645. }
  4646. );
  4647. }
  4648. // -------------------------------------------
  4649. $rootScope.isMask = false;
  4650. SweetAlert.swal(
  4651. {
  4652. title: "保存成功!",
  4653. type: "success",
  4654. confirmButtonColor: "#007AFF",
  4655. },
  4656. function (isConfirm) {
  4657. if(isConfirm){
  4658. $modalInstance.dismiss("cancel");
  4659. // 是否连续建单
  4660. if(scope.isBuildOrderAgagin){
  4661. scope.categorySelect = "";
  4662. scope.categorySelectId = 0;
  4663. scope.incidentModel.assign = 1;
  4664. scope.incidentModel.user = "";
  4665. scope.incidentModel.group = "";
  4666. }else{
  4667. if (localStorage.getItem('fenjiNumber')) {
  4668. $rootScope.jry_shixian();
  4669. }
  4670. scope.cancel();
  4671. }
  4672. $rootScope.newOrderShowOpen = false;
  4673. if($state.current.name === 'app.incident.list'){
  4674. $state.reload();
  4675. }else{
  4676. $state.go("app.incident.list");
  4677. }
  4678. }
  4679. }
  4680. );
  4681. });
  4682. })
  4683. }
  4684. // 取消
  4685. $scope.cancel = function () {
  4686. if (localStorage.getItem('fenjiNumber')) {
  4687. $rootScope.jry_shixian();
  4688. }
  4689. $modalInstance.dismiss("cancel");
  4690. };
  4691. },
  4692. size:'lg',
  4693. resolve: {
  4694. SweetAlert: function () {
  4695. return SweetAlert;
  4696. },
  4697. scope: function(){
  4698. return $scope;
  4699. }
  4700. },
  4701. });
  4702. }
  4703. // 处理顶部责任科室数据
  4704. $scope.handlerDuty = function(){
  4705. if(!$scope.categorySelect){
  4706. return;
  4707. }
  4708. if($scope.categorySelect.branchType == 1){
  4709. // 分院区
  4710. if($scope.incidentModel.branch){
  4711. var dutyConfig = $scope.categorySelect.branchUserGroups.find(v=>v.branchId == $scope.incidentModel.branch.id);
  4712. if(dutyConfig && dutyConfig.dutyId && dutyConfig.dutyName){
  4713. $scope.selectedDuty = {id:dutyConfig.dutyId,dept:dutyConfig.dutyName};
  4714. }else{
  4715. $scope.selectedDuty = null;
  4716. }
  4717. }else{
  4718. $scope.selectedDuty = null;
  4719. }
  4720. }else{
  4721. // 不分院区
  4722. $scope.selectedDuty = $scope.categorySelect.dutyDepartment;
  4723. }
  4724. }
  4725. // 优先级
  4726. $scope.priorityArray = [];
  4727. $scope.jry_prioritySearch = function () {
  4728. api_wechatfile
  4729. .getDictionary({ type: "list", key: "incident_priority" })
  4730. .then(function (data) {
  4731. $scope.priorityArray = data;
  4732. });
  4733. };
  4734. $scope.jry_prioritySearch();
  4735. // 事件来源
  4736. $scope.sourceArray = [];
  4737. $scope.jry_sourceSearch = function () {
  4738. api_wechatfile
  4739. .getDictionary({ type: "list", key: "incident_source" })
  4740. .then(function (data) {
  4741. $scope.sourceArray = data;
  4742. if($scope.incidentModel.source){
  4743. if(!$scope.incidentModel.source.name && $scope.incidentModel.source.id){
  4744. $scope.incidentModel.source = data.find(v=>v.id == $scope.incidentModel.source.id)
  4745. }
  4746. }
  4747. });
  4748. };
  4749. $scope.jry_sourceSearch();
  4750. // 报修科室模糊搜索
  4751. $scope.jry_deptSearch = function (key = "",branchId) {
  4752. console.log(branchId)
  4753. if(!branchId){
  4754. $scope.jry_deptData = [];
  4755. return;
  4756. }
  4757. var deptData = {
  4758. idx: 0,
  4759. sum: 20,
  4760. department: {
  4761. branch:branchId,
  4762. dept:key,
  4763. selectType: "pinyin_qs",
  4764. searchType: "quickStart",
  4765. },
  4766. };
  4767. api_user_data.fetchDataList("department", deptData).then(function (data) {
  4768. $scope.jry_deptData = data.list;
  4769. if($scope.incidentModel.department){
  4770. if(!$scope.incidentModel.department.dept && $scope.incidentModel.department.id){
  4771. // $scope.incidentModel.department = data.list.find(v=>v.id == $scope.incidentModel.department.id)
  4772. api_bpm_data.fetchData('department', $scope.incidentModel.department.id).then(res=>{
  4773. if(res.status == 200){
  4774. $scope.incidentModel.department = res.data;
  4775. }else{
  4776. $scope.incidentModel.department = '';
  4777. }
  4778. })
  4779. }
  4780. }
  4781. });
  4782. };
  4783. // $scope.jry_deptSearch();
  4784. // 报修人模糊搜索
  4785. $scope.jry_requesterSearch = function (key = "") {
  4786. var postData = {
  4787. idx: 0,
  4788. sum: 10,
  4789. user: {
  4790. name: key,
  4791. selectType: "pinyin_all",
  4792. engineer: undefined,
  4793. },
  4794. };
  4795. api_user_data.fetchDataList("user", postData).then(function (data) {
  4796. $scope.jry_requesterData = data.list;
  4797. });
  4798. };
  4799. $scope.jry_requesterSearch();
  4800. $scope.$watch("incidentModel.requester", function (newVal,oldVal) {
  4801. if(newVal){
  4802. if($scope.modelData && newVal == oldVal){
  4803. }else{
  4804. $scope.incidentModel.contacts = newVal.name;
  4805. SweetAlert.swal({
  4806. title: "提示",
  4807. text: "是否覆盖联系电话?",
  4808. type: "warning",
  4809. showCancelButton: true,
  4810. confirmButtonColor: "#DD6B55",
  4811. confirmButtonText: "确认覆盖",
  4812. cancelButtonText: "取消操作",
  4813. closeOnConfirm: true,
  4814. closeOnCancel: true
  4815. }, function (isConfirm) {
  4816. if (isConfirm) {
  4817. $scope.incidentModel.contactsInformation = newVal.phone;
  4818. }
  4819. });
  4820. }
  4821. }
  4822. });
  4823. // 处理人模糊搜索
  4824. $scope.jry_userSearch = function (key = "") {
  4825. var userData = {
  4826. idx: 0,
  4827. sum: 1000,
  4828. user: {
  4829. duty: $scope.selectedDuty || undefined,
  4830. roledata: {rolecode: "first-line support"},
  4831. selectDetails:'1',
  4832. simple:true,
  4833. name: key,
  4834. selectType: "pinyin_qs",
  4835. engineer: 1,
  4836. },
  4837. };
  4838. api_user_data.fetchDataList("user", userData).then(function (data) {
  4839. $scope.jry_userData = data.list;
  4840. if($scope.incidentModel.user){
  4841. if(!$scope.incidentModel.user.name){
  4842. $scope.incidentModel.user = data.list.find(v=>v.id == $scope.incidentModel.user.id);
  4843. }
  4844. }
  4845. });
  4846. };
  4847. $scope.jry_userSearch();
  4848. // 处理组模糊搜索
  4849. $scope.jry_groupSearch = function (key = "") {
  4850. var groupData = {
  4851. idx: 0,
  4852. sum: 1000,
  4853. group: {
  4854. duty: $scope.selectedDuty || undefined,
  4855. selectType: "nouser"
  4856. },
  4857. };
  4858. api_user_data.fetchDataList("group", groupData).then(function (data) {
  4859. $scope.jry_groupData = data.list;
  4860. });
  4861. };
  4862. $scope.jry_groupSearch();
  4863. // 院区模糊搜索
  4864. $scope.jry_branchSearch = function (key = "") {
  4865. var postData = {
  4866. idx: 0,
  4867. sum: 1000
  4868. };
  4869. api_user_data.fetchDataList("branch", postData).then(function (data) {
  4870. $scope.jry_branchData = data.list;
  4871. if(modelData && modelData.incident && modelData.incident.department){
  4872. api_bpm_data.fetchData('department', modelData.incident.department.id).then(res=>{
  4873. if(res.status == 200){
  4874. $scope.incidentModel.branch = $scope.jry_branchData.find(v=>v.id == res.data.branch);
  4875. }
  4876. })
  4877. }
  4878. });
  4879. };
  4880. $scope.jry_branchSearch();
  4881. // 区域模糊搜索
  4882. $scope.jry_areaSearch = function (key='',branchId) {
  4883. if(!branchId){
  4884. $scope.jry_areaData = [];
  4885. return;
  4886. }
  4887. var areaData = {
  4888. idx: 0,
  4889. sum: 30,
  4890. area: {
  4891. branch:branchId,
  4892. area:key,
  4893. selectType:'pinyin_qs'
  4894. },
  4895. };
  4896. api_user_data.fetchDataList("area", areaData).then(function (data) {
  4897. $scope.jry_areaData = data.list;
  4898. });
  4899. };
  4900. // 地点模糊搜索
  4901. $scope.jry_placeSearch = function (key='',areaId) {
  4902. if(!areaId){
  4903. $scope.jry_placeData = [];
  4904. return;
  4905. }
  4906. var placeData = {
  4907. idx: 0,
  4908. sum: 30,
  4909. place: {
  4910. place: key,
  4911. areaId: areaId,
  4912. selectType:'pinyin_qs'
  4913. },
  4914. };
  4915. api_user_data.fetchDataList("place", placeData).then(function (data) {
  4916. $scope.jry_placeData = data.list;
  4917. });
  4918. };
  4919. $scope.changeBranch = function(){
  4920. $scope.incidentModel.area = '';
  4921. $scope.incidentModel.place = '';
  4922. $scope.incidentModel.department = '';
  4923. $scope.jry_placeData = [];
  4924. }
  4925. $scope.changeArea = function(){
  4926. $scope.incidentModel.place = '';
  4927. }
  4928. $scope.$watch("incidentModel.branch", function (newVal,oldVal) {
  4929. $scope.handlerDuty();
  4930. $scope.showUserOrGroup();
  4931. newVal && $scope.jry_areaSearch('',newVal.id);
  4932. newVal && $scope.jry_deptSearch('',newVal.id);
  4933. });
  4934. $scope.$watch("incidentModel.area", function (newVal,oldVal) {
  4935. newVal && $scope.jry_placeSearch('',newVal.id);
  4936. console.log(modelData, $scope.oldDept,$scope.incidentModel)
  4937. });
  4938. $scope.$watch("categorySelect", function (newVal,oldVal) {
  4939. if(newVal&&newVal.priority){
  4940. // 回显优先级
  4941. $scope.incidentModel.priority = newVal.priority;
  4942. }
  4943. // 选择了院区,科室,故障现象,责任科室
  4944. $scope.showUserOrGroup();
  4945. // 回显人员
  4946. if($scope.incidentModel.user){
  4947. if(!$scope.incidentModel.user.name){
  4948. $scope.incidentModel.user = $scope.jry_userData.find(v=>v.id == $scope.incidentModel.user.id);
  4949. }
  4950. }
  4951. });
  4952. // 派人或派组
  4953. async function assignCommon(sj){
  4954. console.log(sj);
  4955. if(!sj){return;}
  4956. await $scope.userAndGroupSearch();
  4957. if (sj.branchType == 0) {
  4958. if (sj.userOrGroupType === 1) {
  4959. //派人
  4960. $scope.incidentModel.assign = 1;
  4961. $scope.incidentModel.user = sj.handleUser ? $scope.jry_userData.find(v=>v.id == sj.handleUser.id) : "";
  4962. } else if (sj.userOrGroupType === 2) {
  4963. //派组
  4964. $scope.incidentModel.assign = 2;
  4965. $scope.incidentModel.group = sj.group ? sj.group : "";
  4966. } else {
  4967. $scope.incidentModel.assign = 0;
  4968. $scope.incidentModel.user = "";
  4969. $scope.incidentModel.group = "";
  4970. }
  4971. } else if (sj.branchType == 1) {
  4972. // 分院区
  4973. // 选择了院区
  4974. if ($scope.incidentModel.branch) {
  4975. let branchId = $scope.incidentModel.branch.id;
  4976. let branchUserGroup =
  4977. sj.branchUserGroups.find(v => v.branchId == branchId) || {};
  4978. if (branchUserGroup.branchUserOrGroupType == 1) {
  4979. //派人
  4980. $scope.incidentModel.assign = 1;
  4981. console.log($scope.jry_userData)
  4982. $scope.incidentModel.user = branchUserGroup.userId
  4983. ? $scope.jry_userData.find(v=>v.id == branchUserGroup.userId)
  4984. : "";
  4985. } else if (branchUserGroup.branchUserOrGroupType === 2) {
  4986. //派组
  4987. $scope.incidentModel.assign = 2;
  4988. $scope.incidentModel.group = branchUserGroup.groupId
  4989. ? {id:branchUserGroup.groupId,groupName:branchUserGroup.groupName}
  4990. : "";
  4991. } else {
  4992. $scope.incidentModel.assign = 1;
  4993. $scope.incidentModel.user = "";
  4994. $scope.incidentModel.group = "";
  4995. }
  4996. } else {
  4997. $scope.incidentModel.assign = 1;
  4998. $scope.incidentModel.user = "";
  4999. $scope.incidentModel.group = "";
  5000. }
  5001. }
  5002. }
  5003. // 取消故障描述弹窗
  5004. $scope.isShowAlertMask = false;
  5005. $scope.copyItem = null;
  5006. $scope.cancelAlertMask = function(){
  5007. $scope.isShowAlertMask = false;
  5008. }
  5009. // 覆盖
  5010. $scope.overlayAlertMask = function(){
  5011. $scope.incidentModel.description = $scope.copyItem.mutiCategory;
  5012. $scope.isShowAlertMask = false;
  5013. }
  5014. // 前覆盖
  5015. $scope.overlayLeftAlertMask = function(){
  5016. $scope.incidentModel.description = $scope.copyItem.mutiCategory + $scope.incidentModel.description;
  5017. $scope.isShowAlertMask = false;
  5018. }
  5019. // 后覆盖
  5020. $scope.overlayRightAlertMask = function(){
  5021. $scope.incidentModel.description = $scope.incidentModel.description + $scope.copyItem.mutiCategory;
  5022. $scope.isShowAlertMask = false;
  5023. }
  5024. // 故障现象选中
  5025. $scope.categorySelectId = 0;
  5026. $scope.categorySelect = "";
  5027. $scope.selectedDuty = null;//选择故障现象后的责任科室
  5028. $scope.changeCategorySelect = function(item){
  5029. $scope.copyItem = angular.copy(item);
  5030. $scope.copyItem.mutiCategory = $scope.copyItem.mutiCategory.replace(/<[^<>]+>/g,'');
  5031. if($scope.incidentModel.description){
  5032. $scope.isShowAlertMask = true;
  5033. // SweetAlert.swal({
  5034. // title: "提示",
  5035. // text: "是否覆盖故障描述?",
  5036. // type: "warning",
  5037. // showCancelButton: true,
  5038. // confirmButtonColor: "#DD6B55",
  5039. // confirmButtonText: "确认覆盖",
  5040. // cancelButtonText: "取消操作",
  5041. // closeOnConfirm: true,
  5042. // closeOnCancel: true
  5043. // }, function (isConfirm) {
  5044. // if (isConfirm) {
  5045. // $scope.incidentModel.description = $scope.copyItem.mutiCategory;
  5046. // }
  5047. // });
  5048. }else{
  5049. $scope.incidentModel.description = $scope.copyItem.mutiCategory;
  5050. }
  5051. $scope.categorySelect = $scope.copyItem;
  5052. $scope.categorySelectId = $scope.copyItem.id;
  5053. // 处理责任科室数据
  5054. $scope.handlerDuty();
  5055. if($scope.selectTab == 2){
  5056. $scope.jry_solution($scope.categorySelect.id);
  5057. }
  5058. }
  5059. // 故障现象查询
  5060. $scope.c_timer = null;
  5061. $scope.c_keyword = '';
  5062. $scope.jry_categorySearch = function (key = '') {
  5063. $scope.c_keyword = key;
  5064. clearTimeout($scope.c_timer);
  5065. $scope.c_timer = setTimeout(()=>{
  5066. var categoryData = {
  5067. idx: 0,
  5068. sum: 9999,
  5069. incidentcategory: {
  5070. category: key,
  5071. selectType:'pinyin_qs',
  5072. hierarchyQuery:'three'
  5073. },
  5074. };
  5075. if($rootScope.user.duty){
  5076. categoryData.incidentcategory.dutyDepartment = $rootScope.user.duty;
  5077. }else if($rootScope.user.branch){
  5078. // categoryData.incidentcategory.branch = $rootScope.user.branch.id;
  5079. }
  5080. $scope.loading_c = true;
  5081. api_user_data.fetchDataList("incidentcategory", categoryData).then(function (data) {
  5082. if($scope.c_keyword == key){
  5083. $scope.loading_c = false;
  5084. data.list.forEach(v=>{
  5085. if(v.mutiCategory){
  5086. v.mutiCategory = v.mutiCategory.replace($scope.jry_modelLeft,'<span class="colorRed">'+$scope.jry_modelLeft+'</span>');
  5087. }
  5088. })
  5089. $scope.jry_categoryData = data.list;
  5090. if(modelData){
  5091. if( modelData.incident.category && !modelData.incident.category.complexity){
  5092. $scope.categorySelect = data.list.find(v=>v.id == modelData.incident.category.id);
  5093. if($scope.categorySelect){
  5094. $scope.categorySelectId = $scope.categorySelect.id;
  5095. }
  5096. }
  5097. }
  5098. }
  5099. });
  5100. },500)
  5101. };
  5102. $scope.jry_categorySearch($scope.jry_modelLeft);
  5103. // 右侧tab选中
  5104. $scope.selectTab = 1;
  5105. $scope.changeTab = function(id){
  5106. $scope.selectTab = id;
  5107. if(id == 1){
  5108. $scope.jry_incident($scope.incidentModel.department?$scope.incidentModel.department.id:undefined);
  5109. }else if(id == 2){
  5110. $scope.jry_solution($scope.categorySelect?$scope.categorySelect.id:undefined);
  5111. }
  5112. }
  5113. // 近期报修
  5114. $scope.jry_incident = function (deptId) {
  5115. $scope.loading_i = true;
  5116. var placeData = {
  5117. idx: 0,
  5118. sum: 6,
  5119. incident: {
  5120. department: {id:deptId},
  5121. },
  5122. };
  5123. api_user_data.fetchDataList("incident", placeData).then(function (data) {
  5124. $scope.loading_i = false;
  5125. data.list.forEach(v=>{
  5126. v.acceptDate = moment(v.acceptDate).format('MM-DD HH:mm')
  5127. })
  5128. $scope.jry_incidentData = data.list;
  5129. });
  5130. };
  5131. $scope.$watch("incidentModel.department", function (newVal,oldVal) {
  5132. $scope.showUserOrGroup();
  5133. newVal && $scope.jry_incident(newVal.id);
  5134. console.log(newVal);
  5135. if($scope.modelData && newVal == oldVal){
  5136. }else{
  5137. if(newVal){
  5138. if($scope.incidentModel.department){
  5139. if($scope.incidentModel.department.place){
  5140. $scope.incidentModel.place = $scope.incidentModel.department.place;
  5141. $scope.incidentModel.area = $scope.incidentModel.department.place.area;
  5142. }else{
  5143. $scope.incidentModel.place = '';
  5144. $scope.incidentModel.area = '';
  5145. }
  5146. $scope.incidentModel.address = $scope.incidentModel.department.address || '';
  5147. // 如果回显的有联系电话,联系电话不用科室带出
  5148. !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = ($scope.incidentModel.department.phone)?$scope.incidentModel.department.phone.split(',')[0]:'');
  5149. }else{
  5150. $scope.incidentModel.place = '';
  5151. $scope.incidentModel.area = '';
  5152. $scope.incidentModel.address = '';
  5153. // 如果回显的有联系电话,联系电话不用科室带出
  5154. !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (newVal&&newVal.phone)?newVal.phone:'');
  5155. }
  5156. // api_bpm_data.fetchData('department', $scope.incidentModel.department.id).then(res=>{
  5157. // if(res.status == 200){
  5158. // // $scope.incidentModel.department = res.data;
  5159. // if(res.data && res.data.place){
  5160. // $scope.incidentModel.place = res.data.place;
  5161. // $scope.incidentModel.area = res.data.place.area;
  5162. // }else{
  5163. // $scope.incidentModel.place = '';
  5164. // $scope.incidentModel.area = '';
  5165. // }
  5166. // $scope.incidentModel.address = res.data.address || '';
  5167. // // 如果回显的有联系电话,联系电话不用科室带出
  5168. // !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (res.data&&res.data.phone)?res.data.phone.split(',')[0]:'');
  5169. // }else{
  5170. // $scope.incidentModel.place = '';
  5171. // $scope.incidentModel.area = '';
  5172. // $scope.incidentModel.address = '';
  5173. // // 如果回显的有联系电话,联系电话不用科室带出
  5174. // !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (newVal&&newVal.phone)?newVal.phone:'');
  5175. // }
  5176. // })
  5177. }else{
  5178. $scope.incidentModel.place = '';
  5179. $scope.incidentModel.area = '';
  5180. $scope.incidentModel.address = '';
  5181. // 如果回显的有联系电话,联系电话不用科室带出
  5182. !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (newVal&&newVal.phone)?newVal.phone:'');
  5183. }
  5184. // if(newVal && newVal.place){
  5185. // $scope.incidentModel.place = newVal.place;
  5186. // $scope.incidentModel.area = newVal.place.area;
  5187. // }else{
  5188. // $scope.incidentModel.place = '';
  5189. // $scope.incidentModel.area = '';
  5190. // }
  5191. // // 如果回显的有联系电话,联系电话不用科室带出
  5192. // !(oldVal && !oldVal.dept) && ($scope.incidentModel.contactsInformation = (newVal&&newVal.phone)?newVal.phone:'');
  5193. }
  5194. });
  5195. // 知识库
  5196. $scope.jry_solution = function (id,key='') {
  5197. $scope.loading_i = true;
  5198. var placeData = {
  5199. idx: 0,
  5200. sum: 1000,
  5201. solution: {
  5202. threeSearch:key,
  5203. status: {id: 72},
  5204. selectType: "keySearch",
  5205. },
  5206. };
  5207. if(id){
  5208. placeData.solution.category = {id:id};
  5209. }
  5210. api_user_data.fetchDataList("solution", placeData).then(function (data) {
  5211. $scope.loading_i = false;
  5212. $scope.jry_solutionData = data.list;
  5213. });
  5214. };
  5215. // getFileFromBase64($scope.imgshows[0],'tt')
  5216. // 图片上传
  5217. $scope.imgshows = [];
  5218. $scope.uploadimgs = [];
  5219. var model = $parse("upload_img");
  5220. var modelSetter = model.assign;
  5221. var uploader = ($scope.uploader = new FileUploader({
  5222. url: "/uploader",
  5223. }));
  5224. // uploader.filters.push({
  5225. // name: "customFilter",
  5226. // fn: function (item /*{File|FileLikeObject}*/, options) {
  5227. // return this.queue.length < 10;
  5228. // },
  5229. // });
  5230. $scope.getDetail = function(imgs){
  5231. function getImageFileFromUrl(url, imageName, callback) {
  5232. // imageName一定要带上后缀
  5233. var blob = null
  5234. var xhr = new XMLHttpRequest()
  5235. xhr.open('GET', url)
  5236. xhr.setRequestHeader('Accept', 'image/jpeg')
  5237. xhr.responseType = 'blob'
  5238. xhr.onload = () => {
  5239. if (xhr.status === 200) {
  5240. blob = xhr.response
  5241. let imgFile = new File([blob], imageName, {type: 'image/jpeg'})
  5242. console.log(imgFile)
  5243. callback.call(this, imgFile)
  5244. }
  5245. }
  5246. xhr.send()
  5247. }
  5248. imgs.forEach((v,i)=>{
  5249. v.previewUrl = $rootScope.attachmentAddressSplicing(v.relativeFilePath);
  5250. getImageFileFromUrl(v.previewUrl,v.name,function(file){
  5251. var dummy = new FileUploader.FileItem(uploader, file);
  5252. uploader.queue.push(dummy);
  5253. getFile(file, $scope);
  5254. })
  5255. })
  5256. //获得预览图地址并且把file对象放入上传合集内
  5257. function getFile(imgupload, $scope) {
  5258. if (!imgupload) {
  5259. return;
  5260. }
  5261. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  5262. console.log(result)
  5263. $scope.imgshows.push(result);
  5264. var file = imgupload;
  5265. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  5266. console.log($scope.imgshows, $scope.uploadimgs);
  5267. if ($scope.imgshows.length < 3) {
  5268. $("#upupgogo").show();
  5269. } else {
  5270. $("#upupgogo").hide();
  5271. }
  5272. });
  5273. }
  5274. }
  5275. // 是否回显报修端图片
  5276. // if(modelData){
  5277. // if (modelData.flow) {
  5278. // api_wechatfile
  5279. // .listAttachment("wechatRequesterIncident", modelData.flow)
  5280. // .then(function (res) {
  5281. // $scope.getDetail(res.data)
  5282. // });
  5283. // }
  5284. // }
  5285. // 添加
  5286. $scope.change = function (event) {
  5287. var element = $(".upinp");
  5288. modelSetter($scope, element[0].files[0]);
  5289. //附件预览
  5290. $scope.imgupload = event.files[0];
  5291. getFile($scope.imgupload, $scope);
  5292. //获得预览图地址并且把file对象放入上传合集内
  5293. function getFile(imgupload, $scope) {
  5294. if (!imgupload) {
  5295. return;
  5296. }
  5297. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  5298. console.log(result)
  5299. $scope.imgshows.push(result);
  5300. var file = document.querySelector("#upupgogo input[type=file]").files[0];
  5301. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  5302. console.log($scope.imgshows, $scope.uploadimgs);
  5303. if ($scope.imgshows.length < 3) {
  5304. $("#upupgogo").show();
  5305. } else {
  5306. $("#upupgogo").hide();
  5307. }
  5308. });
  5309. }
  5310. };
  5311. // 删除
  5312. $scope.uploadimg_del = function (index, imgs) {
  5313. console.log(index, imgs);
  5314. $scope.imgshows.splice(index, 1);
  5315. $scope.uploadimgs.splice(index, 1);
  5316. $scope.uploader.queue.splice(index, 1);
  5317. if ($scope.imgshows.length < 3) {
  5318. $("#upupgogo").show();
  5319. } else {
  5320. $("#upupgogo").hide();
  5321. }
  5322. };
  5323. // 预览
  5324. $scope.preview = function (url, idx) {
  5325. var name = $scope.uploadimgs[idx].name;
  5326. $modal.open({
  5327. backdrop: false,
  5328. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  5329. controller: function ($scope, scope, $modalInstance) {
  5330. //创建一个标签用来加载图片
  5331. const image = document.createElement("img");
  5332. image.src = url
  5333. //待图片加载完成读取图片的真实宽高。
  5334. image.addEventListener("load", function(e) {
  5335. $scope.imgWidth = e.target.width + 'px';
  5336. $scope.imgHeight = e.target.height + 'px';
  5337. })
  5338. $scope.title = name;
  5339. $scope.imageurl = url;
  5340. $scope.cancel = function () {
  5341. $modalInstance.dismiss("cancel");
  5342. };
  5343. },
  5344. resolve: {
  5345. scope: function () {
  5346. return $scope;
  5347. },
  5348. },
  5349. });
  5350. };
  5351. if (uploader) {
  5352. uploader.onWhenAddingFileFailed = function (
  5353. item /*{File|FileLikeObject}*/,
  5354. filter,
  5355. options
  5356. ) {
  5357. console.info("onWhenAddingFileFailed", item, filter, options);
  5358. };
  5359. uploader.onAfterAddingFile = function (fileItem) {
  5360. console.info("onAfterAddingFile", fileItem);
  5361. };
  5362. uploader.onAfterAddingAll = function (addedFileItems) {
  5363. console.info("onAfterAddingAll", addedFileItems);
  5364. };
  5365. uploader.onBeforeUploadItem = function (item) {
  5366. console.info("onBeforeUploadItem", item);
  5367. };
  5368. uploader.onProgressItem = function (fileItem, progress) {
  5369. console.info("onProgressItem", fileItem, progress);
  5370. };
  5371. uploader.onProgressAll = function (progress) {
  5372. console.info("onProgressAll", progress);
  5373. };
  5374. uploader.onSuccessItem = function (
  5375. fileItem,
  5376. response,
  5377. status,
  5378. headers
  5379. ) {
  5380. console.info("onSuccessItem", fileItem, response, status, headers);
  5381. };
  5382. uploader.onErrorItem = function (
  5383. fileItem,
  5384. response,
  5385. status,
  5386. headers
  5387. ) {
  5388. console.info("onErrorItem", fileItem, response, status, headers);
  5389. };
  5390. uploader.onCancelItem = function (
  5391. fileItem,
  5392. response,
  5393. status,
  5394. headers
  5395. ) {
  5396. console.info("onCancelItem", fileItem, response, status, headers);
  5397. };
  5398. uploader.onCompleteItem = function (
  5399. fileItem,
  5400. response,
  5401. status,
  5402. headers
  5403. ) {
  5404. console.info("onCompleteItem", fileItem, response, status, headers);
  5405. };
  5406. uploader.onCompleteAll = function () {
  5407. console.info("onCompleteAll");
  5408. };
  5409. }
  5410. // 取消
  5411. $scope.cancel = function () {
  5412. if (localStorage.getItem('fenjiNumber')) {
  5413. $rootScope.jry_shixian();
  5414. }
  5415. $rootScope.newOrderShowOpen = false;
  5416. $modalInstance.dismiss("cancel");
  5417. };
  5418. // -------------------end----------------------
  5419. },
  5420. resolve: {
  5421. modelData:function(){
  5422. return model1;
  5423. }
  5424. },
  5425. });
  5426. }
  5427. // 事件实时播报
  5428. $rootScope.realtimeBroadcast = function(){
  5429. location.href = location.origin+'/#/bigScreen/realtimeBroadcast';
  5430. // window.open(location.origin+'/#/bigScreen/realtimeBroadcast');
  5431. }
  5432. // save settings to local storage
  5433. if (angular.isDefined($localStorage.layout)) {
  5434. $scope.app.layout = $localStorage.layout;
  5435. } else {
  5436. $localStorage.layout = $scope.app.layout;
  5437. }
  5438. $scope.$watch('app.layout', function () {
  5439. // save to local storage
  5440. $localStorage.layout = $scope.app.layout;
  5441. }, true);
  5442. //global function to scroll page up
  5443. $scope.toTheTop = function () {
  5444. $document.scrollTopAnimated(0, 600);
  5445. };
  5446. // angular translate
  5447. // ----------------------
  5448. $scope.language = {
  5449. // Handles language dropdown
  5450. listIsOpen: false,
  5451. // list of available languages
  5452. available: {
  5453. 'en': 'English',
  5454. 'it_IT': 'Italiano',
  5455. 'de_DE': 'Deutsch',
  5456. 'zh_cn': 'Chinese'
  5457. },
  5458. // display always the current ui language
  5459. init: function () {
  5460. var proposedLanguage = $translate.proposedLanguage() || $translate.use();
  5461. var preferredLanguage = $translate.preferredLanguage();
  5462. // we know we have set a preferred one in app.config
  5463. $scope.language.selected = $scope.language.available[(proposedLanguage || preferredLanguage)];
  5464. },
  5465. set: function (localeId, ev) {
  5466. $translate.use(localeId);
  5467. $scope.language.selected = $scope.language.available[localeId];
  5468. $scope.language.listIsOpen = !$scope.language.listIsOpen;
  5469. }
  5470. };
  5471. $scope.language.init();
  5472. // Function that find the exact height and width of the viewport in a cross-browser way
  5473. var viewport = function () {
  5474. var e = window,
  5475. a = 'inner';
  5476. if (!('innerWidth' in window)) {
  5477. a = 'client';
  5478. e = document.documentElement || document.body;
  5479. }
  5480. return {
  5481. width: e[a + 'Width'],
  5482. height: e[a + 'Height']
  5483. };
  5484. };
  5485. // function that adds information in a scope of the height and width of the page
  5486. $scope.getWindowDimensions = function () {
  5487. return {
  5488. 'h': viewport().height,
  5489. 'w': viewport().width
  5490. };
  5491. };
  5492. // Detect when window is resized and set some variables
  5493. $scope.$watch($scope.getWindowDimensions, function (newValue, oldValue) {
  5494. $scope.windowHeight = newValue.h;
  5495. $scope.windowWidth = newValue.w;
  5496. if (newValue.w >= 992) {
  5497. $scope.isLargeDevice = true;
  5498. } else {
  5499. $scope.isLargeDevice = false;
  5500. }
  5501. if (newValue.w < 992) {
  5502. $scope.isSmallDevice = true;
  5503. } else {
  5504. $scope.isSmallDevice = false;
  5505. }
  5506. if (newValue.w <= 768) {
  5507. $scope.isMobileDevice = true;
  5508. } else {
  5509. $scope.isMobileDevice = false;
  5510. }
  5511. }, true);
  5512. // Apply on resize
  5513. $win.on('resize', function () {
  5514. $scope.$apply();
  5515. });
  5516. $rootScope.app.layout.isNavbarFixed = false;
  5517. $rootScope.app.layout.isSidebarFixed = false;
  5518. $rootScope.app.layout.isFooterFixed = false;
  5519. $scope.login_signquick = function (Requesteruserinform) {
  5520. $rootScope.statuscall = 1;
  5521. $scope.loginForm = {
  5522. username: Requesteruserinform.username,
  5523. password: Requesteruserinform.password
  5524. }
  5525. $auth.submitLogin($scope.loginForm)
  5526. .then(function (resp) {
  5527. localStorage.setItem("jry_user", JSON.stringify(resp));
  5528. $rootScope.user = JSON.parse(localStorage.getItem("jry_user"));
  5529. $rootScope.isRealtimeBroadcast = ($rootScope.user && $rootScope.user.menu)?$rootScope.user.menu.some(v => v.link == 'realtimeBroadcast'):false;
  5530. // $rootScope.userMenus = JSON.parse(localStorage.getItem("jry_user")).menu;
  5531. var allJurisdiction = JSON.parse(localStorage.getItem("jry_user")).menu;
  5532. var onlyMenu = [];
  5533. for (var i = 0; i < allJurisdiction.length; i++) {
  5534. if (allJurisdiction[i].event == "1") {
  5535. onlyMenu.push(allJurisdiction[i])
  5536. }
  5537. };
  5538. $rootScope.userMenus = onlyMenu;
  5539. getMenus();
  5540. if (resp.error != 500) {
  5541. // $state.go('app.dashboard');
  5542. $rootScope.app.isLoginFixed = false;
  5543. } else {
  5544. resp.error = "";
  5545. $scope.loginForm.password = "";
  5546. SweetAlert.swal("用户名或者密码验证失败,请重试!", "error");
  5547. }
  5548. })
  5549. .catch(function (resp) {
  5550. $scope.loginForm.password = "";
  5551. SweetAlert.swal("系统错误,请重试!", "登录错误", "error");
  5552. });
  5553. }
  5554. var url = location.hash; //获取url中"?"符后的字串 var index=obj.lastIndexOf("\-");
  5555. var theRequest = {};
  5556. var index = url.substring(index + 1, url.length).lastIndexOf("\?");
  5557. if (url.indexOf("?") != -1 && url.indexOf("fixed_list")) {
  5558. var str = url.substr(index + 1);
  5559. var strs = str.split("&");
  5560. for (var i = 0; i < strs.length; i++) {
  5561. theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
  5562. }
  5563. // return theRequest;
  5564. $scope.login_signquick(theRequest)
  5565. }
  5566. // $scope.casUserId = window.location.search;
  5567. // $scope.loginForm = {
  5568. // username: theRequest[0].split("=")[1],
  5569. // password: theRequest[1].split("=")[1]
  5570. // }
  5571. // $scope.lodingstyle = 'nodata';
  5572. var userAgent = window.navigator.userAgent.toLowerCase();
  5573. var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
  5574. var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
  5575. var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
  5576. var isSafari = userAgent.indexOf("Safari") > -1; //判断是否Safari浏览器
  5577. var isChrome = userAgent.indexOf("chrome") > -1; //判断是否Safari浏览器
  5578. if (isOpera) {
  5579. $scope.checkchrome = '当前所用浏览器是Opera浏览器,';
  5580. // return alert("访问失败,当前所用浏览器是Opera浏览器,请用Chrome浏览器访问!");
  5581. }
  5582. if (isIE) {
  5583. $scope.checkchrome = '当前所用浏览器是IE浏览器,';
  5584. // return alert("访问失败,当前所用浏览器是IE浏览器,请用Chrome浏览器访问!");
  5585. }
  5586. if (isFF) {
  5587. $scope.checkchrome = '当前所用浏览器是火狐浏览器,';
  5588. // return alert("访问失败,当前所用浏览器是火狐浏览器,请用Chrome浏览器访问!");
  5589. }
  5590. if (isSafari) {
  5591. $scope.checkchrome = '当前所用浏览器是Safari浏览器,';
  5592. // return alert("访问失败,当前所用浏览器是Safari浏览器,请用Chrome浏览器访问!");
  5593. }
  5594. if (isChrome) {
  5595. // login_sign();
  5596. $rootScope.app.isChrome = false;
  5597. // return alert("访问失败,当前所用浏览器是Chrome浏览器");
  5598. } else {
  5599. $rootScope.app.isChrome = true;
  5600. $scope.checkchrome = '';
  5601. // return alert("访问失败,请用Chrome浏览器访问!");
  5602. }
  5603. // }
  5604. // $scope.handleloginEnter = function(e) {
  5605. // if (e.keyCode == 13) {
  5606. // $scope.handleLoginClick();
  5607. // }
  5608. // };
  5609. // if (document.getElementById("isWatch").value == "true") {
  5610. // $scope.isHanderuser = true;
  5611. // } else {
  5612. // if (!JSON.parse(sessionStorage.getItem('header'))) {
  5613. // $scope.isHanderuser = false;
  5614. // $scope.login_sign();
  5615. // }
  5616. // }
  5617. // $scope.viewType = "password";
  5618. // $scope.isPassword = true;
  5619. // $scope.toggleView = function() {
  5620. // $scope.isPassword = !$scope.isPassword;
  5621. // $scope.viewType = $scope.isPassword ? "password" : "text";
  5622. // }
  5623. // $scope.handleSignOutBtnClick = function() {
  5624. // $auth.signOut()
  5625. // .then(function(resp) {
  5626. // // handle success response
  5627. // })
  5628. // .catch(function(resp) {
  5629. // // handle error response
  5630. // });
  5631. // };
  5632. // }
  5633. // }
  5634. // if (!isEmpty($auth.retrieveData('auth_headers'))) {
  5635. // } else {
  5636. // $scope.loginstart();
  5637. // }
  5638. //websocket 信息中心
  5639. console.log(atmosphere)
  5640. var socket = atmosphere;
  5641. var subSocket;
  5642. // We are now ready to cut the request
  5643. var request = {
  5644. url: 'ws://192.168.199.150:8080/messagestation/cache',
  5645. contentType: "application/json",
  5646. shared: true, // 标签共享
  5647. trackMessageLength: true, //校验数据完整性
  5648. transport: 'websocket'
  5649. };
  5650. // subSocket = socket.subscribe(request);暂时注释,不知道干啥的
  5651. request.onOpen = function (response) {
  5652. console.log(response)
  5653. subSocket.push(JSON.stringify({ login: $rootScope.user.id }));
  5654. // alert("开始连接")
  5655. };
  5656. request.onMessage = function (response) {
  5657. var message = response.responseBody;
  5658. // alert("连接成功")
  5659. console.log(message)
  5660. try {
  5661. var json = JSON.parse(message);
  5662. console.log(json.noRead)
  5663. $scope.noReadData = json.noRead
  5664. } catch (e) {
  5665. console.log('呵呵哒: ', message);
  5666. return;
  5667. }
  5668. };
  5669. request.onClose = function (response) {
  5670. // alert("连接结束")
  5671. }
  5672. request.onError = function (response) {
  5673. // alert('连接失败')
  5674. };
  5675. //信息中心模态框
  5676. var loginUser = $rootScope.user;
  5677. // if(loginUser){
  5678. // // 未读消息数量
  5679. // api_msg.msgDataList({idx: 0, sum: 1, messageStation: {readStatus: 0, userId: loginUser.id}}).then(function(data) {
  5680. // if (data.status == 200) {
  5681. // $scope.noReadData=data.totalNum
  5682. // // $rootScope.option.all = $rootScope.all;
  5683. // } else {
  5684. // $scope.noReadData=0
  5685. // }
  5686. // })
  5687. // }
  5688. // $scope.noReadData=($rootScope.noReadData||0)
  5689. // // $rootScope.all = 5;
  5690. // setTimeout(function() {
  5691. // console.log($scope.noReadData)
  5692. // }, 500)
  5693. $rootScope.wt_messages = function () {
  5694. var modalInstance = $modal.open({
  5695. templateUrl: '../../../assets/views/wt_messages.html',
  5696. controller: function ($scope, $modalInstance, SweetAlert) {
  5697. $rootScope.msgData = {
  5698. idx: 0,
  5699. sum: 5,
  5700. messageStation: {
  5701. readStatus: 0,
  5702. userId: $rootScope.user.id
  5703. }
  5704. }
  5705. // 关闭
  5706. $scope.closeModel = function () {
  5707. modalInstance.close();
  5708. }
  5709. $scope.getMsgData = function () {
  5710. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  5711. if (data) {
  5712. $rootScope.msg = data.list
  5713. $rootScope.all = data.pageCount;
  5714. $scope.wt_msgData = data
  5715. $rootScope.noReadData = data.totalNum
  5716. }
  5717. })
  5718. }
  5719. $scope.getMsgData()
  5720. $scope.message_type = 2;
  5721. $scope.message_no = function (type) { //未读1
  5722. $scope.wt_msgData = {};
  5723. $scope.message_type = type;
  5724. $rootScope.msgData.messageStation.readStatus = 0,
  5725. // $rootScope.option.curr = 1;
  5726. $rootScope.msgData.idx = 0;
  5727. // console.log($rootScope.option.curr)
  5728. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  5729. $scope.msg_yesType = true;
  5730. if (data.status == 200) {
  5731. $scope.msg_yesType = false
  5732. $scope.wt_msgData = data
  5733. $rootScope.msg = data.list
  5734. $rootScope.all = data.pageCount;
  5735. $rootScope.noReadData = data.totalNum;
  5736. // $rootScope.option.all = $rootScope.all;
  5737. } else {
  5738. $scope.msg_yesType = true;
  5739. }
  5740. })
  5741. }
  5742. $scope.message_yes = function (type) { //已读0
  5743. $scope.wt_msgData = {};
  5744. $scope.message_type = type;
  5745. $rootScope.msgData.messageStation.readStatus = 1,
  5746. $rootScope.msgData.idx = 0;
  5747. // $rootScope.option.curr = 1;
  5748. // console.log($rootScope.option.curr)
  5749. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  5750. $scope.msg_noType = true;
  5751. if (data.status == 200) {
  5752. $scope.msg_noType = false
  5753. $scope.wt_msgData = data
  5754. $rootScope.msg = data.list;
  5755. $rootScope.all = data.pageCount;
  5756. // $rootScope.option.all = $rootScope.all;
  5757. } else {
  5758. $scope.msg_noType = true
  5759. }
  5760. })
  5761. };
  5762. $scope.sBtn = function () {
  5763. // console.log($rootScope.msgData)
  5764. // console.log($scope.wt_msgData)
  5765. $rootScope.msgData.idx = $rootScope.msgData.idx - 1;
  5766. console.log($rootScope.msgData)
  5767. $scope.getMsgData()
  5768. }
  5769. $scope.xBtn = function () {
  5770. // console.log($rootScope.msgData)
  5771. // console.log($scope.wt_msgData)
  5772. $rootScope.msgData.idx = $rootScope.msgData.idx + 1;
  5773. console.log($rootScope.msgData)
  5774. $scope.getMsgData()
  5775. }
  5776. $scope.redIn = function (data) {
  5777. var start = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
  5778. $scope.messageStation = {
  5779. messageStation: {
  5780. id: data.id,
  5781. readStatus: 1,
  5782. readTime: start
  5783. }
  5784. }
  5785. api_msg.updateDataList($scope.messageStation).then(function (data) {
  5786. console.log(data);
  5787. if (data.status == 200) {
  5788. $rootScope.msgData.messageStation.readStatus = 0,
  5789. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  5790. $rootScope.msg = data.list
  5791. $rootScope.all = data.pageCount;
  5792. $rootScope.noReadData = data.totalNum;
  5793. })
  5794. }
  5795. })
  5796. };
  5797. // 一键已读
  5798. $scope.redAllIn = function () {
  5799. SweetAlert.swal({
  5800. title: "是否确认?",
  5801. type: "warning",
  5802. showCancelButton: true,
  5803. confirmButtonColor: "#DD6B55",
  5804. confirmButtonText: "确认",
  5805. cancelButtonText: "取消",
  5806. closeOnConfirm: true,
  5807. closeOnCancel: true
  5808. }, function (isConfirm) {
  5809. if (isConfirm) {
  5810. $rootScope.isMask = true;
  5811. api_msg.oneClickRead({userId: $rootScope.user.id}).then(function (data) {
  5812. $rootScope.isMask = false;
  5813. if (data.status == 200) {
  5814. $rootScope.msgData.messageStation.readStatus = 0,
  5815. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  5816. $scope.wt_msgData = data
  5817. $rootScope.msg = data.list
  5818. $rootScope.all = data.pageCount;
  5819. $rootScope.noReadData = data.totalNum;
  5820. })
  5821. }
  5822. })
  5823. } else {}
  5824. });
  5825. };
  5826. },
  5827. size: 'lg',
  5828. resolve: {
  5829. }
  5830. })
  5831. }
  5832. }
  5833. ]);
  5834. // 录音盒子
  5835. app.service('WebsocketPhoneService', function () {
  5836. return {
  5837. lockReconnect: false, //避免ws重复连接
  5838. ws: null, //定义websocket
  5839. url: "", //ws连接地址
  5840. urlParams: null, //ws连接传参
  5841. isHandler: false, //是否手动
  5842. subject: null,
  5843. reconnectTimer: null,//重连的计时器
  5844. // 连接websocket
  5845. connectWs(url, data) {
  5846. this.url = url;
  5847. this.urlParams = data;
  5848. this.subject = new rxjs.Subject();
  5849. let request = {
  5850. webSocketUrl: url,
  5851. trackMessageLength: true, //校验数据完整性
  5852. transport: "websocket",
  5853. handleOnlineOffline: false,
  5854. suspend: false,
  5855. maxReconnectOnClose: 0,
  5856. };
  5857. request.onOpen = (response) => {
  5858. console.log("ws连接成功" + new Date().toLocaleString());
  5859. this.heartCheck.reset().start(this);
  5860. console.log(response);
  5861. this.ws.push(JSON.stringify(data));
  5862. };
  5863. request.onMessage = (response) => {
  5864. this.heartCheck.reset().start(this);
  5865. let message = response.responseBody;
  5866. try {
  5867. console.log("收到消息" + message);
  5868. if (message !== "pong") {
  5869. this.subject.next(JSON.parse(message));
  5870. }
  5871. } catch (e) {
  5872. console.log("This doesn't look like a valid JSON: ", message);
  5873. return;
  5874. }
  5875. };
  5876. request.onClose = (response) => {
  5877. console.log("ws连接关闭" + new Date().toLocaleString(), this.isHandler);
  5878. this.ws = null;
  5879. console.log(response)
  5880. if (!this.isHandler && response.status === 408) {
  5881. this.reconnect(this.url, this.urlParams);
  5882. }
  5883. };
  5884. request.onError = (response) => {
  5885. console.log("ws连接错误", this.isHandler);
  5886. this.ws = null;
  5887. if (response.status === 0) {
  5888. this.reconnect(this.url, this.urlParams);
  5889. }
  5890. };
  5891. this.ws = atmosphere.subscribe(request);
  5892. return this.subject.asObservable();
  5893. },
  5894. //断线重连
  5895. reconnect(url, data) {
  5896. if (this.lockReconnect) return;
  5897. this.lockReconnect = true;
  5898. this.reconnectTimer = setTimeout(() => {
  5899. //没连接上会一直重连,设置延迟避免请求过多
  5900. this.connectWs(url, data);
  5901. this.lockReconnect = false;
  5902. }, 15000);
  5903. },
  5904. heartCheck: {
  5905. timeout: 30000, //发一次心跳的间隔时间
  5906. timeoutObj: null,
  5907. serverTimeoutObj: null,
  5908. reset: function () {
  5909. clearTimeout(this.timeoutObj);
  5910. clearTimeout(this.serverTimeoutObj);
  5911. return this;
  5912. },
  5913. start: function (_this) {
  5914. this.timeoutObj = setTimeout(() => {
  5915. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  5916. //onmessage拿到返回的心跳就说明连接正常
  5917. if (_this.ws) {
  5918. _this.ws.push("ping");
  5919. }
  5920. this.serverTimeoutObj = setTimeout(() => {
  5921. //如果超过一定时间还没重置,说明后端主动断开了
  5922. _this.closeWs(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  5923. }, this.timeout);
  5924. }, this.timeout);
  5925. },
  5926. },
  5927. // 断开websocket
  5928. closeWs(flag = false) {
  5929. this.isHandler = flag;
  5930. if (flag) {
  5931. clearTimeout(this.reconnectTimer);
  5932. }
  5933. if (this.ws) {
  5934. this.ws.close();
  5935. }
  5936. }
  5937. };
  5938. });
  5939. //消息中心分页组件
  5940. app.controller('msgCtrl', ['$scope', '$rootScope', 'api_msg', 'Myservice', function ($scope, $rootScope, api_msg, Myservice) {
  5941. $rootScope.option = {
  5942. curr: 1, //当前页数
  5943. all: $rootScope.all, //总页数
  5944. count: 5, //最多显示的页数,默认为10
  5945. //点击页数的回调函数,参数page为点击的页数
  5946. click: function (page) {
  5947. $rootScope.msgData.idx = page - 1;
  5948. //这里可以写跳转到某个页面等...
  5949. api_msg.msgDataList($rootScope.msgData).then(function (data) {
  5950. $rootScope.msg = data.list
  5951. $rootScope.all = data.pageCount;
  5952. $rootScope.option.all = $rootScope.all;
  5953. })
  5954. }
  5955. }
  5956. }]);
  5957. app.directive('myPagination', function () {
  5958. return {
  5959. restrict: 'EA',
  5960. replace: true,
  5961. rootScope: {
  5962. option: '=pageOption'
  5963. },
  5964. controller: 'msgCtrl',
  5965. template: '<ul class="pagination">' +
  5966. '<li ng-click="pageClick(p)" ng-repeat="p in page" class="{{option.curr==p?\'active\':\'\'}}">' +
  5967. '<a href="javascript:;">{{p}}</a>' +
  5968. '</li>' +
  5969. '</ul>',
  5970. link: function ($rootScope) {
  5971. //容错处理
  5972. if (!$rootScope.option.curr || isNaN($rootScope.option.curr) || $rootScope.option.curr < 1) $rootScope.option.curr = 1;
  5973. if (!$rootScope.option.all || isNaN($rootScope.option.all) || $rootScope.option.all < 1) $rootScope.option.all = 1;
  5974. if ($rootScope.option.curr > $rootScope.option.all) $rootScope.option.curr = $rootScope.option.all;
  5975. if (!$rootScope.option.count || isNaN($rootScope.option.count) || $rootScope.option.count < 1) $rootScope.option.count = 10;
  5976. //得到显示页数的数组
  5977. $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
  5978. //绑定点击事件
  5979. $rootScope.pageClick = function (page) {
  5980. if (page == '«') {
  5981. page = parseInt($rootScope.option.curr) - 1;
  5982. } else if (page == '»') {
  5983. page = parseInt($rootScope.option.curr) + 1;
  5984. }
  5985. if (page < 1) page = 1;
  5986. else if (page > $rootScope.option.all) page = $rootScope.option.all;
  5987. //点击相同的页数 不执行点击事件
  5988. if (page == $rootScope.option.curr) return;
  5989. if ($rootScope.option.click && typeof $rootScope.option.click === 'function') {
  5990. $rootScope.option.click(page);
  5991. $rootScope.option.curr = page;
  5992. $rootScope.page = getRange($rootScope.option.curr, $rootScope.option.all, $rootScope.option.count);
  5993. }
  5994. };
  5995. //返回页数范围(用来遍历)
  5996. function getRange(curr, all, count) {
  5997. //计算显示的页数
  5998. // console.log(curr, all, count)
  5999. curr = parseInt(curr);
  6000. all = parseInt(all);
  6001. count = parseInt(count);
  6002. var from = curr - parseInt(count / 2);
  6003. var to = curr + parseInt(count / 2) + (count % 2) - 1;
  6004. //显示的页数容处理
  6005. if (from <= 0) {
  6006. from = 1;
  6007. to = from + count - 1;
  6008. if (to > all) {
  6009. to = all;
  6010. }
  6011. }
  6012. if (to > all) {
  6013. to = all;
  6014. from = to - count + 1;
  6015. if (from <= 0) {
  6016. from = 1;
  6017. }
  6018. }
  6019. var range = [];
  6020. for (var i = from; i <= to; i++) {
  6021. range.push(i);
  6022. }
  6023. range.push('»');
  6024. range.unshift('«');
  6025. return range;
  6026. }
  6027. }
  6028. }
  6029. });
  6030. app.service('Myservice', function () {
  6031. return {
  6032. };
  6033. });
  6034. // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
  6035. // console.log(bh)
  6036. // if(bh>=0&&bh<=53){
  6037. // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
  6038. // }else{
  6039. // $('#sidebar').css('padding-bottom', 0 + 'px')
  6040. // }
  6041. window.onscroll = function () {
  6042. if (window.pageYOffset >= 0 && window.pageYOffset <= 65) {
  6043. $('#sidebar').css('padding-top', (65 - window.pageYOffset) + 'px')
  6044. } else {
  6045. $('#sidebar').css('padding-top', '0')
  6046. }
  6047. // console.log(window.pageYOffset)
  6048. // console.log(window.innerHeight)
  6049. // console.log(document.body.scrollHeight)
  6050. // 底部padding
  6051. // var bh=document.body.scrollHeight-window.innerHeight-window.pageYOffset;
  6052. // console.log(bh)
  6053. // if(bh>=0&&bh<=53){
  6054. // $('#sidebar').css('padding-bottom', (53-bh) + 'px')
  6055. // }else{
  6056. // $('#sidebar').css('padding-bottom', 0 + 'px')
  6057. // }
  6058. }